You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
957 B

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