@gurge/sdk-react-native 0.3.120 → 0.3.130
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/common/src/crypto/babyJub.cjs +1 -1
- package/common/src/crypto/babyJub.mjs +6 -7
- package/common/src/crypto/eddsa.cjs +1 -1
- package/common/src/crypto/eddsa.mjs +6 -7
- package/common/src/crypto/poseidon.cjs +1 -1
- package/common/src/crypto/poseidon.mjs +11 -19
- package/common/src/data-structures/IndexedDB/key-val-store.cjs +1 -1
- package/common/src/data-structures/IndexedDB/key-val-store.mjs +18 -17
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +0 -1
- package/common/src/functions/utils/bigint-math.utils.cjs +1 -1
- package/common/src/functions/utils/bigint-math.utils.mjs +1 -18
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.mjs +1 -1
- 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/viteWorkerURL.constant.mjs +3 -3
- 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/package.json +2 -2
- package/scripts/patch-libsodium-for-rn.js +3 -8
- package/shims/circomlibjs-hinkal-fork.mjs +1758 -3
- package/shims/circomlibjs.cjs +1 -1
- 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/shims/circomlibjs-hinkal-fork.cjs +0 -14
package/shims/circomlibjs.cjs
CHANGED
|
@@ -2,7 +2,7 @@ function notSupported(name) {
|
|
|
2
2
|
return () => {
|
|
3
3
|
throw new Error(
|
|
4
4
|
`[hinkal-rn] circomlibjs.${name} is not available on React Native. ` +
|
|
5
|
-
'
|
|
5
|
+
'Use circomlibjs-hinkal-fork RN builders instead.',
|
|
6
6
|
);
|
|
7
7
|
};
|
|
8
8
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`../constants/protocol.constants.cjs`),t=require(`../functions/utils/bigint-math.utils.cjs`);var n={p:e.CIRCOM_P,zero:0n,one:1n,e:e=>t.mod(BigInt(e)),add:(e,n)=>t.mod(e+n),sub:(e,n)=>t.mod(e-n),mul:(e,n)=>t.mod(e*n),div:(e,n)=>{if(n===0n)throw Error(`Division by zero in BabyJub field`);return t.mod(e*t.modInverse(n))},toString:e=>t.mod(e).toString()},r={X:n.zero,Y:n.one,Z:n.one,T:n.zero},i=e=>{let t=n.e(e[0]),r=n.e(e[1]);return{X:t,Y:r,Z:n.one,T:n.mul(t,r)}},a=e=>{let r=t.modInverse(e.Z);return[n.mul(e.X,r),n.mul(e.Y,r)]},o=n.e(`168700`),s=n.e(`168696`),c=(e,t)=>{let r=n.mul(e.X,t.X),i=n.mul(e.Y,t.Y),a=n.mul(n.mul(e.T,t.T),s),c=n.mul(e.Z,t.Z),l=n.sub(n.mul(n.add(e.X,e.Y),n.add(t.X,t.Y)),n.add(r,i)),u=n.sub(c,a),d=n.add(c,a),f=n.sub(i,n.mul(o,r));return{X:n.mul(l,u),Y:n.mul(d,f),T:n.mul(l,f),Z:n.mul(u,d)}},l=e=>{let t=n.mul(e.X,e.X),r=n.mul(e.Y,e.Y),i=n.mul(n.mul(e.Z,e.Z),2n),a=n.mul(o,t),s=n.sub(n.mul(n.add(e.X,e.Y),n.add(e.X,e.Y)),n.add(t,r)),c=n.add(a,r),l=n.sub(c,i),u=n.sub(a,r);return{X:n.mul(s,l),Y:n.mul(c,u),T:n.mul(s,u),Z:n.mul(l,c)}},u=class{static A=o;static D=s;F=n;A=o;D=s;Base8=[n.e(`5299619240641551281634865583518297030282874472190772894086521144482721001553`),n.e(`16950150798460657717958625567821834550301663161624707787222815936182638968203`)];addPoint(e,t){return a(c(i(e),i(t)))}mulPointEscalar(e,t){let n=r,o=i(e),s=BigInt(t);for(;s!==0n;)s%2n==1n&&(n=c(n,o)),o=l(o),s/=2n;return a(n)}};exports.BabyJubRN=u;
|
|
@@ -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 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 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,14 +0,0 @@
|
|
|
1
|
-
function notSupported(name) {
|
|
2
|
-
return () => {
|
|
3
|
-
throw new Error(
|
|
4
|
-
`[hinkal-rn] circomlibjs-hinkal-fork.${name} is not available on React Native. ` +
|
|
5
|
-
'The SDK uses poseidon-lite + an inline BabyJubJub instead.',
|
|
6
|
-
);
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
buildPoseidon: notSupported('buildPoseidon'),
|
|
12
|
-
buildPoseidonReference: notSupported('buildPoseidonReference'),
|
|
13
|
-
buildBabyjub: notSupported('buildBabyjub'),
|
|
14
|
-
};
|