Skip to content

Commit

Permalink
clearer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Nov 29, 2023
1 parent b8a1e6c commit edf4628
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion yarn-project/acir-simulator/src/client/view_data_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ViewDataOracle extends TypedOracle {
public async getMembershipWitness(blockNumber: number, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
const index = await this.db.findLeafIndex(blockNumber, treeId, leafValue);
if (!index) {
throw new Error(`Leaf value: ${leafValue} not found in tree ${treeId}`);
throw new Error(`Leaf value: ${leafValue} not found in ${MerkleTreeId[treeId]}`);
}
const siblingPath = await this.db.getSiblingPath(blockNumber, treeId, index);
return [new Fr(index), ...siblingPath];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe('e2e_inclusion_proofs_contract', () => {
// on low_nullifier.value < nullifier.value check.
await expect(
contract.methods.proveNullifierNonInclusion(owner, blockNumber, nullifier).send().wait(),
).rejects.toThrowError(/Proving that low_nullifier.value < nullifier.value failed/);
).rejects.toThrowError(
/Proving nullifier non-inclusion failed: low_nullifier.value < nullifier.value check failed/,
);
}
});

Expand All @@ -85,7 +87,7 @@ describe('e2e_inclusion_proofs_contract', () => {
const randomNoteCommitment = Fr.random();
await expect(
contract.methods.proveNoteInclusion(owner, blockNumber, randomNoteCommitment).send().wait(),
).rejects.toThrow(/Leaf value: 0x[0-9a-fA-F]+ not found in tree/);
).rejects.toThrow(/Leaf value: 0x[0-9a-fA-F]+ not found in NOTE_HASH_TREE/);
});

it('proves an existence of a public value in private context', async () => {
Expand All @@ -98,7 +100,7 @@ describe('e2e_inclusion_proofs_contract', () => {
const randomPublicValue = Fr.random();
await expect(
contract.methods.provePublicValueInclusion(randomPublicValue, blockNumber).send().wait(),
).rejects.toThrow(/Proving membership of a value in public data tree failed/);
).rejects.toThrow(/Proving public value inclusion failed/);
});

it('proves existence of a nullifier in private context', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ contract InclusionProofs {
// 5) Prove that the commitment is in the note hash tree
assert(
block_data.note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path),
"Proving membership of a note in note hash tree failed"
"Proving note inclusion failed"
);

// --> Now we have traversed the trees all the way up to blocks tree root.
Expand Down Expand Up @@ -177,20 +177,20 @@ contract InclusionProofs {
let low_nullifier_leaf = witness.leaf_data.hash();
assert(
block_data.nullifier_tree_root == compute_merkle_root(low_nullifier_leaf, witness.index, witness.path),
"Proving membership of a low nullifier in the nullifier tree failed"
"Proving nullifier non-inclusion failed: Could not prove low nullifier inclusion"
);

// 5.b) Prove that the low nullifier is smaller than the nullifier
assert(
full_field_less_than(witness.leaf_data.value, nullifier),
"Proving that low_nullifier.value < nullifier.value failed"
"Proving nullifier non-inclusion failed: low_nullifier.value < nullifier.value check failed"
);

// 5.c) Prove that the low nullifier is pointing "over" the nullifier to prove that the nullifier is not
// included in the nullifier tree
assert(
full_field_greater_than(witness.leaf_data.next_value, nullifier),
"Proving that low_nullifier.next_value > nullifier.value failed"
"Proving nullifier non-inclusion failed: low_nullifier.next_value > nullifier.value check failed"
);

// --> Now we have traversed the trees all the way up to blocks tree root and verified that the nullifier
Expand Down Expand Up @@ -237,7 +237,7 @@ contract InclusionProofs {
// 5) Prove that the nullifier is in the nullifier tree
assert(
block_data.nullifier_tree_root == compute_merkle_root(nullifier_leaf, witness.index, witness.path),
"Proving membership of a nullifier in nullifier tree failed"
"Proving nullifier inclusion failed"
);

// --> Now we have traversed the trees all the way up to blocks tree root and verified that the nullifier
Expand Down Expand Up @@ -274,7 +274,7 @@ contract InclusionProofs {
// 4) Prove that the public value provided on input is in the public data tree
assert(
block_data.public_data_tree_root == compute_merkle_root(public_value, public_value_leaf_index, path),
"Proving membership of a value in public data tree failed"
"Proving public value inclusion failed"
);

// --> Now we have traversed the trees all the way up to blocks tree root and that way verified that
Expand Down

0 comments on commit edf4628

Please sign in to comment.