wire

package
v1.7.0-citest.0-nomain Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

nolint

nolint

nolint

nolint

nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivationTxFromWireV1

func ActivationTxFromWireV1(atx *ActivationTxV1) *types.ActivationTx

func NiPostFromWireV1 added in v1.6.0

func NiPostFromWireV1(nipost *NIPostV1) *types.NIPost

func PostFromWireV1 added in v1.6.0

func PostFromWireV1(post *PostV1) *types.Post

Types

type ATXMetadataV1

type ATXMetadataV1 struct {
	Publish types.EpochID
	MsgHash types.Hash32
}

func (*ATXMetadataV1) DecodeScale

func (t *ATXMetadataV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*ATXMetadataV1) EncodeScale

func (t *ATXMetadataV1) EncodeScale(enc *scale.Encoder) (total int, err error)

type ATXProof added in v1.7.0

type ATXProof struct {
	// LayerID is the layer in which the proof was created. This can be used to implement different versions of the ATX
	// proof in the future.
	Layer types.LayerID
	// ProofType is the type of proof that is being provided.
	ProofType ProofType
	// Proof is the actual proof. Its type depends on the ProofType.
	Proof []byte `scale:"max=1048576"` // max size of proof is 1MiB
}

func (*ATXProof) DecodeScale added in v1.7.0

func (t *ATXProof) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*ATXProof) EncodeScale added in v1.7.0

func (t *ATXProof) EncodeScale(enc *scale.Encoder) (total int, err error)

type ActivationTxV1

type ActivationTxV1 struct {
	InnerActivationTxV1

	SmesherID types.NodeID
	Signature types.EdSignature
	// contains filtered or unexported fields
}

func DecodeAtxV1 added in v1.7.0

func DecodeAtxV1(blob []byte) (*ActivationTxV1, error)

func (*ActivationTxV1) Blob added in v1.7.0

func (atx *ActivationTxV1) Blob() types.AtxBlob

func (*ActivationTxV1) DecodeScale

func (t *ActivationTxV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*ActivationTxV1) EncodeScale

func (t *ActivationTxV1) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*ActivationTxV1) HashInnerBytes

func (atx *ActivationTxV1) HashInnerBytes() (result types.Hash32)

func (*ActivationTxV1) ID added in v1.5.3

func (atx *ActivationTxV1) ID() types.ATXID

func (*ActivationTxV1) MarshalLogObject added in v1.6.0

func (atx *ActivationTxV1) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*ActivationTxV1) SetID added in v1.6.0

func (atx *ActivationTxV1) SetID(id types.ATXID)

func (*ActivationTxV1) Sign added in v1.6.0

func (atx *ActivationTxV1) Sign(signer *signing.EdSigner)

func (*ActivationTxV1) SignedBytes

func (atx *ActivationTxV1) SignedBytes() []byte

type ActivationTxV2 added in v1.6.0

type ActivationTxV2 struct {
	PublishEpoch   types.EpochID
	PositioningATX types.ATXID
	Coinbase       types.Address

	// only present in initial ATX
	Initial      *InitialAtxPartsV2
	PreviousATXs []types.ATXID `scale:"max=256"`
	NiPosts      []NiPostsV2   `scale:"max=2"`

	// The VRF nonce must be valid for the collected space of all included IDs.
	VRFNonce uint64

	// The list of marriages with other IDs.
	// A marriage is permanent and cannot be revoked or repeated.
	// All new IDs that are married to this ID are added to the equivocation set
	// that this ID belongs to.
	// It must contain a self-marriage certificate (needed for malfeasance proofs).
	Marriages []MarriageCertificate `scale:"max=256"`

	// The ID of the ATX containing marriage for the included IDs.
	// Only required when the ATX includes married IDs.
	MarriageATX *types.ATXID

	SmesherID types.NodeID
	Signature types.EdSignature
	// contains filtered or unexported fields
}

func DecodeAtxV2 added in v1.7.0

func DecodeAtxV2(blob []byte) (*ActivationTxV2, error)

func (*ActivationTxV2) Blob added in v1.7.0

func (atx *ActivationTxV2) Blob() types.AtxBlob

func (*ActivationTxV2) DecodeScale added in v1.6.0

func (t *ActivationTxV2) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*ActivationTxV2) EncodeScale added in v1.6.0

func (t *ActivationTxV2) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*ActivationTxV2) ID added in v1.6.0

func (atx *ActivationTxV2) ID() types.ATXID

func (*ActivationTxV2) MarshalLogObject added in v1.6.0

func (atx *ActivationTxV2) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*ActivationTxV2) Sign added in v1.6.0

func (atx *ActivationTxV2) Sign(signer *signing.EdSigner)

func (*ActivationTxV2) SignedBytes added in v1.6.0

func (atx *ActivationTxV2) SignedBytes() []byte

func (*ActivationTxV2) TotalNumUnits added in v1.6.0

func (atx *ActivationTxV2) TotalNumUnits() uint32

type InitialAtxPartsV2 added in v1.6.0

type InitialAtxPartsV2 struct {
	CommitmentATX types.ATXID
	Post          PostV1
}

func (*InitialAtxPartsV2) DecodeScale added in v1.6.0

func (t *InitialAtxPartsV2) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*InitialAtxPartsV2) EncodeScale added in v1.6.0

func (t *InitialAtxPartsV2) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*InitialAtxPartsV2) MarshalLogObject added in v1.6.0

func (parts *InitialAtxPartsV2) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*InitialAtxPartsV2) Root added in v1.6.0

func (i *InitialAtxPartsV2) Root() []byte

type InnerActivationTxV1

type InnerActivationTxV1 struct {
	NIPostChallengeV1

	Coinbase types.Address
	NumUnits uint32

	NIPost   *NIPostV1
	NodeID   *types.NodeID // only present in initial ATX to make hash of the first InnerActivationTxV2 unique
	VRFNonce *uint64       // only present when the nonce changed (or initial ATX)
}

InnerActivationTxV1 is a set of all of an ATX's fields, except the signature. To generate the ATX signature, this structure is serialized and signed.

func (*InnerActivationTxV1) DecodeScale

func (t *InnerActivationTxV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*InnerActivationTxV1) EncodeScale

func (t *InnerActivationTxV1) EncodeScale(enc *scale.Encoder) (total int, err error)

type MarriageCertificate added in v1.6.0

type MarriageCertificate struct {
	// An ATX of the ID that marries. It proves that the ID exists.
	// Note: the reference ATX does not need to be from the previous epoch.
	// It only needs to prove the existence of the ID.
	ReferenceAtx types.ATXID
	// Signature over the other ID that this ID marries with
	// If Alice marries Bob, then Alice signs Bob's ID
	// and Bob includes this certificate in his ATX.
	Signature types.EdSignature
}

MarriageCertificate proves the will of ID to be married with the ID that includes this certificate. A marriage allows for publishing a merged ATX, which can contain PoST for all married IDs. Any ID from the marriage can publish a merged ATX on behalf of all married IDs.

func (*MarriageCertificate) DecodeScale added in v1.6.0

func (t *MarriageCertificate) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*MarriageCertificate) EncodeScale added in v1.6.0

func (t *MarriageCertificate) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*MarriageCertificate) MarshalLogObject added in v1.6.0

func (marriage *MarriageCertificate) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*MarriageCertificate) Root added in v1.6.0

func (mc *MarriageCertificate) Root() []byte

type MerkleProofV1

type MerkleProofV1 struct {
	// Nodes on path from leaf to root (not including leaf)
	Nodes     []types.Hash32 `scale:"max=32"`
	LeafIndex uint64
}

func (*MerkleProofV1) DecodeScale

func (t *MerkleProofV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*MerkleProofV1) EncodeScale

func (t *MerkleProofV1) EncodeScale(enc *scale.Encoder) (total int, err error)

type MerkleProofV2 added in v1.6.0

type MerkleProofV2 struct {
	// Nodes on path from leaf to root (not including leaf)
	Nodes []types.Hash32 `scale:"max=32"`
}

MerkleProofV2 proves membership of multiple challenges in a PoET membership merkle tree.

func (*MerkleProofV2) DecodeScale added in v1.6.0

func (t *MerkleProofV2) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*MerkleProofV2) EncodeScale added in v1.6.0

func (t *MerkleProofV2) EncodeScale(enc *scale.Encoder) (total int, err error)

type NIPostChallengeV1

type NIPostChallengeV1 struct {
	PublishEpoch types.EpochID
	// Sequence number counts the number of ancestors of the ATX. It sequentially increases for each ATX in the chain.
	// Two ATXs with the same sequence number from the same miner can be used as the proof of malfeasance against
	// that miner.
	Sequence uint64
	// the previous ATX's ID (for all but the first in the sequence)
	PrevATXID        types.ATXID
	PositioningATXID types.ATXID

	// CommitmentATXID is the ATX used in the commitment for initializing the PoST of the node.
	CommitmentATXID *types.ATXID
	InitialPost     *PostV1
}

func NIPostChallengeToWireV1

func NIPostChallengeToWireV1(c *types.NIPostChallenge) *NIPostChallengeV1

func (*NIPostChallengeV1) DecodeScale

func (t *NIPostChallengeV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*NIPostChallengeV1) EncodeScale

func (t *NIPostChallengeV1) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*NIPostChallengeV1) Hash

func (c *NIPostChallengeV1) Hash() types.Hash32

Hash serializes the NIPostChallenge and returns its hash. The serialized challenge is first prepended with a byte 0x00, and then hashed for second preimage resistance of poet membership merkle tree.

func (*NIPostChallengeV1) MarshalLogObject added in v1.6.0

func (c *NIPostChallengeV1) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type NIPostChallengeV2 added in v1.6.0

type NIPostChallengeV2 struct {
	PublishEpoch     types.EpochID
	PrevATXID        types.ATXID
	PositioningATXID types.ATXID
	InitialPost      *PostV1
}

NIPostChallengeV2 collects information needed to generate a PoET challenge. It's hash is the challenge registered in the PoET.

func NIPostChallengeToWireV2 added in v1.6.0

func NIPostChallengeToWireV2(c *types.NIPostChallenge) *NIPostChallengeV2

func (*NIPostChallengeV2) DecodeScale added in v1.6.0

func (t *NIPostChallengeV2) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*NIPostChallengeV2) EncodeScale added in v1.6.0

func (t *NIPostChallengeV2) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*NIPostChallengeV2) Hash added in v1.6.0

func (c *NIPostChallengeV2) Hash() types.Hash32

Hash serializes the NIPostChallenge and returns its hash. The serialized challenge is first prepended with a byte 0x00, and then hashed for second preimage resistance of poet membership merkle tree.

func (*NIPostChallengeV2) MarshalLogObject added in v1.6.0

func (c *NIPostChallengeV2) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type NIPostV1

type NIPostV1 struct {
	// Membership proves that the challenge for the PoET, which is
	// constructed from fields in the activation transaction,
	// is a member of the poet's proof.
	// Proof.Root must match the Poet's POSW statement.
	Membership MerkleProofV1

	// Post is the proof that the prover data is still stored (or was recomputed) at
	// the time he learned the challenge constructed from the PoET.
	Post *PostV1

	// PostMetadata is the Post metadata, associated with the proof.
	// The proof should be verified upon the metadata during the syntactic validation,
	// while the metadata should be verified during the contextual validation.
	PostMetadata *PostMetadataV1
}

func NiPostToWireV1 added in v1.6.0

func NiPostToWireV1(n *types.NIPost) *NIPostV1

func (*NIPostV1) DecodeScale

func (t *NIPostV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*NIPostV1) EncodeScale

func (t *NIPostV1) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*NIPostV1) MarshalLogObject added in v1.6.0

func (nipost *NIPostV1) MarshalLogObject(encoder zapcore.ObjectEncoder) error

type NiPostsV2 added in v1.6.0

type NiPostsV2 struct {
	// Single membership proof for all IDs in `Posts`.
	Membership MerkleProofV2
	// The root of the PoET proof, that serves as the challenge for PoSTs.
	Challenge types.Hash32
	Posts     []SubPostV2 `scale:"max=256"` // support merging up to 256 IDs
}

func (*NiPostsV2) DecodeScale added in v1.6.0

func (t *NiPostsV2) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*NiPostsV2) EncodeScale added in v1.6.0

func (t *NiPostsV2) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*NiPostsV2) MarshalLogObject added in v1.6.0

func (posts *NiPostsV2) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*NiPostsV2) Root added in v1.6.0

func (np *NiPostsV2) Root(prevATXs []types.ATXID) []byte

type PostMetadataV1

type PostMetadataV1 struct {
	Challenge     []byte `scale:"max=32"`
	LabelsPerUnit uint64
}

func (*PostMetadataV1) DecodeScale

func (t *PostMetadataV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*PostMetadataV1) EncodeScale

func (t *PostMetadataV1) EncodeScale(enc *scale.Encoder) (total int, err error)

type PostV1

type PostV1 struct {
	Nonce   uint32
	Indices []byte `scale:"max=800"` // up to K2=100
	Pow     uint64
}

func PostToWireV1 added in v1.6.0

func PostToWireV1(p *types.Post) *PostV1

func (*PostV1) DecodeScale

func (t *PostV1) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*PostV1) EncodeScale

func (t *PostV1) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*PostV1) MarshalLogObject added in v1.6.0

func (p *PostV1) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*PostV1) Root added in v1.6.0

func (p *PostV1) Root() []byte

type ProofType added in v1.7.0

type ProofType byte

ProofType is an identifier for the type of proof that is encoded in the ATXProof.

const (
	DoublePublish ProofType = iota + 1
	DoubleMarry
	DoubleMerge
	InvalidPost
)

type SubPostV2 added in v1.6.0

type SubPostV2 struct {
	// Index of marriage certificate for this ID in the 'Marriages' slice. Only valid for merged ATXs.
	// Can be used to extract the nodeID and verify if it is married with the smesher of the ATX.
	// Must be 0 for non-merged ATXs.
	MarriageIndex uint32
	PrevATXIndex  uint32 // Index of the previous ATX in the `InnerActivationTxV2.PreviousATXs` slice
	// Index of the leaf for this ID's challenge in the poet membership tree.
	// IDs might shared the same index if their nipost challenges are equal.
	// This happens when the IDs are continuously merged (they share the previous ATX).
	MembershipLeafIndex uint64
	Post                PostV1
	NumUnits            uint32
}

func (*SubPostV2) DecodeScale added in v1.6.0

func (t *SubPostV2) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*SubPostV2) EncodeScale added in v1.6.0

func (t *SubPostV2) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*SubPostV2) MarshalLogObject added in v1.6.0

func (post *SubPostV2) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (*SubPostV2) Root added in v1.6.0

func (sp *SubPostV2) Root(prevATXs []types.ATXID) []byte

Jump to

Keyboard shortcuts

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