Skip to content

Commit 6eba608

Browse files
committed
Fix sqrt
1 parent e7eeb24 commit 6eba608

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.vscode/launch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
"args": [
1616
"${workspaceFolder}/test/bn128.js"
1717
]
18+
},
19+
{
20+
"type": "pwa-node",
21+
"request": "launch",
22+
"name": "Test Algebra",
23+
"skipFiles": [
24+
"<node_internals>/**"
25+
],
26+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
27+
"args": [
28+
"${workspaceFolder}/test/algebra.js"
29+
]
1830
}
1931
]
2032
}

build/main.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,8 @@ class FFT {
16611661
this.G = G;
16621662
this.opMulGF = opMulGF;
16631663

1664-
let rem = F.sqrt_t;
1665-
let s = F.sqrt_s;
1664+
let rem = F.sqrt_t || F.t;
1665+
let s = F.sqrt_s || F.s;
16661666

16671667
let nqr = F.one;
16681668
while (F.eq(F.pow(nqr, F.half), F.one)) nqr = F.add(nqr, F.one);
@@ -1694,7 +1694,7 @@ class FFT {
16941694
this.roots.push(rootsi);
16951695
}
16961696
*/
1697-
this._setRoots(15);
1697+
this._setRoots(Math.min(s, 15));
16981698
}
16991699

17001700
_setRoots(n) {

src/fft.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default class FFT {
3030
this.G = G;
3131
this.opMulGF = opMulGF;
3232

33-
let rem = F.sqrt_t;
34-
let s = F.sqrt_s;
33+
let rem = F.sqrt_t || F.t;
34+
let s = F.sqrt_s || F.s;
3535

3636
let nqr = F.one;
3737
while (F.eq(F.pow(nqr, F.half), F.one)) nqr = F.add(nqr, F.one);
@@ -63,7 +63,7 @@ export default class FFT {
6363
this.roots.push(rootsi);
6464
}
6565
*/
66-
this._setRoots(15);
66+
this._setRoots(Math.min(s, 15));
6767
}
6868

6969
_setRoots(n) {

test/bn128.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe("bn128", async function () {
1616
let bn128;
1717
before( async() => {
1818
bn128 = await buildBn128();
19+
console.log(bn128.Fr.toString(bn128.Fr.w[28]));
1920
});
2021
after( async() => {
2122
bn128.terminate();

0 commit comments

Comments
 (0)