2023-12-21 17:05:53 +08:00
|
|
|
# Nimbus
|
2024-02-28 18:31:45 +01:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-12-21 17:05:53 +08:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
2024-02-28 18:31:45 +01:00
|
|
|
import stint, eth/[common, trie], ./state_proof_types
|
2023-12-21 17:05:53 +08:00
|
|
|
|
|
|
|
proc generateAccountProof*(
|
2024-02-28 18:31:45 +01:00
|
|
|
state: AccountState, address: EthAddress
|
|
|
|
): AccountProof {.raises: [RlpError].} =
|
2023-12-21 17:05:53 +08:00
|
|
|
let key = keccakHash(address).data
|
|
|
|
state.getBranch(key).AccountProof
|
|
|
|
|
|
|
|
proc generateStorageProof*(
|
2024-02-28 18:31:45 +01:00
|
|
|
state: StorageState, slotKey: UInt256
|
|
|
|
): StorageProof {.raises: [RlpError].} =
|
2023-12-21 17:05:53 +08:00
|
|
|
let key = keccakHash(toBytesBE(slotKey)).data
|
2024-02-28 18:31:45 +01:00
|
|
|
state.getBranch(key).StorageProof
|