@arcanetech/stellar-privacy-pool-zk-sdk 0.9.1-rc.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.
Files changed (43) hide show
  1. package/dist/ciphertext-blob.d.ts +17 -0
  2. package/dist/circuit-artifacts.d.ts +9 -0
  3. package/dist/circuit-urls-2x2-COiK1uEc.mjs +6 -0
  4. package/dist/circuit-urls-2x2-COiK1uEc.mjs.map +1 -0
  5. package/dist/circuit-urls-2x2-DVpZIkgS.js +12 -0
  6. package/dist/circuit-urls-2x2-DVpZIkgS.js.map +1 -0
  7. package/dist/circuit-urls-2x2.d.ts +3 -0
  8. package/dist/circuit-urls-6x6-CqdzNC4I.js +12 -0
  9. package/dist/circuit-urls-6x6-CqdzNC4I.js.map +1 -0
  10. package/dist/circuit-urls-6x6-Dtp8u02o.mjs +6 -0
  11. package/dist/circuit-urls-6x6-Dtp8u02o.mjs.map +1 -0
  12. package/dist/circuit-urls-6x6.d.ts +3 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.js +3114 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/derived-escrow-key.d.ts +10 -0
  17. package/dist/domain-separators.d.ts +16 -0
  18. package/dist/ephemeral-key.d.ts +28 -0
  19. package/dist/index.d.ts +30 -0
  20. package/dist/index.mjs +3875 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/kyt-flow.d.ts +60 -0
  23. package/dist/kyt-onboarding.d.ts +36 -0
  24. package/dist/kyt-passage.d.ts +83 -0
  25. package/dist/output-note-encryption.d.ts +72 -0
  26. package/dist/prover.d.ts +5 -0
  27. package/dist/sdk.d.ts +130 -0
  28. package/dist/shared-secret.d.ts +24 -0
  29. package/dist/stealth-address.d.ts +23 -0
  30. package/dist/stealth-sign-message.d.ts +20 -0
  31. package/dist/stealth-signature.d.ts +29 -0
  32. package/dist/transaction-audit.d.ts +26 -0
  33. package/dist/types.d.ts +64 -0
  34. package/dist/wasm.d.ts +1 -0
  35. package/dist/withdrawal-transaction-input.d.ts +162 -0
  36. package/dist/witness.d.ts +3 -0
  37. package/dist/zk-artifact-url.d.ts +4 -0
  38. package/dist/zk-layout.d.ts +84 -0
  39. package/package.json +57 -0
  40. package/pkg/client_sdk_wasm.d.ts +120 -0
  41. package/pkg/client_sdk_wasm.js +765 -0
  42. package/pkg/client_sdk_wasm_bg.wasm +0 -0
  43. package/pkg/client_sdk_wasm_bg.wasm.d.ts +21 -0
@@ -0,0 +1,36 @@
1
+ import { xdr } from '@stellar/stellar-sdk';
2
+ export interface PlaintextNotePayload {
3
+ value: bigint;
4
+ asset_hi: Buffer;
5
+ asset_lo: Buffer;
6
+ nullifier: Buffer;
7
+ secret: Buffer;
8
+ deposited_ephemeral_scalar?: Buffer;
9
+ }
10
+ export type OptionalPrivateAddressRegistrationPayload = {
11
+ tag: 'None';
12
+ } | {
13
+ tag: 'Some';
14
+ values: readonly [
15
+ {
16
+ owner: string;
17
+ public_key_x: Buffer;
18
+ public_key_y: Buffer;
19
+ }
20
+ ];
21
+ };
22
+ export interface OnboardingPayloadInput {
23
+ owner: string;
24
+ temp_public_key_x: Buffer;
25
+ temp_public_key_y: Buffer;
26
+ encrypted_private_key: Buffer;
27
+ notes: PlaintextNotePayload[];
28
+ private_address_registration: OptionalPrivateAddressRegistrationPayload;
29
+ }
30
+ declare const ONBOARDING_ZERO_DOMAIN = "privacy-pool-onboarding-zero-v1";
31
+ /** Canonical `onboardingHash` matching `libs/kyt-passage/src/lib.rs::hash_onboarding`. */
32
+ export declare function hashOnboardingCanonical(onboarding: OnboardingPayloadInput | null | undefined): string;
33
+ export declare function onboardingToScVal(onboarding: OnboardingPayloadInput): xdr.ScVal;
34
+ export declare function onboardingOptionToScVal(onboarding: OnboardingPayloadInput | null | undefined): xdr.ScVal;
35
+ export declare function addressToScVal(address: string): xdr.ScVal;
36
+ export { ONBOARDING_ZERO_DOMAIN };
@@ -0,0 +1,83 @@
1
+ export declare const KYT_PASSAGE_AUTH_DOMAIN = "privacy-pool-kyt-passage-v1";
2
+ export declare const PUBLIC_LEG_CONTEXT_DOMAIN = "privacy-pool-public-leg-context-v1";
3
+ export declare const PASSAGE_ID_DOMAIN = "privacy-pool-passage-id-v3";
4
+ export declare const PASSAGE_ID_DOMAIN_V2 = "privacy-pool-passage-id-v2";
5
+ export declare const PASSAGE_ID_DOMAIN_V1 = "privacy-pool-passage-id-v1";
6
+ export declare const NOTE_AUDIT_LEN = 12;
7
+ export declare const TOTAL_PUBLIC_SIGNALS = 93;
8
+ export declare const NOTE_AUDIT_PLAINTEXT_LEN = 12;
9
+ export interface PublicLegLayout {
10
+ publicNInputs: number;
11
+ publicNOutputs: number;
12
+ }
13
+ export interface PublicLegContextInput {
14
+ owner: string;
15
+ withdrawAddress: string;
16
+ publicDeposits: string[];
17
+ publicWithdrawals: string[];
18
+ publicDepositedAssets: [string, string][];
19
+ publicWithdrawnAssets: [string, string][];
20
+ }
21
+ export interface KytPassageDerivation {
22
+ publicSignalHash: string;
23
+ publicLegContextHash: string;
24
+ passageId: string;
25
+ }
26
+ export interface KytPassageAuthorization {
27
+ authorizationHash: string;
28
+ poolContract: string;
29
+ kytRegistry: string;
30
+ passageId: string;
31
+ expiresAtLedger: number;
32
+ }
33
+ /** Canonical zero-address sentinel for absent public-leg slots: `u32_be(0)` with no XDR bytes. */
34
+ export declare function zeroAddressSentinelBuffer(): Buffer;
35
+ export declare function addressToCanonicalXdr(address: string): Buffer;
36
+ export declare function hashPublicSignalBytes(publicSignalsBytes: Buffer | string, zkConfigNonce?: bigint): string;
37
+ export declare function hashPublicLegContext(layout: PublicLegLayout, input: PublicLegContextInput): string;
38
+ export declare function derivePassageId(owner: string, nonce: bigint | number, publicSignalHash: string, publicLegContextHash: string, ciphertextHash: string): string;
39
+ export declare function derivePassageIdV2(owner: string, nonce: bigint | number, publicSignalHash: string, publicLegContextHash: string): string;
40
+ export declare function derivePassageIdV1(owner: string, nonce: bigint | number, publicSignalHash: string, publicLegContextHash: string, onboardingHash: string): string;
41
+ export declare function buildKytPassageAuthorization(input: {
42
+ poolContract: string;
43
+ kytRegistry: string;
44
+ passageId: string;
45
+ expiresAtLedger: number;
46
+ }): KytPassageAuthorization;
47
+ export declare function derivePassageFromTransactContext(input: {
48
+ owner: string;
49
+ nonce?: bigint | number;
50
+ publicSignalsBytes: Buffer | string;
51
+ ciphertextBytes?: Buffer | string;
52
+ publicLegContext: PublicLegContextInput;
53
+ layout?: PublicLegLayout;
54
+ }): KytPassageDerivation;
55
+ export declare function hashCiphertextBytes(ciphertextBytes: Buffer | string): string;
56
+ export declare function zeroBindingTagsInPublicSignals(publicSignalsBytes: Buffer | string, zkConfigNonce?: bigint): Buffer;
57
+ export declare function spliceBindingTagsIntoPublicSignals(parameters: {
58
+ publicSignalsBytes: Buffer | string;
59
+ zkConfigNonce: bigint;
60
+ auditTags: readonly string[];
61
+ outputNoteTags: readonly string[];
62
+ }): Buffer;
63
+ export declare function accountIdFromAddress(address: string): Buffer;
64
+ export interface InspectKytPassageRequest {
65
+ owner: string;
66
+ poolContract: string;
67
+ kytRegistry: string;
68
+ proofBytes: string;
69
+ publicSignalsBytes: string;
70
+ applicationIdsPlaintext: string[];
71
+ ciphertextBytes?: string;
72
+ outputNoteEphemeralScalars?: string[];
73
+ nonce?: string;
74
+ zkConfigNonce?: string;
75
+ }
76
+ export interface InspectKytPassageApproved {
77
+ status: 'approved';
78
+ passageId: string;
79
+ signature: string;
80
+ expiresAtLedger: number;
81
+ }
82
+ export declare function inspectKytPassage(backendUrl: string, request: InspectKytPassageRequest): Promise<InspectKytPassageApproved>;
83
+ export declare function signatureBase64ToBytes(signature: string): Buffer;
@@ -0,0 +1,72 @@
1
+ import { buildPoseidon } from 'circomlibjs';
2
+ import type { DepositObject, TransactionWitnessInput } from './withdrawal-transaction-input.js';
3
+ import type { EcdhSharedKeyFn } from './shared-secret.js';
4
+ import type { ZkLayoutParams } from './zk-layout.js';
5
+ export declare const NOTE_OUTPUT_LEN = 6;
6
+ export declare const NOTE_AUDIT_LEN = 12;
7
+ export declare const STREAM_DOMAIN = 1n;
8
+ export declare const FR_SIZE = 32;
9
+ type Poseidon = Awaited<ReturnType<typeof buildPoseidon>>;
10
+ export type OutputNotePlaintext = {
11
+ value: string;
12
+ assetHi: string;
13
+ assetLo: string;
14
+ nullifier: string;
15
+ secret: string;
16
+ applicationId: string;
17
+ };
18
+ export type OutputNoteEncryption = {
19
+ ciphertext: [string, string, string, string, string, string];
20
+ tag: string;
21
+ };
22
+ export type DecryptedOutputNote = OutputNotePlaintext & {
23
+ commitmentHex: string;
24
+ commitmentMatches: boolean;
25
+ };
26
+ export type OutputNoteEventInput = {
27
+ recipientScalarHex: string;
28
+ commitmentHashHex: string;
29
+ createdEphemeralKey: readonly [string, string];
30
+ ciphertext: readonly string[];
31
+ tag: string;
32
+ ownerMode?: bigint;
33
+ };
34
+ export declare function poseidonMacTag(parameters: {
35
+ poseidon: Poseidon;
36
+ domain: bigint;
37
+ key: bigint;
38
+ nonce: bigint;
39
+ message: readonly bigint[];
40
+ }): bigint;
41
+ export declare function secretFromDepositEphemeralScalarDecimal(ephemeralKeyScalarDecimal: string): Promise<string>;
42
+ export declare function encryptOutputNoteForDeposit(parameters: {
43
+ deposit: DepositObject;
44
+ ecdhShared: EcdhSharedKeyFn;
45
+ }): Promise<OutputNoteEncryption>;
46
+ export declare function buildOutputNoteEncryptionPublicInputs(parameters: {
47
+ deposits: [DepositObject, DepositObject];
48
+ ecdhShared: EcdhSharedKeyFn;
49
+ }): Promise<{
50
+ outputNoteCiphertexts: [OutputNoteEncryption['ciphertext'], OutputNoteEncryption['ciphertext']];
51
+ outputNoteTags: [string, string];
52
+ }>;
53
+ export declare function decryptOutputNoteEvent(input: OutputNoteEventInput): Promise<DecryptedOutputNote>;
54
+ export declare function encryptNoteAuditSlot(parameters: {
55
+ auditPublicKey: readonly [string, string];
56
+ auditEphemeralScalar: string;
57
+ plaintext: readonly string[];
58
+ ecdhShared: EcdhSharedKeyFn;
59
+ }): Promise<{
60
+ ciphertext: string[];
61
+ tag: string;
62
+ }>;
63
+ export declare function encryptTransactionCiphertextBlob(parameters: {
64
+ witness: TransactionWitnessInput;
65
+ layout: ZkLayoutParams;
66
+ ecdhShared: EcdhSharedKeyFn;
67
+ }): Promise<{
68
+ ciphertextHex: string;
69
+ auditCiphertexts: string[][];
70
+ outputNoteCiphertexts: string[][];
71
+ }>;
72
+ export {};
@@ -0,0 +1,5 @@
1
+ /** @deprecated Groth16 proving is in the main SDK WASM (`proveGroth16`). */
2
+ export declare function generateProof(_wtns: Uint8Array, _zkey?: BufferSource, _zkeyFileName?: string): Promise<{
3
+ proof: object;
4
+ publicSignals: string[];
5
+ }>;
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,130 @@
1
+ import type { CoinData, GeneratedCoin, SDKOptions, StateFile, WithdrawMerkleWitness, WithdrawResult } from "./types";
2
+ import { type DecodedDepositorSharedSecretPreimage, type DecodedEphemeralKey, type EncodedDepositorSharedSecretPreimage, type EncodedEphemeralKey } from "./ephemeral-key";
3
+ import { type SharedSecret } from "./shared-secret";
4
+ import { type SpendScalarDomain } from "./stealth-sign-message";
5
+ import type { DecodedRecipientSharedSecretPreimage } from "./stealth-address";
6
+ import { type DepositSlot, type TransactionPublicLegParams, type WithdrawalProofPublicParams, type WithdrawSlot } from "./withdrawal-transaction-input";
7
+ import { type TransactionAuditParams } from "./transaction-audit";
8
+ import { type ZkLayoutParams } from "./zk-layout";
9
+ export declare class PrivacyPoolSDK {
10
+ private wasm;
11
+ private options;
12
+ private zkConfigNonce;
13
+ private circuitConfig;
14
+ private layout;
15
+ private circuitArtifacts;
16
+ private constructor();
17
+ getZkConfigNonce(): bigint;
18
+ getLayout(): ZkLayoutParams;
19
+ /**
20
+ * Initialize the SDK by loading WASM modules.
21
+ *
22
+ * In Node.js, proving artifacts load from `zkArtifactBaseUrl` or
23
+ * `ZK_ARTIFACT_BASE_URL`, defaulting to this package's GitHub release.
24
+ * In browser, pass pre-loaded WASM via options:
25
+ * ```ts
26
+ * const sdk = await PrivacyPoolSDK.init({
27
+ * wasmBinary: await fetch('/pkg/client_sdk_wasm_bg.wasm').then(r => r.arrayBuffer()),
28
+ * zkArtifactBaseUrl: 'https://github.com/Polynom-Labs/stellar-privacy-layer-contracts/releases/download/v0.8.0',
29
+ * });
30
+ * ```
31
+ */
32
+ static init(options?: SDKOptions): Promise<PrivacyPoolSDK>;
33
+ /**
34
+ * Uniform 32-byte scalar as lowercase hex (Web Crypto). Same in browser and Node 19+.
35
+ */
36
+ static generateRandomScalarHex32(): string;
37
+ /**
38
+ * Text to sign with a Stellar wallet for spend-key derivation (UTF-8). No WASM required.
39
+ * The message binds network, pool, registry, and schema version (H6).
40
+ */
41
+ static buildStealthAddressSignMessage(address: string, domain: SpendScalarDomain, nonce?: string): string;
42
+ /**
43
+ * Generate a new coin with random nullifier, secret, and random owner-pub field elements (dev / self-contained tests).
44
+ * @param amount Decimal field element as `bigint` or decimal `string` (never JS `number`).
45
+ * @param assetHiDecimal / assetLoDecimal Decimal Fr strings for Stellar asset contract id (two limbs).
46
+ */
47
+ generateCoin(amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
48
+ /**
49
+ * Generate a coin with the same commitment shape as on-chain deposit: pass owner public key (hex x, y).
50
+ * @param amount Decimal field element (`bigint` | `string`).
51
+ */
52
+ generateCoinWithOwnerPub(ownerPub: {
53
+ x: string;
54
+ y: string;
55
+ }, amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
56
+ /**
57
+ * Coin for a depositor `ephemeralKeyScalar` (32-byte hex): `coin.secret = Poseidon255(1)(scalar)` as in `deposit.circom`.
58
+ * @param amount Decimal field element (`bigint` | `string`).
59
+ */
60
+ generateCoinFromDepositEphemeralScalarHex(scalarHex: string, amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
61
+ /**
62
+ * Aligned deposit coin: `secret = Poseidon₁(scalar)` and owner pub from recipient hex coords.
63
+ * @param amount Decimal field element (`bigint` | `string`).
64
+ */
65
+ generateCoinForDepositWithOwnerPubHex(scalarHex: string, ownerXHex: string, ownerYHex: string, amount: bigint | string, assetHiDecimal: string, assetLoDecimal: string, applicationIdDecimal?: string): GeneratedCoin;
66
+ /**
67
+ * Merkle root, path, and coin fields for the first withdraw leg (Rust LeanIMT + Poseidon).
68
+ */
69
+ buildWithdrawMerkleWitness(coin: CoinData, state: StateFile): WithdrawMerkleWitness;
70
+ /**
71
+ * Full `Transaction(20,2,2)` withdrawal proof: one real withdraw + dummies, using coin/state and depositor ECDH point (hex).
72
+ *
73
+ * Optional **partial public withdraw**: spend the full coin commitment `coin.value` (V), send `publicWithdrawStroops` (W) to the
74
+ * Stellar receiver, and re-deposit the remainder (V−W) as a new private note to `changeRecipientStealthAddress` (same circuit balance).
75
+ */
76
+ proveWithdrawal(coin: CoinData, state: StateFile, params: {
77
+ withdrawAddressHi: string;
78
+ withdrawAddressLo: string;
79
+ privKeyScalar: string;
80
+ ephemeralXHex: string;
81
+ ephemeralYHex: string;
82
+ /** If set, public leg amount W (stroops). Must satisfy 0 < W < V. Remainder (V−W) stays in the pool as a new commitment. */
83
+ publicWithdrawStroops?: bigint;
84
+ /** Required when `publicWithdrawStroops` is set: stealth recipient for the change note (typically same as deposit). */
85
+ changeRecipientStealthAddress?: string;
86
+ applicationId?: string;
87
+ audit?: TransactionAuditParams;
88
+ }): Promise<WithdrawResult>;
89
+ /**
90
+ * Convert a snarkjs proof JSON to hex bytes for Soroban.
91
+ */
92
+ proofToHex(proof: object): string;
93
+ /**
94
+ * Convert snarkjs public signals to hex bytes for Soroban.
95
+ */
96
+ publicToHex(publicSignals: string[]): string;
97
+ /**
98
+ * BabyJubJub ephemeral point from a 32-byte scalar (hex). For custom {@link WithdrawObject} / tests.
99
+ */
100
+ ecdhEphemeralPublicKeyFromScalarHex(scalarHex: string): {
101
+ x: string;
102
+ y: string;
103
+ };
104
+ /** Circuit `ECDH`: scalar (32-byte hex) × recipient BabyJub point → shared key hex coords. */
105
+ ecdhSharedKey(scalarHex: string, recipientPubXHex: string, recipientPubYHex: string): SharedSecret;
106
+ /**
107
+ * `Transaction(20,nIns,nOuts)` proof from high-level legs: maps to witness input (incl. `"dummy"` ECDH via WASM), then Groth16 → Soroban hex.
108
+ * Slots are padded to the selected ZK config layout (bundled 2×2 or 6×6).
109
+ */
110
+ proveTransaction(publicParams: WithdrawalProofPublicParams, publicLegs: TransactionPublicLegParams, withdraws: WithdrawSlot[], deposits: DepositSlot[], audit: TransactionAuditParams): Promise<WithdrawResult>;
111
+ proveTransactionSlots(publicParams: WithdrawalProofPublicParams, publicLegs: TransactionPublicLegParams, withdraws: WithdrawSlot[], deposits: DepositSlot[], audit: TransactionAuditParams): Promise<WithdrawResult>;
112
+ /**
113
+ * Calculate owner-bound nullifier hash: Poseidon(DOM_NULLIFIER, nullifier, privKeyScalar)
114
+ * @param nullifier Nullifier decimal string from coin data
115
+ * @param privKeyScalar Spend scalar decimal string
116
+ * @returns Hex string (0x...) of the hash bytes
117
+ */
118
+ calculateNullifierHash(nullifier: string, privKeyScalar: string): string;
119
+ /**
120
+ * Ed25519 signature from signing {@link buildStealthAddressSignMessage}: **128 hex chars** (optional `0x`)
121
+ * or **base64** (64 raw bytes after decode). Domain-separated SHA-256 → scalar → ECDH → `stpl1` Bech32.
122
+ */
123
+ generateStealthAddressFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<string>;
124
+ encodeDecodedEphemeralKey(decoded: DecodedEphemeralKey): EncodedEphemeralKey;
125
+ decodeDecodedEphemeralKey(encoded: EncodedEphemeralKey): DecodedEphemeralKey;
126
+ encodeDepositorSharedSecretPreimage(decoded: DecodedDepositorSharedSecretPreimage): EncodedDepositorSharedSecretPreimage;
127
+ decodeDepositorSharedSecretPreimage(encoded: EncodedDepositorSharedSecretPreimage): DecodedDepositorSharedSecretPreimage;
128
+ sharedSecretFromDepositorPreimage(preimage: DecodedDepositorSharedSecretPreimage): SharedSecret;
129
+ sharedSecretFromRecipientPreimage(preimage: DecodedRecipientSharedSecretPreimage): SharedSecret;
130
+ }
@@ -0,0 +1,24 @@
1
+ import type { DecodedDepositorSharedSecretPreimage, DecodedEphemeralKey } from './ephemeral-key';
2
+ import type { DecodedRecipientSharedSecretPreimage, Hex } from './stealth-address';
3
+ /** ECDH shared key coordinates (`ecdh_shared_key` / circuit `ECDH` output). */
4
+ export interface SharedSecret {
5
+ x: Hex;
6
+ y: Hex;
7
+ }
8
+ /** Withdrawer-side material: recipient private scalar ‖ depositor’s ephemeral point. */
9
+ export interface DecodedWithdrawerSharedSecret {
10
+ recipientScalar: Hex;
11
+ ephemeralKey: DecodedEphemeralKey;
12
+ }
13
+ export type EcdhSharedKeyFn = (privHex64: string, pubXHex64: string, pubYHex64: string) => {
14
+ x: string;
15
+ y: string;
16
+ };
17
+ /**
18
+ * Depositor: `randomNonceScalar * recipientStealthPoint` (same as circom `ECDH` with depositor scalar).
19
+ */
20
+ export declare function sharedSecretFromDepositorPreimage(ecdhShared: EcdhSharedKeyFn, preimage: DecodedDepositorSharedSecretPreimage): SharedSecret;
21
+ /**
22
+ * Recipient: `recipientScalar * ephemeralKey` (same shared point as depositor path when keys match).
23
+ */
24
+ export declare function sharedSecretFromRecipientPreimage(ecdhShared: EcdhSharedKeyFn, preimage: DecodedRecipientSharedSecretPreimage): SharedSecret;
@@ -0,0 +1,23 @@
1
+ import type { DecodedEphemeralKey } from './ephemeral-key';
2
+ /** Lowercase hex string (optional `0x` prefix when parsing). */
3
+ export type Hex = string;
4
+ export type StealthAddress = string;
5
+ export interface DecodedStealthAddress {
6
+ x: Hex;
7
+ y: Hex;
8
+ }
9
+ /** Withdrawer preimage: recipient scalar ‖ depositor-revealed ephemeral point. */
10
+ export interface DecodedRecipientSharedSecretPreimage {
11
+ ephemeralKey: DecodedEphemeralKey;
12
+ recipientScalar: Hex;
13
+ }
14
+ export declare const STEALTH_ADDRESS_HRP: "stpl1";
15
+ /**
16
+ * Encodes `x || y` as Bech32 (BIP-173) with human-readable part {@link STEALTH_ADDRESS_HRP} (`stpl1`).
17
+ * `x` and `y` must have the same byte length so decoding can split the payload in half.
18
+ */
19
+ export declare function encodeStealthAddress(decoded: DecodedStealthAddress): StealthAddress;
20
+ /**
21
+ * Decodes a `stpl1` Bech32 stealth address into `x` and `y` (each half of the payload, as lowercase hex).
22
+ */
23
+ export declare function decodeStealthAddress(address: StealthAddress): DecodedStealthAddress;
@@ -0,0 +1,20 @@
1
+ /** Default nonce when deriving the wallet sign-in message. */
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;
14
+ /**
15
+ * Plaintext for Stellar wallet message signing (spend-key derivation).
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.
19
+ */
20
+ export declare function buildStealthAddressSignMessage(address: string, domain: SpendScalarDomain, nonce?: string): string;
@@ -0,0 +1,29 @@
1
+ import { type SpendScalarDomain } from './stealth-sign-message';
2
+ /**
3
+ * Ed25519 signature as **128 hex chars** (optional `0x`) or **base64** (typically 88 chars for 64 bytes, whitespace ignored).
4
+ */
5
+ export declare function parseStellarEd25519SignatureRaw(input: string): Uint8Array;
6
+ /** SHA-256 via Web Crypto only (`crypto.subtle`) — works in browsers and Node 19+ (global `crypto`). */
7
+ export declare function sha256(data: Uint8Array): Promise<Uint8Array>;
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.
17
+ */
18
+ export declare function stealthAddressFromStellarSignature(ecdhFromScalarHex: (scalarHex64: string) => {
19
+ x: string;
20
+ y: string;
21
+ }, encodeStealth: (decoded: {
22
+ x: string;
23
+ y: string;
24
+ }) => string, signature: string, domain: SpendScalarDomain): Promise<string>;
25
+ /**
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)`.
28
+ */
29
+ export declare function privKeyScalarDecimalFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<string>;
@@ -0,0 +1,26 @@
1
+ import { type DepositObject, type DepositSlot, type WithdrawObject, type WithdrawSlot } from './withdrawal-transaction-input';
2
+ export declare const TRANSACTION_N_AUDIT_SLOTS = 4;
3
+ export declare const SIX_BY_SIX_N_AUDIT_SLOTS = 12;
4
+ export declare const DEFAULT_APPLICATION_ID = "101";
5
+ /** BabyJub audit public key (decimal Fr) used in BDD / local demo when env is unset. */
6
+ export declare const DEMO_AUDIT_PUBLIC_KEY: AuditPublicKey;
7
+ export type AuditPublicKey = [string, string];
8
+ export interface TransactionAuditParams {
9
+ applicationId: string;
10
+ noteAuditPublicKey: AuditPublicKey;
11
+ auditEphemeralScalar: string;
12
+ }
13
+ export interface TransactionSlotApplicationIds {
14
+ inputApplicationIds: string[];
15
+ outputApplicationIds: string[];
16
+ }
17
+ export declare function buildUniformAuditParams(applicationId: string | undefined, auditPublicKey: AuditPublicKey, _nAuditSlots?: number): TransactionAuditParams;
18
+ export declare function resolveSlotApplicationIds(audit: TransactionAuditParams, withdrawSlots: WithdrawSlot[], depositSlots: DepositSlot[]): TransactionSlotApplicationIds;
19
+ export declare function withApplicationIdOnDeposit(deposit: DepositObject, applicationId: string): DepositObject;
20
+ export declare function withApplicationIdOnWithdraw(withdraw: WithdrawObject, applicationId: string): WithdrawObject;
21
+ /**
22
+ * Prefer an explicit key, then `NOTE_AUDIT_PUBLIC_KEY_X`/`_Y` env (decimal Fr),
23
+ * then the built-in demo key. Used by CLI/`demo.sh` for per-app audit pubkeys.
24
+ */
25
+ export declare function resolveAuditPublicKeyFromEnv(auditPublicKey?: AuditPublicKey): AuditPublicKey;
26
+ export declare function resolveTransactionAuditParams(applicationId: string, auditPublicKey?: AuditPublicKey, nAuditSlots?: number): TransactionAuditParams;
@@ -0,0 +1,64 @@
1
+ export interface CoinData {
2
+ value: string;
3
+ nullifier: string;
4
+ secret: string;
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;
9
+ /** Decimal Fr application id (per-note KYT slot); optional on legacy coins. */
10
+ application_id?: string;
11
+ }
12
+ export interface GeneratedCoin {
13
+ coin: CoinData;
14
+ commitment_hex: string;
15
+ /** 64-char lowercase hex (no `0x`), Fr big-endian for audit `precommitement`. */
16
+ precommitement_hex: string;
17
+ /** JS alias of {@link GeneratedCoin.precommitement_hex}. */
18
+ precommitementHex: string;
19
+ }
20
+ /** Pool Merkle tree depth (matches `coin::TREE_DEPTH` / `Transaction` circuit). */
21
+ export declare const POOL_MERKLE_TREE_DEPTH = 20;
22
+ /** Default coin value in stroops (1 XLM); matches Rust `coin::COIN_VALUE`. */
23
+ export declare const COIN_VALUE_STROOPS = 1000000000;
24
+ /**
25
+ * Merkle path + coin fields for the first withdraw leg (WASM `buildWithdrawMerkleWitness`).
26
+ * Serde: `withdrawnValue`, `stateRoot`, `stateIndex`, `stateSiblings`.
27
+ */
28
+ export interface WithdrawMerkleWitness {
29
+ /** Withdrawn amount in stroops as decimal Fr string; matches `coin.value`. */
30
+ withdrawnValue: string;
31
+ /** Coin value as decimal field string. */
32
+ value: string;
33
+ nullifier: string;
34
+ secret: string;
35
+ /** `[asset_hi, asset_lo]` decimal Fr strings (Stellar asset contract id). */
36
+ withdrawnAsset: [string, string];
37
+ stateRoot: string;
38
+ stateIndex: string;
39
+ /** Length is always {@link POOL_MERKLE_TREE_DEPTH}; each entry is a decimal field element. */
40
+ stateSiblings: string[];
41
+ }
42
+ export interface StateFile {
43
+ commitments: string[];
44
+ }
45
+ export interface WithdrawResult {
46
+ proof_hex: string;
47
+ public_hex: string;
48
+ ciphertext_hex: string;
49
+ output_note_ephemeral_scalars: string[];
50
+ }
51
+ export interface SDKOptions {
52
+ /** Pre-loaded Rust WASM binary (ArrayBuffer). Required in browser. */
53
+ wasmBinary?: BufferSource;
54
+ /** Nonce-keyed circuit map. Defaults to {@link DEFAULT_ZK_CIRCUITS}. */
55
+ zkCircuits?: Record<string, import('./zk-layout').ZkCircuitConfig>;
56
+ /** Selected pool `ZkConfig` nonce. Defaults to {@link DEFAULT_ZK_CONFIG_NONCE}. */
57
+ zkConfigNonce?: bigint;
58
+ /**
59
+ * Directory or URL prefix for graph/r1cs/proving-key files.
60
+ * Defaults to the GitHub release for this SDK version. Node also reads
61
+ * `ZK_ARTIFACT_BASE_URL`.
62
+ */
63
+ zkArtifactBaseUrl?: string;
64
+ }
package/dist/wasm.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function loadWasm(wasmBinary?: BufferSource): Promise<any>;