@gurge/sdk 0.3.122 → 0.3.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -159
- package/common/src/crypto/babyJub.cjs +1 -1
- package/common/src/crypto/babyJub.mjs +2 -3
- package/common/src/crypto/eddsa.cjs +1 -1
- package/common/src/crypto/eddsa.mjs +2 -3
- package/common/src/crypto/poseidon.cjs +1 -1
- package/common/src/crypto/poseidon.mjs +8 -17
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +0 -1
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.d.ts +0 -1
- package/common/src/functions/utils/index.mjs +0 -1
- package/common/src/webworker/logError-CZYZ3oyV.js +2 -0
- package/common/src/webworker/package.json +119 -0
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -0
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -0
- package/common/src/webworker/viteWorkerURL.constant.cjs +3 -3
- package/common/src/webworker/viteWorkerURL.constant.mjs +3 -3
- package/common/src/webworker/workerProxy-DPeuP2Mg.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -0
- package/package.json +2 -3
- package/common/src/crypto/BabyJubRN.cjs +0 -1
- package/common/src/crypto/BabyJubRN.d.ts +0 -20
- package/common/src/crypto/BabyJubRN.mjs +0 -66
- package/common/src/crypto/EddsaRN.cjs +0 -1
- package/common/src/crypto/EddsaRN.d.ts +0 -19
- package/common/src/crypto/EddsaRN.mjs +0 -41
- package/common/src/functions/utils/bigint-math.utils.cjs +0 -1
- package/common/src/functions/utils/bigint-math.utils.d.ts +0 -2
- package/common/src/functions/utils/bigint-math.utils.mjs +0 -18
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare class BabyJubRN {
|
|
2
|
-
static readonly A: bigint;
|
|
3
|
-
static readonly D: bigint;
|
|
4
|
-
F: {
|
|
5
|
-
p: bigint;
|
|
6
|
-
zero: bigint;
|
|
7
|
-
one: bigint;
|
|
8
|
-
e: (v: bigint | number | string) => bigint;
|
|
9
|
-
add: (a: bigint, b: bigint) => bigint;
|
|
10
|
-
sub: (a: bigint, b: bigint) => bigint;
|
|
11
|
-
mul: (a: bigint, b: bigint) => bigint;
|
|
12
|
-
div: (a: bigint, b: bigint) => bigint;
|
|
13
|
-
toString: (a: bigint) => string;
|
|
14
|
-
};
|
|
15
|
-
A: bigint;
|
|
16
|
-
D: bigint;
|
|
17
|
-
Base8: [bigint, bigint];
|
|
18
|
-
addPoint(a: [bigint, bigint], b: [bigint, bigint]): [bigint, bigint];
|
|
19
|
-
mulPointEscalar(base: [bigint, bigint], e: bigint | number | string): [bigint, bigint];
|
|
20
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { CIRCOM_P as e } from "../constants/protocol.constants.mjs";
|
|
2
|
-
import { mod as t, modInverse as n } from "../functions/utils/bigint-math.utils.mjs";
|
|
3
|
-
//#region libs/shared/common/src/crypto/BabyJubRN.ts
|
|
4
|
-
var r = {
|
|
5
|
-
p: e,
|
|
6
|
-
zero: 0n,
|
|
7
|
-
one: 1n,
|
|
8
|
-
e: (e) => t(BigInt(e)),
|
|
9
|
-
add: (e, n) => t(e + n),
|
|
10
|
-
sub: (e, n) => t(e - n),
|
|
11
|
-
mul: (e, n) => t(e * n),
|
|
12
|
-
div: (e, r) => {
|
|
13
|
-
if (r === 0n) throw Error("Division by zero in BabyJub field");
|
|
14
|
-
return t(e * n(r));
|
|
15
|
-
},
|
|
16
|
-
toString: (e) => t(e).toString()
|
|
17
|
-
}, i = {
|
|
18
|
-
X: r.zero,
|
|
19
|
-
Y: r.one,
|
|
20
|
-
Z: r.one,
|
|
21
|
-
T: r.zero
|
|
22
|
-
}, a = (e) => {
|
|
23
|
-
let t = r.e(e[0]), n = r.e(e[1]);
|
|
24
|
-
return {
|
|
25
|
-
X: t,
|
|
26
|
-
Y: n,
|
|
27
|
-
Z: r.one,
|
|
28
|
-
T: r.mul(t, n)
|
|
29
|
-
};
|
|
30
|
-
}, o = (e) => {
|
|
31
|
-
let t = n(e.Z);
|
|
32
|
-
return [r.mul(e.X, t), r.mul(e.Y, t)];
|
|
33
|
-
}, s = r.e("168700"), c = r.e("168696"), l = (e, t) => {
|
|
34
|
-
let n = r.mul(e.X, t.X), i = r.mul(e.Y, t.Y), a = r.mul(r.mul(e.T, t.T), c), o = r.mul(e.Z, t.Z), l = r.sub(r.mul(r.add(e.X, e.Y), r.add(t.X, t.Y)), r.add(n, i)), u = r.sub(o, a), d = r.add(o, a), f = r.sub(i, r.mul(s, n));
|
|
35
|
-
return {
|
|
36
|
-
X: r.mul(l, u),
|
|
37
|
-
Y: r.mul(d, f),
|
|
38
|
-
T: r.mul(l, f),
|
|
39
|
-
Z: r.mul(u, d)
|
|
40
|
-
};
|
|
41
|
-
}, u = (e) => {
|
|
42
|
-
let t = r.mul(e.X, e.X), n = r.mul(e.Y, e.Y), i = r.mul(r.mul(e.Z, e.Z), 2n), a = r.mul(s, t), o = r.sub(r.mul(r.add(e.X, e.Y), r.add(e.X, e.Y)), r.add(t, n)), c = r.add(a, n), l = r.sub(c, i), u = r.sub(a, n);
|
|
43
|
-
return {
|
|
44
|
-
X: r.mul(o, l),
|
|
45
|
-
Y: r.mul(c, u),
|
|
46
|
-
T: r.mul(o, u),
|
|
47
|
-
Z: r.mul(l, c)
|
|
48
|
-
};
|
|
49
|
-
}, d = class {
|
|
50
|
-
static A = s;
|
|
51
|
-
static D = c;
|
|
52
|
-
F = r;
|
|
53
|
-
A = s;
|
|
54
|
-
D = c;
|
|
55
|
-
Base8 = [r.e("5299619240641551281634865583518297030282874472190772894086521144482721001553"), r.e("16950150798460657717958625567821834550301663161624707787222815936182638968203")];
|
|
56
|
-
addPoint(e, t) {
|
|
57
|
-
return o(l(a(e), a(t)));
|
|
58
|
-
}
|
|
59
|
-
mulPointEscalar(e, t) {
|
|
60
|
-
let n = i, r = a(e), s = BigInt(t);
|
|
61
|
-
for (; s !== 0n;) s % 2n == 1n && (n = l(n, r)), r = u(r), s /= 2n;
|
|
62
|
-
return o(n);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
//#endregion
|
|
66
|
-
export { d as BabyJubRN };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`../../../_virtual/_rolldown/runtime.cjs`);const e=require(`./poseidon.cjs`),t=require(`../functions/utils/bigint-math.utils.cjs`),n=require(`./babyJub.cjs`);let r=require(`@noble/hashes/blake1.js`);var i=21888242871839275222246405745257275088614511777268538073601725287587578984328n/8n,a=(e,t=0,n=e.length-t)=>{let r=0n;for(let i=n-1;i>=0;--i)r=(r<<8n)+BigInt(e[t+i]);return r},o=(e,n,r,i)=>{let a=t.mod(r);for(let t=0;t<i;t+=1)e[n+t]=Number(a&255n),a>>=8n},s=e=>t.mod(e,i),c=e=>{let t=new Uint8Array(e);return t[0]&=248,t[31]&=127,t[31]|=64,t},l=class{constructor(e,t){this.babyJub=e,this.poseidon=t}prv2pub(e){let t=a(c((0,r.blake512)(e).slice(0,32)),0,32);return this.babyJub.mulPointEscalar(this.babyJub.Base8,t/8n)}signPoseidon(e,n){let i=c((0,r.blake512)(e)),l=a(i,0,32),u=this.babyJub.mulPointEscalar(this.babyJub.Base8,l/8n),d=new Uint8Array(64);d.set(i.slice(32),0),o(d,32,n,32);let f=s(a((0,r.blake512)(d),0,64)),p=this.babyJub.mulPointEscalar(this.babyJub.Base8,f),m=this.poseidon([p[0],p[1],u[0],u[1],n]);return{R8:p,S:s(f+s(t.mod(BigInt(this.poseidon.F.toString(m)))*l))}}},u=async()=>(await e.poseidonHolder.init(),await n.jubHolder.init(),new l(n.jubHolder.getJub(),e.poseidonHolder.getPoseidon()));exports.buildEddsaRN=u;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BabyJubRN } from './BabyJubRN';
|
|
2
|
-
type PoseidonFn = {
|
|
3
|
-
(inputs: bigint[]): bigint;
|
|
4
|
-
F: {
|
|
5
|
-
toString: (v: bigint | number | string) => string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare class EddsaRN {
|
|
9
|
-
private readonly babyJub;
|
|
10
|
-
private readonly poseidon;
|
|
11
|
-
constructor(babyJub: BabyJubRN, poseidon: PoseidonFn);
|
|
12
|
-
prv2pub(prv: Uint8Array): [bigint, bigint];
|
|
13
|
-
signPoseidon(prv: Uint8Array, msg: bigint): {
|
|
14
|
-
R8: [bigint, bigint];
|
|
15
|
-
S: bigint;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export declare const buildEddsaRN: () => Promise<EddsaRN>;
|
|
19
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { poseidonHolder as e } from "./poseidon.mjs";
|
|
2
|
-
import { mod as t } from "../functions/utils/bigint-math.utils.mjs";
|
|
3
|
-
import { jubHolder as n } from "./babyJub.mjs";
|
|
4
|
-
import { blake512 as r } from "@noble/hashes/blake1.js";
|
|
5
|
-
//#region libs/shared/common/src/crypto/EddsaRN.ts
|
|
6
|
-
var i = 21888242871839275222246405745257275088614511777268538073601725287587578984328n / 8n, a = (e, t = 0, n = e.length - t) => {
|
|
7
|
-
let r = 0n;
|
|
8
|
-
for (let i = n - 1; i >= 0; --i) r = (r << 8n) + BigInt(e[t + i]);
|
|
9
|
-
return r;
|
|
10
|
-
}, o = (e, n, r, i) => {
|
|
11
|
-
let a = t(r);
|
|
12
|
-
for (let t = 0; t < i; t += 1) e[n + t] = Number(a & 255n), a >>= 8n;
|
|
13
|
-
}, s = (e) => t(e, i), c = (e) => {
|
|
14
|
-
let t = new Uint8Array(e);
|
|
15
|
-
return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
|
|
16
|
-
}, l = class {
|
|
17
|
-
constructor(e, t) {
|
|
18
|
-
this.babyJub = e, this.poseidon = t;
|
|
19
|
-
}
|
|
20
|
-
prv2pub(e) {
|
|
21
|
-
let t = a(c(r(e).slice(0, 32)), 0, 32);
|
|
22
|
-
return this.babyJub.mulPointEscalar(this.babyJub.Base8, t / 8n);
|
|
23
|
-
}
|
|
24
|
-
signPoseidon(e, n) {
|
|
25
|
-
let i = c(r(e)), l = a(i, 0, 32), u = this.babyJub.mulPointEscalar(this.babyJub.Base8, l / 8n), d = new Uint8Array(64);
|
|
26
|
-
d.set(i.slice(32), 0), o(d, 32, n, 32);
|
|
27
|
-
let f = s(a(r(d), 0, 64)), p = this.babyJub.mulPointEscalar(this.babyJub.Base8, f), m = this.poseidon([
|
|
28
|
-
p[0],
|
|
29
|
-
p[1],
|
|
30
|
-
u[0],
|
|
31
|
-
u[1],
|
|
32
|
-
n
|
|
33
|
-
]);
|
|
34
|
-
return {
|
|
35
|
-
R8: p,
|
|
36
|
-
S: s(f + s(t(BigInt(this.poseidon.F.toString(m))) * l))
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}, u = async () => (await e.init(), await n.init(), new l(n.getJub(), e.getPoseidon()));
|
|
40
|
-
//#endregion
|
|
41
|
-
export { u as buildEddsaRN };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`../../constants/protocol.constants.cjs`);var t=(t,n=e.CIRCOM_P)=>{let r=t%n;return r>=0n?r:r+n},n=(n,r=e.CIRCOM_P)=>{let i=1n,a=0n,o=t(n,r),s=r;if(o===0n)throw Error(`Division by zero`);for(;o>1n;){let e=s%o,t=s/o;s=o,o=e;let n=a-i*t;a=i,i=n}return i<0n?i+r:i};exports.mod=t,exports.modInverse=n;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CIRCOM_P as e } from "../../constants/protocol.constants.mjs";
|
|
2
|
-
//#region libs/shared/common/src/functions/utils/bigint-math.utils.ts
|
|
3
|
-
var t = (t, n = e) => {
|
|
4
|
-
let r = t % n;
|
|
5
|
-
return r >= 0n ? r : r + n;
|
|
6
|
-
}, n = (n, r = e) => {
|
|
7
|
-
let i = 1n, a = 0n, o = t(n, r), s = r;
|
|
8
|
-
if (o === 0n) throw Error("Division by zero");
|
|
9
|
-
for (; o > 1n;) {
|
|
10
|
-
let e = s % o, t = s / o;
|
|
11
|
-
s = o, o = e;
|
|
12
|
-
let n = a - i * t;
|
|
13
|
-
a = i, i = n;
|
|
14
|
-
}
|
|
15
|
-
return i < 0n ? i + r : i;
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
export { t as mod, n as modInverse };
|