types

package
v0.0.88 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package types contains common types

Index

Constants

View Source
const SignatureLength = int(65)

SignatureLength for ecdsa signature.

Variables

This section is empty.

Functions

func DecodeAgentSignatures added in v0.0.51

func DecodeAgentSignatures(toDecode []byte) ([]Signature, []Signature, error)

DecodeAgentSignatures decodes agent signatures.

func EncodeAgentSignatures added in v0.0.51

func EncodeAgentSignatures(guardSignatures, notarySignatures []Signature) ([]byte, error)

EncodeAgentSignatures encodes the guard and notary signatures.

func EncodeAttestation

func EncodeAttestation(attestation Attestation) ([]byte, error)

EncodeAttestation encodes an attestation.

func EncodeHeader

func EncodeHeader(header Header) ([]byte, error)

EncodeHeader encodes a message header.

func EncodeMessage

func EncodeMessage(m Message) ([]byte, error)

EncodeMessage encodes a message.

func EncodeSignature

func EncodeSignature(sig Signature) ([]byte, error)

EncodeSignature encodes a signature.

func EncodeSignatures added in v0.0.51

func EncodeSignatures(signatures []Signature) ([]byte, error)

EncodeSignatures encodes the signatures.

func EncodeSignedAttestation

func EncodeSignedAttestation(signed SignedAttestation) ([]byte, error)

EncodeSignedAttestation encodes a signed attestation.

func EncodeTips

func EncodeTips(tips Tips) ([]byte, error)

EncodeTips encodes a list of tips.

func Hash added in v0.0.58

func Hash(a Attestation) ([32]byte, error)

Hash takes the hash of the encoded attestation.

func HashRawBytes added in v0.0.58

func HashRawBytes(rawBytes []byte) (common.Hash, error)

HashRawBytes takes the raw bytes and produces a hash.

func TotalTips

func TotalTips(tips Tips) *big.Int

TotalTips gets the combined value of the tips.

Types

type Attestation

type Attestation interface {
	// Origin gets the origin of the attestation
	Origin() uint32
	// Destination gets the destination of the attestation
	Destination() uint32
	// Nonce gets the nonce of the attestation
	Nonce() uint32
	// Root gets the root of the contract
	Root() [32]byte
}

Attestation is the attestation.

func DecodeAttestation

func DecodeAttestation(toDecode []byte) (Attestation, error)

DecodeAttestation decodes an attestation.

func NewAttestation

func NewAttestation(rawKey *big.Int, root [32]byte) Attestation

NewAttestation creates a new attestation.

func NewAttestationFromBytes added in v0.0.34

func NewAttestationFromBytes(rawBytes []byte) Attestation

NewAttestationFromBytes creates a new attesation from raw bytes.

type AttestationAgentCounts added in v0.0.51

type AttestationAgentCounts struct {
	// GuardCount is the number of guard signatures collected in the SignedAttestation.
	GuardCount uint32
	// NotaryCount is the number of notary signatures collected in the SignedAttestation.
	NotaryCount uint32
}

AttestationAgentCounts is the tuple (GuardCount, NotaryCount) so we know how many of each type of signature we have.

func NewAttestationAgentCounts added in v0.0.51

func NewAttestationAgentCounts(rawBytes []byte) AttestationAgentCounts

NewAttestationAgentCounts takes the raw AttestationAgentCounts serialized as a big endian big.Int and converts it to AttestationAgentCounts which is a tuple of (GuardCount, NotaryCount).

func (AttestationAgentCounts) GetRawAgentCounts added in v0.0.51

func (a AttestationAgentCounts) GetRawAgentCounts() []byte

GetRawAgentCounts returns the AttestationAgentCounts which is a tuple of (GuardCount, NotaryCount) as a serialized big.Int.

type AttestationKey added in v0.0.34

type AttestationKey struct {
	// Origin of the attestation
	Origin uint32
	// Destination of the attestation
	Destination uint32
	// Nonce of the attestation
	Nonce uint32
}

AttestationKey is the tuple (origin, destination, nonce).

func NewAttestationKey added in v0.0.51

func NewAttestationKey(rawKey *big.Int) AttestationKey

NewAttestationKey takes the raw AttestationKey serialized as a big endian big.Int and converts it to AttestationKey which is a tuple of (origin, destination, nonce).

func (AttestationKey) GetRawKey added in v0.0.34

func (a AttestationKey) GetRawKey() *big.Int

GetRawKey returns the AttestationKey as a serialized big.Int.

type AttestationState added in v0.0.58

type AttestationState uint32

AttestationState is the state the attestation is in, in terms of being processed by an agent.

const (
	// AttestationStateNotaryUnsigned is when attestation has been fetched from origin but not yet signed.
	AttestationStateNotaryUnsigned AttestationState = iota // 0
	// AttestationStateNotarySignedUnsubmitted is when attestation has been signed but not yet submitted to the attestation collector.
	AttestationStateNotarySignedUnsubmitted // 1
	// AttestationStateNotarySubmittedUnconfirmed is when the attestation was signed and submitted to the attestation collector but not yet confirmed.
	AttestationStateNotarySubmittedUnconfirmed // 2
	// AttestationStateNotaryConfirmed is when the attestation was confirmed as posted on the attestation collector.
	AttestationStateNotaryConfirmed // 3
	// AttestationStateGuardUnsignedAndUnverified is when the attestation was signed by Notary but not yet by the Guard.
	AttestationStateGuardUnsignedAndUnverified // 4
	// AttestationStateGuardUnsignedAndVerified is when the attestation was signed by Notary but not yet by the Guard, but Guard verified it on origin.
	AttestationStateGuardUnsignedAndVerified // 5
	// AttestationStateGuardSignedUnsubmitted is when the attestation was signed by Guard (and Notary) but not yet submitted.
	AttestationStateGuardSignedUnsubmitted // 6
	// AttestationStateGuardSubmittedToCollectorUnconfirmed is when the attestation was signed by Guard and Notary and submitted to the attestation collector but not destination,
	// but we have yet to confirm it on the AttestationCollector.
	AttestationStateGuardSubmittedToCollectorUnconfirmed // 7
	// AttestationStateGuardConfirmedOnCollector is when the attestation was signed by Guard and Notary and submitted to the attestation collector but not destination,
	// and we have confirmed it on the AttestationCollector.
	AttestationStateGuardConfirmedOnCollector // 8
	// AttestationStateSubmittedToDestinationUnconfirmed is when the attestation was signed by Guard and Notary and submitted to the attestation collector and destination but not yet confirmed on destination.
	AttestationStateSubmittedToDestinationUnconfirmed // 9
	// AttestationStateConfirmedOnDestination is when the attestation was confirmed as posted on the destination.
	AttestationStateConfirmedOnDestination // 10
)

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 AttestedDomains added in v0.0.34

type AttestedDomains struct {
	// Origin of the attestation
	Origin uint32
	// Destination of the attestation
	Destination uint32
}

AttestedDomains is the tuple (origin, destination).

func NewAttestedDomains added in v0.0.34

func NewAttestedDomains(rawDomains *big.Int) AttestedDomains

NewAttestedDomains takes the raw AttestedDomains serialized as a big endian big.Int and converts it to AttestedDomains which is a tuple of (origin, destination).

func (AttestedDomains) GetRawDomains added in v0.0.34

func (a AttestedDomains) GetRawDomains() *big.Int

GetRawDomains returns the AttestedDomains which is a tuple of (origin, destination) as a serialized big.Int.

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.

func (ChainType) String

func (i ChainType) String() string

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

type CommittedMessageEncoder struct {
	CommittedRoot common.Hash
	Message       []byte
}

CommittedMessageEncoder is used to export fields for struct encoding.

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

func DecodeHeader(header []byte) (Header, error)

DecodeHeader decodes a header from a byte slice.

func NewHeader

func NewHeader(originDomain uint32, sender common.Hash, nonce uint32, destinationDomain uint32, recipient common.Hash, optimisticSeconds uint32) Header

NewHeader creates a new header type.

type InProgressAttestation added in v0.0.58

type InProgressAttestation interface {
	// SignedAttestation gets the signed attestation
	SignedAttestation() SignedAttestation
	// DispatchedBlockNumber when message was dispatched on origin
	OriginDispatchBlockNumber() uint64
	// SubmittedToAttestationCollectorTime is time when signed attestation was submitted to AttestationCollector
	SubmittedToAttestationCollectorTime() *time.Time
	// SubmittedToDestinationTime is time when signed attestation was submitted to the Destination
	SubmittedToDestinationTime() *time.Time
	// AttestationState is the state the in-progress attestation is in right now
	AttestationState() AttestationState
}

InProgressAttestation is an attestation to be processed by offline agent.

func NewInProgressAttestation added in v0.0.58

func NewInProgressAttestation(signedAttestation SignedAttestation, originDispatchBlockNumber uint64, submittedToAttestationCollectorTime *time.Time, state AttestationState) InProgressAttestation

NewInProgressAttestation creates a new to process attestation.

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

func DecodeMessage(message []byte) (Message, error)

DecodeMessage decodes a message from a byte slice.

func NewMessage

func NewMessage(header Header, tips Tips, body []byte) Message

NewMessage creates a new message from fields passed in.

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.

func DecodeProof

func DecodeProof(rawProof []byte) (Proof, error)

DecodeProof decodes a proof.

func NewProof

func NewProof(leaf common.Hash, index uint32, path common.Hash) Proof

NewProof creates a new merkle proof.

type ProofEncoder

type ProofEncoder struct {
	Leaf  common.Hash
	Index uint32
	Path  common.Hash
}

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

func DecodeSignature(toDecode []byte) (sig Signature, err error)

DecodeSignature decodes a signature.

func DecodeSignatures added in v0.0.51

func DecodeSignatures(toDecode []byte) ([]Signature, error)

DecodeSignatures decodes signatures.

func NewSignature

func NewSignature(v, r, s *big.Int) Signature

NewSignature creates a new signature.

type SignedAttestation

type SignedAttestation interface {
	// Attestation gets the unsigned attestation
	Attestation() Attestation
	// GuardSignatures is the guard signatures of the attestation
	GuardSignatures() []Signature
	// NotarySignatures is the notary signatures of the attestation
	NotarySignatures() []Signature
}

SignedAttestation is a signed attestation.

func DecodeSignedAttestation

func DecodeSignedAttestation(toDecode []byte) (SignedAttestation, error)

DecodeSignedAttestation decodes a signed attestation.

func NewSignedAttestation

func NewSignedAttestation(attestation Attestation, guardSignatures []Signature, notarySignatures []Signature) SignedAttestation

NewSignedAttestation creates a new signed attestation.

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

func DecodeTips(toDecode []byte) (Tips, error)

DecodeTips decodes a tips typed mem view.

func NewTips

func NewTips(notaryTip, broadcasterTip, proverTip, executorTip *big.Int) Tips

NewTips creates a new tips type.

Jump to

Keyboard shortcuts

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