From ea133572f14bbe8a5bcdf115da0204ffd8100f55 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 17 Feb 2022 13:55:31 +0100 Subject: [PATCH 1/2] remove ineffective statement --- trie/utils/verkle.go | 1 - 1 file changed, 1 deletion(-) diff --git a/trie/utils/verkle.go b/trie/utils/verkle.go index c54af04877a5..421b2e578bf5 100644 --- a/trie/utils/verkle.go +++ b/trie/utils/verkle.go @@ -42,7 +42,6 @@ var ( func GetTreeKey(address []byte, treeIndex *uint256.Int, subIndex byte) []byte { var poly [256]fr.Element - verkle.FromLEBytes(&poly[0], []byte{1}) verkle.FromLEBytes(&poly[0], []byte{2, 63}) verkle.FromLEBytes(&poly[1], address[:16]) verkle.FromLEBytes(&poly[2], address[16:]) From 38fbd23197ef325d8ae88492bf77148442c7045d Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 17 Feb 2022 14:00:00 +0100 Subject: [PATCH 2/2] fix endianness in pedersen_hash --- trie/utils/verkle.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trie/utils/verkle.go b/trie/utils/verkle.go index 421b2e578bf5..eb4fe9ff382f 100644 --- a/trie/utils/verkle.go +++ b/trie/utils/verkle.go @@ -42,11 +42,14 @@ var ( func GetTreeKey(address []byte, treeIndex *uint256.Int, subIndex byte) []byte { var poly [256]fr.Element - verkle.FromLEBytes(&poly[0], []byte{2, 63}) + verkle.FromLEBytes(&poly[0], []byte{2, 64}) // little endian, 64 bytes verkle.FromLEBytes(&poly[1], address[:16]) verkle.FromLEBytes(&poly[2], address[16:]) + // little-endian, 32-byte aligned treeIndex var index [32]byte - copy(index[:], treeIndex.Bytes()) + for i, b := range treeIndex.Bytes() { + index[len(treeIndex.Bytes())-1-i] = b + } verkle.FromLEBytes(&poly[3], index[:16]) verkle.FromLEBytes(&poly[4], index[16:]) for i := 5; i < len(poly); i++ {