Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp fix: little endian pedersen_hash #103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion trie/verkle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func TestReproduceCondrieuPoAStemConflictWithAnotherStem(t *testing.T) {

func TestGetTreeKeys(t *testing.T) {
addr := common.Hex2Bytes("71562b71999873DB5b286dF957af199Ec94617f7")
target := common.Hex2Bytes("0e19316be898a50719b7c321005583ddab6398f4e568d8efafb0619609700f00")
target := common.Hex2Bytes("e00f70099661b0afefd868e5f49863abdd83550021c3b71907a598e86b311900")
key := utils.GetTreeKeyVersion(addr)
t.Logf("key=%x", key)
t.Logf("actualKey=%x", target)
Expand Down