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.
 

44 lines
1003 B

const bigInt = require("./bigint");
const fUtils = require("./futils.js");
class ZqField {
constructor(q) {
this.q = q;
this.zero = bigInt.zero;
this.one = bigInt.one;
this.add = bigInt.genAdd();
this.double = bigInt.genDouble();
this.sub = bigInt.genSub();
this.neg = bigInt.genNeg();
this.mul = bigInt.genMul(q);
this.inverse = bigInt.genInverse(q);
this.square = bigInt.genSquare(q);
this.equals = bigInt.genEquals(q);
this.affine = bigInt.genAffine(q);
this.isZero = bigInt.genIsZero(q);
}
copy(a) {
return bigInt(a);
}
div(a, b) {
return this.mul(a, this.inverse(b));
}
mulEscalar(base, e) {
return fUtils.mulEscalar(this, base, e);
}
exp(base, e) {
return fUtils.exp(this, base, e);
}
toString(a) {
const ca = this.affine(a);
return `"0x${ca.toString(16)}"`;
}
}
module.exports = ZqField;