-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9511cce
commit 9483263
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pragma circom 2.1.1; | ||
|
||
include "../../../circuits/lib/query/valueCommitment.circom"; | ||
|
||
component main = ValueCommitment(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {describe} from "mocha"; | ||
|
||
const path = require("path"); | ||
const wasm_tester = require("circom_tester").wasm; | ||
|
||
|
||
describe("ValueCommitment test", function () { | ||
let valueCommitmentCircuit; | ||
|
||
before(async function () { | ||
valueCommitmentCircuit = await wasm_tester(path.join(__dirname, "../circuits/query/", "valueCommitmentTest.circom")); | ||
}); | ||
|
||
it("should commit a value with a non-zero nonce", async () => { | ||
const inputs = { value: "5", commitNonce: "7" }; | ||
const expectedOut = { out: "21007229687521157814825902919006068496120320911167801732994749038798743998593" }; | ||
|
||
const witness = await valueCommitmentCircuit.calculateWitness(inputs, true); | ||
await valueCommitmentCircuit.assertOut(witness, expectedOut); | ||
await valueCommitmentCircuit.checkConstraints(witness); | ||
}); | ||
|
||
it("should return zero for a commit with zero nonce", async () => { | ||
const inputs = { value: "10", commitNonce: "0" }; | ||
const expectedOut = { out: "0" }; | ||
|
||
const witness = await valueCommitmentCircuit.calculateWitness(inputs, true); | ||
await valueCommitmentCircuit.assertOut(witness, expectedOut); | ||
await valueCommitmentCircuit.checkConstraints(witness); | ||
}); | ||
}); |