Documentation ¶
Index ¶
- Variables
- func CalculateLimit(maxCapacity, numItems, size uint64) uint64
- func DecodeDynamicLength(buf []byte, maxSize int) (int, error)
- func DivideInt(a, b int) (int, bool)
- func DivideInt2(a, b, max int) (int, error)
- func ErrBytesLengthFn(name string, found, expected int) error
- func ErrListTooBigFn(name string, found, max int) error
- func ErrVectorLengthFn(name string, found, expected int) error
- func ExtendUint16(b []uint16, needLen int) []uint16
- func ExtendUint32(b []uint32, needLen int) []uint32
- func ExtendUint64(b []uint64, needLen int) []uint64
- func ExtendUint8(b []uint8, needLen int) []uint8
- func HashWithDefaultHasher(v HashRoot) ([32]byte, error)
- func MarshalBool(dst []byte, b bool) []byte
- func MarshalSSZ(m Marshaler) ([]byte, error)
- func MarshalTime(dst []byte, t time.Time) []byte
- func MarshalUint16(dst []byte, i uint16) []byte
- func MarshalUint32(dst []byte, i uint32) []byte
- func MarshalUint64(dst []byte, i uint64) []byte
- func MarshalUint8(dst []byte, i uint8) []byte
- func ReadOffset(buf []byte) uint64
- func UnmarshalBool(src []byte) bool
- func UnmarshalDynamic(src []byte, length int, f func(indx int, b []byte) error) error
- func UnmarshalSSZTest(content []byte, result interface{}) error
- func UnmarshalTime(src []byte) time.Time
- func UnmarshallUint16(src []byte) uint16
- func UnmarshallUint32(src []byte) uint32
- func UnmarshallUint64(src []byte) uint64
- func UnmarshallUint8(src []byte) uint8
- func ValidateBitlist(buf []byte, bitLimit uint64) error
- func VerifyMultiproof(root []byte, proof [][]byte, leaves [][]byte, indices []int) (bool, error)
- func VerifyProof(root []byte, proof *Proof) (bool, error)
- func WriteOffset(dst []byte, i int) []byte
- type CompressedMultiproof
- type HashFn
- type HashRoot
- type HashWalker
- type Hasher
- func (h *Hasher) Append(i []byte)
- func (h *Hasher) AppendBytes32(b []byte)
- func (h *Hasher) AppendUint32(i uint32)
- func (h *Hasher) AppendUint64(i uint64)
- func (h *Hasher) AppendUint8(i uint8)
- func (h *Hasher) FillUpTo32()
- func (h *Hasher) Hash() []byte
- func (h *Hasher) HashRoot() (res [32]byte, err error)
- func (h *Hasher) Index() int
- func (h *Hasher) Merkleize(indx int)
- func (h *Hasher) MerkleizeWithMixin(indx int, num, limit uint64)
- func (h *Hasher) PutBitlist(bb []byte, maxSize uint64)
- func (h *Hasher) PutBool(b bool)
- func (h *Hasher) PutBytes(b []byte)
- func (h *Hasher) PutRootVector(b [][]byte, maxCapacity ...uint64) error
- func (h *Hasher) PutUint16(i uint16)
- func (h *Hasher) PutUint32(i uint32)
- func (h *Hasher) PutUint64(i uint64)
- func (h *Hasher) PutUint64Array(b []uint64, maxCapacity ...uint64)
- func (h *Hasher) PutUint8(i uint8)
- func (h *Hasher) Reset()
- type HasherPool
- type Marshaler
- type Multiproof
- type Node
- func EmptyLeaf() *Node
- func LeafFromBool(b bool) *Node
- func LeafFromBytes(b []byte) *Node
- func LeafFromUint16(i uint16) *Node
- func LeafFromUint32(i uint32) *Node
- func LeafFromUint64(i uint64) *Node
- func LeafFromUint8(i uint8) *Node
- func LeavesFromUint64(items []uint64) []*Node
- func NewEmptyNode(zeroOrderHash []byte) *Node
- func NewNodeWithLR(left, right *Node) *Node
- func NewNodeWithValue(value []byte) *Node
- func ProofTree(v HashRoot) (*Node, error)
- func TreeFromChunks(chunks [][]byte) (*Node, error)
- func TreeFromNodes(leaves []*Node, limit int) (*Node, error)
- func TreeFromNodesWithMixin(leaves []*Node, num, limit int) (*Node, error)
- type Proof
- type Unmarshaler
- type Wrapper
- func (w *Wrapper) AddBytes(b []byte)
- func (w *Wrapper) AddEmpty()
- func (w *Wrapper) AddNode(n *Node)
- func (w *Wrapper) AddUint16(i uint16)
- func (w *Wrapper) AddUint32(i uint32)
- func (w *Wrapper) AddUint64(i uint64)
- func (w *Wrapper) AddUint8(i uint8)
- func (w *Wrapper) Append(i []byte)
- func (w *Wrapper) AppendBytes32(b []byte)
- func (w *Wrapper) AppendUint32(i uint32)
- func (w *Wrapper) AppendUint64(i uint64)
- func (w *Wrapper) AppendUint8(i uint8)
- func (w *Wrapper) Commit(i int)
- func (w *Wrapper) CommitWithMixin(i, num, limit int)
- func (w *Wrapper) FillUpTo32()
- func (w *Wrapper) Hash() []byte
- func (w *Wrapper) Index() int
- func (w *Wrapper) Merkleize(indx int)
- func (w *Wrapper) MerkleizeWithMixin(indx int, num, limit uint64)
- func (w *Wrapper) Node() *Node
- func (w *Wrapper) PutBitlist(bb []byte, maxSize uint64)
- func (w *Wrapper) PutBool(b bool)
- func (w *Wrapper) PutBytes(b []byte)
- func (w *Wrapper) PutUint16(i uint16)
- func (w *Wrapper) PutUint32(i uint32)
- func (w *Wrapper) PutUint64(i uint64)
- func (w *Wrapper) PutUint64Array(b []uint64, maxCapacity ...uint64)
- func (w *Wrapper) PutUint8(i uint8)
Constants ¶
This section is empty.
Variables ¶
var ( ErrOffset = fmt.Errorf("incorrect offset") ErrSize = fmt.Errorf("incorrect size") ErrBytesLength = fmt.Errorf("bytes array does not have the correct length") ErrVectorLength = fmt.Errorf("vector does not have the correct length") ErrListTooBig = fmt.Errorf("list length is higher than max value") ErrEmptyBitlist = fmt.Errorf("bitlist is empty") ErrInvalidVariableOffset = fmt.Errorf("invalid ssz encoding. first variable element offset indexes into fixed value data") )
var ( // ErrIncorrectByteSize means that the byte size is incorrect ErrIncorrectByteSize = fmt.Errorf("incorrect byte size") // ErrIncorrectListSize means that the size of the list is incorrect ErrIncorrectListSize = fmt.Errorf("incorrect list size") )
Functions ¶
func CalculateLimit ¶
func DecodeDynamicLength ¶
DecodeDynamicLength decodes the length from the dynamic input
func DivideInt2 ¶
func ErrBytesLengthFn ¶
func ErrListTooBigFn ¶
func ErrVectorLengthFn ¶
func ExtendUint16 ¶
ExtendUint16 extends a uint16 buffer to a given size
func ExtendUint32 ¶
ExtendUint32 extends a uint32 buffer to a given size
func ExtendUint64 ¶
ExtendUint64 extends a uint64 buffer to a given size
func ExtendUint8 ¶
ExtendUint16 extends a uint16 buffer to a given size
func HashWithDefaultHasher ¶
HashWithDefaultHasher hashes a HashRoot object with a Hasher from the default HasherPool
func MarshalBool ¶
MarshalBool marshals a boolean to dst
func MarshalTime ¶
MarshalTime marshals a time to dst
func MarshalUint16 ¶
MarshalUint16 marshals a little endian uint16 to dst
func MarshalUint32 ¶
MarshalUint32 marshals a little endian uint32 to dst
func MarshalUint64 ¶
MarshalUint64 marshals a little endian uint64 to dst
func MarshalUint8 ¶
MarshalUint8 marshals a little endian uint8 to dst
func UnmarshalBool ¶
UnmarshalBool unmarshals a boolean from the src input
func UnmarshalDynamic ¶
UnmarshalDynamic unmarshals the dynamic items from the input
func UnmarshalSSZTest ¶
func UnmarshalTime ¶
UnmarshalTime unmarshals a time.Time from the src input
func UnmarshallUint16 ¶
UnmarshallUint16 unmarshals a little endian uint16 from the src input
func UnmarshallUint32 ¶
UnmarshallUint32 unmarshals a little endian uint32 from the src input
func UnmarshallUint64 ¶
UnmarshallUint64 unmarshals a little endian uint64 from the src input
func UnmarshallUint8 ¶
UnmarshallUint8 unmarshals a little endian uint8 from the src input
func ValidateBitlist ¶
ValidateBitlist validates that the bitlist is correct
func VerifyMultiproof ¶
VerifyMultiproof verifies a proof for multiple leaves against the given root.
func VerifyProof ¶
VerifyProof verifies a single merkle branch. It's more efficient than VerifyMultiproof for proving one leaf.
Types ¶
type CompressedMultiproof ¶
type CompressedMultiproof struct { Indices []int Leaves [][]byte Hashes [][]byte ZeroLevels []int // Stores the level for every omitted zero hash in the proof }
CompressedMultiproof represents a compressed merkle proof of several leaves. Compression is achieved by omitting zero hashes (and their hashes). `ZeroLevels` contains information which helps the verifier fill in those hashes.
func (*CompressedMultiproof) Decompress ¶
func (c *CompressedMultiproof) Decompress() *Multiproof
Decompress returns a new multiproof, filling in the omitted zero hashes. See `CompressedMultiProof` for more info.
type HashFn ¶
func NativeHashWrapper ¶
type HashWalker ¶
type HashWalker interface { // Intended for testing purposes to know the latest hash generated during merkleize Hash() []byte AppendUint8(i uint8) AppendUint32(i uint32) AppendUint64(i uint64) AppendBytes32(b []byte) PutUint64Array(b []uint64, maxCapacity ...uint64) PutUint64(i uint64) PutUint32(i uint32) PutUint16(i uint16) PutUint8(i uint8) FillUpTo32() Append(i []byte) PutBitlist(bb []byte, maxSize uint64) PutBool(b bool) PutBytes(b []byte) Index() int Merkleize(indx int) MerkleizeWithMixin(indx int, num, limit uint64) }
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher is a utility tool to hash SSZ structs
func NewHasherWithHash ¶
NewHasherWithHash creates a new Hasher object with a custom hash.Hash function
func NewHasherWithHashFn ¶
NewHasherWithHashFn creates a new Hasher object with a custom HashFn function
func (*Hasher) AppendBytes32 ¶
func (*Hasher) AppendUint32 ¶
func (*Hasher) AppendUint64 ¶
func (*Hasher) AppendUint8 ¶
func (*Hasher) FillUpTo32 ¶
func (h *Hasher) FillUpTo32()
func (*Hasher) MerkleizeWithMixin ¶
MerkleizeWithMixin is used to merkleize the last group of the hasher
func (*Hasher) PutBitlist ¶
PutBitlist appends a ssz bitlist
func (*Hasher) PutRootVector ¶
PutRootVector appends an array of roots
func (*Hasher) PutUint64Array ¶
PutUint64Array appends an array of uint64
type HasherPool ¶
type HasherPool struct {
// contains filtered or unexported fields
}
HasherPool may be used for pooling Hashers for similarly typed SSZs.
var DefaultHasherPool HasherPool
DefaultHasherPool is a default hasher pool
type Marshaler ¶
type Marshaler interface { MarshalSSZTo(dst []byte) ([]byte, error) MarshalSSZ() ([]byte, error) SizeSSZ() int }
Marshaler is the interface implemented by types that can marshal themselves into valid SZZ.
type Multiproof ¶
Multiproof represents a merkle proof of several leaves.
func (*Multiproof) Compress ¶
func (p *Multiproof) Compress() *CompressedMultiproof
Compress returns a new proof with zero hashes omitted. See `CompressedMultiproof` for more info.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a node in the tree backing of a SSZ object.
func LeafFromBool ¶
func LeafFromBytes ¶
func LeafFromUint16 ¶
func LeafFromUint32 ¶
func LeafFromUint64 ¶
func LeafFromUint8 ¶
func LeavesFromUint64 ¶
func NewEmptyNode ¶
func NewNodeWithLR ¶
NewNodeWithLR initializes a branch node.
func NewNodeWithValue ¶
NewNodeWithValue initializes a leaf node.
func TreeFromChunks ¶
TreeFromChunks constructs a tree from leaf values. The number of leaves should be a power of 2.
func TreeFromNodes ¶
TreeFromNodes constructs a tree from leaf nodes. This is useful for merging subtrees. The limit should be a power of 2. Adjacent sibling nodes will be filled with zero order hashes that have been precomputed based on the tree depth.
func TreeFromNodesWithMixin ¶
func (*Node) Hash ¶
Hash returns the hash of the subtree with the given Node as its root. If root has no children, it returns root's value (not its hash).
func (*Node) Prove ¶
Prove returns a list of sibling values and hashes needed to compute the root hash for a given general index.
func (*Node) ProveMulti ¶
func (n *Node) ProveMulti(indices []int) (*Multiproof, error)
type Unmarshaler ¶
Unmarshaler is the interface implemented by types that can unmarshal a SSZ description of themselves
type Wrapper ¶
type Wrapper struct {
// contains filtered or unexported fields
}
func (*Wrapper) AppendBytes32 ¶
func (*Wrapper) AppendUint32 ¶
func (*Wrapper) AppendUint64 ¶
func (*Wrapper) AppendUint8 ¶
func (*Wrapper) CommitWithMixin ¶
func (*Wrapper) FillUpTo32 ¶
func (w *Wrapper) FillUpTo32()
func (*Wrapper) MerkleizeWithMixin ¶
func (*Wrapper) PutBitlist ¶
func (*Wrapper) PutUint64Array ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Code generated by fastssz.
|
Code generated by fastssz. |
testcases
Code generated by fastssz.
|
Code generated by fastssz. |
testcases/other
Code generated by fastssz.
|
Code generated by fastssz. |
Code generated by fastssz.
|
Code generated by fastssz. |