merklesignature

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MerkleSignatureSchemeRootSize = stateproofcrypto.SumhashDigestSize

	// 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.

View Source
const KeysInMSS stateproofcrypto.HashID = "KP"

Variables

View Source
var (
	ErrKeyLifetimeIsZero                 = errors.New("received zero KeyLifetime")
	ErrSignatureSchemeVerificationFailed = errors.New("merkle signature verification failed")
	ErrSignatureSaltVersionMismatch      = errors.New("the signature's salt version does not match")
)

Errors for the merkle signature scheme

Functions

This section is empty.

Types

type Commitment

Commitment represents the root of the vector commitment tree built upon the MSS keys.

type CommittablePublicKey

type CommittablePublicKey struct {
	VerifyingKey stateproofcrypto.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() (stateproofcrypto.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 Signature

type Signature struct {
	Signature             stateproofcrypto.FalconSignature `codec:"sig"`
	VectorCommitmentIndex uint64                           `codec:"idx"`
	Proof                 merklearray.SingleLeafProof      `codec:"prf"`
	VerifyingKey          stateproofcrypto.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) GetFixedLengthHashableRepresentation

func (s *Signature) GetFixedLengthHashableRepresentation() ([]byte, error)

GetFixedLengthHashableRepresentation returns the signature as a hashable byte sequence. the format details can be found in the Algorand's spec.

func (*Signature) MsgIsZero

func (s *Signature) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*Signature) ValidateSaltVersion

func (s *Signature) ValidateSaltVersion(version byte) error

ValidateSaltVersion validates that the version of the signature is matching the expected version

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) FirstRoundInKeyLifetime

func (v *Verifier) FirstRoundInKeyLifetime(round uint64) (uint64, error)

FirstRoundInKeyLifetime calculates the round of the valid key for a given round by lowering to the closest KeyLiftime divisor.

func (*Verifier) VerifyBytes

func (v *Verifier) VerifyBytes(round uint64, msg []byte, sig *Signature) error

VerifyBytes verifies that a merklesignature sig is valid, on a specific round, under a given public key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL