diff --git a/empty.go b/empty.go index f744d40..bb9a857 100644 --- a/empty.go +++ b/empty.go @@ -53,7 +53,7 @@ func (Empty) Commitment() *Point { return &id } -func (Empty) GetProofItems(keylist, StateEpoch, NodeResolverFn) (*ProofElements, []byte, []Stem, error) { +func (Empty) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, []Stem, error) { return nil, nil, nil, errors.New("trying to produce a commitment for an empty subtree") } diff --git a/empty_test.go b/empty_test.go index e237f44..318e110 100644 --- a/empty_test.go +++ b/empty_test.go @@ -51,7 +51,7 @@ func TestEmptyFuncs(t *testing.T) { t.Fatal("commitment and commit mismatch") } - if _, _, _, err := e.GetProofItems(nil, 0, nil); err == nil { + if _, _, _, err := e.GetProofItems(nil, nil); err == nil { t.Fatal("get proof items should error") } diff --git a/expired_leaf.go b/expired_leaf.go index 9aa48eb..f4fdab4 100644 --- a/expired_leaf.go +++ b/expired_leaf.go @@ -62,7 +62,7 @@ func (n *ExpiredLeafNode) Commitment() *Point { return n.commitment } -func (n *ExpiredLeafNode) GetProofItems(keys keylist, curEpoch StateEpoch, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { +func (n *ExpiredLeafNode) GetProofItems(keys keylist, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { var ( pe = &ProofElements{ Vals: make([][]byte, len(keys)), diff --git a/hashednode.go b/hashednode.go index 7613cd6..881080c 100644 --- a/hashednode.go +++ b/hashednode.go @@ -58,7 +58,7 @@ func (HashedNode) Commitment() *Point { panic("can not get commitment of a hash node") } -func (HashedNode) GetProofItems(keylist, StateEpoch, NodeResolverFn) (*ProofElements, []byte, []Stem, error) { +func (HashedNode) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, []Stem, error) { return nil, nil, nil, errors.New("can not get the full path, and there is no proof of absence") } diff --git a/hashednode_test.go b/hashednode_test.go index fb53307..1c48d9d 100644 --- a/hashednode_test.go +++ b/hashednode_test.go @@ -46,7 +46,7 @@ func TestHashedNodeFuncs(t *testing.T) { if v != nil { t.Fatal("non-nil get from a hashed node") } - if _, _, _, err := e.GetProofItems(nil, 0, nil); err == nil { + if _, _, _, err := e.GetProofItems(nil, nil); err == nil { t.Fatal("got nil error when getting proof items from a hashed node") } if _, err := e.Serialize(); err != errSerializeHashedNode { diff --git a/proof_ipa.go b/proof_ipa.go index 0e25fba..9fc25e9 100644 --- a/proof_ipa.go +++ b/proof_ipa.go @@ -188,20 +188,20 @@ func (sd StateDiff) Equal(other StateDiff) error { func GetCommitmentsForMultiproof(root VerkleNode, keys [][]byte, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { sort.Sort(keylist(keys)) - return root.GetProofItems(keylist(keys), curEpoch, resolver) + return root.GetProofItems(keylist(keys), resolver) } // getProofElementsFromTree factors the logic that is used both in the proving and verification methods. It takes a pre-state // tree and an optional post-state tree, extracts the proof data from them and returns all the items required to build/verify // a proof. -func getProofElementsFromTree(preroot, postroot VerkleNode, keys [][]byte, preEpoch, postEpoch StateEpoch, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, [][]byte, error) { +func getProofElementsFromTree(preroot, postroot VerkleNode, keys [][]byte, postEpoch StateEpoch, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, [][]byte, error) { // go-ipa won't accept no key as an input, catch this corner case // and return an empty result. if len(keys) == 0 { return nil, nil, nil, nil, errors.New("no key provided for proof") } - pe, es, poas, err := GetCommitmentsForMultiproof(preroot, keys, preEpoch, resolver) + pe, es, poas, err := GetCommitmentsForMultiproof(preroot, keys, resolver) if err != nil { return nil, nil, nil, nil, fmt.Errorf("error getting pre-state proof data: %w", err) } @@ -228,8 +228,8 @@ func getProofElementsFromTree(preroot, postroot VerkleNode, keys [][]byte, preEp return pe, es, poas, postvals, nil } -func MakeVerkleMultiProof(preroot, postroot VerkleNode, keys [][]byte, preEpoch, postEpoch StateEpoch, resolver NodeResolverFn) (*Proof, []*Point, []byte, []*Fr, error) { - pe, es, poas, postvals, err := getProofElementsFromTree(preroot, postroot, keys, preEpoch, postEpoch, resolver) +func MakeVerkleMultiProof(preroot, postroot VerkleNode, keys [][]byte, postEpoch StateEpoch, resolver NodeResolverFn) (*Proof, []*Point, []byte, []*Fr, error) { + pe, es, poas, postvals, err := getProofElementsFromTree(preroot, postroot, keys, postEpoch, resolver) if err != nil { return nil, nil, nil, nil, fmt.Errorf("get commitments for multiproof: %s", err) } @@ -272,7 +272,7 @@ func MakeVerkleMultiProof(preroot, postroot VerkleNode, keys [][]byte, preEpoch, // verifyVerkleProofWithPreState takes a proof and a trusted tree root and verifies that the proof is valid. func verifyVerkleProofWithPreState(proof *Proof, preroot VerkleNode, preEpoch StateEpoch) error { - pe, _, _, _, err := getProofElementsFromTree(preroot, nil, proof.Keys, preEpoch, 0, nil) + pe, _, _, _, err := getProofElementsFromTree(preroot, nil, proof.Keys, 0, nil) if err != nil { return fmt.Errorf("error getting proof elements: %w", err) } diff --git a/proof_test.go b/proof_test.go index 5338020..8417424 100644 --- a/proof_test.go +++ b/proof_test.go @@ -43,7 +43,7 @@ func TestProofEmptyTree(t *testing.T) { root := New() root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ffx32KeyTest}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ffx32KeyTest}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { t.Fatalf("could not verify verkle proof: %s", ToDot(root)) @@ -65,7 +65,7 @@ func TestProofVerifyTwoLeaves(t *testing.T) { } root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ffx32KeyTest}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ffx32KeyTest}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { @@ -92,7 +92,7 @@ func TestProofVerifyMultipleLeaves(t *testing.T) { } root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{keys[0]}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{keys[0]}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { @@ -119,9 +119,9 @@ func TestMultiProofVerifyMultipleLeaves(t *testing.T) { } root.Commit() - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keys[0:2], 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keys[0:2], 0, nil) - pe, _, _, err := GetCommitmentsForMultiproof(root, keys[0:2], 0, nil) + pe, _, _, err := GetCommitmentsForMultiproof(root, keys[0:2], nil) if err != nil { t.Fatal(err) } @@ -159,9 +159,9 @@ func TestMultiProofVerifyMultipleLeavesWithAbsentStem(t *testing.T) { absent[3] = 1 // and the stem differs keys = append(keys, absent) - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keys, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keys, 0, nil) - pe, _, isabsent, err := GetCommitmentsForMultiproof(root, keys, 0, nil) + pe, _, isabsent, err := GetCommitmentsForMultiproof(root, keys, nil) if err != nil { t.Fatal(err) } @@ -193,9 +193,9 @@ func TestMultiProofVerifyMultipleLeavesCommitmentRedundancy(t *testing.T) { } root.Commit() - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keys, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keys, 0, nil) - pe, _, _, err := GetCommitmentsForMultiproof(root, keys, 0, nil) + pe, _, _, err := GetCommitmentsForMultiproof(root, keys, nil) if err != nil { t.Fatal(err) } @@ -217,7 +217,7 @@ func TestProofOfAbsenceInternalVerify(t *testing.T) { } root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ffx32KeyTest}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ffx32KeyTest}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { @@ -237,7 +237,7 @@ func TestProofOfAbsenceLeafVerify(t *testing.T) { } root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{oneKeyTest}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{oneKeyTest}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { @@ -262,7 +262,7 @@ func TestProofOfAbsenceLeafVerifyOtherSuffix(t *testing.T) { return ret }() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{key}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{key}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { @@ -284,7 +284,7 @@ func TestProofOfAbsenceStemVerify(t *testing.T) { }() root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{key}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{key}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { @@ -310,7 +310,7 @@ func BenchmarkProofCalculation(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - if _, _, _, _, err := MakeVerkleMultiProof(root, nil, [][]byte{keys[len(keys)/2]}, 0, 0, nil); err != nil { + if _, _, _, _, err := MakeVerkleMultiProof(root, nil, [][]byte{keys[len(keys)/2]}, 0, nil); err != nil { b.Fatal(err) } } @@ -331,7 +331,7 @@ func BenchmarkProofVerification(b *testing.B) { } root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{keys[len(keys)/2]}, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{keys[len(keys)/2]}, 0, nil) b.ResetTimer() b.ReportAllocs() @@ -362,7 +362,7 @@ func TestProofSerializationNoAbsentStem(t *testing.T) { } } - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, [][]byte{keys[0]}, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, [][]byte{keys[0]}, 0, nil) vp, statediff, err := SerializeProof(proof) if err != nil { @@ -401,7 +401,7 @@ func TestProofSerializationWithAbsentStem(t *testing.T) { absentkey[2] = 2 absentkey[3] = 1 - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, [][]byte{absentkey[:]}, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, [][]byte{absentkey[:]}, 0, nil) vp, statediff, err := SerializeProof(proof) if err != nil { @@ -442,7 +442,7 @@ func TestProofDeserialize(t *testing.T) { absentkey[2] = 2 absentkey[3] = 1 - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, [][]byte{absentkey[:]}, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, [][]byte{absentkey[:]}, 0, nil) vp, statediff, err := SerializeProof(proof) if err != nil { @@ -455,7 +455,7 @@ func TestProofDeserialize(t *testing.T) { } _ = deserialized - pe, _, _, err := root.GetProofItems(keylist{absentkey[:]}, 0, nil) + pe, _, _, err := root.GetProofItems(keylist{absentkey[:]}, nil) if err != nil { t.Fatal(err) } @@ -472,7 +472,7 @@ func TestProofOfAbsenceEdgeCase(t *testing.T) { root.Commit() ret, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030303") - proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ret}, 0, 0, nil) + proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ret}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cs, zis, yis, cfg); !ok || err != nil { t.Fatal("could not verify proof") @@ -493,7 +493,7 @@ func TestProofOfAbsenceOtherMultipleLeaves(t *testing.T) { ret1, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030300") ret2, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030301") - proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ret1, ret2}, 0, 0, nil) + proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ret1, ret2}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cs, zis, yis, cfg); !ok || err != nil { t.Fatal("could not verify proof") @@ -555,7 +555,7 @@ func TestProofOfAbsenceNoneMultipleStems(t *testing.T) { ret1, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030300") ret2, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030200") - proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ret1, ret2}, 0, 0, nil) + proof, cs, zis, yis, _ := MakeVerkleMultiProof(root, nil, [][]byte{ret1, ret2}, 0, nil) cfg := GetConfig() if ok, err := verifyVerkleProof(proof, cs, zis, yis, cfg); !ok || err != nil { t.Fatal("could not verify proof") @@ -862,7 +862,7 @@ func TestProofOfExpiryOneLeaf(t *testing.T) { t.Fatalf("expected commitment to be %x, got %x", init, comm) } - proof, cis, zis, yis, err := MakeVerkleMultiProof(root, nil, [][]byte{zeroKeyTest}, 0, 0, nil) + proof, cis, zis, yis, err := MakeVerkleMultiProof(root, nil, [][]byte{zeroKeyTest}, 0, nil) if err != nil { t.Fatalf("could not make verkle proof: %v", err) } @@ -914,7 +914,7 @@ func TestProofOfExpiryMultipleLeaves(t *testing.T) { t.Fatalf("expected commitment to be %x, got %x", init, comm) } - proof, cis, zis, yis, err := MakeVerkleMultiProof(root, nil, [][]byte{zeroKeyTest, ffx32KeyTest}, 0, 0, nil) + proof, cis, zis, yis, err := MakeVerkleMultiProof(root, nil, [][]byte{zeroKeyTest, ffx32KeyTest}, 0, nil) if err != nil { t.Fatalf("could not make verkle proof: %v", err) } @@ -970,7 +970,7 @@ func testSerializeDeserializeProof(t *testing.T, insertKVs map[string][]byte, pr proveKVs[string(key)] = value } - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, proveKeys, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, proveKeys, 0, nil) serialized, statediff, err := SerializeProof(proof) if err != nil { @@ -1119,7 +1119,7 @@ func TestProofVerificationWithPostState(t *testing.T) { // skipcq: GO-R1005 } postroot.Commit() - proof, _, _, _, _ := MakeVerkleMultiProof(root, postroot, data.keystoprove, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, postroot, data.keystoprove, 0, nil) keys: for i := range proof.Keys { @@ -1206,7 +1206,7 @@ func TestProofVerificationPreStateExpiredPostStateResurrected(t *testing.T) { t.Fatalf("could not insert key: %v", err) } - proof, _, _, _, _ := MakeVerkleMultiProof(preRoot, postRoot, keylist{zeroKeyTest}, preEpoch, postEpoch, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(preRoot, postRoot, keylist{zeroKeyTest}, postEpoch, nil) p, diff, err := SerializeProof(proof) if err != nil { @@ -1259,7 +1259,7 @@ func TestGenerateProofWithOnlyAbsentKeys(t *testing.T) { // Create a proof with a key with the same first byte, but different second byte (i.e: absent). absentKey, _ := hex.DecodeString("4010000000000000000000000000000000000000000000000000000000000000") - proof, cis, zis, yis, err := MakeVerkleMultiProof(root, nil, keylist{absentKey}, 0, 0, nil) + proof, cis, zis, yis, err := MakeVerkleMultiProof(root, nil, keylist{absentKey}, 0, nil) if err != nil { t.Fatal(err) } @@ -1284,7 +1284,7 @@ func TestGenerateProofWithOnlyAbsentKeys(t *testing.T) { } // From the rebuilt tree, validate the proof. - pe, _, _, err := GetCommitmentsForMultiproof(droot, keylist{absentKey}, 0, nil) + pe, _, _, err := GetCommitmentsForMultiproof(droot, keylist{absentKey}, nil) if err != nil { t.Fatal(err) } @@ -1339,7 +1339,7 @@ func TestDoubleProofOfAbsence(t *testing.T) { // in that leaf node. i.e: two proof of absence in the same leaf node with no proof of presence. key2, _ := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000000100") key3, _ := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000000200") - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keylist{key2, key3}, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keylist{key2, key3}, 0, nil) serialized, statediff, err := SerializeProof(proof) if err != nil { @@ -1388,7 +1388,7 @@ func TestProveAbsenceInEmptyHalf(t *testing.T) { key2, _ := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000000100") key3, _ := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000000000") - proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keylist{key2, key3}, 0, 0, nil) + proof, _, _, _, _ := MakeVerkleMultiProof(root, nil, keylist{key2, key3}, 0, nil) serialized, statediff, err := SerializeProof(proof) if err != nil { diff --git a/tree.go b/tree.go index 9c8c651..3234cdc 100644 --- a/tree.go +++ b/tree.go @@ -91,7 +91,7 @@ type VerkleNode interface { // returns them breadth-first. On top of that, it returns // one "extension status" per stem, and an alternate stem // if the key is missing but another stem has been found. - GetProofItems(keylist, StateEpoch, NodeResolverFn) (*ProofElements, []byte, []Stem, error) + GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, []Stem, error) // Serialize encodes the node to RLP. Serialize() ([]byte, error) @@ -990,7 +990,7 @@ func groupKeys(keys keylist, depth byte) []keylist { return groups } -func (n *InternalNode) GetProofItems(keys keylist, curEpoch StateEpoch, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { +func (n *InternalNode) GetProofItems(keys keylist, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { var ( groups = groupKeys(keys, n.depth) pe = &ProofElements{ @@ -1085,7 +1085,7 @@ func (n *InternalNode) GetProofItems(keys keylist, curEpoch StateEpoch, resolver continue } - pec, es, other, err := n.children[childIdx].GetProofItems(group, curEpoch, resolver) + pec, es, other, err := n.children[childIdx].GetProofItems(group, resolver) if err != nil { // TODO: add a test case to cover this scenario. return nil, nil, nil, err @@ -1577,7 +1577,7 @@ func leafToComms(poly []Fr, val []byte) error { return nil } -func (n *LeafNode) GetProofItems(keys keylist, curEpoch StateEpoch, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { // skipcq: GO-R1005 +func (n *LeafNode) GetProofItems(keys keylist, resolver NodeResolverFn) (*ProofElements, []byte, []Stem, error) { // skipcq: GO-R1005 var ( poly [NodeWidth]Fr // top-level polynomial pe = &ProofElements{ @@ -1593,19 +1593,6 @@ func (n *LeafNode) GetProofItems(keys keylist, curEpoch StateEpoch, resolver Nod poass []Stem // list of proof-of-absence and proof-of-expiry stems ) - // If the leaf node is expired, generate the proof of expiry. - if IsExpired(n.lastEpoch, curEpoch) { - for i := range keys { - pe.ByPath[string(keys[i][:n.depth])] = n.commitment - pe.Vals[i] = nil - - esses = append(esses, extStatusExpired|(n.depth<<3)) - poass = append(poass, n.stem) - } - - return &ProofElements{}, esses, poass, nil - } - // Initialize the top-level polynomial with 1 + stem + C1 + C2 + lastEpoch poly[0].SetUint64(1) if err := StemFromLEBytes(&poly[1], n.stem); err != nil { @@ -1654,8 +1641,10 @@ func (n *LeafNode) GetProofItems(keys keylist, curEpoch StateEpoch, resolver Nod pe.Fis = append(pe.Fis, poly[:]) } + // We do not check for expiry, as we assume that the expiry detection is done before + // proof creation. poly[4].SetUint64(uint64(n.lastEpoch)) - + pe.Cis = append(pe.Cis, n.commitment) pe.Zis = append(pe.Zis, 4) pe.Yis = append(pe.Yis, &poly[4]) diff --git a/tree_test.go b/tree_test.go index b5f4989..e9799ad 100644 --- a/tree_test.go +++ b/tree_test.go @@ -1025,7 +1025,7 @@ func TestEmptyCommitment(t *testing.T) { t.Fatalf("inserting into the original failed: %v", err) } root.Commit() - pe, _, _, err := root.GetProofItems(keylist{ffx32KeyTest}, 0, nil) + pe, _, _, err := root.GetProofItems(keylist{ffx32KeyTest}, nil) if err != nil { t.Fatal(err) } @@ -1092,7 +1092,7 @@ func TestGetProofItemsNoPoaIfStemPresent(t *testing.T) { key1, _ := hex.DecodeString("ffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") key2, _ := hex.DecodeString("ffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff") - _, esses, poas, err := root.GetProofItems(keylist{key1, key2, ffx32KeyTest}, 0, nil) + _, esses, poas, err := root.GetProofItems(keylist{key1, key2, ffx32KeyTest}, nil) if err != nil { t.Fatal(err) } @@ -1347,7 +1347,7 @@ func TestRustBanderwagonBlock48(t *testing.T) { r := tree.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(tree, nil, keys, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(tree, nil, keys, 0, nil) vp, statediff, err := SerializeProof(proof) if err != nil { t.Fatal(err) @@ -1368,7 +1368,7 @@ func TestRustBanderwagonBlock48(t *testing.T) { if err != nil { t.Fatal(err) } - pe, _, _, err := droot.GetProofItems(keylist(keys), 0, nil) + pe, _, _, err := droot.GetProofItems(keylist(keys), nil) if err != nil { t.Fatal(err) } @@ -1819,7 +1819,7 @@ func runRandTest(rt randTest) error { continue } root.Commit() - proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, keys, 0, 0, nil) + proof, cis, zis, yis, _ := MakeVerkleMultiProof(root, nil, keys, 0, nil) if ok, err := verifyVerkleProof(proof, cis, zis, yis, cfg); !ok || err != nil { rt[i].err = fmt.Errorf("could not verify verkle proof: %s, err %v", ToDot(root), err) } diff --git a/unknown.go b/unknown.go index 8810757..62d8232 100644 --- a/unknown.go +++ b/unknown.go @@ -51,7 +51,7 @@ func (UnknownNode) Commitment() *Point { return &id } -func (UnknownNode) GetProofItems(keylist, StateEpoch, NodeResolverFn) (*ProofElements, []byte, []Stem, error) { +func (UnknownNode) GetProofItems(keylist, NodeResolverFn) (*ProofElements, []byte, []Stem, error) { return nil, nil, nil, errors.New("can't generate proof items for unknown node") } diff --git a/unknown_test.go b/unknown_test.go index a0fca43..8fb1c40 100644 --- a/unknown_test.go +++ b/unknown_test.go @@ -24,7 +24,7 @@ func TestUnknownFuncs(t *testing.T) { if comm := un.Commitment(); !comm.Equal(&identity) { t.Errorf("got %v, want identity", comm) } - if _, _, _, err := un.GetProofItems(nil, 0, nil); err == nil { + if _, _, _, err := un.GetProofItems(nil, nil); err == nil { t.Errorf("got nil error when getting proof items from a hashed node") } if _, err := un.Serialize(); err == nil {