Documentation
¶
Overview ¶
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Copyright (c) 2019 Polychain Crypto Laboratory, LLC (licensed under the Blue Oak Model License 1.0.0) Modifications Copyright (c) 2021, Foris Limited (licensed under the Apache License, Version 2.0)
Index ¶
- func CanonicalVoteToStep(vote *tmProto.CanonicalVote) int8
- func CheckOnlyDifferByTimestamp(step int8, lastSignBytes []byte, newSignBytes []byte) (time.Time, bool)
- func ProposalToStep(_ *tmProto.Proposal) int8
- func ReadMsg(reader io.Reader) (msg tmProtoPrivval.Message, err error)
- func UnpackHRS(signBytes []byte) (height int64, round int64, step int8, chainId string, err error)
- func VoteToStep(vote *tmProto.Vote) int8
- func WriteMsg(writer io.Writer, msg tmProtoPrivval.Message) (err error)
- type Block
- type CoConfig
- type Cosigner
- type CosignerConfig
- type CosignerEndSessionRequest
- type CosignerEndSessionResponse
- type CosignerRequest
- type CosignerSetSignatureRequest
- type CosignerSetSignatureResponse
- type CosignerStartSessionRequest
- type CosignerStartSessionResponse
- type HRSKey
- type HRSMeta
- type KeyGenOutput
- type LocalCosigner
- func (cosigner *LocalCosigner) EndSession(req CosignerEndSessionRequest) (CosignerEndSessionResponse, error)
- func (cosigner *LocalCosigner) FinalSign(hrsKey HRSKey, partyIds []byte, msg2out [][]byte) ([]byte, error)
- func (cosigner *LocalCosigner) SetSignature(req CosignerSetSignatureRequest) (CosignerSetSignatureResponse, error)
- func (cosigner *LocalCosigner) StartSession(req CosignerStartSessionRequest) (CosignerStartSessionResponse, error)
- type NodeConfig
- type PvGuard
- type ReconnRemoteSigner
- type RemoteCosigners
- func (cosigners *RemoteCosigners) EndSession(req CosignerEndSessionRequest) (CosignerEndSessionResponse, error)
- func (cosigners *RemoteCosigners) ResetParties() []byte
- func (cosigners *RemoteCosigners) SetSignature(req CosignerSetSignatureRequest) (CosignerSetSignatureResponse, error)
- func (cosigners *RemoteCosigners) StartSession(req CosignerStartSessionRequest) (CosignerStartSessionResponse, error)
- type SignState
- type SignerServer
- type SortedPartyIds
- type ThresholdValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalVoteToStep ¶
func CanonicalVoteToStep(vote *tmProto.CanonicalVote) int8
func ProposalToStep ¶
func ReadMsg ¶
func ReadMsg(reader io.Reader) (msg tmProtoPrivval.Message, err error)
ReadMsg reads a message from an io.Reader
func VoteToStep ¶
Types ¶
type CoConfig ¶
type CoConfig struct { PrivValStateFile string `toml:"state_file"` ChainID string `toml:"chain_id"` CosignerId byte `toml:"cosigner_id"` CosignerThreshold byte `toml:"cosigner_threshold"` KeygenProxyPub string `toml:"keygen_proxy_pub"` KeygenProxySub string `toml:"keygen_proxy_sub"` SessionTimeoutSec int `toml:"session_timeout_sec"` ListenAddress string `toml:"cosigner_listen_address"` Nodes []NodeConfig `toml:"node"` Cosigners []CosignerConfig `toml:"cosigner"` }
func LoadConfigFromFile ¶
type Cosigner ¶
type Cosigner interface { // Start signing session StartSession(req CosignerStartSessionRequest) (CosignerStartSessionResponse, error) // Final round EndSession(req CosignerEndSessionRequest) (CosignerEndSessionResponse, error) // Set the provided signature SetSignature(req CosignerSetSignatureRequest) (CosignerSetSignatureResponse, error) }
Cosigner interface is a set of methods for an m-of-n threshold signature. This interface abstracts the underlying key storage and management
type CosignerConfig ¶
type CosignerEndSessionRequest ¶
func (CosignerEndSessionRequest) PartyId ¶
func (req CosignerEndSessionRequest) PartyId() byte
type CosignerRequest ¶
type CosignerRequest interface {
PartyId() byte
}
func MsgToRequest ¶
func MsgToRequest(msg [][]byte) CosignerRequest
type CosignerSetSignatureRequest ¶
func (CosignerSetSignatureRequest) PartyId ¶
func (req CosignerSetSignatureRequest) PartyId() byte
type CosignerSetSignatureResponse ¶
type CosignerSetSignatureResponse struct {
ID byte
}
type CosignerStartSessionRequest ¶
func (CosignerStartSessionRequest) PartyId ¶
func (req CosignerStartSessionRequest) PartyId() byte
type KeyGenOutput ¶
type KeyGenOutput struct { Secret *eddsa.SecretShare }
func LoadKeygenOutputFromFile ¶
func LoadKeygenOutputFromFile(file string) (KeyGenOutput, error)
type LocalCosigner ¶
type LocalCosigner struct {
// contains filtered or unexported fields
}
LocalCosigner responds to sign requests using their share key The cosigner maintains a watermark to avoid double-signing
LocalCosigner signing is thread saafe
func NewLocalCosigner ¶
func NewLocalCosigner(cfg CoConfig) (*LocalCosigner, error)
func (*LocalCosigner) EndSession ¶
func (cosigner *LocalCosigner) EndSession(req CosignerEndSessionRequest) (CosignerEndSessionResponse, error)
func (*LocalCosigner) SetSignature ¶
func (cosigner *LocalCosigner) SetSignature(req CosignerSetSignatureRequest) (CosignerSetSignatureResponse, error)
func (*LocalCosigner) StartSession ¶
func (cosigner *LocalCosigner) StartSession(req CosignerStartSessionRequest) (CosignerStartSessionResponse, error)
type NodeConfig ¶
type NodeConfig struct {
Address string `toml:"address"`
}
type PvGuard ¶
type PvGuard struct { PrivValidator tm.PrivValidator // contains filtered or unexported fields }
PvGuard guards access to an underlying PrivValidator by using mutexes for each of the PrivValidator interface functions
func (*PvGuard) SignProposal ¶
SignProposal implementes types.PrivValidator
type ReconnRemoteSigner ¶
type ReconnRemoteSigner struct { tmService.BaseService // contains filtered or unexported fields }
ReconnRemoteSigner dials using its dialer and responds to any signature requests using its privVal.
func NewReconnRemoteSigner ¶
func NewReconnRemoteSigner( address string, logger tmLog.Logger, chainID string, privVal tm.PrivValidator, dialer net.Dialer, ) *ReconnRemoteSigner
NewReconnRemoteSigner return a ReconnRemoteSigner that will dial using the given dialer and respond to any signature requests over the connection using the given privVal.
If the connection is broken, the ReconnRemoteSigner will attempt to reconnect.
func (*ReconnRemoteSigner) OnStart ¶
func (rs *ReconnRemoteSigner) OnStart() error
OnStart implements cmn.Service.
type RemoteCosigners ¶
type RemoteCosigners struct { Context *zmq.Context Clients map[*zmq.Socket]byte ActiveClients map[*zmq.Socket]byte SessionClients map[*zmq.Socket]byte Poller *zmq.Poller LocalID byte Threshold int // contains filtered or unexported fields }
RemoteCosigners maintains the connections to the remote nodes and collects responses from them
NOT thread safe
func NewRemoteCosigners ¶
func NewRemoteCosigners(cfg CoConfig) (*RemoteCosigners, error)
func (*RemoteCosigners) EndSession ¶
func (cosigners *RemoteCosigners) EndSession(req CosignerEndSessionRequest) (CosignerEndSessionResponse, error)
func (*RemoteCosigners) ResetParties ¶
func (cosigners *RemoteCosigners) ResetParties() []byte
func (*RemoteCosigners) SetSignature ¶
func (cosigners *RemoteCosigners) SetSignature(req CosignerSetSignatureRequest) (CosignerSetSignatureResponse, error)
func (*RemoteCosigners) StartSession ¶
func (cosigners *RemoteCosigners) StartSession(req CosignerStartSessionRequest) (CosignerStartSessionResponse, error)
type SignState ¶
type SignState struct { Height int64 `json:"height"` Round int64 `json:"round"` Step int8 `json:"step"` Signature []byte `json:"signature,omitempty"` SignBytes tmBytes.HexBytes `json:"signbytes,omitempty"` // contains filtered or unexported fields }
SignState stores signing information for high level watermark management.
func LoadOrCreateSignState ¶
LoadOrCreateSignState loads the sign state from filepath If the sign state could not be loaded, an empty sign state is initialized and saved to filepath.
func LoadSignState ¶
LoadSignState loads a sign state from disk.
func (*SignState) CheckHRS ¶
CheckHRS checks the given height, round, step (HRS) against that of the SignState. It returns an error if the arguments constitute a regression, or if they match but the SignBytes are empty. Returns true if the HRS matches the arguments and the SignBytes are not empty (indicating we have already signed for this HRS, and can reuse the existing signature). It panics if the HRS matches the arguments, there's a SignBytes, but no Signature.
func (*SignState) OnlyDifferByTimestamp ¶
OnlyDifferByTimestamp returns true if the sign bytes of the sign state are the same as the new sign bytes excluding the timestamp.
type SignerServer ¶
type SignerServer struct { tmService.BaseService Context *zmq.Context Server *zmq.Socket Local *LocalCosigner }
SignerServer listens on zmq and responds to any signature requests its socket.
func NewSignerServer ¶
func NewSignerServer(logger tmlog.Logger, local *LocalCosigner, config CoConfig) (*SignerServer, error)
NewSignerServer instantiates a local cosigner with the specified key and sign state
func (*SignerServer) OnStart ¶
func (rs *SignerServer) OnStart() error
OnStart implements cmn.Service.
type SortedPartyIds ¶
type SortedPartyIds struct {
Ids string
}
type ThresholdValidator ¶
type ThresholdValidator struct {
// contains filtered or unexported fields
}
func NewThresholdValidator ¶
func NewThresholdValidator(cosigner *LocalCosigner, peers *RemoteCosigners) *ThresholdValidator
NewThresholdValidator creates and returns a new ThresholdValidator
func (*ThresholdValidator) GetPubKey ¶
func (pv *ThresholdValidator) GetPubKey() (crypto.PubKey, error)
GetPubKey returns the public key of the validator. Implements PrivValidator.
func (*ThresholdValidator) SignProposal ¶
func (pv *ThresholdValidator) SignProposal(chainID string, proposal *tmProto.Proposal) error
SignProposal signs a canonical representation of the proposal, along with the chainID. Implements PrivValidator.