Documentation ¶
Overview ¶
This package implements different types of signing mechanisms. Each type includes a public key type object, a private key type object, and a signature type object. The public key objects and signature objects must implment the messages.MsgHeader interface, so they can be serialized and sent over the network.
The follow signature types are supported:
- ECDSA signatures using the go crypto library
- Threshold signatures (this needs to be cleaned up, see TODO)
- BLS signatures
- BLS muti-signatures based on https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html
- EDDSA/SCHNORR signatures
Index ¶
- Variables
- func AfterSortPubs(myPriv Priv, fixedCoord Pub, members PubList, otherPubs PubList) (newMyPriv Priv, coord Pub, newMembers, newOtherPubs []Pub, ...)
- func CheckPubsEqual(a, b Pub) bool
- func CheckPubsIDEqual(a, b Pub) bool
- func CheckSerVRF(vrfProof VRFProof, m *messages.Message) error
- func CheckSingleSupporter(msg messages.MsgHeader) error
- func DoSleepValidation(d time.Duration)
- func GetBlsMultiNew() bool
- func GetCoinThresh(to types.TestOptions) int
- func GetDSSThresh(to types.TestOptions) (primary int, secondary int)
- func GetUseMultisig() bool
- func GetUsePubIndex() bool
- func RunFuncWithConfigSetting(toRun func(), usePubIndex types.BoolSetting, useMultisig types.BoolSetting, ...)
- func SetBlsMultiNew(val bool)
- func SetSleepValidate(val bool)
- func SetUseMultisig(val bool)
- func SetUsePubIndex(val bool)
- func SigTestComputeSharedSecret(newPriv func() (Priv, error), t *testing.T)
- func SigTestEncode(newPriv func() (Priv, error), t *testing.T)
- func SigTestFromBytes(newPriv func() (Priv, error), t *testing.T)
- func SigTestMultiSignTestMsgSerialize(newPriv func() (Priv, error), t *testing.T)
- func SigTestPrintStats(newPriv func() (Priv, error), t *testing.T)
- func SigTestRand(newPriv func() (Priv, error), t *testing.T)
- func SigTestSerialize(newPriv func() (Priv, error), signType types.SignType, t *testing.T)
- func SigTestSign(newPriv func() (Priv, error), signType types.SignType, t *testing.T)
- func SigTestSignTestMsgSerialize(newPriv func() (Priv, error), t *testing.T)
- func SigTestSort(newPriv func() (Priv, error), t *testing.T)
- func SigTestVRF(newPriv func() (Priv, error), t *testing.T)
- func TestPartThrsh(privFunc func() (Priv, error), signType types.SignType, tval, n int, ...)
- func TestSigMerge(newPriv func() (Priv, error), t *testing.T)
- func VerifySignature()
- type AllMultiPub
- type AllMultiSig
- type BasicSignedMessage
- type BasicThresholdInterface
- type CoinProof
- type CoinProofPubInterface
- type ConsIDPub
- type CorruptInterface
- type EncodeInterface
- type EncodedMsg
- type MultiPub
- type MultiSig
- type MultiSignTestMsg
- func (scm *MultiSignTestMsg) DeserializeInternal(m *messages.Message) (bytesRead, signEndOffset int, err error)
- func (scm *MultiSignTestMsg) GetBaseMsgHeader() messages.InternalSignedMsgHeader
- func (scm *MultiSignTestMsg) GetID() messages.HeaderID
- func (scm *MultiSignTestMsg) GetMsgID() messages.MsgID
- func (*MultiSignTestMsg) GetSignType() types.SignType
- func (scm *MultiSignTestMsg) NeedsSMValidation(msgIndex types.ConsensusIndex, proposalIdx int) (idx types.ConsensusIndex, proposal []byte, err error)
- func (scm *MultiSignTestMsg) SerializeInternal(m *messages.Message) (bytesWritten, signEndOffset int, err error)
- func (scm *MultiSignTestMsg) ShallowCopy() messages.InternalSignedMsgHeader
- type MultipleSignedMessage
- func (sm *MultipleSignedMessage) DeserSign(m EncodedMsg, l, offset, endOffset int, size uint32) (int, error)
- func (sm *MultipleSignedMessage) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
- func (sm *MultipleSignedMessage) DeserializeEncoded(m EncodedMsg, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
- func (sm *MultipleSignedMessage) GetBytes(m *messages.Message) ([]byte, error)
- func (sm *MultipleSignedMessage) GetHashString() types.HashStr
- func (sm *MultipleSignedMessage) GetIndex() types.ConsensusIndex
- func (sm *MultipleSignedMessage) GetSigCount() (count int)
- func (sm *MultipleSignedMessage) GetSigItems() []*SigItem
- func (sm *MultipleSignedMessage) GetSignedHash() types.HashBytes
- func (sm *MultipleSignedMessage) GetSignedMessage() []byte
- func (sm *MultipleSignedMessage) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (sm *MultipleSignedMessage) Serialize(m *messages.Message) (int, error)
- func (sm *MultipleSignedMessage) SetSigItems(si []*SigItem)
- func (sm *MultipleSignedMessage) ShallowCopy() messages.InternalSignedMsgHeader
- func (sm *MultipleSignedMessage) Sign(m *messages.Message, l, offset, endOffset, sizeOffset int) (int, error)
- type NewPrivFunc
- type Priv
- type PrivList
- type Pub
- type PubKeyBytes
- type PubKeyID
- type PubKeyIndex
- type PubKeyStr
- type PubKeyStrList
- type PubList
- type SecondaryPriv
- type SecondaryPub
- type Sig
- type SigItem
- type SigStats
- type SignedMessage
- type SortPriv
- type SortPub
- type ThreshStateInterface
- type ThresholdCountInterface
- type ThrshSig
- type UnsignedMessage
- func (sm *UnsignedMessage) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
- func (sm *UnsignedMessage) DeserializeEncoded(m EncodedMsg, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
- func (sm *UnsignedMessage) GetBytes(m *messages.Message) ([]byte, error)
- func (sm *UnsignedMessage) GetEncryptPubs() []Pub
- func (sm *UnsignedMessage) GetHashString() types.HashStr
- func (sm *UnsignedMessage) GetIndex() types.ConsensusIndex
- func (sm *UnsignedMessage) GetSigCount() (count int)
- func (sm *UnsignedMessage) GetSignedHash() types.HashBytes
- func (sm *UnsignedMessage) GetSignedMessage() []byte
- func (sm *UnsignedMessage) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (sm *UnsignedMessage) Serialize(m *messages.Message) (int, error)
- func (sm *UnsignedMessage) SetEncryptPubs(pubs []Pub)
- func (sm *UnsignedMessage) ShallowCopy() messages.InternalSignedMsgHeader
- type VRFPriv
- type VRFProof
- type VRFPub
Constants ¶
This section is empty.
Variables ¶
var AdditionalIndecies = []types.ConsensusID{ types.ConsensusHash(types.GetHash(utils.Uint64ToBytes(uint64(TestIndex + 1)))), types.ConsensusHash(types.GetHash(utils.Uint64ToBytes(uint64(TestIndex + 2)))), types.ConsensusHash(types.GetHash(utils.Uint64ToBytes(uint64(TestIndex + 3)))), }
var BlsMultiNew = false
var EdSuite = edwards25519.NewBlakeSHA256Ed25519()
EdSuite is the group used by schnorr and threshold sigs (this can be changed)
var EddsaGroup = new(edwards25519.Curve)
the group used by eddsa signature (this is fixed)
var EncryptMsgSize = 46
var EncryptOverhead = config.EncryptOverhead // 24
var SignMsgSize = 26
var SleepValidate = false
var TestHash types.ConsensusHash = types.ConsensusHash(types.GetHash(utils.Uint64ToBytes(uint64(TestIndex))))
var TestIndex types.ConsensusInt = 10
var TestKeyIndex = PubKeyIndex(0)
var Thrshn2, Thrsht2 = 10, 4
var UseMultisig = false
var UsePubIndex = true
The following settings should be changed in "../../generalconfig.go" and not here
Functions ¶
func AfterSortPubs ¶
func AfterSortPubs(myPriv Priv, fixedCoord Pub, members PubList, otherPubs PubList) (newMyPriv Priv, coord Pub, newMembers, newOtherPubs []Pub, memberMap map[PubKeyID]Pub, allPubs []Pub)
AfterSortPubs should be called after sorting has completed to let the keys know their indecies
func CheckPubsEqual ¶
func CheckPubsIDEqual ¶
func CheckSerVRF ¶
CheckSerVRF is a helper function used by implementations of GenerateSig
func CheckSingleSupporter ¶
CheckSingleSupporter checks if the message is either a Signed or Unsigned message and returns an error if it has a number of supporters not equal to 1.
func DoSleepValidation ¶
DoSleepValidation is called instead of doing a validation when SleepValidate is set to true
func GetBlsMultiNew ¶
func GetBlsMultiNew() bool
func GetCoinThresh ¶
func GetCoinThresh(to types.TestOptions) int
func GetDSSThresh ¶
func GetDSSThresh(to types.TestOptions) (primary int, secondary int)
GetDSSThresh returns the threshold for threshold signatures
func GetUseMultisig ¶
func GetUseMultisig() bool
GetUseMultisig returns the state set by SetUseMultisig
func GetUsePubIndex ¶
func GetUsePubIndex() bool
GetUsePubIndex returns the state set by SetUsePubIndex
func RunFuncWithConfigSetting ¶
func RunFuncWithConfigSetting(toRun func(), usePubIndex types.BoolSetting, useMultisig types.BoolSetting, blsMultiNew types.BoolSetting, sleepValidate types.BoolSetting)
func SetBlsMultiNew ¶
func SetBlsMultiNew(val bool)
SetBlsMultiNew sets what type of multisigs to use, if SetUseMultisig was set to true If true we use multi-sigs from https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html
func SetSleepValidate ¶
func SetSleepValidate(val bool)
SetSleepValidate sets whether or not nodes validate sigs (unsafe just for testing) If true then we dont validate sigs, just sleep and return true.
func SetUseMultisig ¶
func SetUseMultisig(val bool)
SetUseMultisig set wheter to use multi-signatures or not If true will use multisig, must default to false
func SetUsePubIndex ¶
func SetUsePubIndex(val bool)
SetUsePubIndex sets how a node sends its identifier in messages. If true, the when sending a pub it only sends the index it is in the list of participants TODO change index when members are chagned, right now indecies are static are the start
func SigTestSerialize ¶
func SigTestSign ¶
func TestPartThrsh ¶
func VerifySignature ¶
func VerifySignature()
Types ¶
type AllMultiPub ¶
type AllMultiSig ¶
type BasicSignedMessage ¶
type BasicSignedMessage []byte
func (BasicSignedMessage) GetSignedHash ¶
func (bsm BasicSignedMessage) GetSignedHash() types.HashBytes
func (BasicSignedMessage) GetSignedMessage ¶
func (bsm BasicSignedMessage) GetSignedMessage() []byte
type BasicThresholdInterface ¶
type BasicThresholdInterface interface { ThresholdCountInterface GetSharedPub() Pub // Get the shared public key for the threshold. }
type CoinProofPubInterface ¶
type CoinProofPubInterface interface { ThresholdCountInterface CheckCoinProof(SignedMessage, CoinProof) error // Check if a coin proof is valid for a message. CombineProofs(myPriv Priv, items []*SigItem) (coinVal types.BinVal, err error) // DeserializeCoinProof(m *messages.Message) (coinProof CoinProof, size int, err error) NewCoinProof() CoinProof // returns an empty coin proof object }
type ConsIDPub ¶
type ConsIDPub struct { ID types.ConsensusID Pub Pub }
ConsIDPub contains a consensus id and a public key.
type CorruptInterface ¶
type CorruptInterface interface {
Corrupt() // Corrupts a signature for testing
}
type EncodeInterface ¶
type EncodedMsg ¶
func FromMessage ¶
func FromMessage(msg *messages.Message) EncodedMsg
func NewEncodedMsg ¶
func NewEncodedMsg(msg []byte, wasEncrypted bool, pub Pub) EncodedMsg
func NewUnencodedMsg ¶
func NewUnencodedMsg(msg *messages.Message) EncodedMsg
func (EncodedMsg) NewEncodedMsgCopy ¶
func (enc EncodedMsg) NewEncodedMsgCopy(msg []byte) EncodedMsg
func (EncodedMsg) ShallowCopy ¶
func (enc EncodedMsg) ShallowCopy() EncodedMsg
type MultiPub ¶
type MultiPub interface { // Clone returns a new pub only containing the points (no bitid), should be called before merging the first set of keys with MergePubPartial Clone() MultiPub // MergePubPartial merges the pubs without updating the BitID identifiers. MergePubPartial(MultiPub) // DonePartialMerge should be called after merging keys with MergePubPartial to set the bitid. DonePartialMerge(idInterface bitid.NewBitIDInterface) // MergePub combines two BLS public key objects into a single one (doing all necessary steps) MergePub(MultiPub) (MultiPub, error) // GetBitID returns the BitID for this public key GetBitID() bitid.NewBitIDInterface // SubMultiPub removes the input pub from he pub and returns the new pub SubMultiPub(MultiPub) (MultiPub, error) // GenerateSerializedSig serialized the public key and the signature and returns the bytes GenerateSerializedSig(MultiSig) ([]byte, error) }
MultiPub is for multisignatures.
type MultiSignTestMsg ¶
func NewMultiSignTestMsg ¶
func NewMultiSignTestMsg(pub Pub) *MultiSignTestMsg
func (*MultiSignTestMsg) DeserializeInternal ¶
func (scm *MultiSignTestMsg) DeserializeInternal(m *messages.Message) (bytesRead, signEndOffset int, err error)
func (*MultiSignTestMsg) GetBaseMsgHeader ¶
func (scm *MultiSignTestMsg) GetBaseMsgHeader() messages.InternalSignedMsgHeader
GetBaseMsgHeader returns the header pertaning to the message contents.
func (*MultiSignTestMsg) GetID ¶
func (scm *MultiSignTestMsg) GetID() messages.HeaderID
func (*MultiSignTestMsg) GetMsgID ¶
func (scm *MultiSignTestMsg) GetMsgID() messages.MsgID
func (*MultiSignTestMsg) GetSignType ¶
func (*MultiSignTestMsg) GetSignType() types.SignType
func (*MultiSignTestMsg) NeedsSMValidation ¶
func (scm *MultiSignTestMsg) NeedsSMValidation(msgIndex types.ConsensusIndex, proposalIdx int) (idx types.ConsensusIndex, proposal []byte, err error)
func (*MultiSignTestMsg) SerializeInternal ¶
func (scm *MultiSignTestMsg) SerializeInternal(m *messages.Message) (bytesWritten, signEndOffset int, err error)
func (*MultiSignTestMsg) ShallowCopy ¶
func (scm *MultiSignTestMsg) ShallowCopy() messages.InternalSignedMsgHeader
type MultipleSignedMessage ¶
type MultipleSignedMessage struct { messages.InternalSignedMsgHeader // the specific message Index types.ConsensusIndex // the cons index of the message Hash types.HashBytes // The hash of the signed part of the message as bytes Msg []byte // The signed part of the message SigItems []*SigItem // A list of signatures // contains filtered or unexported fields }
MultipleSignedMessage represents a message with a list of signatures for that message
func NewMultipleSignedMsg ¶
func NewMultipleSignedMsg(index types.ConsensusIndex, pub Pub, internalMsg messages.InternalSignedMsgHeader) *MultipleSignedMessage
NewMultipleSignedMsg generates a new multiple signed msg object given the input, it does not compute the hash fields.
func (*MultipleSignedMessage) DeserSign ¶
func (sm *MultipleSignedMessage) DeserSign(m EncodedMsg, l, offset, endOffset int, size uint32) (int, error)
DeserSign takes as input a signed message m, the index in the message where signatures are placed l, the start and end indecies of the signed part of the message (offset and endOffest) and size the total size of the message It fills in the Hash and SigItems fields of the sm object and returns the size of the message.
func (*MultipleSignedMessage) Deserialize ¶
func (sm *MultipleSignedMessage) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
Deserialize deserialzes a header into the object, returning the number of bytes read
func (*MultipleSignedMessage) DeserializeEncoded ¶
func (sm *MultipleSignedMessage) DeserializeEncoded(m EncodedMsg, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
DeserializeEncoded deserialzes a header into the object, returning the number of bytes read
func (*MultipleSignedMessage) GetBytes ¶
func (sm *MultipleSignedMessage) GetBytes(m *messages.Message) ([]byte, error)
GetBytes returns the bytes that make up the message
func (*MultipleSignedMessage) GetHashString ¶
func (sm *MultipleSignedMessage) GetHashString() types.HashStr
GetHashString returns the hash of the message as a string
func (*MultipleSignedMessage) GetIndex ¶
func (sm *MultipleSignedMessage) GetIndex() types.ConsensusIndex
GetIndex returns the consensus index for this message.
func (*MultipleSignedMessage) GetSigCount ¶
func (sm *MultipleSignedMessage) GetSigCount() (count int)
GetSigCount returns the number of times this message has been signed (can be greater than the number of signatures when using threshold signatures)
func (*MultipleSignedMessage) GetSigItems ¶
func (sm *MultipleSignedMessage) GetSigItems() []*SigItem
GetSigItems returns the list of signatures of the message
func (*MultipleSignedMessage) GetSignedHash ¶
func (sm *MultipleSignedMessage) GetSignedHash() types.HashBytes
GetSignedHash returns the hash of the signed part of the message message as bytes (see issue #22)
func (*MultipleSignedMessage) GetSignedMessage ¶
func (sm *MultipleSignedMessage) GetSignedMessage() []byte
GetSignedMessage returns the bytes of the signed part of the message
func (*MultipleSignedMessage) PeekHeaders ¶
func (sm *MultipleSignedMessage) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns the indices related to the messages without impacting m.
func (*MultipleSignedMessage) Serialize ¶
func (sm *MultipleSignedMessage) Serialize(m *messages.Message) (int, error)
Serialize appends a serialized header to the message m, and returns the size of bytes written
func (*MultipleSignedMessage) SetSigItems ¶
func (sm *MultipleSignedMessage) SetSigItems(si []*SigItem)
SetSigItems sets the list of signatures for the message
func (*MultipleSignedMessage) ShallowCopy ¶
func (sm *MultipleSignedMessage) ShallowCopy() messages.InternalSignedMsgHeader
ShallowCopy generates a new multiple signed msg object that is a shallow copy of the original.
func (*MultipleSignedMessage) Sign ¶
func (sm *MultipleSignedMessage) Sign(m *messages.Message, l, offset, endOffset, sizeOffset int) (int, error)
Sign takes as input a message m, it's lenght l, the part of the message to sign (from offset to endOffset) and where within the message the size should be stored (sizeOffset). If the sm object has a private key, then it uses that to sign the message. If the sm object has any signatures (in SigItems) those are also added to the message It returns the total lenght of the message including the signatures
type NewPrivFunc ¶
type Priv ¶
type Priv interface { GetPub() Pub // GetPub returns the public key associated with this private key // SetIndex should be called after sorting the pubs (see SetUsePubIndex) with the sorted pub and the new pub key. SetIndex(newPubIndex PubKeyIndex) GenerateSig(msg SignedMessage, vrf VRFProof, signType types.SignType) (*SigItem, error) // Signs a message and returns the SigItem object containing the signature GetPrivForSignType(signType types.SignType) (Priv, error) // Returns key that is used for signing the sign type. Sign(message SignedMessage) (Sig, error) // Signs a message and returns the signature GetBaseKey() Priv // Returns the normal version of the key (eg. for partial signature keys returns the normal key) ShallowCopy() Priv Clean() // Called when the priv key is no longer used ////////////////////////////////////////////////////// // Static methods ///////////////////////////////////////////////////// // New() Priv // Creates a new private key object of the same type NewSig() Sig // Creates an empty sig object of the same type. }
Priv is a private key object
type PrivList ¶
type PrivList []Priv
func (PrivList) SetIndices ¶
func (a PrivList) SetIndices()
SetIndices should be called after sorting has completed to let the keys know their indecies
type Pub ¶
type Pub interface { VerifySig(SignedMessage, Sig) (bool, error) // Verify a signature, returns (true, nil) if valid, (false, nil) if invalid, or (false, error) if there was an error verifying the signature // CheckSignature will should check what kind of message and signature to verify. It will call CheckCoinProof or VerfiySig // depending on the message type. CheckSignature(msg *MultipleSignedMessage, sig *SigItem) error GetPubBytes() (PubKeyBytes, error) // This is the key we use to sign/verify (might be an hash/operation performed on the original key) // GetRealPubBytes is the original unmodified public key. This is used when adding new public keys, from this we can generate all // the other values. GetRealPubBytes() (PubKeyBytes, error) GetPubString() (PubKeyStr, error) // This is the same as GetPubBytes, except returns a string, this is used to sort the keys GetSigMemberNumber() int // This returns the number of members this sig counts for (can be > 1 for multisigs and threshold sigs) // GetPubID returns the id of the public key (see type definition for PubKeyID). IMPORTANT: this should only be used by // the member checker objects and when sending messages, since the id is based on the current set of member for a consensus index and can chage. // GetPubBytes, GetRealPubBytes, GetPubString should be used in other cases. // The member checker may change the PubID, after making a ShallowCopy, using AfterSortPubs to assign new IDs. GetPubID() (PubKeyID, error) SetIndex(PubKeyIndex) // This should be called after sorting all if the benchmark is using the index as the key id (see SetUsePubIndex) FromPubBytes(PubKeyBytes) (Pub, error) // This creates a public key object from the public key bytes ShallowCopy() Pub // GetIndex gets the index of the node represented by this key in the consensus participants GetIndex() PubKeyIndex New() Pub // Creates a new public key object of the same type DeserializeSig(m *messages.Message, signType types.SignType) (sigItem *SigItem, size int, err error) // Deserializes a public key and signature object from m, size is the number of bytes read messages.MsgHeader EncodeInterface }
Pub is a public key object
func GetSingleSupporter ¶
CheckSingleSupporter checks if the message is either a Signed or Unsigned message and returns the supporter pub. It should be called after CheckSingleSupporter
func RemoveDuplicatePubs ¶
type PubKeyID ¶
type PubKeyID string
PubKeyID is a string that uniquely identifies a public key for a certain consensus instance this may be an integer or the full public key, depending on how SetUsePubIndex was set
func GetPubID ¶
func GetPubID(idx PubKeyIndex, pub Pub) PubKeyID
type PubKeyIndex ¶
type PubKeyIndex int
PubKeyIndex is the index of the pub key in the sorted list of consensus participants
type PubKeyStrList ¶
type PubKeyStrList []PubKeyStr
type SecondaryPriv ¶
type SecondaryPriv interface {
GetSecondaryPriv() Priv
}
type SecondaryPub ¶
type SecondaryPub interface {
VerifySecondarySig(SignedMessage, Sig) (bool, error) // Verify a signature, returns (true, nil) if valid, (false, nil) if invalid, or (false, error) if there was an error verifying the signature
}
type Sig ¶
type Sig interface { ////////////////////////////////////////////////////// // Static methods ///////////////////////////////////////////////////// New() Sig // Creates a new sig object of the same type messages.MsgHeader EncodeInterface }
Sig is a signature object
type SigItem ¶
type SigItem struct { WasEncrypted bool // Set to true if this was an encrypted message Pub Pub // The public key that will be used to verify the signature Sig Sig // The signature VRFProof VRFProof // The VRF proof if enabled VRFID uint64 // The first uint64 computed by the vrf SigBytes []byte // The bytes of the signature }
SigItem tracks a signature and public key object that should verify the signature
func GenerateSigHelper ¶
func GenerateSigHelper(priv Priv, header SignedMessage, allowsVRF bool, vrfProof VRFProof, signType types.SignType) (*SigItem, error)
GenerateSigHelper is a helper function for implementations of GenerateSig
type SignedMessage ¶
type ThreshStateInterface ¶
type ThreshStateInterface interface { BasicThresholdInterface // VerifyPartialSig([]byte, Pub, Sig) error // Verify a partial signature. CombinePartialSigs([]Sig) (*SigItem, error) // Create a threshold signatue for the partial signatures. PartialSign(msg SignedMessage) (Sig, error) // Sign a message using the local node's partial key. }
ThreshStateInterface is for storing state about threshold signatures. Methods should be concurrent safe.
type ThresholdCountInterface ¶
type ThrshSig ¶
type ThrshSig interface {
GetRand() types.BinVal // Get a random binary from the signature if supported.
}
ThrshSig interface of a threshold signature
type UnsignedMessage ¶
type UnsignedMessage struct { messages.InternalSignedMsgHeader // the specific message Index types.ConsensusIndex // the cons index of the message Hash types.HashBytes // The hash of the signed part of the message as bytes Msg []byte // The signed part of the message EncryptPubs []Pub // The nodes who sent this message // contains filtered or unexported fields }
UnsignedMessage represents a message with a list of signatures for that message
func NewUnsignedMessage ¶
func NewUnsignedMessage(index types.ConsensusIndex, pub Pub, internalMsg messages.InternalSignedMsgHeader) *UnsignedMessage
NewMultipleSignedMsg generates a new multiple signed msg object given the input, it does not compute the hash fields.
func (*UnsignedMessage) Deserialize ¶
func (sm *UnsignedMessage) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
Deserialize deserialzes a header into the object, returning the number of bytes read
func (*UnsignedMessage) DeserializeEncoded ¶
func (sm *UnsignedMessage) DeserializeEncoded(m EncodedMsg, unmarFunc types.ConsensusIndexFuncs) (n int, err error)
DeserializeEncoded deserialzes a header into the object, returning the number of bytes read
func (*UnsignedMessage) GetBytes ¶
func (sm *UnsignedMessage) GetBytes(m *messages.Message) ([]byte, error)
GetBytes returns the bytes that make up the message
func (*UnsignedMessage) GetEncryptPubs ¶
func (sm *UnsignedMessage) GetEncryptPubs() []Pub
GetSigItems returns the list of signatures of the message
func (*UnsignedMessage) GetHashString ¶
func (sm *UnsignedMessage) GetHashString() types.HashStr
GetHashString returns the hash of the message as a string
func (*UnsignedMessage) GetIndex ¶
func (sm *UnsignedMessage) GetIndex() types.ConsensusIndex
GetIndex returns the consensus index for this message.
func (*UnsignedMessage) GetSigCount ¶
func (sm *UnsignedMessage) GetSigCount() (count int)
GetSigCount returns the number of times this message has been signed (can be greater than the number of signatures when using threshold signatures)
func (*UnsignedMessage) GetSignedHash ¶
func (sm *UnsignedMessage) GetSignedHash() types.HashBytes
GetSignedHash returns the hash of the signed part of the message message as bytes (see issue #22)
func (*UnsignedMessage) GetSignedMessage ¶
func (sm *UnsignedMessage) GetSignedMessage() []byte
GetSignedMessage returns the bytes of the signed part of the message
func (*UnsignedMessage) PeekHeaders ¶
func (sm *UnsignedMessage) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns the indices related to the messages without impacting m.
func (*UnsignedMessage) Serialize ¶
func (sm *UnsignedMessage) Serialize(m *messages.Message) (int, error)
Serialize appends a serialized header to the message m, and returns the size of bytes written
func (*UnsignedMessage) SetEncryptPubs ¶
func (sm *UnsignedMessage) SetEncryptPubs(pubs []Pub)
SetSigItems sets the list of signatures for the message
func (*UnsignedMessage) ShallowCopy ¶
func (sm *UnsignedMessage) ShallowCopy() messages.InternalSignedMsgHeader
ShallowCopy generates a new multiple signed msg object that is a shallow copy of the original.
type VRFPriv ¶
type VRFPriv interface {
Evaluate(m SignedMessage) (index [32]byte, proof VRFProof) // For generating VRFs.
}
VRFPriv interface for private key VRF operations.
type VRFProof ¶
type VRFProof interface { EncodeInterface ////////////////////////////////////////////////////// // Static methods ///////////////////////////////////////////////////// New() VRFProof // Creates a VRFProof oject of the same type }
type VRFPub ¶
type VRFPub interface { // NewVRFProof returns an empty VRFProof object NewVRFProof() VRFProof // ProofToHash checks the VRF for the message and returns the random bytes if valid ProofToHash(m SignedMessage, proof VRFProof) (index [32]byte, err error) // For validating VRFs }
VRFPub interface for public keys that support VRFs