Documentation ¶
Index ¶
- Constants
- Variables
- func CommitmentMaxSize() (s int)
- func InstallStateProofTable(tx *sql.Tx) error
- func KeyRoundPairMaxSize() (s int)
- func KeysBuilder(numberOfKeys uint64) ([]crypto.FalconSigner, error)
- func SecretsMaxSize() (s int)
- func SignatureMaxSize() (s int)
- func SignerContextMaxSize() (s int)
- func VerifierMaxSize() (s int)
- type Commitment
- func (_ *Commitment) CanMarshalMsg(z interface{}) bool
- func (_ *Commitment) CanUnmarshalMsg(z interface{}) bool
- func (v *Commitment) IsEmpty() bool
- func (z *Commitment) MarshalMsg(b []byte) (o []byte)
- func (z *Commitment) MsgIsZero() bool
- func (z *Commitment) Msgsize() (s int)
- func (z *Commitment) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (z *Commitment) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
- type CommittablePublicKey
- type KeyRoundPair
- func (_ *KeyRoundPair) CanMarshalMsg(z interface{}) bool
- func (_ *KeyRoundPair) CanUnmarshalMsg(z interface{}) bool
- func (z *KeyRoundPair) MarshalMsg(b []byte) (o []byte)
- func (z *KeyRoundPair) MsgIsZero() bool
- func (z *KeyRoundPair) Msgsize() (s int)
- func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (z *KeyRoundPair) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
- type Secrets
- func (_ *Secrets) CanMarshalMsg(z interface{}) bool
- func (_ *Secrets) CanUnmarshalMsg(z interface{}) bool
- func (s *Secrets) GetAllKeys() []KeyRoundPair
- func (s *Secrets) GetKey(round uint64) *crypto.FalconSigner
- func (s *Secrets) GetSigner(round uint64) *Signer
- func (s *Secrets) GetVerifier() *Verifier
- func (z *Secrets) MarshalMsg(b []byte) (o []byte)
- func (z *Secrets) MsgIsZero() bool
- func (z *Secrets) Msgsize() (s int)
- func (s *Secrets) Persist(store db.Accessor) error
- func (s *Secrets) RestoreAllSecrets(store db.Accessor) error
- func (z *Secrets) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (z *Secrets) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
- type Signature
- func (_ *Signature) CanMarshalMsg(z interface{}) bool
- func (_ *Signature) CanUnmarshalMsg(z interface{}) bool
- func (s *Signature) GetFixedLengthHashableRepresentation() ([]byte, error)
- func (z *Signature) MarshalMsg(b []byte) (o []byte)
- func (z *Signature) MsgIsZero() bool
- func (z *Signature) Msgsize() (s int)
- func (z *Signature) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (z *Signature) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
- func (s *Signature) ValidateSaltVersion(version byte) error
- type Signer
- type SignerContext
- func (_ *SignerContext) CanMarshalMsg(z interface{}) bool
- func (_ *SignerContext) CanUnmarshalMsg(z interface{}) bool
- func (s *SignerContext) GetVerifier() *Verifier
- func (z *SignerContext) MarshalMsg(b []byte) (o []byte)
- func (z *SignerContext) MsgIsZero() bool
- func (z *SignerContext) Msgsize() (s int)
- func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (z *SignerContext) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
- type Verifier
- func (_ *Verifier) CanMarshalMsg(z interface{}) bool
- func (_ *Verifier) CanUnmarshalMsg(z interface{}) bool
- func (v *Verifier) FirstRoundInKeyLifetime(round uint64) (uint64, error)
- func (z *Verifier) MarshalMsg(b []byte) (o []byte)
- func (z *Verifier) MsgIsZero() bool
- func (z *Verifier) Msgsize() (s int)
- func (z *Verifier) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (z *Verifier) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
- func (v *Verifier) VerifyBytes(round uint64, msg []byte, sig *Signature) error
Constants ¶
const ( MerkleSignatureSchemeHashFunction = crypto.Sumhash MerkleSignatureSchemeRootSize = crypto.SumhashDigestSize // KeyLifetimeDefault defines the default lifetime of a key in the merkle signature scheme (in rounds). KeyLifetimeDefault = 256 // SchemeSaltVersion is the current salt version of merkleSignature SchemeSaltVersion = byte(0) // CryptoPrimitivesID is an identification that the Merkle Signature Scheme uses a subset sum hash function // and a falcon signature scheme. CryptoPrimitivesID = uint16(0) )
HashType/ hashSize relate to the type of hash this package uses.
Variables ¶
var ( ErrStartBiggerThanEndRound = errors.New("cannot create Merkle Signature Scheme because end round is smaller then start round") ErrKeyLifetimeIsZero = errors.New("received zero KeyLifetime") ErrNoStateProofKeyForRound = errors.New("no stateproof key exists for this round") ErrSignatureSchemeVerificationFailed = errors.New("merkle signature verification failed") ErrSignatureSaltVersionMismatch = errors.New("the signature's salt version does not match") )
Errors for the merkle signature scheme
var ErrIndexOutOfBound = errors.New("index is out of bound")
ErrIndexOutOfBound returned when an index is out of the array's bound
var NoKeysCommitment = Commitment{}
NoKeysCommitment is a const hash value of the empty MerkleSignature Commitment.
Functions ¶
func CommitmentMaxSize ¶
func CommitmentMaxSize() (s int)
MaxSize returns a maximum valid message size for this message type
func InstallStateProofTable ¶
InstallStateProofTable creates (or migrates if exists already) the StateProofKeys database table
func KeyRoundPairMaxSize ¶
func KeyRoundPairMaxSize() (s int)
MaxSize returns a maximum valid message size for this message type
func KeysBuilder ¶
func KeysBuilder(numberOfKeys uint64) ([]crypto.FalconSigner, error)
KeysBuilder Responsible for generate slice of falcon keys
func SecretsMaxSize ¶
func SecretsMaxSize() (s int)
MaxSize returns a maximum valid message size for this message type
func SignatureMaxSize ¶
func SignatureMaxSize() (s int)
MaxSize returns a maximum valid message size for this message type
func SignerContextMaxSize ¶
func SignerContextMaxSize() (s int)
MaxSize returns a maximum valid message size for this message type
func VerifierMaxSize ¶
func VerifierMaxSize() (s int)
MaxSize returns a maximum valid message size for this message type
Types ¶
type Commitment ¶
type Commitment [MerkleSignatureSchemeRootSize]byte
Commitment represents the root of the vector commitment tree built upon the MSS keys.
func (*Commitment) CanMarshalMsg ¶
func (_ *Commitment) CanMarshalMsg(z interface{}) bool
func (*Commitment) CanUnmarshalMsg ¶
func (_ *Commitment) CanUnmarshalMsg(z interface{}) bool
func (*Commitment) IsEmpty ¶
func (v *Commitment) IsEmpty() bool
IsEmpty returns true if the verifier contains an empty key
func (*Commitment) MarshalMsg ¶
func (z *Commitment) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (*Commitment) MsgIsZero ¶
func (z *Commitment) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (*Commitment) Msgsize ¶
func (z *Commitment) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Commitment) UnmarshalMsg ¶
func (z *Commitment) UnmarshalMsg(bts []byte) (o []byte, err error)
func (*Commitment) UnmarshalMsgWithState ¶
func (z *Commitment) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type CommittablePublicKey ¶
type CommittablePublicKey struct { VerifyingKey crypto.FalconVerifier Round uint64 }
CommittablePublicKey is used to create a binary representation of public keys in the merkle signature scheme.
func (*CommittablePublicKey) ToBeHashed ¶
func (e *CommittablePublicKey) ToBeHashed() (protocol.HashID, []byte)
ToBeHashed returns the sequence of bytes that would be used as an input for the hash function when creating a merkle tree. In order to create a more SNARK-friendly commitment we must avoid using the msgpack infrastructure. msgpack creates a compressed representation of the struct which might be varied in length, this will be bad for creating SNARK
type KeyRoundPair ¶
type KeyRoundPair struct { Round uint64 `codec:"rnd"` Key *crypto.FalconSigner `codec:"key"` // contains filtered or unexported fields }
KeyRoundPair represents an ephemeral signing key with it's corresponding round
func (*KeyRoundPair) CanMarshalMsg ¶
func (_ *KeyRoundPair) CanMarshalMsg(z interface{}) bool
func (*KeyRoundPair) CanUnmarshalMsg ¶
func (_ *KeyRoundPair) CanUnmarshalMsg(z interface{}) bool
func (*KeyRoundPair) MarshalMsg ¶
func (z *KeyRoundPair) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (*KeyRoundPair) MsgIsZero ¶
func (z *KeyRoundPair) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (*KeyRoundPair) Msgsize ¶
func (z *KeyRoundPair) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*KeyRoundPair) UnmarshalMsg ¶
func (z *KeyRoundPair) UnmarshalMsg(bts []byte) (o []byte, err error)
func (*KeyRoundPair) UnmarshalMsgWithState ¶
func (z *KeyRoundPair) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Secrets ¶
type Secrets struct { SignerContext // contains filtered or unexported fields }
Secrets contains the private data needed by the merkle signature scheme.
func New ¶
New creates secrets needed for the merkle signature scheme. This function generates one key for each round within the participation period [firstValid, lastValid] (inclusive bounds) which holds round % interval == 0.
func (*Secrets) CanMarshalMsg ¶
func (*Secrets) CanUnmarshalMsg ¶
func (*Secrets) GetAllKeys ¶
func (s *Secrets) GetAllKeys() []KeyRoundPair
GetAllKeys returns all stateproof secrets. An empty array will be return if no stateproof secrets are found
func (*Secrets) GetKey ¶
func (s *Secrets) GetKey(round uint64) *crypto.FalconSigner
GetKey retrieves key from memory the function return nil if the key does not exists
func (*Secrets) GetSigner ¶
GetSigner returns the secret keys required for the specified round as well as the rest of the required state proof immutable data
func (*Secrets) GetVerifier ¶
GetVerifier can be used to store the commitment and verifier for this signer.
func (*Secrets) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Secrets) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Secrets) Persist ¶
Persist dumps the keys into the database and deletes the reference to them in Secrets
func (*Secrets) RestoreAllSecrets ¶
RestoreAllSecrets fetch all stateproof secrets from a persisted storage into memory
func (*Secrets) UnmarshalMsgWithState ¶
UnmarshalMsg implements msgp.Unmarshaler
type Signature ¶
type Signature struct { Signature crypto.FalconSignature `codec:"sig"` VectorCommitmentIndex uint64 `codec:"idx"` Proof merklearray.SingleLeafProof `codec:"prf"` VerifyingKey crypto.FalconVerifier `codec:"vkey"` // contains filtered or unexported fields }
Signature represents a signature in the merkle signature scheme using falcon signatures as an underlying crypto scheme. It consists of an ephemeral public key, a signature, a merkle verification path and an index. The merkle signature considered valid only if the Signature is verified under the ephemeral public key and the Merkle verification path verifies that the ephemeral public key is located at the given index of the tree (for the root given in the long-term public key). More details can be found on Algorand's spec
func (*Signature) CanMarshalMsg ¶
func (*Signature) CanUnmarshalMsg ¶
func (*Signature) GetFixedLengthHashableRepresentation ¶
GetFixedLengthHashableRepresentation returns the signature as a hashable byte sequence. the format details can be found in the Algorand's spec.
func (*Signature) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Signature) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Signature) UnmarshalMsgWithState ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Signature) ValidateSaltVersion ¶
ValidateSaltVersion validates that the version of the signature is matching the expected version
type Signer ¶
type Signer struct { SigningKey *crypto.FalconSigner // The round for which the signature would be valid Round uint64 SignerContext }
Signer represents the StateProof signer for a specified round.
func (*Signer) FirstRoundInKeyLifetime ¶
FirstRoundInKeyLifetime calculates the round of the valid key for a given round by lowering to the closest KeyLiftime divisor.
type SignerContext ¶
type SignerContext struct { FirstValid uint64 `codec:"fv"` KeyLifetime uint64 `codec:"iv"` Tree merklearray.Tree `codec:"tree"` // contains filtered or unexported fields }
SignerContext contains all the immutable data and metadata related to merklesignature.Secrets (without the secret keys)
func (*SignerContext) CanMarshalMsg ¶
func (_ *SignerContext) CanMarshalMsg(z interface{}) bool
func (*SignerContext) CanUnmarshalMsg ¶
func (_ *SignerContext) CanUnmarshalMsg(z interface{}) bool
func (*SignerContext) GetVerifier ¶
func (s *SignerContext) GetVerifier() *Verifier
GetVerifier can be used to store the commitment and verifier for this signer.
func (*SignerContext) MarshalMsg ¶
func (z *SignerContext) MarshalMsg(b []byte) (o []byte)
MarshalMsg implements msgp.Marshaler
func (*SignerContext) MsgIsZero ¶
func (z *SignerContext) MsgIsZero() bool
MsgIsZero returns whether this is a zero value
func (*SignerContext) Msgsize ¶
func (z *SignerContext) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*SignerContext) UnmarshalMsg ¶
func (z *SignerContext) UnmarshalMsg(bts []byte) (o []byte, err error)
func (*SignerContext) UnmarshalMsgWithState ¶
func (z *SignerContext) UnmarshalMsgWithState(bts []byte, st msgp.UnmarshalState) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Verifier ¶
type Verifier struct { Commitment Commitment `codec:"cmt"` KeyLifetime uint64 `codec:"lf"` // contains filtered or unexported fields }
Verifier is used to verify a merklesignature.Signature produced by merklesignature.Secrets.
func (*Verifier) CanMarshalMsg ¶
func (*Verifier) CanUnmarshalMsg ¶
func (*Verifier) FirstRoundInKeyLifetime ¶
FirstRoundInKeyLifetime calculates the round of the valid key for a given round by lowering to the closest KeyLiftime divisor.
func (*Verifier) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Verifier) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Verifier) UnmarshalMsgWithState ¶
UnmarshalMsg implements msgp.Unmarshaler