merkletree

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LeafTypeBalance specifies that leaf stores Balance
	LeafTypeBalance leafType = 0
	// LeafTypeNonce specifies that leaf stores Nonce
	LeafTypeNonce leafType = 1
	// LeafTypeCode specifies that leaf stores Code
	LeafTypeCode leafType = 2
	// LeafTypeStorage specifies that leaf stores Storage Value
	LeafTypeStorage leafType = 3
	// LeafTypeSCLength specifies that leaf stores Storage Value
	LeafTypeSCLength leafType = 4
)
View Source
const (
	// HashPoseidonAllZeroes represents the poseidon hash for an input with all
	// bits set to zero.
	HashPoseidonAllZeroes = "0xc71603f33a1144ca7953db0ab48808f4c4055e3364a246c33c18a9786cb0b359"
)

Variables

This section is empty.

Functions

func H4ToString

func H4ToString(h4 []uint64) string

H4ToString converts array of 4 Scalars of 64 bits into an hex string.

func HashContractBytecode

func HashContractBytecode(code []byte) ([]uint64, error)

HashContractBytecode computes the bytecode hash in order to add it to the state-tree.

func KeyCodeLength

func KeyCodeLength(ethAddr common.Address) ([]byte, error)

KeyCodeLength returns the key of code length leaf: hk0: H([0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0]) key: H([ethAddr[0:4], ethAddr[4:8], ethAddr[8:12], ethAddr[12:16], ethAddr[16:20], 0, 4, 0], [hk0[0], hk0[1], hk0[2], hk0[3]]

func KeyContractCode

func KeyContractCode(ethAddr common.Address) ([]byte, error)

KeyContractCode returns the key of contract code leaf: hk0: H([0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0]) key: H([ethAddr[0:4], ethAddr[4:8], ethAddr[8:12], ethAddr[12:16], ethAddr[16:20], 0, 2, 0], [hk0[0], hk0[1], hk0[2], hk0[3]]

func KeyContractStorage

func KeyContractStorage(ethAddr common.Address, storagePos []byte) ([]byte, error)

KeyContractStorage returns the key of contract storage position leaf: hk0: H([stoPos[0:4], stoPos[4:8], stoPos[8:12], stoPos[12:16], stoPos[16:20], stoPos[20:24], stoPos[24:28], stoPos[28:32], [0, 0, 0, 0]) key: H([ethAddr[0:4], ethAddr[4:8], ethAddr[8:12], ethAddr[12:16], ethAddr[16:20], 0, 3, 0], [hk0[0], hk0[1], hk0[2], hk0[3])

func KeyEthAddrBalance

func KeyEthAddrBalance(ethAddr common.Address) ([]byte, error)

KeyEthAddrBalance returns the key of balance leaf: hk0: H([0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0]) key: H([ethAddr[0:4], ethAddr[4:8], ethAddr[8:12], ethAddr[12:16], ethAddr[16:20], 0, 0, 0], [hk0[0], hk0[1], hk0[2], hk0[3]])

func KeyEthAddrNonce

func KeyEthAddrNonce(ethAddr common.Address) ([]byte, error)

KeyEthAddrNonce returns the key of nonce leaf: hk0: H([0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0]) key: H([ethAddr[0:4], ethAddr[4:8], ethAddr[8:12], ethAddr[12:16], ethAddr[16:20], 0, 1, 0], [hk0[0], hk0[1], hk0[2], hk0[3]]

func ScalarToFilledByteSlice

func ScalarToFilledByteSlice(s *big.Int) []byte

ScalarToFilledByteSlice converts a *big.Int into an array of maxBigIntLen bytes.

func StringToh4

func StringToh4(str string) ([]uint64, error)

StringToh4 converts an hex string into array of 4 Scalars of 64 bits.

Types

type Key

type Key [32]byte

Key stores key of the leaf

Jump to

Keyboard shortcuts

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