common

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMagicBytes

func GetMagicBytes() [32]byte

Types

type BlockMerkleRoot

type BlockMerkleRoot = Commitment

type BlockMerkleSnapshot

type BlockMerkleSnapshot struct {
	Root   BlockMerkleRoot
	Height uint64
}

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

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

func (*FeeInfo) Commit

func (self *FeeInfo) Commit() Commitment

type HotShotBlockMerkleProof

type HotShotBlockMerkleProof struct {
	Proof json.RawMessage `json:"proof"`
}

func (*HotShotBlockMerkleProof) Verify

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

type NamespaceProof = json.RawMessage

type NsTable

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

func (*NsTable) Commit

func (self *NsTable) Commit() Commitment

func (*NsTable) UnmarshalJSON

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

func (b *RawCommitmentBuilder) ArrayField(f string, array []Commitment) *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 Signature

type Signature struct {
	R U256   `json:"r"`
	S U256   `json:"s"`
	V uint64 `json:"v"`
}

func (*Signature) Bytes

func (s *Signature) Bytes() [65]byte

type TaggedBase64

type TaggedBase64 = tagged_base64.TaggedBase64

type Transaction

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

func (*Transaction) Commit

func (self *Transaction) Commit() Commitment

func (*Transaction) UnmarshalJSON

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

type TransactionQueryData

type TransactionQueryData struct {
	Transaction Transaction     `json:"transaction"`
	Hash        *TaggedBase64   `json:"hash"`
	Index       uint64          `json:"index"`
	Proof       json.RawMessage `json:"proof"`
	BlockHash   *TaggedBase64   `json:"block_hash"`
	BlockHeight uint64          `json:"block_height"`
}

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

func (i *U256) ToDecimal() *U256Decimal

func (*U256) UnmarshalJSON

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

type U256Decimal

type U256Decimal struct {
	big.Int
}

A readable decimal format for U256. Please use the struct `U256` to initialize the number first and use the `ToDecimal` to convert.

func (U256Decimal) MarshalJSON

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

func (*U256Decimal) ToU256

func (i *U256Decimal) ToU256() *U256

func (*U256Decimal) UnmarshalJSON

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

type Version

type Version struct {
	Major uint16 `json:"major"`
	Minor uint16 `json:"minor"`
}

func (Version) MarshalJSON added in v0.0.26

func (v Version) MarshalJSON() ([]byte, error)

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(b []byte) error

type VidCommon

type VidCommon = json.RawMessage

type VidCommonQueryData

type VidCommonQueryData struct {
	Height      uint64        `json:"height"`
	BlockHash   *TaggedBase64 `json:"block_hash"`
	PayloadHash *TaggedBase64 `json:"payload_hash"`
	Common      VidCommon     `json:"common"`
}

Jump to

Keyboard shortcuts

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