stateproofcrypto

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: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// FalconSeedSize Represents the size in bytes of the random bytes used to generate Falcon keys
	FalconSeedSize = 48

	// FalconMaxSignatureSize Represents the max possible size in bytes of a falcon signature
	FalconMaxSignatureSize = cfalcon.CTSignatureSize
)
View Source
const (
	Sha512_256Size    = sha512.Size256
	SumhashDigestSize = sumhash.Sumhash512DigestSize
	Sha256Size        = sha256.Size
)

size of each hash

View Source
const MaxHashDigestSize = SumhashDigestSize

MaxHashDigestSize is used to bound the max digest size. it is important to change it if a hash with a longer output is introduced.

Variables

View Source
var ErrInvalidObject = errors.New("unmarshalled object is invalid")

ErrInvalidObject is used to state that an object decoding has failed because it's invalid.

Functions

func GenericHashObj

func GenericHashObj(hsh hash.Hash, h Hashable) []byte

GenericHashObj Makes it easier to sum using hash interface and Hashable interface

func HashRep

func HashRep(h Hashable) []byte

HashRep appends the correct hashid before the message to be hashed.

Types

type FalconPrivateKey

type FalconPrivateKey [cfalcon.PrivateKeySize]byte

FalconPrivateKey is a wrapper for cfalcon.PrivateKeySize (used for packing)

type FalconPublicKey

type FalconPublicKey [cfalcon.PublicKeySize]byte

FalconPublicKey is a wrapper for cfalcon.PublicKeySizey (used for packing)

type FalconSeed

type FalconSeed [FalconSeedSize]byte

FalconSeed represents the seed which is being used to generate Falcon keys

type FalconSignature

type FalconSignature []byte

FalconSignature represents a Falcon signature in a compressed-form

func (FalconSignature) GetFixedLengthHashableRepresentation

func (s FalconSignature) GetFixedLengthHashableRepresentation() ([]byte, error)

GetFixedLengthHashableRepresentation returns a serialized version of the signature

func (FalconSignature) IsSaltVersionEqual

func (s FalconSignature) IsSaltVersionEqual(version byte) bool

IsSaltVersionEqual of the signature matches the given version

func (FalconSignature) MsgIsZero

func (s FalconSignature) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

type FalconVerifier

type FalconVerifier struct {
	PublicKey FalconPublicKey `codec:"k"`
	// contains filtered or unexported fields
}

FalconVerifier implements the type Verifier interface for the falcon signature scheme.

func (*FalconVerifier) GetFixedLengthHashableRepresentation

func (d *FalconVerifier) GetFixedLengthHashableRepresentation() []byte

GetFixedLengthHashableRepresentation is used to fetch a plain serialized version of the public data (without the use of the msgpack).

func (*FalconVerifier) MsgIsZero

func (d *FalconVerifier) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*FalconVerifier) VerifyBytes

func (d *FalconVerifier) VerifyBytes(data []byte, sig FalconSignature) error

VerifyBytes follows falcon algorithm to verify a signature.

type GenericDigest

type GenericDigest []byte

GenericDigest is a digest that implements CustomSizeDigest, and can be used as hash output.

func (GenericDigest) IsEmpty

func (d GenericDigest) IsEmpty() bool

IsEmpty checks wether the generic digest is an empty one or not

func (GenericDigest) IsEqual

func (d GenericDigest) IsEqual(other GenericDigest) bool

IsEqual compare two digests

func (GenericDigest) ToSlice

func (d GenericDigest) ToSlice() []byte

ToSlice is used inside the Tree itself when interacting with TreeDigest

type HashFactory

type HashFactory struct {
	HashType HashType `codec:"t"`
	// contains filtered or unexported fields
}

HashFactory is responsible for generating new hashes accordingly to the type it stores.

func (*HashFactory) MsgIsZero

func (z *HashFactory) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (HashFactory) NewHash

func (z HashFactory) NewHash() hash.Hash

NewHash generates a new hash.Hash to use.

func (*HashFactory) Validate

func (z *HashFactory) Validate() error

Validate states whether the HashFactory is valid, and is safe to use.

type HashID

type HashID string

HashID is a domain separation prefix for an object type that might be hashed This ensures, for example, the hash of a transaction will never collide with the hash of a vote

type HashType

type HashType uint16

HashType represents different hash functions

const (
	Sha512_256 HashType = iota
	Sumhash
	Sha256
	MaxHashType
)

types of hashes

func (HashType) String

func (h HashType) String() string

func (HashType) Validate

func (h HashType) Validate() error

Validate verifies that the hash type is in a valid range.

type Hashable

type Hashable interface {
	ToBeHashed() (HashID, []byte)
}

Hashable is an interface implemented by an object that can be represented with a sequence of bytes to be hashed or signed, together with a type ID to distinguish different types of objects.

type MessageHash

type MessageHash [32]byte

MessageHash represents the message that a state proof will attest to.

Jump to

Keyboard shortcuts

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