Documentation ¶
Index ¶
- Variables
- func GetBlsPartPrivFunc() func() (sig.Priv, error)
- func GetBlsPartPrivFunc2() func() (sig.Priv, error)
- func GetNewPubFromPubBLSMulti(suite pairing.Suite, pub kyber.Point) (kyber.Point, kyber.Scalar, error)
- func MarshalSigBLS(sig kyber.Point) ([]byte, error)
- func NewBLSKeyPair(suite pairing.Suite, random cipher.Stream) (kyber.Scalar, kyber.Point)
- func NewBLSMSKeyPair(suite pairing.Suite, random cipher.Stream) (kyber.Scalar, kyber.Point, kyber.Point, kyber.Scalar)
- func NewBLSMSKeyPairFrom(secret kyber.Scalar, suite pairing.Suite, random cipher.Stream) (kyber.Scalar, kyber.Point, kyber.Point, kyber.Scalar)
- func NewBlsPartPriv(thrsh *BlsThrsh) (sig.Priv, error)
- func NewBlspriv(newBidFunc bitid.FromIntFunc) (sig.Priv, error)
- func NewBlsprivFrom(secret kyber.Scalar, newBidFunc bitid.FromIntFunc) sig.Priv
- func SignBLS(suite pairing.Suite, x kyber.Scalar, msg []byte) (kyber.Point, []byte, error)
- func SignBLSMS(suite pairing.Suite, x kyber.Scalar, hpk kyber.Scalar, msg []byte) (kyber.Point, []byte, error)
- func UnmarshalSig(suite pairing.Suite, b []byte) (kyber.Point, error)
- func VerifyBLS(suite pairing.Suite, X kyber.Point, msg []byte, sig kyber.Point) error
- func VerifyPartialSig(msg []byte, pubInt sig.Pub, sigInt sig.Sig) error
- type BlsShared
- type BlsSharedMarshal
- type BlsThrsh
- func (bt *BlsThrsh) CombinePartialSigs(ps []sig.Sig) (*sig.SigItem, error)
- func (bt *BlsThrsh) GetN() int
- func (bt *BlsThrsh) GetPartialPub() sig.Pub
- func (bt *BlsThrsh) GetSharedPub() sig.Pub
- func (bt *BlsThrsh) GetT() int
- func (bt *BlsThrsh) PartialSign(msg sig.SignedMessage) (sig.Sig, error)
- func (bt *BlsThrsh) ShallowCopy() *BlsThrsh
- type Blspriv
- func (priv *Blspriv) Clean()
- func (priv *Blspriv) ComputeSharedSecret(pub sig.Pub) [32]byte
- func (priv *Blspriv) Evaluate(m sig.SignedMessage) (index [32]byte, proof sig.VRFProof)
- func (priv *Blspriv) GenerateSig(header sig.SignedMessage, vrfProof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)
- func (priv *Blspriv) GetBaseKey() sig.Priv
- func (priv *Blspriv) GetPrivForSignType(signType types.SignType) (sig.Priv, error)
- func (priv *Blspriv) GetPub() sig.Pub
- func (priv *Blspriv) NewSig() sig.Sig
- func (priv *Blspriv) SetIndex(index sig.PubKeyIndex)
- func (priv *Blspriv) ShallowCopy() sig.Priv
- func (priv *Blspriv) Sign(msg sig.SignedMessage) (sig.Sig, error)
- type Blspub
- func (pub *Blspub) CheckSignature(msg *sig.MultipleSignedMessage, sigItem *sig.SigItem) error
- func (pub *Blspub) Clone() sig.MultiPub
- func (pub *Blspub) Decode(reader io.Reader) (n int, err error)
- func (pub *Blspub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
- func (pub *Blspub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)
- func (pub *Blspub) DonePartialMerge(bid bitid.NewBitIDInterface)
- func (pub *Blspub) Encode(writer io.Writer) (n int, err error)
- func (pub *Blspub) FromPubBytes(b sig.PubKeyBytes) (sig.Pub, error)
- func (pub *Blspub) GenerateSerializedSig(bsig sig.MultiSig) ([]byte, error)
- func (pub *Blspub) GetBitID() bitid.NewBitIDInterface
- func (pub *Blspub) GetBytes(m *messages.Message) ([]byte, error)
- func (pub *Blspub) GetID() messages.HeaderID
- func (pub *Blspub) GetIndex() sig.PubKeyIndex
- func (pub *Blspub) GetMsgID() messages.MsgID
- func (pub *Blspub) GetPubBytes() (sig.PubKeyBytes, error)
- func (pub *Blspub) GetPubID() (sig.PubKeyID, error)
- func (pub *Blspub) GetPubString() (sig.PubKeyStr, error)
- func (pub *Blspub) GetRealPubBytes() (sig.PubKeyBytes, error)
- func (pub *Blspub) GetSigMemberNumber() int
- func (pub *Blspub) MergePub(pub2 sig.MultiPub) (sig.MultiPub, error)
- func (pub *Blspub) MergePubPartial(pub2 sig.MultiPub)
- func (pub *Blspub) New() sig.Pub
- func (pub *Blspub) NewVRFProof() sig.VRFProof
- func (Blspub) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (pub *Blspub) ProofToHash(m sig.SignedMessage, proof sig.VRFProof) (index [32]byte, err error)
- func (pub *Blspub) Serialize(m *messages.Message) (int, error)
- func (pub *Blspub) SetIndex(index sig.PubKeyIndex)
- func (pub *Blspub) ShallowCopy() sig.Pub
- func (pub *Blspub) SubMultiPub(pub2 sig.MultiPub) (sig.MultiPub, error)
- func (pub *Blspub) VerifySig(msg sig.SignedMessage, asig sig.Sig) (bool, error)
- type Blssig
- func (sig *Blssig) Corrupt()
- func (sig *Blssig) Decode(reader io.Reader) (n int, err error)
- func (sig *Blssig) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
- func (sig *Blssig) Encode(writer io.Writer) (n int, err error)
- func (sig *Blssig) GetBytes(m *messages.Message) ([]byte, error)
- func (sig *Blssig) GetID() messages.HeaderID
- func (sig *Blssig) GetMsgID() messages.MsgID
- func (sig *Blssig) GetRand() types.BinVal
- func (sig *Blssig) GetSigBytes() []byte
- func (sig1 *Blssig) MergeSig(sig2 sig.MultiSig) (sig.MultiSig, error)
- func (sig *Blssig) New() sig.Sig
- func (Blssig) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
- func (sig *Blssig) Serialize(m *messages.Message) (int, error)
- func (sig1 *Blssig) SubSig(sig2 sig.MultiSig) (sig.MultiSig, error)
- type PartPriv
- func (priv *PartPriv) Clean()
- func (priv *PartPriv) ComputeSharedSecret(pub sig.Pub) [32]byte
- func (priv *PartPriv) Evaluate(m sig.SignedMessage) (index [32]byte, proof sig.VRFProof)
- func (priv *PartPriv) GenerateSig(header sig.SignedMessage, vrfProof sig.VRFProof, _ types.SignType) (*sig.SigItem, error)
- func (priv *PartPriv) GetBaseKey() sig.Priv
- func (priv *PartPriv) GetPrivForSignType(types.SignType) (sig.Priv, error)
- func (priv *PartPriv) GetPub() sig.Pub
- func (priv *PartPriv) New() sig.Priv
- func (priv *PartPriv) NewSig() sig.Sig
- func (priv *PartPriv) SetIndex(idx sig.PubKeyIndex)
- func (priv *PartPriv) ShallowCopy() sig.Priv
- func (priv *PartPriv) Sign(msg sig.SignedMessage) (sig.Sig, error)
- type PartPub
- func (bpp *PartPub) CheckCoinProof(msg sig.SignedMessage, prf sig.CoinProof) error
- func (bpp *PartPub) CheckSignature(msg *sig.MultipleSignedMessage, sigItem *sig.SigItem) error
- func (bpp *PartPub) CombineProofs(myPriv sig.Priv, items []*sig.SigItem) (coinVal types.BinVal, err error)
- func (bpp *PartPub) DeserializeSig(m *messages.Message, _ types.SignType) (*sig.SigItem, int, error)
- func (bpp *PartPub) GetIndex() sig.PubKeyIndex
- func (bpp *PartPub) GetN() int
- func (bpp *PartPub) GetT() int
- func (bpp *PartPub) New() sig.Pub
- func (bpp *PartPub) NewCoinProof() sig.CoinProof
- func (bpp *PartPub) SetIndex(index sig.PubKeyIndex)
- func (bpp *PartPub) ShallowCopy() sig.Pub
- func (bpp *PartPub) VerifySig(msg sig.SignedMessage, asig sig.Sig) (bool, error)
- type PartSig
- type SharedPub
- type VRFProof
Constants ¶
This section is empty.
Variables ¶
var Stats = sig.SigStats{ PubSize: 128, SigSize: 64, ThrshShareSize: 64, VRFSize: 64, SigVerifyTime: 3329283, SignTime: 439761, ShareVerifyTime: 3329283, ShareGenTime: 439761, MultiCombineTime: 3352, VRFGenTime: 439761, VRFVerifyTime: 3329283, ShareCombineTime: 481735 / 7, AllowsMulti: true, AllowsThresh: true, AllowsVRF: true, }
Functions ¶
func GetBlsPartPrivFunc ¶
func GetBlsPartPrivFunc2 ¶
func GetNewPubFromPubBLSMulti ¶
func GetNewPubFromPubBLSMulti(suite pairing.Suite, pub kyber.Point) (kyber.Point, kyber.Scalar, error)
GetNewPubFromPubBLSMulti multiplies the hash of a public key by its hash This is based on https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html it returns the new public key and the hash
func MarshalSigBLS ¶
MarshallSig marshalls a BLS signature
func NewBLSKeyPair ¶
NewBLSKeyPair generates a new random BLS public/private key pair
func NewBLSMSKeyPair ¶
func NewBLSMSKeyPair(suite pairing.Suite, random cipher.Stream) (kyber.Scalar, kyber.Point, kyber.Point, kyber.Scalar)
NewBLSMSKeyPair creates a new key pair that is based on the new multi-sigs from https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html this code is modified from https://go.dedis.ch/kyber/v3/blob/master/sign/bls/bls.go TODO check if hasing the right objects output is public key, private key, public key * hashed public key, hashed public key
func NewBLSMSKeyPairFrom ¶
func NewBLSMSKeyPairFrom(secret kyber.Scalar, suite pairing.Suite, random cipher.Stream) (kyber.Scalar, kyber.Point, kyber.Point, kyber.Scalar)
NewBLSMSKeyPairFrom is the same as NewBLSMSKeyPair except uses secret as the key.
func NewBlspriv ¶
func NewBlspriv(newBidFunc bitid.FromIntFunc) (sig.Priv, error)
NewBlspriv creates a new random BLS private key
func NewBlsprivFrom ¶
func NewBlsprivFrom(secret kyber.Scalar, newBidFunc bitid.FromIntFunc) sig.Priv
func SignBLSMS ¶
func SignBLSMS(suite pairing.Suite, x kyber.Scalar, hpk kyber.Scalar, msg []byte) (kyber.Point, []byte, error)
SignBLSMS signs a message, returning the signature and the serialzed bytes it is based on https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html
func UnmarshalSig ¶
Unmarshall sig unmarshalls a BLS signature
Types ¶
type BlsShared ¶
type BlsShared struct {}
BlsShared represents precomputed information used to create Bls threshold keys.
func NewBlsShared ¶
NewBLShared creates a BlsShared object for creating BLS threshold keys. It generates private values centrally so is only for testing.
func (*BlsShared) PartialMarshal ¶
func (bs *BlsShared) PartialMarshal() (ret BlsSharedMarshal, err error)
PartialMartial partially martials a BlsShared object into a DSSSharedMarshaled object, which can then be mashaled into json for example. The index is the index of the secret key to marshall, all others secrets are nil.
type BlsSharedMarshal ¶
type BlsSharedMarshal struct {}
BlsSharedMarshaled is a partially marshalled version of BlsShared. It can then be input to the go json marshaller for example.
func (BlsSharedMarshal) PartialUnmarshal ¶
func (bsm BlsSharedMarshal) PartialUnmarshal() (ret *BlsShared, err error)
PartialUnmartial takes a BlsSharedMarshalled object, unmarshals it, and returns a BlsShared object.
type BlsThrsh ¶
type BlsThrsh struct {
// contains filtered or unexported fields
}
func NewBlsThrsh ¶
func NewBlsThrsh(n, t int, idx sig.PubKeyIndex, secret kyber.Scalar, pub kyber.Point, sharedPub kyber.Point) *BlsThrsh
NewBlsThrsh creates an object for a given member of a signature threshold scheme.
func NewNonMemberBlsThrsh ¶
func NewNonMemberBlsThrsh(n, t int, idx sig.PubKeyIndex, sharedPub kyber.Point) *BlsThrsh
NewBlsThrsh creates an object for a signature threshold scheme. The object created can combine signatures, but cannot generate its own partial signature as it is not a member of the scheme.
func (*BlsThrsh) CombinePartialSigs ¶
CombinePartialSigs generates a shared signature from the list of partial signatures.
func (*BlsThrsh) GetPartialPub ¶
func (*BlsThrsh) GetSharedPub ¶
func (*BlsThrsh) PartialSign ¶
PartialSign creates a signature on the message that can also be used to create a shared signature.
func (*BlsThrsh) ShallowCopy ¶
type Blspriv ¶
type Blspriv struct {
// contains filtered or unexported fields
}
Blspriv represents a BLS private key object
func (*Blspriv) ComputeSharedSecret ¶
ComputeSharedSecret returns the hash of Diffie-Hellman.
func (*Blspriv) GenerateSig ¶
func (priv *Blspriv) GenerateSig(header sig.SignedMessage, vrfProof sig.VRFProof, signType types.SignType) (*sig.SigItem, error)
GenerateSig signs a message and returns the SigItem object containing the signature
func (*Blspriv) GetBaseKey ¶
GetBaseKey returns the same key.
func (*Blspriv) GetPrivForSignType ¶
Returns key that is used for signing the sign type.
func (*Blspriv) SetIndex ¶
func (priv *Blspriv) SetIndex(index sig.PubKeyIndex)
SetIndex sets the index of the node represented by this key in the consensus participants
func (*Blspriv) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
type Blspub ¶
type Blspub struct {
// contains filtered or unexported fields
}
Blspub represent a BLS public key object
func (*Blspub) CheckSignature ¶
CheckSignature validates the signature with the public key, it returns an error if a coin proof is included.
func (*Blspub) Clone ¶
Clone returns a new Blspub only containing the points (no bitid), should be called before merging the first set of keys with MergePubPartial
func (*Blspub) Deserialize ¶
func (pub *Blspub) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
Deserialize updates the fields of the BLS pub key object from m, and returns the number of bytes read
func (*Blspub) DeserializeSig ¶
func (pub *Blspub) DeserializeSig(m *messages.Message, signType types.SignType) (*sig.SigItem, int, error)
DeserializeSig takes a message and returns a BLS public key object and signature as well as the number of bytes read
func (*Blspub) DonePartialMerge ¶
func (pub *Blspub) DonePartialMerge(bid bitid.NewBitIDInterface)
DonePartialMerge should be called after merging keys with MergePubPartial to set the bitid
func (*Blspub) FromPubBytes ¶
FromPubBytes creates a BLS pub key object from the bytes of a public key
func (*Blspub) GenerateSerializedSig ¶
GenerateSerializedSig serialized the public key and the signature and returns the bytes
func (*Blspub) GetBitID ¶
func (pub *Blspub) GetBitID() bitid.NewBitIDInterface
GetBitID returns the bit id object representing the indecies of the nodes represented by the BLS public key oject
func (*Blspub) GetIndex ¶
func (pub *Blspub) GetIndex() sig.PubKeyIndex
GetIndex gets the index of the node represented by this key in the consensus participants
func (*Blspub) GetPubBytes ¶
func (pub *Blspub) GetPubBytes() (sig.PubKeyBytes, error)
GetPubBytes returns the BLS pub key as bytes, if using new multi sigs, is pub * hpk, otherwise is just the public key
func (*Blspub) 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 (*Blspub) GetPubString ¶
GetPubString is the same as GetPubBytes, except returns a string
func (*Blspub) GetRealPubBytes ¶
func (pub *Blspub) GetRealPubBytes() (sig.PubKeyBytes, error)
GetPubBytes returns the BLS pub key as bytes
func (*Blspub) GetSigMemberNumber ¶
GetSigMemberNumber returns the number of nodes represented by this BLS pub key
func (*Blspub) MergePubPartial ¶
MergePubPartial only merges the pub itself, does not create the new bitid
func (*Blspub) NewVRFProof ¶
NewVRFProof returns an empty VRFProof object
func (Blspub) PeekHeaders ¶
func (Blspub) PeekHeaders(*messages.Message, types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns nil.
func (*Blspub) ProofToHash ¶
ProofToHash is for validating VRFs. For BLS we just use the first 32 bytes of the signature, TODO is this safe?
func (*Blspub) Serialize ¶
Serialize the pub key into the message, return the number of bytes written
func (*Blspub) SetIndex ¶
func (pub *Blspub) SetIndex(index sig.PubKeyIndex)
SetIndex sets the index of the node represented by this public key in the consensus participants
func (*Blspub) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
func (*Blspub) SubMultiPub ¶
SubBlsPub remove pub2 from pub1 and returns the resulting public key object
type Blssig ¶
type Blssig struct {
// contains filtered or unexported fields
}
Blssig represent a bls signature object
func (*Blssig) Deserialize ¶
func (sig *Blssig) Deserialize(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (int, error)
Deserialize takes a message and fills in the fields of the sig oject from the bytes of the message it returns the number of bytes read
func (*Blssig) GetBytes ¶
GetBytes takes the serialized bls signature in a message and returns the signautre as a byte slice
func (*Blssig) GetSigBytes ¶
GetSigBytes returns the bytes of the serialized signature
func (*Blssig) MergeSig ¶
MergeSig combines two signatures, it assumes the sigs are valid to be merged
func (Blssig) PeekHeaders ¶
func (Blssig) PeekHeaders(m *messages.Message, unmarFunc types.ConsensusIndexFuncs) (index types.ConsensusIndex, err error)
PeekHeader returns nil.
type PartPriv ¶
type PartPriv struct { *BlsThrsh // contains filtered or unexported fields }
Blspriv represents a BLS private key object
func (*PartPriv) ComputeSharedSecret ¶
ComputeSharedSecret returns the hash of Diffie-Hellman.
func (*PartPriv) GenerateSig ¶
func (priv *PartPriv) GenerateSig(header sig.SignedMessage, vrfProof sig.VRFProof, _ types.SignType) (*sig.SigItem, error)
GenerateSig signs a message and returns the SigItem object containing the signature
func (*PartPriv) GetBaseKey ¶
GetBaseKey returns threshold key as a normal BSL key.
func (*PartPriv) GetPrivForSignType ¶
Returns key that is used for signing the sign type.
func (*PartPriv) SetIndex ¶
func (priv *PartPriv) SetIndex(idx sig.PubKeyIndex)
func (*PartPriv) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
type PartPub ¶
type PartPub struct { Blspub // contains filtered or unexported fields }
func NewBlsPartPub ¶
func NewBlsPartPub(idx sig.PubKeyIndex, n, t int, p kyber.Point) *PartPub
func (*PartPub) CheckCoinProof ¶
CheckCoinProof calls VerifySignature since coin proofs are signatures here.
func (*PartPub) CheckSignature ¶
CheckSignature validates the partial threshold signature with the public key, it returns an error if a coin proof is included. Coin messages are verified as partial threshold signatures.
func (*PartPub) CombineProofs ¶
func (bpp *PartPub) CombineProofs(myPriv sig.Priv, items []*sig.SigItem) (coinVal types.BinVal, err error)
CombineProofs combines the signatures to get a random binary value.
func (*PartPub) DeserializeSig ¶
func (bpp *PartPub) DeserializeSig(m *messages.Message, _ types.SignType) (*sig.SigItem, int, error)
DeserializeSig takes a message and returns a BLS public key object and partial signature object as well as the number of bytes read
func (*PartPub) GetIndex ¶
func (bpp *PartPub) GetIndex() sig.PubKeyIndex
GetIndex gets the index of the node represented by this key in the consensus participants
func (*PartPub) NewCoinProof ¶
NewCoinProof returns an empty BLS partial signature object.
func (*PartPub) SetIndex ¶
func (bpp *PartPub) SetIndex(index sig.PubKeyIndex)
func (*PartPub) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.
type SharedPub ¶
type SharedPub struct { // contains filtered or unexported fields }
func NewSharedPub ¶
func (*SharedPub) CheckSignature ¶
CheckSignature validates the signature with the public key, it returns an error if a coin proof is included.
func (*SharedPub) GetPubID ¶
GetPubID returns the id for this pubkey. Given that there is only one threshold pub per consensus it returns PubKeyID("blssharedpub").
func (*SharedPub) GetSigMemberNumber ¶
GetSigMemberNumber returns the number of nodes represented by this BLS pub key
func (*SharedPub) ShallowCopy ¶
Shallow copy makes a copy of the object without following pointers.