statekey

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Chapter component for service account state keys.
	ChapterServiceIndex uint8 = 255
	// Hash component for storage state keys begins this this value little endian encoded.
	HashStorageIndex uint32 = math.MaxUint32
	// Hash component for preimage lookup state keys begins this this value little endian encoded.
	HashPreimageLookupIndex uint32 = math.MaxUint32 - 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HashComponent

type HashComponent [27]byte

The hash component of the state key constructor function. See equation D.1 in the graypaper 0.6.6

type StateKey

type StateKey [31]byte

The output of the state key constructor function.

func NewBasic

func NewBasic(i uint8) StateKey

First arity of the stake-key constructor function See equation D.1 in the graypaper 0.6.6

func NewPreimageLookup

func NewPreimageLookup(serviceId block.ServiceId, hash crypto.Hash) (StateKey, error)

Create a new preimage state key. ∀(s ↦ a) ∈ δ, (h ↦ p) ∈ ap ∶ C(s, E4(2^32 −2) ⌢ k_1...24) See equation D.2 in the graypaper v0.6.6

func NewPreimageMeta

func NewPreimageMeta(serviceId block.ServiceId, hash crypto.Hash, length uint32) (StateKey, error)

Create a new preimage state key. ∀(s ↦ a) ∈ δ, ((h,l) ↦ t) ∈ al ∶ C(s, E4(l) ⌢ H(h)_2...25) See equation D.2 in the graypaper v0.6.6

func NewService

func NewService(s block.ServiceId) (StateKey, error)

Second arity of the stake-key constructor function, (uint8, N_S) See equation D.1 in the graypaper v0.6.6

func NewServiceDict

func NewServiceDict(s block.ServiceId, h HashComponent) (StateKey, error)

Last airity of the stake-key constructor function, (N_S, Y_27) See equation D.1 in the graypaper v0.6.6

func NewStorage

func NewStorage(serviceId block.ServiceId, hash crypto.Hash) (StateKey, error)

Create a new storage state key. ∀(s ↦ a) ∈ δ, (k ↦ v) ∈ as ∶ C(s, E4(2^32 − 1) ⌢ k_0...23) See equation D.2 in the graypaper v0.6.6

func (StateKey) ExtractChapterServiceID

func (s StateKey) ExtractChapterServiceID() (uint8,
	block.ServiceId, error)

Extracts the chapter and service ID components from a state key of airty 2. State key is the format: [i, n0, 0, n1, 0, n2, 0, n3, 0, 0,...] where i is an uint8, and n is the service ID (uint32) little endian encoded.

func (StateKey) ExtractServiceIDHash

func (s StateKey) ExtractServiceIDHash() (block.ServiceId, HashComponent, error)

Extracts the service ID and hash components from a state key of airty 3. The state key is the format: [n0, h0, n1, h1, n2, h2, n3, h3, h4, h5,...] Where n is the server ID uint32 little endian encoded, and h is the hash component.

func (StateKey) IsChapterKey

func (s StateKey) IsChapterKey() bool

Checks if the given state key is a chapter key of the format: [i, 0, 0,...]

func (StateKey) IsPreimageLookupKey

func (s StateKey) IsPreimageLookupKey() (bool, error)

Checks if the given state key is a preimage lookup key of the format: [n0, 0xFE, n1, 0xFF, n2, 0xFF, n3, 0xFF, h4, h5,...] Where n is the service ID (uint32) little endian encoded, and h is the hash component.

func (StateKey) IsServiceKey

func (s StateKey) IsServiceKey() bool

Checks if the given state key is a service account key of the format: [255, n0, 0, n1, 0, n2, 0, n3, 0, 0,...] Where n is the service ID (uint32) little endian encoded.

func (StateKey) IsStorageKey

func (s StateKey) IsStorageKey() (bool, error)

Checks if the given state key is a storage key of the format: [n0, 0xFF, n1, 0xFF, n2, 0xFF, n3, 0xFF, h4, h5,...] Where n is the service ID (uint32) little endian encoded, and h is the hash component.

Jump to

Keyboard shortcuts

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