Skip to content

Commit

Permalink
Fix sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaylina committed Apr 1, 2022
1 parent e7eeb24 commit 6eba608
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
"args": [
"${workspaceFolder}/test/bn128.js"
]
},
{
"type": "pwa-node",
"request": "launch",
"name": "Test Algebra",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"${workspaceFolder}/test/algebra.js"
]
}
]
}
6 changes: 3 additions & 3 deletions build/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,8 @@ class FFT {
this.G = G;
this.opMulGF = opMulGF;

let rem = F.sqrt_t;
let s = F.sqrt_s;
let rem = F.sqrt_t || F.t;
let s = F.sqrt_s || F.s;

let nqr = F.one;
while (F.eq(F.pow(nqr, F.half), F.one)) nqr = F.add(nqr, F.one);
Expand Down Expand Up @@ -1694,7 +1694,7 @@ class FFT {
this.roots.push(rootsi);
}
*/
this._setRoots(15);
this._setRoots(Math.min(s, 15));
}

_setRoots(n) {
Expand Down
6 changes: 3 additions & 3 deletions src/fft.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default class FFT {
this.G = G;
this.opMulGF = opMulGF;

let rem = F.sqrt_t;
let s = F.sqrt_s;
let rem = F.sqrt_t || F.t;
let s = F.sqrt_s || F.s;

let nqr = F.one;
while (F.eq(F.pow(nqr, F.half), F.one)) nqr = F.add(nqr, F.one);
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class FFT {
this.roots.push(rootsi);
}
*/
this._setRoots(15);
this._setRoots(Math.min(s, 15));
}

_setRoots(n) {
Expand Down
1 change: 1 addition & 0 deletions test/bn128.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("bn128", async function () {
let bn128;
before( async() => {
bn128 = await buildBn128();
console.log(bn128.Fr.toString(bn128.Fr.w[28]));
});
after( async() => {
bn128.terminate();
Expand Down

0 comments on commit 6eba608

Please sign in to comment.