@auditable/privacy-pool-zk-sdk 0.7.0 → 0.8.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 +740 -569
- package/dist/cli.js.map +1 -1
- package/dist/derived-escrow-key.d.ts +10 -0
- package/dist/domain-separators.d.ts +10 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.mjs +598 -375
- package/dist/index.mjs.map +1 -1
- package/dist/kyt-flow.d.ts +0 -3
- package/dist/kyt-passage.d.ts +8 -11
- package/dist/output-note-encryption.d.ts +1 -0
- package/dist/sdk.d.ts +23 -17
- package/dist/stealth-sign-message.d.ts +15 -2
- package/dist/stealth-signature.d.ts +13 -5
- package/dist/transaction-audit.d.ts +5 -0
- package/dist/types.d.ts +2 -0
- package/dist/withdrawal-transaction-input.d.ts +34 -10
- package/package.json +2 -2
- package/pkg/client_sdk_wasm.d.ts +23 -15
- package/pkg/client_sdk_wasm.js +90 -48
- package/pkg/client_sdk_wasm_bg.wasm +0 -0
- package/pkg/client_sdk_wasm_bg.wasm.d.ts +6 -5
- package/dist/kyt-onboarding.d.ts +0 -36
package/dist/kyt-flow.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Keypair } from '@stellar/stellar-sdk';
|
|
2
2
|
import { buildKytPassageAuthorization, derivePassageFromTransactContext, hashPublicSignalBytes, type InspectKytPassageRequest, type PublicLegContextInput } from './kyt-passage.js';
|
|
3
|
-
import { type OnboardingPayloadInput } from './kyt-onboarding.js';
|
|
4
3
|
export interface RegisterPassageParams {
|
|
5
4
|
kytRegistryId: string;
|
|
6
5
|
poolContract: string;
|
|
@@ -8,7 +7,6 @@ export interface RegisterPassageParams {
|
|
|
8
7
|
nonce?: bigint | number;
|
|
9
8
|
publicSignalsBytes: Buffer | string;
|
|
10
9
|
publicLegContext: PublicLegContextInput;
|
|
11
|
-
onboarding?: OnboardingPayloadInput | null;
|
|
12
10
|
signature: string;
|
|
13
11
|
expiresAtLedger: number;
|
|
14
12
|
source: Keypair;
|
|
@@ -21,7 +19,6 @@ export interface SubmitKytTransactParams {
|
|
|
21
19
|
nonce: bigint | number;
|
|
22
20
|
proofBytes: Buffer;
|
|
23
21
|
publicSignalsBytes: Buffer;
|
|
24
|
-
onboarding?: OnboardingPayloadInput | null;
|
|
25
22
|
/** Omit when the pool's own registered passage covers this call (no explicit signed authorization). */
|
|
26
23
|
kytAuthorization?: {
|
|
27
24
|
expirationLedger: number;
|
package/dist/kyt-passage.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type OnboardingPayloadInput } from './kyt-onboarding.js';
|
|
2
1
|
export declare const KYT_PASSAGE_AUTH_DOMAIN = "privacy-pool-kyt-passage-v1";
|
|
3
2
|
export declare const PUBLIC_LEG_CONTEXT_DOMAIN = "privacy-pool-public-leg-context-v1";
|
|
4
|
-
export declare const PASSAGE_ID_DOMAIN = "privacy-pool-passage-id-
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const NOTE_AUDIT_LEN =
|
|
7
|
-
export declare const TOTAL_PUBLIC_SIGNALS =
|
|
3
|
+
export declare const PASSAGE_ID_DOMAIN = "privacy-pool-passage-id-v2";
|
|
4
|
+
export declare const PASSAGE_ID_DOMAIN_V1 = "privacy-pool-passage-id-v1";
|
|
5
|
+
export declare const NOTE_AUDIT_LEN = 12;
|
|
6
|
+
export declare const TOTAL_PUBLIC_SIGNALS = 93;
|
|
7
|
+
export declare const NOTE_AUDIT_PLAINTEXT_LEN = 12;
|
|
8
8
|
export interface PublicLegLayout {
|
|
9
9
|
publicNInputs: number;
|
|
10
10
|
publicNOutputs: number;
|
|
@@ -20,7 +20,6 @@ export interface PublicLegContextInput {
|
|
|
20
20
|
export interface KytPassageDerivation {
|
|
21
21
|
publicSignalHash: string;
|
|
22
22
|
publicLegContextHash: string;
|
|
23
|
-
onboardingHash: string;
|
|
24
23
|
passageId: string;
|
|
25
24
|
}
|
|
26
25
|
export interface KytPassageAuthorization {
|
|
@@ -33,10 +32,10 @@ export interface KytPassageAuthorization {
|
|
|
33
32
|
/** Canonical zero-address sentinel for absent public-leg slots: `u32_be(0)` with no XDR bytes. */
|
|
34
33
|
export declare function zeroAddressSentinelBuffer(): Buffer;
|
|
35
34
|
export declare function addressToCanonicalXdr(address: string): Buffer;
|
|
36
|
-
export declare function hashPublicSignalBytes(publicSignalsBytes: Buffer | string): string;
|
|
35
|
+
export declare function hashPublicSignalBytes(publicSignalsBytes: Buffer | string, zkConfigNonce?: bigint): string;
|
|
37
36
|
export declare function hashPublicLegContext(layout: PublicLegLayout, input: PublicLegContextInput): string;
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function
|
|
37
|
+
export declare function derivePassageId(owner: string, nonce: bigint | number, publicSignalHash: string, publicLegContextHash: string): string;
|
|
38
|
+
export declare function derivePassageIdV1(owner: string, nonce: bigint | number, publicSignalHash: string, publicLegContextHash: string, onboardingHash: string): string;
|
|
40
39
|
export declare function buildKytPassageAuthorization(input: {
|
|
41
40
|
poolContract: string;
|
|
42
41
|
kytRegistry: string;
|
|
@@ -49,7 +48,6 @@ export declare function derivePassageFromTransactContext(input: {
|
|
|
49
48
|
publicSignalsBytes: Buffer | string;
|
|
50
49
|
publicLegContext: PublicLegContextInput;
|
|
51
50
|
layout?: PublicLegLayout;
|
|
52
|
-
onboarding?: OnboardingPayloadInput | null;
|
|
53
51
|
}): KytPassageDerivation;
|
|
54
52
|
export declare function accountIdFromAddress(address: string): Buffer;
|
|
55
53
|
export interface InspectKytPassageRequest {
|
|
@@ -59,7 +57,6 @@ export interface InspectKytPassageRequest {
|
|
|
59
57
|
proofBytes: string;
|
|
60
58
|
publicSignalsBytes: string;
|
|
61
59
|
applicationIdsPlaintext: [string, string, string, string];
|
|
62
|
-
onboarding?: OnboardingPayloadInput | null;
|
|
63
60
|
nonce?: string;
|
|
64
61
|
}
|
|
65
62
|
export interface InspectKytPassageApproved {
|
|
@@ -26,6 +26,7 @@ export type OutputNoteEventInput = {
|
|
|
26
26
|
createdEphemeralKey: readonly [string, string];
|
|
27
27
|
ciphertext: readonly string[];
|
|
28
28
|
tag: string;
|
|
29
|
+
ownerMode?: bigint;
|
|
29
30
|
};
|
|
30
31
|
export declare function secretFromDepositEphemeralScalarDecimal(ephemeralKeyScalarDecimal: string): Promise<string>;
|
|
31
32
|
export declare function encryptOutputNoteForDeposit(parameters: {
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DecodedDepositorSharedSecretPreimage, type DecodedEphemeralKey, type EncodedDepositorSharedSecretPreimage, type EncodedEphemeralKey } from './ephemeral-key';
|
|
2
2
|
import { type SharedSecret } from './shared-secret';
|
|
3
|
+
import { type SpendScalarDomain } from './stealth-sign-message';
|
|
3
4
|
import type { DecodedRecipientSharedSecretPreimage } from './stealth-address';
|
|
4
5
|
import type { CoinData, GeneratedCoin, SDKOptions, StateFile, WithdrawMerkleWitness, WithdrawResult } from './types';
|
|
5
6
|
import { type DepositSlot, type TransactionPublicLegParams, type WithdrawalProofPublicParams, type WithdrawSlot } from './withdrawal-transaction-input';
|
|
@@ -27,30 +28,34 @@ export declare class PrivacyPoolSDK {
|
|
|
27
28
|
*/
|
|
28
29
|
static generateRandomScalarHex32(): string;
|
|
29
30
|
/**
|
|
30
|
-
* Text to sign with a Stellar wallet for
|
|
31
|
+
* Text to sign with a Stellar wallet for spend-key derivation (UTF-8). No WASM required.
|
|
32
|
+
* The message binds network, pool, registry, and schema version (H6).
|
|
31
33
|
*/
|
|
32
|
-
static buildStealthAddressSignMessage(address: string, nonce?: string): string;
|
|
34
|
+
static buildStealthAddressSignMessage(address: string, domain: SpendScalarDomain, nonce?: string): string;
|
|
33
35
|
/**
|
|
34
|
-
* Generate a new coin with random nullifier, secret, and random
|
|
35
|
-
* @param amount
|
|
36
|
+
* Generate a new coin with random nullifier, secret, and random owner-pub field elements (dev / self-contained tests).
|
|
37
|
+
* @param amount Decimal field element as `bigint` or decimal `string` (never JS `number`).
|
|
36
38
|
* @param assetHiDecimal / assetLoDecimal Decimal Fr strings for Stellar asset contract id (two limbs).
|
|
37
39
|
*/
|
|
38
|
-
generateCoin(amount: bigint |
|
|
40
|
+
generateCoin(amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
|
|
39
41
|
/**
|
|
40
|
-
* Generate a coin with the same commitment shape as on-chain deposit: pass
|
|
41
|
-
* @param amount
|
|
42
|
+
* Generate a coin with the same commitment shape as on-chain deposit: pass owner public key (hex x, y).
|
|
43
|
+
* @param amount Decimal field element (`bigint` | `string`).
|
|
42
44
|
*/
|
|
43
|
-
|
|
45
|
+
generateCoinWithOwnerPub(ownerPub: {
|
|
46
|
+
x: string;
|
|
47
|
+
y: string;
|
|
48
|
+
}, amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
|
|
44
49
|
/**
|
|
45
50
|
* Coin for a depositor `ephemeralKeyScalar` (32-byte hex): `coin.secret = Poseidon255(1)(scalar)` as in `deposit.circom`.
|
|
46
|
-
* @param amount
|
|
51
|
+
* @param amount Decimal field element (`bigint` | `string`).
|
|
47
52
|
*/
|
|
48
|
-
generateCoinFromDepositEphemeralScalarHex(scalarHex: string, amount: bigint |
|
|
53
|
+
generateCoinFromDepositEphemeralScalarHex(scalarHex: string, amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
|
|
49
54
|
/**
|
|
50
|
-
* Aligned deposit coin: `secret = Poseidon₁(scalar)` and
|
|
51
|
-
* @param amount
|
|
55
|
+
* Aligned deposit coin: `secret = Poseidon₁(scalar)` and owner pub from recipient hex coords.
|
|
56
|
+
* @param amount Decimal field element (`bigint` | `string`).
|
|
52
57
|
*/
|
|
53
|
-
|
|
58
|
+
generateCoinForDepositWithOwnerPubHex(scalarHex: string, ownerXHex: string, ownerYHex: string, amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
|
|
54
59
|
/**
|
|
55
60
|
* Merkle root, path, and coin fields for the first withdraw leg (Rust LeanIMT + Poseidon).
|
|
56
61
|
*/
|
|
@@ -101,16 +106,17 @@ export declare class PrivacyPoolSDK {
|
|
|
101
106
|
*/
|
|
102
107
|
proveTransaction(publicParams: WithdrawalProofPublicParams, publicLegs: TransactionPublicLegParams, withdraws: [WithdrawSlot, WithdrawSlot], deposits: [DepositSlot, DepositSlot], audit: TransactionAuditParams): Promise<WithdrawResult>;
|
|
103
108
|
/**
|
|
104
|
-
* Calculate nullifier hash: Poseidon(nullifier)
|
|
109
|
+
* Calculate owner-bound nullifier hash: Poseidon(DOM_NULLIFIER, nullifier, privKeyScalar)
|
|
105
110
|
* @param nullifier Nullifier decimal string from coin data
|
|
111
|
+
* @param privKeyScalar Spend scalar decimal string
|
|
106
112
|
* @returns Hex string (0x...) of the hash bytes
|
|
107
113
|
*/
|
|
108
|
-
calculateNullifierHash(nullifier: string): string;
|
|
114
|
+
calculateNullifierHash(nullifier: string, privKeyScalar: string): string;
|
|
109
115
|
/**
|
|
110
116
|
* Ed25519 signature from signing {@link buildStealthAddressSignMessage}: **128 hex chars** (optional `0x`)
|
|
111
|
-
* or **base64** (64 raw bytes after decode).
|
|
117
|
+
* or **base64** (64 raw bytes after decode). Domain-separated SHA-256 → scalar → ECDH → `stpl1` Bech32.
|
|
112
118
|
*/
|
|
113
|
-
generateStealthAddressFromStellarSignature(signature: string): Promise<string>;
|
|
119
|
+
generateStealthAddressFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<string>;
|
|
114
120
|
encodeDecodedEphemeralKey(decoded: DecodedEphemeralKey): EncodedEphemeralKey;
|
|
115
121
|
decodeDecodedEphemeralKey(encoded: EncodedEphemeralKey): DecodedEphemeralKey;
|
|
116
122
|
encodeDepositorSharedSecretPreimage(decoded: DecodedDepositorSharedSecretPreimage): EncodedDepositorSharedSecretPreimage;
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
/** Default nonce when deriving the wallet sign-in message. */
|
|
2
2
|
export declare const DEFAULT_STEALTH_SIGN_NONCE = "main address";
|
|
3
|
+
/** Domain tag mixed into the spend-scalar digest (H6). */
|
|
4
|
+
export declare const SPEND_SCALAR_DOMAIN_TAG = "privacy-pool-spend-scalar-v1";
|
|
5
|
+
/** Schema version bound into the spend-scalar message and digest. */
|
|
6
|
+
export declare const OWNER_BOUND_NOTE_SCHEMA_VERSION = 1;
|
|
7
|
+
export type SpendScalarDomain = {
|
|
8
|
+
networkPassphrase: string;
|
|
9
|
+
poolContract: string;
|
|
10
|
+
registryContract: string;
|
|
11
|
+
schemaVersion?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function resolveSpendScalarSchemaVersion(domain: SpendScalarDomain): number;
|
|
3
14
|
/**
|
|
4
|
-
* Plaintext for Stellar wallet message signing (
|
|
15
|
+
* Plaintext for Stellar wallet message signing (spend-key derivation).
|
|
5
16
|
* Sign the exact bytes of this string (UTF-8) with the stellar account key.
|
|
17
|
+
*
|
|
18
|
+
* The derived scalar is the owner-bound spend key for notes in this environment.
|
|
6
19
|
*/
|
|
7
|
-
export declare function buildStealthAddressSignMessage(address: string, nonce?: string): string;
|
|
20
|
+
export declare function buildStealthAddressSignMessage(address: string, domain: SpendScalarDomain, nonce?: string): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SpendScalarDomain } from './stealth-sign-message';
|
|
1
2
|
/**
|
|
2
3
|
* Ed25519 signature as **128 hex chars** (optional `0x`) or **base64** (typically 88 chars for 64 bytes, whitespace ignored).
|
|
3
4
|
*/
|
|
@@ -5,7 +6,14 @@ export declare function parseStellarEd25519SignatureRaw(input: string): Uint8Arr
|
|
|
5
6
|
/** SHA-256 via Web Crypto only (`crypto.subtle`) — works in browsers and Node 19+ (global `crypto`). */
|
|
6
7
|
export declare function sha256(data: Uint8Array): Promise<Uint8Array>;
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Domain-separated spend-scalar digest: SHA-256(
|
|
10
|
+
* SPEND_SCALAR_DOMAIN_TAG || network || pool || registry || schemaVersion || signature
|
|
11
|
+
* ).
|
|
12
|
+
*/
|
|
13
|
+
export declare function spendScalarDigestFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<Uint8Array>;
|
|
14
|
+
export declare function spendScalarHexFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Stellar Ed25519 signature (hex or base64) → domain-separated SHA-256 → scalar → WASM ECDH.
|
|
9
17
|
*/
|
|
10
18
|
export declare function stealthAddressFromStellarSignature(ecdhFromScalarHex: (scalarHex64: string) => {
|
|
11
19
|
x: string;
|
|
@@ -13,9 +21,9 @@ export declare function stealthAddressFromStellarSignature(ecdhFromScalarHex: (s
|
|
|
13
21
|
}, encodeStealth: (decoded: {
|
|
14
22
|
x: string;
|
|
15
23
|
y: string;
|
|
16
|
-
}) => string, signature: string): Promise<string>;
|
|
24
|
+
}) => string, signature: string, domain: SpendScalarDomain): Promise<string>;
|
|
17
25
|
/**
|
|
18
|
-
* SHA-256(signature
|
|
19
|
-
* `
|
|
26
|
+
* Domain-separated SHA-256(signature, network, pool, registry, schema) reduced into
|
|
27
|
+
* `(0, BabyJub subgroup order)` so `privKeyScalar` matches `BabyPbk` and circom `LessThan(l)`.
|
|
20
28
|
*/
|
|
21
|
-
export declare function privKeyScalarDecimalFromStellarSignature(signature: string): Promise<string>;
|
|
29
|
+
export declare function privKeyScalarDecimalFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<string>;
|
|
@@ -22,4 +22,9 @@ export declare function buildUniformAuditParams(applicationId: string | undefine
|
|
|
22
22
|
export declare function resolveSlotApplicationIds(audit: TransactionAuditParams, withdrawSlots: [WithdrawSlot, WithdrawSlot], depositSlots: [DepositSlot, DepositSlot]): TransactionSlotApplicationIds;
|
|
23
23
|
export declare function withApplicationIdOnDeposit(deposit: DepositObject, applicationId: string): DepositObject;
|
|
24
24
|
export declare function withApplicationIdOnWithdraw(withdraw: WithdrawObject, applicationId: string): WithdrawObject;
|
|
25
|
+
/**
|
|
26
|
+
* Prefer an explicit key, then `NOTE_AUDIT_PUBLIC_KEY_X`/`_Y` env (decimal Fr),
|
|
27
|
+
* then the built-in demo key. Used by CLI/`demo.sh` for per-app audit pubkeys.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveAuditPublicKeyFromEnv(auditPublicKey?: AuditPublicKey): AuditPublicKey;
|
|
25
30
|
export declare function resolveTransactionAuditParams(applicationId: string, auditPublicKey?: AuditPublicKey): TransactionAuditParams;
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface GeneratedCoin {
|
|
|
14
14
|
commitment_hex: string;
|
|
15
15
|
/** 64-char lowercase hex (no `0x`), Fr big-endian for audit `precommitement`. */
|
|
16
16
|
precommitement_hex: string;
|
|
17
|
+
/** JS alias of {@link GeneratedCoin.precommitement_hex}. */
|
|
18
|
+
precommitementHex: string;
|
|
17
19
|
}
|
|
18
20
|
/** Pool Merkle tree depth (matches `coin::TREE_DEPTH` / `Transaction` circuit). */
|
|
19
21
|
export declare const POOL_MERKLE_TREE_DEPTH = 20;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TransactionAuditParams } from './transaction-audit';
|
|
2
2
|
import type { WithdrawMerkleWitness } from './types';
|
|
3
|
-
/** Matches `Transaction(20, 2, 2, publicNInputs, publicNOutputs, 4,
|
|
3
|
+
/** Matches `Transaction(20, 2, 2, publicNInputs, publicNOutputs, 4, 12, 6)` in `circuits/main.circom`. */
|
|
4
4
|
export declare const TRANSACTION_TREE_DEPTH = 20;
|
|
5
5
|
export declare const TRANSACTION_N_INS = 2;
|
|
6
6
|
export declare const TRANSACTION_N_OUTS = 2;
|
|
7
7
|
export declare const TRANSACTION_N_AUDIT_SLOTS = 4;
|
|
8
|
-
export declare const NOTE_AUDIT_LEN =
|
|
8
|
+
export declare const NOTE_AUDIT_LEN = 12;
|
|
9
9
|
export declare const NOTE_OUTPUT_LEN = 6;
|
|
10
10
|
/** Must match `Transaction(..., publicNInputs, publicNOutputs)` and contract `get_public_slot_config`. */
|
|
11
11
|
export declare const TRANSACTION_PUBLIC_N_INPUTS = 1;
|
|
@@ -24,7 +24,15 @@ export interface WithdrawalProofPublicParams {
|
|
|
24
24
|
withdrawAddressHi: string;
|
|
25
25
|
/** Decimal string, circom `withdrawAddressLo` (Ed25519 key bytes [16..32] as big-endian u128). */
|
|
26
26
|
withdrawAddressLo: string;
|
|
27
|
-
/** Decimal string, circom `
|
|
27
|
+
/** Decimal string, circom `escrowRecipientHi`. */
|
|
28
|
+
escrowRecipientHi?: string;
|
|
29
|
+
/** Decimal string, circom `escrowRecipientLo`. */
|
|
30
|
+
escrowRecipientLo?: string;
|
|
31
|
+
/** Decimal string, circom `sweepOutputOwnerPubX`. Zero off-sweep. */
|
|
32
|
+
sweepOutputOwnerPubX?: string;
|
|
33
|
+
/** Decimal string, circom `sweepOutputOwnerPubY`. Zero off-sweep. */
|
|
34
|
+
sweepOutputOwnerPubY?: string;
|
|
35
|
+
/** Decimal string, default owner scalar copied onto dummy withdraw slots. */
|
|
28
36
|
privKeyScalar: string;
|
|
29
37
|
}
|
|
30
38
|
/** Public accounting legs (`publicWithdrawnAssets`, `publicDepositedAssets`, `publicDeposits`, `publicWithdrawals`). */
|
|
@@ -45,8 +53,13 @@ export interface WithdrawObject {
|
|
|
45
53
|
asset: [string, string];
|
|
46
54
|
/** BN254 Fr decimal; `0` for dummy slots. */
|
|
47
55
|
applicationId: string;
|
|
48
|
-
/**
|
|
49
|
-
|
|
56
|
+
/** Owner BabyJubJub public key `[x, y]` as decimal strings. */
|
|
57
|
+
ownerPub: [string, string];
|
|
58
|
+
/** Per-input owner scalar. */
|
|
59
|
+
privKeyScalar: string;
|
|
60
|
+
paddingRandom: string;
|
|
61
|
+
escrowNonce: string;
|
|
62
|
+
recipientStellar: [string, string];
|
|
50
63
|
stateSiblings: string[];
|
|
51
64
|
stateIndex: string;
|
|
52
65
|
}
|
|
@@ -60,6 +73,8 @@ export interface DepositObject {
|
|
|
60
73
|
applicationId: string;
|
|
61
74
|
/** Recipient public key `[x, y]` as decimal strings. */
|
|
62
75
|
recipientPublicKeys: [string, string];
|
|
76
|
+
escrowNonce?: string;
|
|
77
|
+
recipientStellar?: [string, string];
|
|
63
78
|
}
|
|
64
79
|
export type WithdrawSlot = WithdrawObject | 'dummy';
|
|
65
80
|
export type DepositSlot = DepositObject | 'dummy';
|
|
@@ -68,12 +83,19 @@ export interface TransactionWitnessInput {
|
|
|
68
83
|
stateRoot: string;
|
|
69
84
|
withdrawAddressHi: string;
|
|
70
85
|
withdrawAddressLo: string;
|
|
71
|
-
|
|
86
|
+
escrowRecipientHi: string;
|
|
87
|
+
escrowRecipientLo: string;
|
|
88
|
+
sweepOutputOwnerPubX: string;
|
|
89
|
+
sweepOutputOwnerPubY: string;
|
|
90
|
+
privKeyScalars: [string, string];
|
|
91
|
+
ownerPubs: [[string, string], [string, string]];
|
|
92
|
+
paddingRandoms: [string, string];
|
|
72
93
|
withdrawnValues: [string, string];
|
|
73
94
|
withdrawnNullifiers: [string, string];
|
|
74
95
|
withdrawnSecrets: [string, string];
|
|
75
96
|
withdrawnAssets: [[string, string], [string, string]];
|
|
76
|
-
|
|
97
|
+
withdrawnEscrowNonces: [string, string];
|
|
98
|
+
inputRecipientStellar: [[string, string], [string, string]];
|
|
77
99
|
stateSiblings: [string[], string[]];
|
|
78
100
|
stateIndex: [string, string];
|
|
79
101
|
depositedValues: [string, string];
|
|
@@ -81,6 +103,8 @@ export interface TransactionWitnessInput {
|
|
|
81
103
|
depositedAssets: [[string, string], [string, string]];
|
|
82
104
|
depositedEphemeralKeyScalars: [string, string];
|
|
83
105
|
depositedRecipientPublicKeys: [[string, string], [string, string]];
|
|
106
|
+
depositedEscrowNonces: [string, string];
|
|
107
|
+
outputRecipientStellar: [[string, string], [string, string]];
|
|
84
108
|
publicWithdrawnAssets: Array<[string, string]>;
|
|
85
109
|
publicDepositedAssets: Array<[string, string]>;
|
|
86
110
|
publicDeposits: string[];
|
|
@@ -140,8 +164,8 @@ export declare function resolveDepositsForWitness(depositSlots: [DepositSlot, De
|
|
|
140
164
|
export declare function buildTransactionWitnessInput(publicParams: WithdrawalProofPublicParams, publicLegs: TransactionPublicLegParams, withdrawSlots: [WithdrawSlot, WithdrawSlot], depositSlots: [DepositSlot, DepositSlot], audit: TransactionAuditParams, wasm: WasmEcdhPointFns): TransactionWitnessInput;
|
|
141
165
|
/** `stpl1…` stealth address → `[x, y]` as decimal field strings for `depositedRecipientPublicKeys`. */
|
|
142
166
|
export declare function recipientPublicKeysDecimalFromStealthAddress(stealthAddress: string): [string, string];
|
|
143
|
-
/** First withdraw leg: Merkle witness +
|
|
144
|
-
export declare function withdrawObjectFromMerkleWitness(witness: WithdrawMerkleWitness,
|
|
167
|
+
/** First withdraw leg: Merkle witness + owner public key (hex) and matching scalar. */
|
|
168
|
+
export declare function withdrawObjectFromMerkleWitness(witness: WithdrawMerkleWitness, ownerPubHex: {
|
|
145
169
|
x: string;
|
|
146
170
|
y: string;
|
|
147
|
-
}, applicationId: string): WithdrawObject;
|
|
171
|
+
}, applicationId: string, privKeyScalar: string): WithdrawObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auditable/privacy-pool-zk-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"build:ts": "rollup -c",
|
|
37
37
|
"build": "rollup -c",
|
|
38
38
|
"cli": "node dist/cli.js",
|
|
39
|
-
"test:kyt": "node test/kyt-
|
|
39
|
+
"test:kyt": "node test/kyt-flow-atomic.mjs && node test/kyt-public-leg-context.mjs && node test/kyt-passage-id-auth.mjs && node test/derived-escrow-key.mjs && node test/spend-scalar-domain.mjs && node test/eighteen-decimal-value.mjs && node test/no-onboarding-exports.mjs && node test/owner-bound-witness-check.mjs",
|
|
40
40
|
"test:output-note": "node test/output-note-encryption.mjs"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
package/pkg/client_sdk_wasm.d.ts
CHANGED
|
@@ -7,10 +7,17 @@
|
|
|
7
7
|
export function buildWithdrawMerkleWitness(coin_json: string, state_json: string): string;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Calculate nullifier hash from nullifier decimal
|
|
10
|
+
* Calculate owner-bound nullifier hash from nullifier and spend-scalar decimal strings.
|
|
11
11
|
* Returns hex string (0x...)
|
|
12
12
|
*/
|
|
13
|
-
export function calculateNullifierHash(nullifier_decimal: string): string;
|
|
13
|
+
export function calculateNullifierHash(nullifier_decimal: string, priv_key_scalar_decimal: string): string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `R = Poseidon255(2)(hi, lo)`; `scalar` is the raw Poseidon hash when it is
|
|
17
|
+
* already in `(0, BabyJub subgroup order)`. Out-of-range hashes fail so the
|
|
18
|
+
* caller can rejection-sample a new nonce.
|
|
19
|
+
*/
|
|
20
|
+
export function derivedEscrowKey(nonce_decimal: string, recipient_hi_decimal: string, recipient_lo_decimal: string): any;
|
|
14
21
|
|
|
15
22
|
/**
|
|
16
23
|
* UTF-8 seed → `SHA256` → scalar → BabyJubJub `BASE8 * r` (circom `ECDHEphemeralKey`).
|
|
@@ -29,27 +36,27 @@ export function ecdhEphemeralPublicKeyFromScalarHex(scalar_hex: string): any;
|
|
|
29
36
|
export function ecdhSharedKey(priv_hex: string, pub_x_hex: string, pub_y_hex: string): any;
|
|
30
37
|
|
|
31
38
|
/**
|
|
32
|
-
* Generate a new coin with random nullifier, secret, and
|
|
33
|
-
* `
|
|
39
|
+
* Generate a new coin with random nullifier, secret, and owner public-key field elements.
|
|
40
|
+
* `amount_decimal` is an arbitrary-precision decimal field element (never JS `number`).
|
|
34
41
|
* `asset_hi_decimal` / `asset_lo_decimal` are decimal Fr strings for the Stellar asset contract id (two limbs).
|
|
35
42
|
* Returns JSON: { coin: { value, nullifier, secret, commitment, asset_hi, asset_lo }, commitment_hex, precommitement_hex }
|
|
36
43
|
*/
|
|
37
|
-
export function generateCoin(
|
|
44
|
+
export function generateCoin(amount_decimal: string, asset_hi_decimal: string, asset_lo_decimal: string, application_id_decimal: string): any;
|
|
38
45
|
|
|
39
46
|
/**
|
|
40
|
-
* `Poseidon₁(scalar)` secret +
|
|
47
|
+
* `Poseidon₁(scalar)` secret + recipient owner public key (hex), matching an aligned deposit witness.
|
|
41
48
|
*/
|
|
42
|
-
export function
|
|
49
|
+
export function generateCoinForDepositWithOwnerPubHex(scalar_hex: string, owner_x_hex: string, owner_y_hex: string, amount_decimal: string, asset_hi_decimal: string, asset_lo_decimal: string, application_id_decimal: string): any;
|
|
43
50
|
|
|
44
51
|
/**
|
|
45
52
|
* `secret` in coin = `Poseidon255(1)(scalar)` per `deposit.circom`; scalar is 32-byte hex (64 chars, optional `0x`).
|
|
46
53
|
*/
|
|
47
|
-
export function generateCoinFromDepositEphemeralScalarHex(scalar_hex: string,
|
|
54
|
+
export function generateCoinFromDepositEphemeralScalarHex(scalar_hex: string, amount_decimal: string, asset_hi_decimal: string, asset_lo_decimal: string, application_id_decimal: string): any;
|
|
48
55
|
|
|
49
56
|
/**
|
|
50
|
-
* Same as `generateCoin`, but commitment uses the given
|
|
57
|
+
* Same as `generateCoin`, but commitment uses the given owner public key (64-char hex coords).
|
|
51
58
|
*/
|
|
52
|
-
export function
|
|
59
|
+
export function generateCoinWithOwnerPubHex(owner_x_hex: string, owner_y_hex: string, amount_decimal: string, asset_hi_decimal: string, asset_lo_decimal: string, application_id_decimal: string): any;
|
|
53
60
|
|
|
54
61
|
/**
|
|
55
62
|
* Convert snarkjs proof JSON to hex bytes for Soroban contract.
|
|
@@ -66,14 +73,15 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
66
73
|
export interface InitOutput {
|
|
67
74
|
readonly memory: WebAssembly.Memory;
|
|
68
75
|
readonly buildWithdrawMerkleWitness: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
69
|
-
readonly calculateNullifierHash: (a: number, b: number, c: number) => void;
|
|
76
|
+
readonly calculateNullifierHash: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
77
|
+
readonly derivedEscrowKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
70
78
|
readonly ecdhEphemeralPublicKey: (a: number, b: number, c: number) => void;
|
|
71
79
|
readonly ecdhEphemeralPublicKeyFromScalarHex: (a: number, b: number, c: number) => void;
|
|
72
80
|
readonly ecdhSharedKey: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
73
|
-
readonly generateCoin: (a: number, b:
|
|
74
|
-
readonly
|
|
75
|
-
readonly generateCoinFromDepositEphemeralScalarHex: (a: number, b: number, c: number, d:
|
|
76
|
-
readonly
|
|
81
|
+
readonly generateCoin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
82
|
+
readonly generateCoinForDepositWithOwnerPubHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => void;
|
|
83
|
+
readonly generateCoinFromDepositEphemeralScalarHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
84
|
+
readonly generateCoinWithOwnerPubHex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
77
85
|
readonly proofToHex: (a: number, b: number, c: number) => void;
|
|
78
86
|
readonly publicToHex: (a: number, b: number, c: number) => void;
|
|
79
87
|
readonly __wbindgen_export: (a: number, b: number) => number;
|