@auditable/privacy-pool-zk-sdk 0.1.0 → 0.4.0
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/assets/main.wasm +0 -0
- package/assets/main_final.zkey +0 -0
- package/dist/cli.js +29256 -181
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +29639 -304
- package/dist/index.mjs.map +1 -1
- package/dist/sdk.d.ts +15 -6
- package/dist/types.d.ts +7 -0
- package/dist/withdrawal-transaction-input.d.ts +28 -2
- package/package.json +2 -1
- package/pkg/client_sdk_wasm.d.ts +10 -9
- package/pkg/client_sdk_wasm.js +46 -82
- package/pkg/client_sdk_wasm_bg.wasm +0 -0
- package/pkg/client_sdk_wasm_bg.wasm.d.ts +4 -4
package/dist/sdk.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type DecodedDepositorSharedSecretPreimage, type DecodedEphemeralKey, ty
|
|
|
2
2
|
import { type SharedSecret } from './shared-secret';
|
|
3
3
|
import type { DecodedRecipientSharedSecretPreimage } from './stealth-address';
|
|
4
4
|
import type { CoinData, GeneratedCoin, SDKOptions, StateFile, WithdrawMerkleWitness, WithdrawResult } from './types';
|
|
5
|
-
import { type DepositSlot, type WithdrawalProofPublicParams, type WithdrawSlot } from './withdrawal-transaction-input';
|
|
5
|
+
import { type DepositSlot, type TransactionPublicLegParams, type WithdrawalProofPublicParams, type WithdrawSlot } from './withdrawal-transaction-input';
|
|
6
6
|
export declare class PrivacyPoolSDK {
|
|
7
7
|
private wasm;
|
|
8
8
|
private options;
|
|
@@ -32,29 +32,33 @@ export declare class PrivacyPoolSDK {
|
|
|
32
32
|
/**
|
|
33
33
|
* Generate a new coin with random nullifier, secret, and random shared-secret field elements (dev / self-contained tests).
|
|
34
34
|
* @param amount Stroops encoded as `bigint` or integer `number` (WASM `u64`).
|
|
35
|
+
* @param assetHiDecimal / assetLoDecimal Decimal Fr strings for Stellar asset contract id (two limbs).
|
|
35
36
|
*/
|
|
36
|
-
generateCoin(amount: bigint | number): GeneratedCoin;
|
|
37
|
+
generateCoin(amount: bigint | number, assetHiDecimal: string, assetLoDecimal: string): GeneratedCoin;
|
|
37
38
|
/**
|
|
38
39
|
* Generate a coin with the same commitment shape as on-chain deposit: pass `ecdhSharedKey` output (hex x, y).
|
|
39
40
|
* @param amount Stroops (`bigint` | `number`).
|
|
40
41
|
*/
|
|
41
|
-
generateCoinWithSharedSecret(shared: SharedSecret, amount: bigint | number): GeneratedCoin;
|
|
42
|
+
generateCoinWithSharedSecret(shared: SharedSecret, amount: bigint | number, assetHiDecimal: string, assetLoDecimal: string): GeneratedCoin;
|
|
42
43
|
/**
|
|
43
44
|
* Coin for a depositor `ephemeralKeyScalar` (32-byte hex): `coin.secret = Poseidon255(1)(scalar)` as in `deposit.circom`.
|
|
44
45
|
* @param amount Stroops (`bigint` | `number`).
|
|
45
46
|
*/
|
|
46
|
-
generateCoinFromDepositEphemeralScalarHex(scalarHex: string, amount: bigint | number): GeneratedCoin;
|
|
47
|
+
generateCoinFromDepositEphemeralScalarHex(scalarHex: string, amount: bigint | number, assetHiDecimal: string, assetLoDecimal: string): GeneratedCoin;
|
|
47
48
|
/**
|
|
48
49
|
* Aligned deposit coin: `secret = Poseidon₁(scalar)` and ECDH shared key from hex coords (e.g. `ecdhSharedKey(scalar, recipient_x, recipient_y)`).
|
|
49
50
|
* @param amount Stroops (`bigint` | `number`).
|
|
50
51
|
*/
|
|
51
|
-
generateCoinForDepositWithSharedHex(scalarHex: string, sharedXHex: string, sharedYHex: string, amount: bigint | number): GeneratedCoin;
|
|
52
|
+
generateCoinForDepositWithSharedHex(scalarHex: string, sharedXHex: string, sharedYHex: string, amount: bigint | number, assetHiDecimal: string, assetLoDecimal: string): GeneratedCoin;
|
|
52
53
|
/**
|
|
53
54
|
* Merkle root, path, and coin fields for the first withdraw leg (Rust LeanIMT + Poseidon).
|
|
54
55
|
*/
|
|
55
56
|
buildWithdrawMerkleWitness(coin: CoinData, state: StateFile): WithdrawMerkleWitness;
|
|
56
57
|
/**
|
|
57
58
|
* Full `Transaction(20,2,2)` withdrawal proof: one real withdraw + dummies, using coin/state and depositor ECDH point (hex).
|
|
59
|
+
*
|
|
60
|
+
* Optional **partial public withdraw**: spend the full coin commitment `coin.value` (V), send `publicWithdrawStroops` (W) to the
|
|
61
|
+
* Stellar receiver, and re-deposit the remainder (V−W) as a new private note to `changeRecipientStealthAddress` (same circuit balance).
|
|
58
62
|
*/
|
|
59
63
|
proveWithdrawal(coin: CoinData, state: StateFile, params: {
|
|
60
64
|
withdrawAddressHi: string;
|
|
@@ -62,6 +66,10 @@ export declare class PrivacyPoolSDK {
|
|
|
62
66
|
privKeyScalar: string;
|
|
63
67
|
ephemeralXHex: string;
|
|
64
68
|
ephemeralYHex: string;
|
|
69
|
+
/** If set, public leg amount W (stroops). Must satisfy 0 < W < V. Remainder (V−W) stays in the pool as a new commitment. */
|
|
70
|
+
publicWithdrawStroops?: bigint;
|
|
71
|
+
/** Required when `publicWithdrawStroops` is set: stealth recipient for the change note (typically same as deposit). */
|
|
72
|
+
changeRecipientStealthAddress?: string;
|
|
65
73
|
}): Promise<WithdrawResult>;
|
|
66
74
|
/**
|
|
67
75
|
* Convert a snarkjs proof JSON to hex bytes for Soroban.
|
|
@@ -84,10 +92,11 @@ export declare class PrivacyPoolSDK {
|
|
|
84
92
|
* `Transaction(20,2,2)` proof from high-level legs: maps to witness input (incl. `"dummy"` ECDH via WASM), then Groth16 → Soroban hex.
|
|
85
93
|
*
|
|
86
94
|
* @param publicParams Public inputs: `stateRoot`, `withdrawAddressHi` / `withdrawAddressLo`, `privKeyScalar` (decimal field strings).
|
|
95
|
+
* @param publicLegs Public token legs (`publicWithdrawnAssets`, `publicDepositedAssets`, `publicDeposits`, `publicWithdrawals`).
|
|
87
96
|
* @param withdraws Exactly two withdraw slots (`WithdrawObject` or `"dummy"`).
|
|
88
97
|
* @param deposits Exactly two deposit slots (`DepositObject` or `"dummy"`).
|
|
89
98
|
*/
|
|
90
|
-
proveTransaction(publicParams: WithdrawalProofPublicParams, withdraws: [WithdrawSlot, WithdrawSlot], deposits: [DepositSlot, DepositSlot]): Promise<WithdrawResult>;
|
|
99
|
+
proveTransaction(publicParams: WithdrawalProofPublicParams, publicLegs: TransactionPublicLegParams, withdraws: [WithdrawSlot, WithdrawSlot], deposits: [DepositSlot, DepositSlot]): Promise<WithdrawResult>;
|
|
91
100
|
/**
|
|
92
101
|
* Calculate nullifier hash: Poseidon(nullifier)
|
|
93
102
|
* @param nullifier Nullifier decimal string from coin data
|
package/dist/types.d.ts
CHANGED
|
@@ -3,10 +3,15 @@ export interface CoinData {
|
|
|
3
3
|
nullifier: string;
|
|
4
4
|
secret: string;
|
|
5
5
|
commitment: string;
|
|
6
|
+
/** Decimal Fr strings for Stellar asset contract id (`asset[0]`, `asset[1]` in `commitment.circom`). */
|
|
7
|
+
asset_hi: string;
|
|
8
|
+
asset_lo: string;
|
|
6
9
|
}
|
|
7
10
|
export interface GeneratedCoin {
|
|
8
11
|
coin: CoinData;
|
|
9
12
|
commitment_hex: string;
|
|
13
|
+
/** 64-char lowercase hex (no `0x`), Fr big-endian for audit `precommitement`. */
|
|
14
|
+
precommitement_hex: string;
|
|
10
15
|
}
|
|
11
16
|
/** Pool Merkle tree depth (matches `coin::TREE_DEPTH` / `Transaction` circuit). */
|
|
12
17
|
export declare const POOL_MERKLE_TREE_DEPTH = 20;
|
|
@@ -23,6 +28,8 @@ export interface WithdrawMerkleWitness {
|
|
|
23
28
|
value: string;
|
|
24
29
|
nullifier: string;
|
|
25
30
|
secret: string;
|
|
31
|
+
/** `[asset_hi, asset_lo]` decimal Fr strings (Stellar asset contract id). */
|
|
32
|
+
withdrawnAsset: [string, string];
|
|
26
33
|
stateRoot: string;
|
|
27
34
|
stateIndex: string;
|
|
28
35
|
/** Length is always {@link POOL_MERKLE_TREE_DEPTH}; each entry is a decimal field element. */
|
|
@@ -3,6 +3,9 @@ import type { WithdrawMerkleWitness } from './types';
|
|
|
3
3
|
export declare const TRANSACTION_TREE_DEPTH = 20;
|
|
4
4
|
export declare const TRANSACTION_N_INS = 2;
|
|
5
5
|
export declare const TRANSACTION_N_OUTS = 2;
|
|
6
|
+
/** Must match `Transaction(..., publicNInputs, publicNOutputs)` and contract `get_public_slot_config`. */
|
|
7
|
+
export declare const TRANSACTION_PUBLIC_N_INPUTS = 1;
|
|
8
|
+
export declare const TRANSACTION_PUBLIC_N_OUTPUTS = 1;
|
|
6
9
|
/** BN254 scalar field modulus (ark `Fr`, circom signals). */
|
|
7
10
|
export declare const BN254_SCALAR_MOD = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
8
11
|
/**
|
|
@@ -20,11 +23,22 @@ export interface WithdrawalProofPublicParams {
|
|
|
20
23
|
/** Decimal string, circom `privKeyScalar`. */
|
|
21
24
|
privKeyScalar: string;
|
|
22
25
|
}
|
|
26
|
+
/** Public accounting legs (`publicWithdrawnAssets`, `publicDepositedAssets`, `publicDeposits`, `publicWithdrawals`). */
|
|
27
|
+
export interface TransactionPublicLegParams {
|
|
28
|
+
publicWithdrawnAssets: Array<[string, string]>;
|
|
29
|
+
publicDepositedAssets: Array<[string, string]>;
|
|
30
|
+
publicDeposits: string[];
|
|
31
|
+
publicWithdrawals: string[];
|
|
32
|
+
}
|
|
33
|
+
/** All-zero public legs (private-only pool moves). */
|
|
34
|
+
export declare function zeroPublicLegs(): TransactionPublicLegParams;
|
|
23
35
|
/** Real withdraw leg; coordinates are decimal field strings (same as `CoinData`). */
|
|
24
36
|
export interface WithdrawObject {
|
|
25
37
|
value: string;
|
|
26
38
|
nullifier: string;
|
|
27
39
|
secret: string;
|
|
40
|
+
/** Asset contract id as two decimal Fr strings (`asset[0]`, `asset[1]`). */
|
|
41
|
+
asset: [string, string];
|
|
28
42
|
/** Depositor ECDH point `[x, y]` as decimal strings. */
|
|
29
43
|
ephemeralKeys: [string, string];
|
|
30
44
|
stateSiblings: string[];
|
|
@@ -34,12 +48,14 @@ export interface DepositObject {
|
|
|
34
48
|
value: string;
|
|
35
49
|
nullifier: string;
|
|
36
50
|
ephemeralKeyScalar: string;
|
|
51
|
+
/** Asset contract id as two decimal Fr strings. */
|
|
52
|
+
asset: [string, string];
|
|
37
53
|
/** Recipient public key `[x, y]` as decimal strings. */
|
|
38
54
|
recipientPublicKeys: [string, string];
|
|
39
55
|
}
|
|
40
56
|
export type WithdrawSlot = WithdrawObject | 'dummy';
|
|
41
57
|
export type DepositSlot = DepositObject | 'dummy';
|
|
42
|
-
/** Witness calculator input for `circuits/main.circom` `Transaction(20,2,2)`. */
|
|
58
|
+
/** Witness calculator input for `circuits/main.circom` `Transaction(20,2,2,publicNInputs,publicNOutputs)`. */
|
|
43
59
|
export interface TransactionWitnessInput {
|
|
44
60
|
stateRoot: string;
|
|
45
61
|
withdrawAddressHi: string;
|
|
@@ -48,13 +64,19 @@ export interface TransactionWitnessInput {
|
|
|
48
64
|
withdrawnValues: [string, string];
|
|
49
65
|
withdrawnNullifiers: [string, string];
|
|
50
66
|
withdrawnSecrets: [string, string];
|
|
67
|
+
withdrawnAssets: [[string, string], [string, string]];
|
|
51
68
|
ephemeralKeys: [[string, string], [string, string]];
|
|
52
69
|
stateSiblings: [string[], string[]];
|
|
53
70
|
stateIndex: [string, string];
|
|
54
71
|
depositedValues: [string, string];
|
|
55
72
|
depositedNullifiers: [string, string];
|
|
73
|
+
depositedAssets: [[string, string], [string, string]];
|
|
56
74
|
depositedEphemeralKeyScalars: [string, string];
|
|
57
75
|
depositedRecipientPublicKeys: [[string, string], [string, string]];
|
|
76
|
+
publicWithdrawnAssets: Array<[string, string]>;
|
|
77
|
+
publicDepositedAssets: Array<[string, string]>;
|
|
78
|
+
publicDeposits: string[];
|
|
79
|
+
publicWithdrawals: string[];
|
|
58
80
|
}
|
|
59
81
|
export interface WasmEcdhPointFns {
|
|
60
82
|
ecdhEphemeralPublicKeyFromScalarHex(scalarHex: string): {
|
|
@@ -77,11 +99,15 @@ export declare function ed25519PubkeyPayloadHexToWithdrawFrDecimals(hex: string)
|
|
|
77
99
|
hi: string;
|
|
78
100
|
lo: string;
|
|
79
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Stellar contract id (`C…`) → two circom field decimals for `asset[0]`, `asset[1]` (same 32-byte split as accounts).
|
|
104
|
+
*/
|
|
105
|
+
export declare function stellarContractAddressToAssetFrDecimals(address: string): [string, string];
|
|
80
106
|
/** Uniform random `Fr` as decimal (32 random bytes, mod r). For Poseidon-only inputs (e.g. nullifiers). */
|
|
81
107
|
export declare function randomFrDecimal(): string;
|
|
82
108
|
/** Random scalar < 2^253 for BabyJub ECDH / `Num2Bits(253)` (uses {@link generateRandomScalarHex32}). */
|
|
83
109
|
export declare function randomFrDecimal253(): string;
|
|
84
|
-
export declare function buildTransactionWitnessInput(publicParams: WithdrawalProofPublicParams, withdrawSlots: [WithdrawSlot, WithdrawSlot], depositSlots: [DepositSlot, DepositSlot], wasm: WasmEcdhPointFns): TransactionWitnessInput;
|
|
110
|
+
export declare function buildTransactionWitnessInput(publicParams: WithdrawalProofPublicParams, publicLegs: TransactionPublicLegParams, withdrawSlots: [WithdrawSlot, WithdrawSlot], depositSlots: [DepositSlot, DepositSlot], wasm: WasmEcdhPointFns): TransactionWitnessInput;
|
|
85
111
|
/** `stpl1…` stealth address → `[x, y]` as decimal field strings for `depositedRecipientPublicKeys`. */
|
|
86
112
|
export declare function recipientPublicKeysDecimalFromStealthAddress(stealthAddress: string): [string, string];
|
|
87
113
|
/** First withdraw leg: Merkle witness + depositor ECDH point coordinates (hex). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auditable/privacy-pool-zk-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Client SDK for Soroban Privacy Pools - coin generation, withdrawal proofs, and proof serialization",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"cli": "node dist/cli.js"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@stellar/stellar-base": "^13.0.0",
|
|
41
42
|
"bech32": "^2.0.0",
|
|
42
43
|
"snarkjs": "^0.7.0"
|
|
43
44
|
},
|
package/pkg/client_sdk_wasm.d.ts
CHANGED
|
@@ -31,24 +31,25 @@ export function ecdhSharedKey(priv_hex: string, pub_x_hex: string, pub_y_hex: st
|
|
|
31
31
|
/**
|
|
32
32
|
* Generate a new coin with random nullifier, secret, and shared-secret field elements.
|
|
33
33
|
* `amount` is stroops (u64); JS passes `bigint`.
|
|
34
|
-
*
|
|
34
|
+
* `asset_hi_decimal` / `asset_lo_decimal` are decimal Fr strings for the Stellar asset contract id (two limbs).
|
|
35
|
+
* Returns JSON: { coin: { value, nullifier, secret, commitment, asset_hi, asset_lo }, commitment_hex, precommitement_hex }
|
|
35
36
|
*/
|
|
36
|
-
export function generateCoin(amount: bigint): any;
|
|
37
|
+
export function generateCoin(amount: bigint, asset_hi_decimal: string, asset_lo_decimal: string): any;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* `Poseidon₁(scalar)` secret + fixed ECDH shared coords (hex), matching an aligned deposit witness.
|
|
40
41
|
*/
|
|
41
|
-
export function generateCoinForDepositWithSharedHex(scalar_hex: string, shared_x_hex: string, shared_y_hex: string, amount: bigint): any;
|
|
42
|
+
export function generateCoinForDepositWithSharedHex(scalar_hex: string, shared_x_hex: string, shared_y_hex: string, amount: bigint, asset_hi_decimal: string, asset_lo_decimal: string): any;
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* `secret` in coin = `Poseidon255(1)(scalar)` per `deposit.circom`; scalar is 32-byte hex (64 chars, optional `0x`).
|
|
45
46
|
*/
|
|
46
|
-
export function generateCoinFromDepositEphemeralScalarHex(scalar_hex: string, amount: bigint): any;
|
|
47
|
+
export function generateCoinFromDepositEphemeralScalarHex(scalar_hex: string, amount: bigint, asset_hi_decimal: string, asset_lo_decimal: string): any;
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* Same as `generateCoin`, but commitment uses the given ECDH shared key (64-char hex coords from `ecdhSharedKey`); shared coords are not stored in `coin` JSON.
|
|
50
51
|
*/
|
|
51
|
-
export function generateCoinWithSharedSecretHex(shared_x_hex: string, shared_y_hex: string, amount: bigint): any;
|
|
52
|
+
export function generateCoinWithSharedSecretHex(shared_x_hex: string, shared_y_hex: string, amount: bigint, asset_hi_decimal: string, asset_lo_decimal: string): any;
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Convert snarkjs proof JSON to hex bytes for Soroban contract.
|
|
@@ -69,10 +70,10 @@ export interface InitOutput {
|
|
|
69
70
|
readonly ecdhEphemeralPublicKey: (a: number, b: number, c: number) => void;
|
|
70
71
|
readonly ecdhEphemeralPublicKeyFromScalarHex: (a: number, b: number, c: number) => void;
|
|
71
72
|
readonly ecdhSharedKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
72
|
-
readonly generateCoin: (a: bigint) =>
|
|
73
|
-
readonly generateCoinForDepositWithSharedHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => void;
|
|
74
|
-
readonly generateCoinFromDepositEphemeralScalarHex: (a: number, b: number, c: number, d: bigint) => void;
|
|
75
|
-
readonly generateCoinWithSharedSecretHex: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
|
|
73
|
+
readonly generateCoin: (a: number, b: bigint, c: number, d: number, e: number, f: number) => void;
|
|
74
|
+
readonly generateCoinForDepositWithSharedHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: number, j: number, k: number, l: number) => void;
|
|
75
|
+
readonly generateCoinFromDepositEphemeralScalarHex: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number) => void;
|
|
76
|
+
readonly generateCoinWithSharedSecretHex: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
|
|
76
77
|
readonly proofToHex: (a: number, b: number, c: number) => void;
|
|
77
78
|
readonly publicToHex: (a: number, b: number, c: number) => void;
|
|
78
79
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
package/pkg/client_sdk_wasm.js
CHANGED
|
@@ -147,13 +147,31 @@ export function ecdhSharedKey(priv_hex, pub_x_hex, pub_y_hex) {
|
|
|
147
147
|
/**
|
|
148
148
|
* Generate a new coin with random nullifier, secret, and shared-secret field elements.
|
|
149
149
|
* `amount` is stroops (u64); JS passes `bigint`.
|
|
150
|
-
*
|
|
150
|
+
* `asset_hi_decimal` / `asset_lo_decimal` are decimal Fr strings for the Stellar asset contract id (two limbs).
|
|
151
|
+
* Returns JSON: { coin: { value, nullifier, secret, commitment, asset_hi, asset_lo }, commitment_hex, precommitement_hex }
|
|
151
152
|
* @param {bigint} amount
|
|
153
|
+
* @param {string} asset_hi_decimal
|
|
154
|
+
* @param {string} asset_lo_decimal
|
|
152
155
|
* @returns {any}
|
|
153
156
|
*/
|
|
154
|
-
export function generateCoin(amount) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
export function generateCoin(amount, asset_hi_decimal, asset_lo_decimal) {
|
|
158
|
+
try {
|
|
159
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
160
|
+
const ptr0 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
161
|
+
const len0 = WASM_VECTOR_LEN;
|
|
162
|
+
const ptr1 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
163
|
+
const len1 = WASM_VECTOR_LEN;
|
|
164
|
+
wasm.generateCoin(retptr, amount, ptr0, len0, ptr1, len1);
|
|
165
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
166
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
167
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
168
|
+
if (r2) {
|
|
169
|
+
throw takeObject(r1);
|
|
170
|
+
}
|
|
171
|
+
return takeObject(r0);
|
|
172
|
+
} finally {
|
|
173
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
174
|
+
}
|
|
157
175
|
}
|
|
158
176
|
|
|
159
177
|
/**
|
|
@@ -162,9 +180,11 @@ export function generateCoin(amount) {
|
|
|
162
180
|
* @param {string} shared_x_hex
|
|
163
181
|
* @param {string} shared_y_hex
|
|
164
182
|
* @param {bigint} amount
|
|
183
|
+
* @param {string} asset_hi_decimal
|
|
184
|
+
* @param {string} asset_lo_decimal
|
|
165
185
|
* @returns {any}
|
|
166
186
|
*/
|
|
167
|
-
export function generateCoinForDepositWithSharedHex(scalar_hex, shared_x_hex, shared_y_hex, amount) {
|
|
187
|
+
export function generateCoinForDepositWithSharedHex(scalar_hex, shared_x_hex, shared_y_hex, amount, asset_hi_decimal, asset_lo_decimal) {
|
|
168
188
|
try {
|
|
169
189
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
170
190
|
const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -173,7 +193,11 @@ export function generateCoinForDepositWithSharedHex(scalar_hex, shared_x_hex, sh
|
|
|
173
193
|
const len1 = WASM_VECTOR_LEN;
|
|
174
194
|
const ptr2 = passStringToWasm0(shared_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
175
195
|
const len2 = WASM_VECTOR_LEN;
|
|
176
|
-
|
|
196
|
+
const ptr3 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
197
|
+
const len3 = WASM_VECTOR_LEN;
|
|
198
|
+
const ptr4 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
199
|
+
const len4 = WASM_VECTOR_LEN;
|
|
200
|
+
wasm.generateCoinForDepositWithSharedHex(retptr, ptr0, len0, ptr1, len1, ptr2, len2, amount, ptr3, len3, ptr4, len4);
|
|
177
201
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
178
202
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
179
203
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -190,14 +214,20 @@ export function generateCoinForDepositWithSharedHex(scalar_hex, shared_x_hex, sh
|
|
|
190
214
|
* `secret` in coin = `Poseidon255(1)(scalar)` per `deposit.circom`; scalar is 32-byte hex (64 chars, optional `0x`).
|
|
191
215
|
* @param {string} scalar_hex
|
|
192
216
|
* @param {bigint} amount
|
|
217
|
+
* @param {string} asset_hi_decimal
|
|
218
|
+
* @param {string} asset_lo_decimal
|
|
193
219
|
* @returns {any}
|
|
194
220
|
*/
|
|
195
|
-
export function generateCoinFromDepositEphemeralScalarHex(scalar_hex, amount) {
|
|
221
|
+
export function generateCoinFromDepositEphemeralScalarHex(scalar_hex, amount, asset_hi_decimal, asset_lo_decimal) {
|
|
196
222
|
try {
|
|
197
223
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
198
224
|
const ptr0 = passStringToWasm0(scalar_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
199
225
|
const len0 = WASM_VECTOR_LEN;
|
|
200
|
-
|
|
226
|
+
const ptr1 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
227
|
+
const len1 = WASM_VECTOR_LEN;
|
|
228
|
+
const ptr2 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
229
|
+
const len2 = WASM_VECTOR_LEN;
|
|
230
|
+
wasm.generateCoinFromDepositEphemeralScalarHex(retptr, ptr0, len0, amount, ptr1, len1, ptr2, len2);
|
|
201
231
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
202
232
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
203
233
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -215,16 +245,22 @@ export function generateCoinFromDepositEphemeralScalarHex(scalar_hex, amount) {
|
|
|
215
245
|
* @param {string} shared_x_hex
|
|
216
246
|
* @param {string} shared_y_hex
|
|
217
247
|
* @param {bigint} amount
|
|
248
|
+
* @param {string} asset_hi_decimal
|
|
249
|
+
* @param {string} asset_lo_decimal
|
|
218
250
|
* @returns {any}
|
|
219
251
|
*/
|
|
220
|
-
export function generateCoinWithSharedSecretHex(shared_x_hex, shared_y_hex, amount) {
|
|
252
|
+
export function generateCoinWithSharedSecretHex(shared_x_hex, shared_y_hex, amount, asset_hi_decimal, asset_lo_decimal) {
|
|
221
253
|
try {
|
|
222
254
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
223
255
|
const ptr0 = passStringToWasm0(shared_x_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
224
256
|
const len0 = WASM_VECTOR_LEN;
|
|
225
257
|
const ptr1 = passStringToWasm0(shared_y_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
226
258
|
const len1 = WASM_VECTOR_LEN;
|
|
227
|
-
|
|
259
|
+
const ptr2 = passStringToWasm0(asset_hi_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
260
|
+
const len2 = WASM_VECTOR_LEN;
|
|
261
|
+
const ptr3 = passStringToWasm0(asset_lo_decimal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
262
|
+
const len3 = WASM_VECTOR_LEN;
|
|
263
|
+
wasm.generateCoinWithSharedSecretHex(retptr, ptr0, len0, ptr1, len1, amount, ptr2, len2, ptr3, len3);
|
|
228
264
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
229
265
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
230
266
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -295,13 +331,6 @@ function __wbg_get_imports() {
|
|
|
295
331
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
296
332
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
297
333
|
},
|
|
298
|
-
__wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
|
|
299
|
-
const ret = debugString(getObject(arg1));
|
|
300
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
301
|
-
const len1 = WASM_VECTOR_LEN;
|
|
302
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
303
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
304
|
-
},
|
|
305
334
|
__wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
|
|
306
335
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
307
336
|
return ret;
|
|
@@ -427,71 +456,6 @@ function addHeapObject(obj) {
|
|
|
427
456
|
return idx;
|
|
428
457
|
}
|
|
429
458
|
|
|
430
|
-
function debugString(val) {
|
|
431
|
-
// primitive types
|
|
432
|
-
const type = typeof val;
|
|
433
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
434
|
-
return `${val}`;
|
|
435
|
-
}
|
|
436
|
-
if (type == 'string') {
|
|
437
|
-
return `"${val}"`;
|
|
438
|
-
}
|
|
439
|
-
if (type == 'symbol') {
|
|
440
|
-
const description = val.description;
|
|
441
|
-
if (description == null) {
|
|
442
|
-
return 'Symbol';
|
|
443
|
-
} else {
|
|
444
|
-
return `Symbol(${description})`;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
if (type == 'function') {
|
|
448
|
-
const name = val.name;
|
|
449
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
450
|
-
return `Function(${name})`;
|
|
451
|
-
} else {
|
|
452
|
-
return 'Function';
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
// objects
|
|
456
|
-
if (Array.isArray(val)) {
|
|
457
|
-
const length = val.length;
|
|
458
|
-
let debug = '[';
|
|
459
|
-
if (length > 0) {
|
|
460
|
-
debug += debugString(val[0]);
|
|
461
|
-
}
|
|
462
|
-
for(let i = 1; i < length; i++) {
|
|
463
|
-
debug += ', ' + debugString(val[i]);
|
|
464
|
-
}
|
|
465
|
-
debug += ']';
|
|
466
|
-
return debug;
|
|
467
|
-
}
|
|
468
|
-
// Test for built-in
|
|
469
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
470
|
-
let className;
|
|
471
|
-
if (builtInMatches && builtInMatches.length > 1) {
|
|
472
|
-
className = builtInMatches[1];
|
|
473
|
-
} else {
|
|
474
|
-
// Failed to match the standard '[object ClassName]'
|
|
475
|
-
return toString.call(val);
|
|
476
|
-
}
|
|
477
|
-
if (className == 'Object') {
|
|
478
|
-
// we're a user defined class or Object
|
|
479
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
480
|
-
// easier than looping through ownProperties of `val`.
|
|
481
|
-
try {
|
|
482
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
483
|
-
} catch (_) {
|
|
484
|
-
return 'Object';
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
// errors
|
|
488
|
-
if (val instanceof Error) {
|
|
489
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
490
|
-
}
|
|
491
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
492
|
-
return className;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
459
|
function dropObject(idx) {
|
|
496
460
|
if (idx < 1028) return;
|
|
497
461
|
heap[idx] = heap_next;
|
|
Binary file
|
|
@@ -6,10 +6,10 @@ export const calculateNullifierHash: (a: number, b: number, c: number) => void;
|
|
|
6
6
|
export const ecdhEphemeralPublicKey: (a: number, b: number, c: number) => void;
|
|
7
7
|
export const ecdhEphemeralPublicKeyFromScalarHex: (a: number, b: number, c: number) => void;
|
|
8
8
|
export const ecdhSharedKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
9
|
-
export const generateCoin: (a: bigint) =>
|
|
10
|
-
export const generateCoinForDepositWithSharedHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => void;
|
|
11
|
-
export const generateCoinFromDepositEphemeralScalarHex: (a: number, b: number, c: number, d: bigint) => void;
|
|
12
|
-
export const generateCoinWithSharedSecretHex: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
|
|
9
|
+
export const generateCoin: (a: number, b: bigint, c: number, d: number, e: number, f: number) => void;
|
|
10
|
+
export const generateCoinForDepositWithSharedHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: number, j: number, k: number, l: number) => void;
|
|
11
|
+
export const generateCoinFromDepositEphemeralScalarHex: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number) => void;
|
|
12
|
+
export const generateCoinWithSharedSecretHex: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number, j: number) => void;
|
|
13
13
|
export const proofToHex: (a: number, b: number, c: number) => void;
|
|
14
14
|
export const publicToHex: (a: number, b: number, c: number) => void;
|
|
15
15
|
export const __wbindgen_export: (a: number, b: number) => number;
|