This commit is contained in:
Jordi Baylina
2018-08-15 11:05:17 +02:00
parent f7ac040b3b
commit a7ac0b5d18
3 changed files with 80 additions and 20 deletions

View File

@@ -2,9 +2,31 @@ const chai = require("chai");
const bigInt = require("../src/bigint.js");
const BN128 = require("../src/BN128.js");
const F1Field = require("../src/zqfield.js");
const assert = chai.assert;
describe("F1 testing", () => {
it("Should compute euclidean", () => {
const F = new F1Field(bigInt(7));
const res = F.inverse(bigInt(4));
assert(F.equals(res, bigInt(2)));
});
it("Should multiply and divide in F1", () => {
const bn128 = new BN128();
const a = bigInt("1");
const b = bn128.F1.affine(bigInt("-3"));
const c = bn128.F1.mul(a,b);
const d = bn128.F1.div(c,b);
assert(bn128.F1.equals(a, d));
});
});
describe("Curve G1 Test", () => {
it("r*one == 0", () => {
const bn128 = new BN128();