arnaucube
arnaucube/grapevine-sonobePublic Self-hosted repository
grapevine-sonobe/circom/node_modules/circomlib/test/point2bits.js
circom/node_modules/circomlib/test/point2bits.jsRaw
 1const path = require("path");
 2const wasm_tester = require("circom_tester").wasm;
 3const buildBabyJub = require("circomlibjs").buildBabyjub;
 4
 5const babyJub = require("circomlibjs").babyjub;
 6
 7
 8describe("Point 2 bits test", function() {
 9    let babyJub;
10    let F;
11    let circuit;
12    this.timeout(100000);
13    before( async() => {
14        babyJub = await buildBabyJub();
15        F = babyJub.F;
16
17        circuit = await wasm_tester(path.join(__dirname, "circuits", "pointbits_loopback.circom"));
18    });
19
20    it("Should do the both convertions for 8Base", async () => {
21        const w = await circuit.calculateWitness({ in: [F.toObject(babyJub.Base8[0]), F.toObject(babyJub.Base8[1])]}, true);
22
23        await circuit.checkConstraints(w);
24    });
25    it("Should do the both convertions for Zero point", async () => {
26        const w = await circuit.calculateWitness({ in: [0, 1]}, true);
27
28        await circuit.checkConstraints(w);
29    });
30});