Skip to content

Commit

Permalink
exclusion proof of key passes for an existent key/val
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed Sep 6, 2023
1 parent bccef22 commit 62a057b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions go/vectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,51 @@ func TestVectors(t *testing.T) {
if !valid {
t.Fatal("Invalid proof")
}
if tc.Spec == SmtSpec {
existProof := proof.GetExist()
path, _ := doHash(HashOp_SHA256, existProof.Key)
val, _ := doHash(HashOp_SHA256, existProof.Value)
exclusionProof := &CommitmentProof{
Proof: &CommitmentProof_Exclusion{
Exclusion: &ExclusionProof{
Key: existProof.Key,
ActualPath: path,
ActualValueHash: val,
Leaf: &LeafOp{
Hash: HashOp_SHA256,
PrehashKey: HashOp_NO_HASH,
PrehashValue: HashOp_NO_HASH,
Length: LengthOp_NO_PREFIX,
Prefix: []byte{0},
},
Path: existProof.Path,
},
},
}
spec := &ProofSpec{
LeafSpec: &LeafOp{
Hash: HashOp_SHA256,
PrehashKey: HashOp_NO_HASH,
PrehashValue: HashOp_NO_HASH,
Length: LengthOp_NO_PREFIX,
Prefix: []byte{0},
},
InnerSpec: &InnerSpec{
ChildOrder: []int32{0, 1},
ChildSize: 32,
MinPrefixLength: 1,
MaxPrefixLength: 1,
EmptyChild: make([]byte, 32),
Hash: HashOp_SHA256,
},
MaxDepth: 256,
PrehashKeyBeforeComparison: true,
}
invalid := VerifyNonMembership(spec, ref.RootHash, exclusionProof, ref.Key)
if invalid {
t.Fatal("verify nonmembership works for valid key/val")
}
}
}
})
}
Expand Down

0 comments on commit 62a057b

Please sign in to comment.