types

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMagicBytes added in v0.0.9

func GetMagicBytes() [32]byte

Types

type BlockMerkleRoot added in v0.0.10

type BlockMerkleRoot = Commitment

type Bytes

type Bytes []byte

A bytes type which serializes to JSON as an array, rather than a base64 string. This ensures compatibility with the Espresso APIs.

func (Bytes) MarshalJSON

func (b Bytes) MarshalJSON() ([]byte, error)

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(in []byte) error

type Commitment

type Commitment [32]byte

func CommitmentFromUint256

func CommitmentFromUint256(n *U256) (Commitment, error)

func (Commitment) Equals

func (c Commitment) Equals(other Commitment) bool

func (Commitment) Uint256

func (c Commitment) Uint256() *U256

type FeeInfo added in v0.0.7

type FeeInfo struct {
	Account common.Address `json:"account"`
	Amount  U256           `json:"amount"`
}

func (*FeeInfo) Commit added in v0.0.7

func (self *FeeInfo) Commit() Commitment
type Header struct {
	Height              uint64        `json:"height"`
	Timestamp           uint64        `json:"timestamp"`
	L1Head              uint64        `json:"l1_head"`
	L1Finalized         *L1BlockInfo  `json:"l1_finalized"           rlp:"nil"`
	NsTable             *NsTable      `json:"ns_table"`
	PayloadCommitment   *TaggedBase64 `json:"payload_commitment"`
	BlockMerkleTreeRoot *TaggedBase64 `json:"block_merkle_tree_root"`
	FeeMerkleTreeRoot   *TaggedBase64 `json:"fee_merkle_tree_root"`
	FeeInfo             *FeeInfo      `json:"fee_info"`
}

func (*Header) Commit

func (self *Header) Commit() Commitment

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(b []byte) error

type HotShotBlockMerkleProof added in v0.0.10

type HotShotBlockMerkleProof json.RawMessage

func (*HotShotBlockMerkleProof) Verify added in v0.0.10

Validates a block merkle proof, returning the validated HotShot block height. This is mocked until we have real merkle tree snapshot support.

type L1BlockInfo

type L1BlockInfo struct {
	Number    uint64      `json:"number"`
	Timestamp U256        `json:"timestamp"`
	Hash      common.Hash `json:"hash"`
}

func (*L1BlockInfo) Commit

func (self *L1BlockInfo) Commit() Commitment

func (*L1BlockInfo) UnmarshalJSON

func (i *L1BlockInfo) UnmarshalJSON(b []byte) error

type NamespaceProof added in v0.0.6

type NamespaceProof = json.RawMessage

type NsTable added in v0.0.6

type NsTable struct {
	Bytes Bytes `json:"bytes"`
}

func (*NsTable) Commit added in v0.0.6

func (self *NsTable) Commit() Commitment

func (*NsTable) UnmarshalJSON added in v0.0.6

func (r *NsTable) UnmarshalJSON(b []byte) error

type RawCommitmentBuilder

type RawCommitmentBuilder struct {
	// contains filtered or unexported fields
}

func NewRawCommitmentBuilder

func NewRawCommitmentBuilder(name string) *RawCommitmentBuilder

func (*RawCommitmentBuilder) ConstantString

func (b *RawCommitmentBuilder) ConstantString(s string) *RawCommitmentBuilder

Append a constant string to the running hash.

WARNING: The string `s` must be a constant. This function does not encode the length of `s` in the hash, which can lead to domain collisions when different strings with different lengths are used depending on the input object.

func (*RawCommitmentBuilder) Field

Include a named field of another committable type.

func (*RawCommitmentBuilder) Finalize

func (b *RawCommitmentBuilder) Finalize() Commitment

func (*RawCommitmentBuilder) FixedSizeBytes

func (b *RawCommitmentBuilder) FixedSizeBytes(bytes Bytes) *RawCommitmentBuilder

Append a fixed size byte array to the running hash.

WARNING: Go's type system cannot express the requirement that `bytes` is a fixed size array of any size. The best we can do is take a dynamically sized slice. However, this function uses a fixed-size encoding; namely, it does not encode the length of `bytes` in the hash, which can lead to domain collisions when this function is called with a slice which can have different lengths depending on the input object.

The caller must ensure that this function is only used with slices whose length is statically determined by the type being committed to.

func (*RawCommitmentBuilder) FixedSizeField

func (b *RawCommitmentBuilder) FixedSizeField(f string, bytes Bytes) *RawCommitmentBuilder

Include a named field of fixed length in the hash.

WARNING: Go's type system cannot express the requirement that `bytes` is a fixed size array of any size. The best we can do is take a dynamically sized slice. However, this function uses a fixed-size encoding; namely, it does not encode the length of `bytes` in the hash, which can lead to domain collisions when this function is called with a slice which can have different lengths depending on the input object.

The caller must ensure that this function is only used with slices whose length is statically determined by the type being committed to.

func (*RawCommitmentBuilder) OptionalField

func (*RawCommitmentBuilder) Uint256

Include a value of type `uint256` in the hash.

func (*RawCommitmentBuilder) Uint256Field

func (b *RawCommitmentBuilder) Uint256Field(f string, n *U256) *RawCommitmentBuilder

Include a named field of type `uint256` in the hash.

func (*RawCommitmentBuilder) Uint64

Include a value of type `uint64` in the hash.

func (*RawCommitmentBuilder) Uint64Field

Include a named field of type `uint64` in the hash.

func (*RawCommitmentBuilder) VarSizeBytes

func (b *RawCommitmentBuilder) VarSizeBytes(bytes Bytes) *RawCommitmentBuilder

Include a byte array whose length can be dynamic to the running hash.

func (*RawCommitmentBuilder) VarSizeField

func (b *RawCommitmentBuilder) VarSizeField(f string, bytes Bytes) *RawCommitmentBuilder

Include a named field of dynamic length in the hash.

type TaggedBase64 added in v0.0.4

type TaggedBase64 = tagged_base64.TaggedBase64

type Transaction

type Transaction struct {
	Namespace uint64 `json:"namespace"`
	Payload   Bytes  `json:"payload"`
}

func (*Transaction) Commit added in v0.0.10

func (self *Transaction) Commit() Commitment

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(b []byte) error

type U256

type U256 struct {
	big.Int
}

A BigInt type which serializes to JSON a a hex string. This ensures compatibility with the Espresso APIs.

func NewU256

func NewU256() *U256

func (U256) Equal

func (i U256) Equal(other U256) bool

func (U256) MarshalJSON

func (i U256) MarshalJSON() ([]byte, error)

func (*U256) SetBigInt

func (i *U256) SetBigInt(n *big.Int) *U256

func (*U256) SetBytes

func (i *U256) SetBytes(buf [32]byte) *U256

func (*U256) SetUint64

func (i *U256) SetUint64(n uint64) *U256

func (*U256) UnmarshalJSON

func (i *U256) UnmarshalJSON(in []byte) error

Jump to

Keyboard shortcuts

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