Skip to content

Commit

Permalink
fix: redundant proof-of-absence stems (ethereum#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet authored Apr 1, 2022
1 parent fc9c06d commit 8f01a89
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/fatih/color v1.7.0
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
github.com/gballet/go-verkle v0.0.0-20220330063001-d9fddb499b7a
github.com/gballet/go-verkle v0.0.0-20220401072859-0ae88725b839
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.0
github.com/golang/protobuf v1.4.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ github.com/gballet/go-verkle v0.0.0-20220309192943-d9f613553c79 h1:IGryvoVakS5AN
github.com/gballet/go-verkle v0.0.0-20220309192943-d9f613553c79/go.mod h1:S2TbrZxLyGqCqwtl2IA09xxun6oretK6byC1lHY+sAk=
github.com/gballet/go-verkle v0.0.0-20220330063001-d9fddb499b7a h1:WDnnkoIpO6lqoUydcAzsrYnXOaZyZCFBz3IIRZy5fZ0=
github.com/gballet/go-verkle v0.0.0-20220330063001-d9fddb499b7a/go.mod h1:S2TbrZxLyGqCqwtl2IA09xxun6oretK6byC1lHY+sAk=
github.com/gballet/go-verkle v0.0.0-20220401072859-0ae88725b839 h1:Dmwdz0Db5n3PwCu+xvrnyIohV7PMfsfaFFuUDULMJyU=
github.com/gballet/go-verkle v0.0.0-20220401072859-0ae88725b839/go.mod h1:S2TbrZxLyGqCqwtl2IA09xxun6oretK6byC1lHY+sAk=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down
47 changes: 47 additions & 0 deletions trie/verkle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,50 @@ func TestChunkifyCodeFuzz(t *testing.T) {
}
t.Logf("code=%x, chunks=%x\n", code, chunks)
}

// Cover the case in which a stem is both used for a proof of absence, and for a proof of presence.
func TestReproduceCondrieuPoAStemConflictWithAnotherStem(t *testing.T) {
presentKeys := [][]byte{
common.Hex2Bytes("6766d007d8fd90ea45b2ac9027ff04fa57e49527f11010a12a73f58ffa580800"),
}

absentKeys := [][]byte{
common.Hex2Bytes("6766d007d8fd90ea45b2ac9027ff04fa57e49527f11010a12a73008ffa580800"),
// the key differs from the key present... ^^ here
}

values := [][]byte{
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000000"),
}

root := verkle.New()
kv := make(map[string][]byte)

for i, key := range presentKeys {
root.Insert(key, values[i], nil)
kv[string(key)] = values[i]
}

proof, Cs, zis, yis := verkle.MakeVerkleMultiProof(root, append(presentKeys, absentKeys...), kv)
cfg, _ := verkle.GetConfig()
if !verkle.VerifyVerkleProof(proof, Cs, zis, yis, cfg) {
t.Fatal("could not verify proof")
}

t.Log("commitments returned by proof:")
for i, c := range Cs {
t.Logf("%d %x", i, c.Bytes())
}

p, _, err := verkle.SerializeProof(proof)
if err != nil {
t.Fatal(err)
}
t.Logf("serialized: %x", p)
t.Logf("tree: %s\n%x\n", verkle.ToDot(root), root.ComputeCommitment().Bytes())

t.Logf("%d", len(proof.ExtStatus))
if len(proof.PoaStems) != 0 {
t.Fatal("a proof-of-absence stem was declared, when there was no need")
}
}

0 comments on commit 8f01a89

Please sign in to comment.