Skip to content

Commit

Permalink
temp fix: little endian pedersen_hash (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet authored Jun 2, 2022
1 parent f7f8d18 commit 5292241
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion trie/utils/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ func GetTreeKey(address []byte, treeIndex *uint256.Int, subIndex byte) []byte {

cfg, _ := verkle.GetConfig()
ret := cfg.CommitToPoly(poly[:], 0)
retb := ret.Bytes()

// The output of Byte() is big engian for banderwagon. This
// introduces an inbalance in the tree, because hashes are
// elements of a 253-bit field. This means more than half the
// tree would be empty. To avoid this problem, use a little
// endian commitment and chop the MSB.
var retb [32]byte
retb = ret.Bytes()
for i := 0; i < 16; i++ {
retb[31-i], retb[i] = retb[i], retb[31-i]
}
retb[31] = subIndex
return retb[:]

Expand Down

0 comments on commit 5292241

Please sign in to comment.