Documentation ¶
Overview ¶
Package types contains common types
Index ¶
- Constants
- func EncodeAttestation(attestation Attestation) ([]byte, error)
- func EncodeHeader(header Header) ([]byte, error)
- func EncodeMessage(m Message) ([]byte, error)
- func EncodeSignature(sig Signature) ([]byte, error)
- func EncodeSnapshot(snapshot Snapshot) ([]byte, error)
- func EncodeState(state State) ([]byte, error)
- func EncodeTips(tips Tips) ([]byte, error)
- func HashRawBytes(rawBytes []byte) (common.Hash, error)
- func TotalTips(tips Tips) *big.Int
- type Attestation
- type AttestationSubmitted
- type ChainType
- type CommittedMessage
- type CommittedMessageEncoder
- type Header
- type Message
- type Proof
- type ProofEncoder
- type Signature
- type Snapshot
- type State
- type Tips
Constants ¶
const SignatureLength = int(65)
SignatureLength for ecdsa signature.
Variables ¶
This section is empty.
Functions ¶
func EncodeAttestation ¶
func EncodeAttestation(attestation Attestation) ([]byte, error)
EncodeAttestation encodes an attestation.
func EncodeHeader ¶
EncodeHeader encodes a message header.
func EncodeSignature ¶
EncodeSignature encodes a signature.
func EncodeSnapshot ¶ added in v0.0.130
EncodeSnapshot encodes a snapshot.
func EncodeState ¶ added in v0.0.130
EncodeState encodes a state.
func HashRawBytes ¶ added in v0.0.58
HashRawBytes takes the raw bytes and produces a hash.
Types ¶
type Attestation ¶
type Attestation interface { // SnapshotRoot is the root of the Snapshot Merkle Tree. SnapshotRoot() [32]byte // Height is the height of the Snapshot Merkle Tree. Height() uint8 // Nonce is the attestation nonce. Nonce() uint32 // BlockNumber is the block number when the attestation was created in Summit. BlockNumber() *big.Int // Timestamp is the timestamp when the attestation was created in Summit. Timestamp() *big.Int }
Attestation is the attestation interface.
func DecodeAttestation ¶
func DecodeAttestation(toDecode []byte) (Attestation, error)
DecodeAttestation decodes an attestation.
func NewAttestation ¶
func NewAttestation(snapshotRoot [32]byte, height uint8, nonce uint32, blockNumber *big.Int, timestamp *big.Int) Attestation
NewAttestation creates a new attestation.
type AttestationSubmitted ¶
type AttestationSubmitted interface { // Notary gets the notary of the attestation. Notary() common.Hash // Attestation gets the raw bytes of the attestation. Attestation() []byte }
AttestationSubmitted is the type emitted by the AttestationCollector when an attestation is submitted.
func NewAttestationSubmitted ¶
func NewAttestationSubmitted(notary common.Hash, attestation []byte) AttestationSubmitted
NewAttestationSubmitted creates a new attestation submitted type.
type ChainType ¶
type ChainType uint8
ChainType is the type of chain being used (e.g. evm).
const ( // EVM is a chain that conforms to the evm standard. EVM ChainType = 0 )
func AllChainTypes ¶
func AllChainTypes() []ChainType
AllChainTypes gets all chain types for the chain.
type CommittedMessage ¶
type CommittedMessage interface { // Message is the fully detailed message that was committed Message() []byte // Leaf gets a leaf Leaf() [32]byte // Encode encodes a message Encode() ([]byte, error) }
CommittedMessage is the message that got committed.
func DecodeCommittedMessage ¶
func DecodeCommittedMessage(rawMessage []byte) (CommittedMessage, error)
DecodeCommittedMessage decodes a committed message into a struct.
func NewCommittedMessage ¶
func NewCommittedMessage(message []byte) CommittedMessage
NewCommittedMessage creates a new committed message.
type CommittedMessageEncoder ¶
CommittedMessageEncoder is used to export fields for struct encoding.
type Header ¶
type Header interface { // Version gets the version of the header Version() uint16 // OriginDomain is the origin domain of the message OriginDomain() uint32 // Sender is the sender of the message Sender() common.Hash // Nonce is the nonce of the message Nonce() uint32 // DestinationDomain is the destination domain of the message DestinationDomain() uint32 // Recipient is the recipient of the message Recipient() common.Hash // OptimisticSeconds is the optimistic time period of the message in seconds OptimisticSeconds() uint32 }
Header contains information of a message.
func DecodeHeader ¶
DecodeHeader decodes a header from a byte slice.
type Message ¶
type Message interface { // Version gets the version of the message Version() uint16 // Header gets the message header Header() Header // Tips gets the tips Tips() Tips // Body gets the message body Body() []byte // OriginDomain returns the Slip-44 ID OriginDomain() uint32 // Sender is the address of the sender Sender() common.Hash // Nonce is the count of all previous messages to the destination Nonce() uint32 // DestinationDomain is the slip-44 id of the destination DestinationDomain() uint32 // Recipient is the address of the recipient Recipient() common.Hash // ToLeaf converts a leaf to a keccac256 ToLeaf() (leaf [32]byte, err error) // OptimisticSeconds gets the optimistic seconds count OptimisticSeconds() uint32 }
Message is an interface that contains metadata.
func DecodeMessage ¶
DecodeMessage decodes a message from a byte slice.
type Proof ¶
type Proof interface { // Leaf is the leaf in the proof Leaf() common.Hash // Index is the index in the tree Index() uint32 // Path is the merkle branch Path() common.Hash // Encode encodes a message Encode() ([]byte, error) }
Proof is a merkle proof object. The leaf it's path to the root and its index in the tree.
type ProofEncoder ¶
ProofEncoder is exported to allow proofs to be encoded/deoded from binary.
type Signature ¶
type Signature interface { // V gets the v value of the signature V() *big.Int // R is the r value of the signature R() *big.Int // S is the s value of the signature S() *big.Int }
Signature creates a new signature.
func DecodeSignature ¶
DecodeSignature decodes a signature.
func NewSignature ¶
NewSignature creates a new signature.
type Snapshot ¶ added in v0.0.130
type Snapshot interface { // States are the states of the snapshot. States() []State // SnapshotRootAndProofs returns the snapshot root, calculated from the states, as well as each state's proof. SnapshotRootAndProofs() ([32]byte, [][][]byte, error) // TreeHeight returns the height of the merkle tree given `len(states)*2` leafs. TreeHeight() uint32 // SignSnapshot returns the signature of the snapshot payload signed by the signer SignSnapshot(ctx context.Context, signer signer.Signer) (signer.Signature, []byte, common.Hash, error) }
Snapshot is the snapshot interface.
func DecodeSnapshot ¶ added in v0.0.130
DecodeSnapshot decodes a snapshot.
func NewSnapshot ¶ added in v0.0.130
NewSnapshot creates a new snapshot.
type State ¶ added in v0.0.130
type State interface { // Root is the root of the Origin Merkle Tree. Root() [32]byte // Origin is the domain where Origin is located. Origin() uint32 // Nonce is the amount of dispatched messages. Nonce() uint32 // BlockNumber is the block of the last dispatched message. BlockNumber() *big.Int // Timestamp is the unix time of the last dispatched message. Timestamp() *big.Int // Hash returns the hash of the state. Hash() ([32]byte, error) // SubLeaves returns the left and right sub-leaves of the state. SubLeaves() (leftLeaf, rightLeaf [32]byte, err error) }
State is the state interface.
func DecodeState ¶ added in v0.0.130
DecodeState decodes a state.
type Tips ¶
type Tips interface { // Version gets the version of the tips header Version() uint16 // NotaryTip gets the tips for the notary NotaryTip() *big.Int // BroadcasterTip gets the tips for the broadcaster BroadcasterTip() *big.Int // ProverTip gets the tips for the prover ProverTip() *big.Int // ExecutorTip gets the tips for the executor ExecutorTip() *big.Int }
Tips contain tips used for scientizing different agents.
func DecodeTips ¶
DecodeTips decodes a tips typed mem view.