From fb003b2adceaec87302fc0bad9f0551d585452c9 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Thu, 27 Apr 2023 15:02:13 +0200 Subject: [PATCH 1/2] fix include in poseidon_old The included file was renamed, but the include not. Signed-off-by: Csaba Kiraly --- circuits/poseidon_old.circom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/poseidon_old.circom b/circuits/poseidon_old.circom index b8e2316b..dbebd18b 100644 --- a/circuits/poseidon_old.circom +++ b/circuits/poseidon_old.circom @@ -1,6 +1,6 @@ pragma circom 2.0.0; -include "./poseidon_constants.circom"; +include "./poseidon_constants_old.circom"; template Sigma() { signal input in; From 95dfc6d562621bdc815e1cec2f8246b95d28a965 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Thu, 27 Apr 2023 15:20:58 +0200 Subject: [PATCH 2/2] add minimal test code for old poseidon Signed-off-by: Csaba Kiraly --- test/circuits/poseidonold3_test.circom | 5 ++++ test/poseidonoldcircuit.js | 41 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/circuits/poseidonold3_test.circom create mode 100644 test/poseidonoldcircuit.js diff --git a/test/circuits/poseidonold3_test.circom b/test/circuits/poseidonold3_test.circom new file mode 100644 index 00000000..217153aa --- /dev/null +++ b/test/circuits/poseidonold3_test.circom @@ -0,0 +1,5 @@ +pragma circom 2.0.0; + +include "../../circuits/poseidon_old.circom"; + +component main = Poseidon(2); diff --git a/test/poseidonoldcircuit.js b/test/poseidonoldcircuit.js new file mode 100644 index 00000000..b618bc2f --- /dev/null +++ b/test/poseidonoldcircuit.js @@ -0,0 +1,41 @@ +const chai = require("chai"); +const path = require("path"); +const wasm_tester = require("circom_tester").wasm; + +const buildPoseidon = require("circomlibjs").buildPoseidon; + +const assert = chai.assert; + +describe("Poseidon(old) Circuit test", function () { + let poseidon; + let F; + let circuit3; + this.timeout(1000000); + + before( async () => { + poseidon = await buildPoseidon(); + F = poseidon.F; + circuit3 = await wasm_tester(path.join(__dirname, "circuits", "poseidonold3_test.circom")); + }); + + it("Should check constrain of hash([1, 2]) t=3", async () => { + const w = await circuit3.calculateWitness({inputs: [1, 2]}); + + const res2 = poseidon([1,2]); + + assert(F.eq(F.e("7853200120776062878684798364095072458815029376092732009249414926327459813530"), F.e(res2))); + await circuit3.assertOut(w, {out : F.toObject(res2)}); + await circuit3.checkConstraints(w); + }); + + it("Should check constrain of hash([3, 4]) t=3", async () => { + const w = await circuit3.calculateWitness({inputs: [3, 4]}); + + const res2 = poseidon([3, 4]); + + assert(F.eq(F.e("14763215145315200506921711489642608356394854266165572616578112107564877678998"), F.e(res2))); + await circuit3.assertOut(w, {out : F.toObject(res2)}); + await circuit3.checkConstraints(w); + }); + +});