Documentation ¶
Index ¶
- func VerifyEIP1186(proof *StorageProof) (bool, error)
- func VerifyEthAccountProof(proof *StorageProof) (bool, error)
- func VerifyEthStorageProof(proof *StorageResult, storageHash common.Hash) (bool, error)
- func VerifyProof(rootHash common.Hash, key []byte, value []byte, proof [][]byte) (bool, error)
- type MemDB
- type QuantityBytes
- type SliceData
- type StorageProof
- type StorageResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyEIP1186 ¶
func VerifyEIP1186(proof *StorageProof) (bool, error)
VerifyEIP1186 verifies the whole Ethereum proof obtained with eth_getProof method against a StateRoot. It verifies Account proof against StateRoot and all Storage proofs against StorageHash.
func VerifyEthAccountProof ¶
func VerifyEthAccountProof(proof *StorageProof) (bool, error)
VerifyEthAccountProof verifies an Ethereum account proof against the StateRoot. It does not verify the storage proof(s).
func VerifyEthStorageProof ¶
func VerifyEthStorageProof(proof *StorageResult, storageHash common.Hash) (bool, error)
VerifyEthStorageProof verifies an Ethereum storage proof against the StateRoot. It does not verify the account proof against the Ethereum StateHash.
func VerifyProof ¶
VerifyProof verifies that the path generated from key, following the nodes in proof leads to a leaf with value, where the hashes are correct up to the rootHash. WARNING: When the value is not found, `eth_getProof` will return "0x0" at the StorageProof `value` field. In order to verify the proof of non existence, you must set `value` to nil, *not* the RLP encoding of 0 or null (which would be 0x80).
Types ¶
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
MemDB is an ethdb.KeyValueReader implementation which is not thread safe and assumes that all keys are common.Hash.
type QuantityBytes ¶
type QuantityBytes []byte
QuantityBytes marshals/unmarshals as a JSON string in hex with 0x prefix encoded as a QUANTITY. The empty slice marshals as "0x0".
func (QuantityBytes) MarshalText ¶
func (q QuantityBytes) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (*QuantityBytes) UnmarshalText ¶
func (q *QuantityBytes) UnmarshalText(input []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type SliceData ¶
type SliceData [][]byte
SliceData marshals/unmarshals as a JSON vector of strings with in hex with 0x prefix.
func (SliceData) MarshalJSON ¶
MarshalText implements encoding.TextMarshaler
func (*SliceData) UnmarshalJSON ¶
UnmarshalText implements encoding.TextUnmarshaler.
type StorageProof ¶
type StorageProof struct { Height *big.Int `json:"height"` Address common.Address `json:"address"` Balance *hexutil.Big `json:"balance"` CodeHash common.Hash `json:"codeHash"` Nonce hexutil.Uint64 `json:"nonce"` StateRoot common.Hash `json:"stateRoot"` StorageHash common.Hash `json:"storageHash"` AccountProof SliceData `json:"accountProof"` StorageProof []StorageResult `json:"storageProof"` }
StorageProof allows unmarshaling the object returned by `eth_getProof`. From https://eips.ethereum.org/EIPS/eip-1186:
Parameters DATA, 20 Bytes - address of the account. ARRAY, 32 Bytes - array of storage-keys which should be proofed and included. See eth_getStorageAt QUANTITY|TAG - integer block number, or the string "latest" or "earliest", see the default block parameter
Returns ¶
Object - A account object:
balance: QUANTITY - the balance of the account. See eth_getBalance codeHash: DATA, 32 Bytes - hash of the code of the account. For a simple Account without code it will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470" nonce: QUANTITY, - nonce of the account. See eth_getTransactionCount storageHash: DATA, 32 Bytes - SHA3 of the StorageRoot. All storage will deliver a MerkleProof starting with this rootHash. accountProof: ARRAY - Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-Node, following the path of the SHA3 (address) as key. storageProof: ARRAY - Array of storage-entries as requested. Each entry is a object with these properties: key: QUANTITY - the requested storage key value: QUANTITY - the storage value proof: ARRAY - Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3 (key) as path.
NOTE: QUANTITY is supposed to follow this spec: https://infura.io/docs/ethereum#section/Value-encoding/Quantity but go-ethereum sometimes gives the string without the `0x` prefix
type StorageResult ¶
type StorageResult struct { Key QuantityBytes `json:"key"` Value QuantityBytes `json:"value"` Proof SliceData `json:"proof"` }
StorageResult is an object from StorageProof that contains a proof of storage.