arnaucube
arnaucube/circomlibPublic Self-hosted repository
circomlib/test/point2bits.js
test/point2bits.jsRaw
 1const chai = require("chai");
 2const path = require("path");
 3const snarkjs = require("snarkjs");
 4const compiler = require("circom");
 5
 6const assert = chai.assert;
 7
 8const bigInt = snarkjs.bigInt;
 9
10const babyJub = require("../src/babyjub.js");
11
12
13describe("Point 2 bits test", function() {
14    let circuit;
15    this.timeout(100000);
16    before( async() => {
17        const cirDef = await compiler(path.join(__dirname, "circuits", "pointbits_loopback.circom"));
18
19        circuit = new snarkjs.Circuit(cirDef);
20
21        console.log("NConstrains Point2Bits loopback: " + circuit.nConstraints);
22    });
23    it("Should do the both convertions for 8Base", async () => {
24        const w = circuit.calculateWitness({ in: babyJub.Base8});
25
26        assert(circuit.checkWitness(w));
27    });
28    it("Should do the both convertions for Zero point", async () => {
29        const w = circuit.calculateWitness({ in: [0, 1]});
30
31        assert(circuit.checkWitness(w));
32    });
33});