Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func CheckLeadingZeroBits(data []byte, expected uint) bool
- func DecodeSliceOfByteSliceWithLimit(d *scale.Decoder, outerLimit, innerLimit uint32) ([][]byte, int, error)
- func EncodeCert(c *Cert) ([]byte, error)
- func FiatShamir(challenge []byte, spaceSize uint64, securityParam uint8) map[uint64]bool
- func FindSubmitPowNonce(ctx context.Context, powChallenge, poetChallenge, nodeID []byte, ...) (uint64, error)
- func HashMembershipTreeNode(buf, lChild, rChild []byte) []byte
- func MakeLabelFunc() func(hash LabelHash, labelID uint64, leftSiblings [][]byte) []byte
- func NewPowHasher(inputs ...[]byte) *powHasher
- type Cert
- type CertOnWire
- type LabelHash
- type MerkleProof
- type NIP
- type OpaqueCert
- type UnixTimestamp
Constants ¶
const ( // T is the security param which determines the number of leaves // to be included in a non-interactive proof. T uint8 = 150 )
Variables ¶
var ErrCertExpired = errors.New("certificate expired")
Functions ¶
func CheckLeadingZeroBits ¶ added in v0.7.0
CheckLeadingZeroBits checks if the first 'expected' bits of the byte array are all zero.
func DecodeSliceOfByteSliceWithLimit ¶ added in v0.6.6
func EncodeCert ¶ added in v0.10.3
func FiatShamir ¶
FiatShamir generates a set of indices to include in a non-interactive proof.
func FindSubmitPowNonce ¶ added in v0.7.0
func FindSubmitPowNonce( ctx context.Context, powChallenge, poetChallenge, nodeID []byte, difficulty uint, ) (uint64, error)
FindSubmitPowNonce finds the nonce that solves the PoW challenge.
func HashMembershipTreeNode ¶ added in v0.8.2
HashMembershipTreeNode calculates internal node of the membership merkle tree.
func MakeLabelFunc ¶ added in v0.2.0
MakeLabelFunc returns a function which generates a PoET DAG label by concatenating a representation of the labelID with the list of left siblings and then hashing the result using the provided hash function.
⚠️ The resulting function is NOT thread-safe, however different generated instances are independent. The code is optimized for performance and memory allocations.
func NewPowHasher ¶ added in v0.9.7
func NewPowHasher(inputs ...[]byte) *powHasher
Types ¶
type Cert ¶ added in v0.10.3
type Cert struct { // The ID that this certificate allows registration for. Pubkey []byte `scale:"max=32"` // The expiration time of the certificate. // The certificate doesn't expire if this field is nil. Expiration *time.Time }
func DecodeCert ¶ added in v0.10.3
func VerifyCertificate ¶ added in v0.10.3
func VerifyCertificate(certificate *OpaqueCert, certifierPubKey, nodeID []byte) (*Cert, error)
type CertOnWire ¶ added in v0.10.3
type CertOnWire struct { Pubkey []byte `scale:"max=32"` Expiration *UnixTimestamp }
CertOnWire is a certificate that is sent `over the wire`. This type is encoded with scale for signing.
func (*CertOnWire) DecodeScale ¶ added in v0.10.3
func (t *CertOnWire) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*CertOnWire) EncodeScale ¶ added in v0.10.3
func (t *CertOnWire) EncodeScale(enc *scale.Encoder) (total int, err error)
type MerkleProof ¶
type MerkleProof struct { Root []byte `scale:"max=32"` ProvenLeaves [][]byte `scale:"max=150"` // max. size is T (security param), and each element is exactly 32 bytes ProofNodes [][]byte `scale:"max=5400"` // 36 nodes per leaf and each node is exactly 32 bytes }
MerkleProof is a non-interactive proof of inclusion in a Merkle tree. Scale encoding is implemented by hand to be able to limit [][]byte slices to a maximum size (inner and outer slices).
func (*MerkleProof) DecodeScale ¶ added in v0.2.0
func (t *MerkleProof) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*MerkleProof) EncodeScale ¶ added in v0.2.0
func (t *MerkleProof) EncodeScale(enc *scale.Encoder) (total int, err error)
type NIP ¶ added in v0.9.2
type NIP struct { MerkleProof Epoch uint Leaves uint64 }
Non-Interactive proof of sequential work.
type OpaqueCert ¶ added in v0.10.3
type OpaqueCert struct { Data []byte // scale-encoded CertOnWire Signature []byte // signature of Data }
OpaqueCert is a certificate that is sent `over the wire`. It holds the encoded certificate and its signature.
func (*OpaqueCert) Decode ¶ added in v0.10.3
func (c *OpaqueCert) Decode() (*Cert, error)
type UnixTimestamp ¶ added in v0.10.3
type UnixTimestamp struct {
Inner uint64
}
func (*UnixTimestamp) DecodeScale ¶ added in v0.10.3
func (t *UnixTimestamp) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*UnixTimestamp) EncodeScale ¶ added in v0.10.3
func (t *UnixTimestamp) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*UnixTimestamp) Time ¶ added in v0.10.3
func (u *UnixTimestamp) Time() *time.Time