Documentation ¶
Index ¶
- Constants
- Variables
- func InstallStateProofTable(tx *sql.Tx) error
- func KeysBuilder(numberOfKeys uint64) ([]crypto.FalconSigner, 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)
- 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)
- 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)
- 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)
- type Verifier
- func (_ *Verifier) CanMarshalMsg(z interface{}) bool
- func (_ *Verifier) CanUnmarshalMsg(z interface{}) bool
- func (v *Verifier) IsEmpty() bool
- 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 (v *Verifier) Verify(round uint64, msg crypto.Hashable, sig Signature) error
Constants ¶
const ( MerkleSignatureSchemeHashFunction = crypto.Sumhash MerkleSignatureSchemeRootSize = crypto.SumhashDigestSize )
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") ErrDivisorIsZero = errors.New("received zero Interval") ErrNoStateProofKeyForRound = errors.New("no stateproof key exists for this round") ErrSignatureSchemeVerificationFailed = errors.New("merkle signature verification failed") )
Errors for the merkle signature scheme
var CryptoPrimitivesID = uint16(0)
CryptoPrimitivesID is an identification that the Merkle Signature Scheme uses a subset sum hash function and a falcon signature scheme.
var ErrIndexOutOfBound = errors.New("index is out of bound")
ErrIndexOutOfBound returned when an index is out of the array's bound
Functions ¶
func InstallStateProofTable ¶
InstallStateProofTable creates (or migrates if exists already) the StateProofKeys database table
func KeysBuilder ¶
func KeysBuilder(numberOfKeys uint64) ([]crypto.FalconSigner, error)
KeysBuilder Responsible for generate slice of falcon keys
Types ¶
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)
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. In case firstValid equals zero then signer will generate all keys from (0,Z], i.e will not generate key for round zero.
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
type Signature ¶
type Signature struct { Signature crypto.FalconSignature `codec:"sig"` MerkleArrayIndex 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
서명은 기본 암호 체계로 FalconSignature을 사용하는 머클 서명 체계의 서명을 나타냅니다. 임시 공개 키, 서명, 머클 검증 경로 및 인덱스로 구성됩니다. 머클 서명은 서명이 임시 공개 키에서 확인되고 머클 검증 경로가 임시 공개 키가 트리의 주어진 인덱스(장기 공개 키에 주어진 루트에 대해)에 있는지 확인하는 경우에만 유효한 것으로 간주됩니다.
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
type Signer ¶
type Signer struct { SigningKey *crypto.FalconSigner // The round for which this SigningKey is related to Round uint64 SignerContext }
Signer represents the StateProof signer for a specified round.
서명자는 지정된 라운드에 대한 StateProof 서명자를 나타냅니다.
type SignerContext ¶
type SignerContext struct { FirstValid uint64 `codec:"fv"` Interval 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)
UnmarshalMsg implements msgp.Unmarshaler
type Verifier ¶
type Verifier [MerkleSignatureSchemeRootSize]byte
Verifier is used to verify a merklesignature.Signature produced by merklesignature.Secrets.
func (*Verifier) CanMarshalMsg ¶
func (*Verifier) CanUnmarshalMsg ¶
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) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler