Documentation ¶
Index ¶
- Variables
- func NewEdPartPriv(thrsh *EdCoinThresh) (sig.Priv, error)
- func NewEdpriv() (sig.Priv, error)
- func NewSchnorrpriv() (sig.Priv, error)
- func NewSchnorrprivFrom(secret kyber.Scalar) sig.Priv
- type CoinShared
- type CoinSharedMarshaled
- type EdCoinThresh
- func (et *EdCoinThresh) CheckCoinProof(msg sig.SignedMessage, prf sig.CoinProof) error
- func (et *EdCoinThresh) CombineProofs(_ sig.Priv, items []*sig.SigItem) (coinVal types.BinVal, err error)
- func (et *EdCoinThresh) GetN() int
- func (et *EdCoinThresh) GetPartialPub() sig.Pub
- func (et *EdCoinThresh) GetSharedPub() sig.Pub
- func (et *EdCoinThresh) GetT() int
- func (et *EdCoinThresh) ShallowCopy() *EdCoinThresh
- type Edpriv
- func (priv *Edpriv) Clean()
- func (priv *Edpriv) ComputeSharedSecret(pub sig.Pub) [32]byte
- func (priv *Edpriv) GenerateSig(header sig.SignedMessage, proof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)
- func (priv *Edpriv) GetBaseKey() sig.Priv
- func (priv *Edpriv) GetPrivForSignType(signType types.SignType) (sig.Priv, error)
- func (priv *Edpriv) GetPub() sig.Pub
- func (priv *Edpriv) New() sig.Priv
- func (priv *Edpriv) NewSig() sig.Sig
- func (priv *Edpriv) SetIndex(index sig.PubKeyIndex)
- func (priv *Edpriv) ShallowCopy() sig.Priv
- func (priv *Edpriv) Sign(msg sig.SignedMessage) (sig.Sig, error)
- type Edpub
- func (pub *Edpub) CheckSignature(msg *sig.MultipleSignedMessage, sigItem *sig.SigItem) error
- func (pub *Edpub) Decode(reader io.Reader) (n int, err error)
- func (pub *Edpub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
- func (pub *Edpub) DeserializeCoinProof(m *messages.Message) (coinProof *coinproof.CoinProof, size int, err error)
- func (pub *Edpub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)
- func (pub *Edpub) Encode(writer io.Writer) (n int, err error)
- func (pub *Edpub) FromPubBytes(b sig.PubKeyBytes) (sig.Pub, error)
- func (pub *Edpub) GetBytes(m *messages.Message) ([]byte, error)
- func (pub *Edpub) GetID() messages.HeaderID
- func (pub *Edpub) GetIndex() sig.PubKeyIndex
- func (pub *Edpub) GetMsgID() messages.MsgID
- func (pub *Edpub) GetPubBytes() (sig.PubKeyBytes, error)
- func (pub *Edpub) GetPubID() (sig.PubKeyID, error)
- func (pub *Edpub) GetPubString() (sig.PubKeyStr, error)
- func (pub *Edpub) GetRealPubBytes() (sig.PubKeyBytes, error)
- func (pub *Edpub) GetSigMemberNumber() int
- func (pub *Edpub) New() sig.Pub
- func (Edpub) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (pub *Edpub) Serialize(m *messages.Message) (int, error)
- func (pub *Edpub) SetIndex(index sig.PubKeyIndex)
- func (pub *Edpub) ShallowCopy() sig.Pub
- func (pub *Edpub) VerifySig(msg sig.SignedMessage, asig sig.Sig) (bool, error)
- type Edsig
- func (sig *Edsig) Corrupt()
- func (sig *Edsig) Decode(reader io.Reader) (n int, err error)
- func (sig *Edsig) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
- func (sig *Edsig) Encode(writer io.Writer) (n int, err error)
- func (sig *Edsig) GetBytes(m *messages.Message) ([]byte, error)
- func (sig *Edsig) GetID() messages.HeaderID
- func (sig *Edsig) GetMsgID() messages.MsgID
- func (sig *Edsig) GetRand() types.BinVal
- func (sig *Edsig) New() sig.Sig
- func (Edsig) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (sig *Edsig) Serialize(m *messages.Message) (int, error)
- type PartPub
- func (pub *PartPub) CheckSignature(msg *sig.MultipleSignedMessage, sigItem *sig.SigItem) error
- func (pub *PartPub) Decode(r io.Reader) (n int, err error)
- func (pub *PartPub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
- func (pub *PartPub) DeserializeCoinProof(m *messages.Message) (coinProof sig.CoinProof, size int, err error)
- func (pub *PartPub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)
- func (pub *PartPub) Encode(w io.Writer) (n int, err error)
- func (pub *PartPub) FromPubBytes(b sig.PubKeyBytes) (sig.Pub, error)
- func (pub *PartPub) GetBytes(*messages.Message) ([]byte, error)
- func (pub *PartPub) GetID() messages.HeaderID
- func (pub *PartPub) GetIndex() sig.PubKeyIndex
- func (pub *PartPub) GetMsgID() messages.MsgID
- func (pub *PartPub) GetPubBytes() (sig.PubKeyBytes, error)
- func (pub *PartPub) GetPubID() (sig.PubKeyID, error)
- func (pub *PartPub) GetPubString() (sig.PubKeyStr, error)
- func (pub *PartPub) GetRealPubBytes() (sig.PubKeyBytes, error)
- func (pub *PartPub) GetSigMemberNumber() int
- func (pub *PartPub) New() sig.Pub
- func (pub *PartPub) NewCoinProof() sig.CoinProof
- func (PartPub) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (pub *PartPub) Serialize(m *messages.Message) (int, error)
- func (pub *PartPub) SetIndex(index sig.PubKeyIndex)
- func (pub *PartPub) ShallowCopy() sig.Pub
- func (pub *PartPub) VerifySig(msg sig.SignedMessage, asig sig.Sig) (bool, error)
- type PartialPriv
- func (priv *PartialPriv) Clean()
- func (priv *PartialPriv) ComputeSharedSecret(pub sig.Pub) [32]byte
- func (priv *PartialPriv) GenerateSig(header sig.SignedMessage, proof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)
- func (priv *PartialPriv) GetBaseKey() sig.Priv
- func (priv *PartialPriv) GetEdThresh() *EdCoinThresh
- func (priv *PartialPriv) GetPrivForSignType(signType types.SignType) (sig.Priv, error)
- func (priv *PartialPriv) GetPub() sig.Pub
- func (priv *PartialPriv) New() sig.Priv
- func (priv *PartialPriv) NewSig() sig.Sig
- func (priv *PartialPriv) SetIndex(index sig.PubKeyIndex)
- func (priv *PartialPriv) ShallowCopy() sig.Priv
- func (priv *PartialPriv) Sign(msg sig.SignedMessage) (sig.Sig, error)
Constants ¶
This section is empty.
Variables ¶
var EDDSAStats = sig.SigStats{
PubSize: 32,
SigSize: 64,
SigVerifyTime: 342579,
SignTime: 105099,
}
var SchnorrStats = sig.SigStats{ PubSize: 33, SigSize: 64, ThrshShareSize: 192, SigVerifyTime: 359155, SignTime: 199822, ShareVerifyTime: 1208729, ShareGenTime: 1038380, ShareCombineTime: 1814843 / 7, AllowsCoin: true, }
Functions ¶
func NewEdPartPriv ¶
func NewEdPartPriv(thrsh *EdCoinThresh) (sig.Priv, error)
NewEdPartialPriv creates a new partial priv given the thrsh structure.
func NewSchnorrpriv ¶
NewEcpriv creates a new random schnorr private key object
func NewSchnorrprivFrom ¶
Types ¶
type CoinShared ¶
type CoinShared struct {}
CoinShared represents precomputed information used to create threshold secrets for generating random coins.
func NewCoinShared ¶
func NewCoinShared(numTotalNodes, numNonMembers, numThresh int) *CoinShared
NewCoinShared creates a CoinShared object for creating threshold coin keys. It generates private values centrally so is only for testing.
func (*CoinShared) PartialMarshal ¶
func (ds *CoinShared) PartialMarshal() (ret CoinSharedMarshaled, err error)
PartialMartial partially martials a CoinShared object into a CoinSharedMarshaled object, which can then be mashaled into json for example.
type CoinSharedMarshaled ¶
type CoinSharedMarshaled struct {}
CoinSharedMarshaled is a partially marshalled version of CoinShared. It can then be input to the go json marshaller for example. It doesn't include the PartSec field of CoinShared.
func (CoinSharedMarshaled) PartialUnMartial ¶
func (dsm CoinSharedMarshaled) PartialUnMartial() (ret *CoinShared, err error)
PartialUnmartial takes a CoinSharedMarshaled object, unmarshals it, and returns a CoinShared object.
type EdCoinThresh ¶
type EdCoinThresh struct {
// contains filtered or unexported fields
}
EdCoinThresh keys threshold keys that should be generated using a distributed key generation protocol. They support normal EDDSA signatures, plus the use of threshold coin proofs for generating random coins.
func NewEdThresh ¶
func NewEdThresh(index sig.PubKeyIndex, dSh *CoinShared) *EdCoinThresh
func (*EdCoinThresh) CheckCoinProof ¶
func (et *EdCoinThresh) CheckCoinProof(msg sig.SignedMessage, prf sig.CoinProof) error
func (*EdCoinThresh) CombineProofs ¶
func (et *EdCoinThresh) CombineProofs(_ sig.Priv, items []*sig.SigItem) (coinVal types.BinVal, err error)
CombineProofs combines the given proofs and returns the resulting coin values. The proofs are expected to have already been validated by CheckCoinProof.
func (*EdCoinThresh) GetN ¶
func (et *EdCoinThresh) GetN() int
func (*EdCoinThresh) GetPartialPub ¶
func (et *EdCoinThresh) GetPartialPub() sig.Pub
func (*EdCoinThresh) GetSharedPub ¶
func (et *EdCoinThresh) GetSharedPub() sig.Pub
func (*EdCoinThresh) GetT ¶
func (et *EdCoinThresh) GetT() int
func (*EdCoinThresh) ShallowCopy ¶
func (et *EdCoinThresh) ShallowCopy() *EdCoinThresh
type Edpriv ¶
type Edpriv struct {
// contains filtered or unexported fields
}
EDpriv represents the EDDSA private key object
func (*Edpriv) ComputeSharedSecret ¶
ComputeSharedSecret returns the hash of Diffie-Hellman.
func (*Edpriv) GenerateSig ¶
func (priv *Edpriv) GenerateSig(header sig.SignedMessage, proof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)
GenerateSig signs a message and returns the SigItem object containing the signature
func (*Edpriv) GetBaseKey ¶
GetBaseKey returns the same key.
func (*Edpriv) GetPrivForSignType ¶
Returns key that is used for signing the sign type.
func (*Edpriv) SetIndex ¶
func (priv *Edpriv) SetIndex(index sig.PubKeyIndex)
SetIndex sets the index of the node represented by this key in the consensus participants
func (*Edpriv) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
type Edpub ¶
type Edpub struct {
// contains filtered or unexported fields
}
Edpub represents an EDDSA public key
func NewEdThresholdPub ¶
NewEdThresholdPub creates a new threshold type EDDSA public key the only different for threshold pubs is that they are given index -1
func NewEdpub ¶
// NewSchnorrThresholdPub creates a new threshold type schnorr public key // the only different for threshold pubs is that they are given index -1
func NewSchnorrThresholdPub(pub kyber.Point, memberNumber int) (*Edpub, error) { ed := &Edpub{pub: pub, pubEdtype: schnorrType, useIndex: true, index: -1} ed.memberNumber = memberNumber _, err := ed.GetPubBytes() if err != nil { return ed, err } _, err = ed.GetPubID() // to populate values return ed, err }
NewEdpub creates a new a new EDDSA type public key
func NewSchnorrpub ¶
NewEdpub creates a new a new Schnorr type public key
func (*Edpub) CheckSignature ¶
CheckSignature validates the signature with the public key, it returns an error if a coin proof is included.
func (*Edpub) Deserialize ¶
func (pub *Edpub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
Deserialize updates the fields of the pub key object from m, and returns the number of bytes read
func (*Edpub) DeserializeCoinProof ¶
func (*Edpub) DeserializeSig ¶
func (pub *Edpub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)
DeserializeSig takes a message and returns an EDDSA public key object and signature as well as the number of bytes read
func (*Edpub) FromPubBytes ¶
FromPubBytes generates an EDDSA public key object from the bytes of a public key
func (*Edpub) GetIndex ¶
func (pub *Edpub) GetIndex() sig.PubKeyIndex
GetIndex gets the index of the node represented by this key in the consensus participants
func (*Edpub) GetPubBytes ¶
func (pub *Edpub) GetPubBytes() (sig.PubKeyBytes, error)
GetPubBytes returns the EDDSA pub key as bytes (same as GetRealPubBytes for ECDSA keys)
func (*Edpub) GetPubID ¶
GetPubID returns the unique id for this pubkey (given some consensus instance), it could be the encoded bitid, or just the pub key depending on how SetUsePubIndex was set
func (*Edpub) GetPubString ¶
GetPubString is the same as GetPubBytes, except returns a string
func (*Edpub) GetRealPubBytes ¶
func (pub *Edpub) GetRealPubBytes() (sig.PubKeyBytes, error)
GetRealPubBytes returns the EDDSA pub key as bytes (same as GetPubBytes for EDDSA keys)
func (*Edpub) GetSigMemberNumber ¶
GetSigMemberNumber returns the number of signers this signature represents this can be more than one as once combined, threshold signatures are EDDSA signatures
func (Edpub) PeekHeaders ¶
func (Edpub) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns nil.
func (*Edpub) Serialize ¶
Serialize the pub key into the message, return the number of bytes written
func (*Edpub) SetIndex ¶
func (pub *Edpub) SetIndex(index sig.PubKeyIndex)
SetIndex sets the index of the node represented by this key in the consensus participants
func (*Edpub) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
type Edsig ¶
type Edsig struct {
// contains filtered or unexported fields
}
Edsig is the object representing an EDDSA signature
func (*Edsig) Deserialize ¶
func (sig *Edsig) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
GetBytes returns the bytes of the signature from the message
func (Edsig) PeekHeaders ¶
func (Edsig) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns nil.
type PartPub ¶
type PartPub struct { *EdCoinThresh // contains filtered or unexported fields }
func NewEdPartPub ¶
func NewEdPartPub(index sig.PubKeyIndex, point kyber.Point, edThresh *EdCoinThresh) *PartPub
func (*PartPub) CheckSignature ¶
CheckSignature validates the signature with the public key. If the message type is a coin message, it is verified using CoinProof
func (*PartPub) Deserialize ¶
func (*PartPub) DeserializeCoinProof ¶
func (*PartPub) DeserializeSig ¶
func (*PartPub) FromPubBytes ¶
func (*PartPub) GetIndex ¶
func (pub *PartPub) GetIndex() sig.PubKeyIndex
GetIndex gets the index of the node represented by this key in the consensus participants
func (*PartPub) GetPubBytes ¶
func (pub *PartPub) GetPubBytes() (sig.PubKeyBytes, error)
func (*PartPub) GetRealPubBytes ¶
func (pub *PartPub) GetRealPubBytes() (sig.PubKeyBytes, error)
func (*PartPub) GetSigMemberNumber ¶
func (*PartPub) NewCoinProof ¶
func (PartPub) PeekHeaders ¶
func (PartPub) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns nil.
func (*PartPub) SetIndex ¶
func (pub *PartPub) SetIndex(index sig.PubKeyIndex)
func (*PartPub) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
type PartialPriv ¶
type PartialPriv struct { *EdCoinThresh // contains filtered or unexported fields }
EdPartialPriv represents the ECDSA private key object.
func (*PartialPriv) ComputeSharedSecret ¶
func (priv *PartialPriv) ComputeSharedSecret(pub sig.Pub) [32]byte
ComputeSharedSecret returns the hash of Diffie-Hellman.
func (*PartialPriv) GenerateSig ¶
func (priv *PartialPriv) GenerateSig(header sig.SignedMessage, proof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)
GenerateSig signs a message and returns the SigItem object containing the signature.
func (*PartialPriv) GetBaseKey ¶
func (priv *PartialPriv) GetBaseKey() sig.Priv
GetBaseKey returns the key as a normal Schnorr private key.
func (*PartialPriv) GetEdThresh ¶
func (priv *PartialPriv) GetEdThresh() *EdCoinThresh
GetEdThresh returns the EdCoinThresh object.
func (*PartialPriv) GetPrivForSignType ¶
Returns key that is used for signing the sign type.
func (*PartialPriv) GetPub ¶
func (priv *PartialPriv) GetPub() sig.Pub
GetPub returns the coreesponding ECDSA public key object.
func (*PartialPriv) New ¶
func (priv *PartialPriv) New() sig.Priv
New creates an empty ECDSA private key object.
func (*PartialPriv) NewSig ¶
func (priv *PartialPriv) NewSig() sig.Sig
NewSig returns an empty sig object of the same type.
func (*PartialPriv) SetIndex ¶
func (priv *PartialPriv) SetIndex(index sig.PubKeyIndex)
SetIndex sets the index of the node represented by this key in the consensus participants.
func (*PartialPriv) ShallowCopy ¶
func (priv *PartialPriv) ShallowCopy() sig.Priv
Shallow copy makes a copy of the object without following pointers.
func (*PartialPriv) Sign ¶
func (priv *PartialPriv) Sign(msg sig.SignedMessage) (sig.Sig, error)
Sign signs a message and returns the signature.