Skip to content

Commit 3930a4c

Browse files
nodeKey hashing are done with domain 512 not 256
Am currently making a storage prover in noir and found this error In the zktrie repo nodekeys are hashed with ToSecureKey() in type/util.go (afaik) https://github.com/scroll-tech/zktrie/blob/23181f209e94137f74337b150179aeb80c72e7c8/types/util.go#L107 ToSecureKey() uses Hash() in types/bytes32.go which uses HASH_DOMAIN_BYTE32 as domain which is 256 *2 (512) see here: https://github.com/scroll-tech/zktrie/blob/23181f209e94137f74337b150179aeb80c72e7c8/types/hash.go#L16 and here is where i did my test in noir :D (account leaf is lower in same file) https://github.com/jimjimvalkema/scrollZkStorageProofs/blob/bcdd922405e046e99787b8b47f374befac170779/ScrollStorageProver/src/main.nr#L168
1 parent e064a7b commit 3930a4c

File tree

1 file changed

+2
-2
lines changed
  • src/content/docs/en/technology/sequencer

1 file changed

+2
-2
lines changed

src/content/docs/en/technology/sequencer/zktrie.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ An Ethereum Account Leaf Node consists of an Ethereum address and a state accoun
106106
var address byte[20] // 20 bytes in big-endian
107107
valHi := address[0:16]
108108
valLo := address[16:20] * 2^96 // padding 12 bytes of 0 at the end
109-
nodeKey := h{256}(valHi, valLo)
109+
nodeKey := h{512}(valHi, valLo)
110110
```
111111

112112
A state account struct in the Scroll consists of the following fields (`Fr` indicates the finite field and is a 254-bit value)
@@ -182,7 +182,7 @@ A Storage Leaf Node encodes a key-value pair where both key and value are `u256`
182182
var storageKey byte[32] // 32 bytes in big-endian
183183
valHi := storageKey[0:16]
184184
valLo := storageKey[16:32]
185-
nodeKey := h{256}(valHi, valLo)
185+
nodeKey := h{512}(valHi, valLo)
186186
```
187187

188188
The storage value is a `u256` value. The `flag` for the storage value is 1, shown below.

0 commit comments

Comments
 (0)