@arcanetech/privacy-sdk-stellar 0.5.2 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +85 -25
- package/dist/index.js +1081 -258
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +25 -1
- package/dist/node.js +1082 -267
- package/dist/node.js.map +1 -1
- package/dist/state/index.d.ts +31 -1
- package/dist/state/index.js +10 -2
- package/dist/state/index.js.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/transact/index.d.ts +50 -6
- package/dist/transact/index.js +975 -264
- package/dist/transact/index.js.map +1 -1
- package/package.json +7 -7
package/dist/testing/index.d.ts
CHANGED
package/dist/transact/index.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ interface StellarPrivateCoinNote {
|
|
|
29
29
|
asset_lo: string;
|
|
30
30
|
application_id?: string;
|
|
31
31
|
}
|
|
32
|
+
interface StellarLeanImtNode {
|
|
33
|
+
level: number;
|
|
34
|
+
index: number;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
32
37
|
interface StellarPoolMerkleState {
|
|
33
38
|
poolContract: string;
|
|
34
39
|
commitments: string[];
|
|
@@ -36,6 +41,7 @@ interface StellarPoolMerkleState {
|
|
|
36
41
|
merkleRootHex: string;
|
|
37
42
|
updatedAt: number;
|
|
38
43
|
syncedLedger?: number;
|
|
44
|
+
nodes?: StellarLeanImtNode[];
|
|
39
45
|
}
|
|
40
46
|
interface StellarLeafEphemeral {
|
|
41
47
|
poolContract: string;
|
|
@@ -100,6 +106,12 @@ interface LeafEphemeralStatePort {
|
|
|
100
106
|
}): Promise<StellarLeafEphemeral | undefined>;
|
|
101
107
|
set(ephemeral: StellarLeafEphemeral): Promise<void>;
|
|
102
108
|
}
|
|
109
|
+
interface CachedPoolMerkleView {
|
|
110
|
+
commitments: string[];
|
|
111
|
+
updatedAt: number;
|
|
112
|
+
merkleRootHex?: string;
|
|
113
|
+
nodes?: StellarLeanImtNode[];
|
|
114
|
+
}
|
|
103
115
|
|
|
104
116
|
type StellarSignTransaction = (input: {
|
|
105
117
|
xdr: string;
|
|
@@ -232,6 +244,7 @@ interface StellarTransactArtifacts {
|
|
|
232
244
|
};
|
|
233
245
|
executeFinalizeRequired?: boolean;
|
|
234
246
|
spendSource?: 'privateAddress' | 'escrow';
|
|
247
|
+
zkConfigNonce?: bigint;
|
|
235
248
|
}
|
|
236
249
|
interface StellarNetworkConfig {
|
|
237
250
|
id: string;
|
|
@@ -245,6 +258,17 @@ interface StellarBrowserAssets {
|
|
|
245
258
|
sdkWasm: ArrayBuffer;
|
|
246
259
|
}
|
|
247
260
|
|
|
261
|
+
type FeeOutputSpec = {
|
|
262
|
+
requiredFee: bigint;
|
|
263
|
+
feeCollectorPrivateAddress: string;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
type FeeOutputKindInput = {
|
|
267
|
+
kind: OperationKind;
|
|
268
|
+
spendSource?: StellarTransactArtifacts['spendSource'];
|
|
269
|
+
escrowSend?: boolean;
|
|
270
|
+
};
|
|
271
|
+
|
|
248
272
|
declare class PrivacyPoolService {
|
|
249
273
|
private readonly assets?;
|
|
250
274
|
private readonly applicationId?;
|
|
@@ -252,11 +276,12 @@ declare class PrivacyPoolService {
|
|
|
252
276
|
private readonly zkCircuits?;
|
|
253
277
|
private readonly zkConfigNonce?;
|
|
254
278
|
private readonly zkArtifactBaseUrl?;
|
|
255
|
-
private
|
|
256
|
-
private
|
|
279
|
+
private readonly sdks;
|
|
280
|
+
private readonly initPromises;
|
|
257
281
|
constructor(assets?: StellarBrowserAssets | undefined, applicationId?: string | undefined, auditPublicKey?: [string, string] | undefined, zkCircuits?: Record<string, StellarZkCircuitDefinition> | undefined, zkConfigNonce?: bigint | undefined, zkArtifactBaseUrl?: string | undefined);
|
|
258
|
-
|
|
259
|
-
|
|
282
|
+
getInitializedSdk(nonce?: bigint): Promise<PrivacyPoolSDK>;
|
|
283
|
+
feeBearingZkConfigNonce(input: FeeOutputKindInput): bigint;
|
|
284
|
+
private initializeSdk;
|
|
260
285
|
getAuditPublicKey(): [string, string] | undefined;
|
|
261
286
|
getApplicationId(): string;
|
|
262
287
|
generatePrivateAddressFromStellarSignature(signature: string, domain: SpendScalarDomain): Promise<string>;
|
|
@@ -280,6 +305,8 @@ declare class PrivacyPoolService {
|
|
|
280
305
|
depositScalarHex: string;
|
|
281
306
|
merkleRootBytes: Buffer$1;
|
|
282
307
|
tokenAddress: string;
|
|
308
|
+
publicDepositStroops?: bigint;
|
|
309
|
+
feeOutput?: FeeOutputSpec;
|
|
283
310
|
}): Promise<ProofResult>;
|
|
284
311
|
calculateNullifierHash(nullifier: string, privKeyScalar: string): Promise<string>;
|
|
285
312
|
prepareWithdrawTransactProof(parameters: {
|
|
@@ -291,6 +318,7 @@ declare class PrivacyPoolService {
|
|
|
291
318
|
withdrawAmountStroops: bigint;
|
|
292
319
|
changePrivateAddressStpl1: string | undefined;
|
|
293
320
|
tokenAddress: string;
|
|
321
|
+
feeOutput?: FeeOutputSpec;
|
|
294
322
|
}): Promise<ProofWithChange>;
|
|
295
323
|
prepareWithdrawTransactProofDual(parameters: {
|
|
296
324
|
coinA: CoinData;
|
|
@@ -303,6 +331,7 @@ declare class PrivacyPoolService {
|
|
|
303
331
|
withdrawAmountStroops: bigint;
|
|
304
332
|
changePrivateAddressStpl1: string | undefined;
|
|
305
333
|
tokenAddress: string;
|
|
334
|
+
feeOutput?: FeeOutputSpec;
|
|
306
335
|
}): Promise<ProofWithChange>;
|
|
307
336
|
}
|
|
308
337
|
|
|
@@ -435,7 +464,9 @@ declare function loadDefaultStellarBrowserAssets(options?: {
|
|
|
435
464
|
|
|
436
465
|
declare const STANDARD_ZK_CONFIG_NONCE = 0n;
|
|
437
466
|
declare const COMMITMENT_V2_ZK_NONCE = 2n;
|
|
467
|
+
declare const BINDING_ZK_NONCE = 3n;
|
|
438
468
|
declare const SIX_BY_SIX_ZK_NONCE = 6n;
|
|
469
|
+
declare const SIX_BY_SIX_BINDING_ZK_NONCE = 7n;
|
|
439
470
|
declare const DEFAULT_ZK_CONFIG_NONCE = 3n;
|
|
440
471
|
declare function resolveZkConfigNonce(transactEnvironment: StellarTransactEnvironment): bigint;
|
|
441
472
|
|
|
@@ -483,6 +514,7 @@ interface SubmitSorobanConfidentialTransferInput {
|
|
|
483
514
|
ciphertextHex?: string;
|
|
484
515
|
outputNoteEphemeralScalars?: string[];
|
|
485
516
|
applicationIdsPlaintext?: KytApplicationIdHints;
|
|
517
|
+
zkConfigNonce?: bigint;
|
|
486
518
|
networkPassphrase: string;
|
|
487
519
|
sorobanRpcUrl: string;
|
|
488
520
|
transactEnvironment: StellarTransactEnvironment;
|
|
@@ -512,6 +544,7 @@ type PrepareConfidentialTransferProofDualParameters = {
|
|
|
512
544
|
tokenAddress: string;
|
|
513
545
|
escrowSend?: TransferEscrowSend;
|
|
514
546
|
escrowClaimantLimbs?: TransferEscrowClaimantLimbs;
|
|
547
|
+
feeOutput?: FeeOutputSpec;
|
|
515
548
|
};
|
|
516
549
|
type PrepareConfidentialTransferProofDualResult = {
|
|
517
550
|
proof_hex: string;
|
|
@@ -535,6 +568,7 @@ type PrepareConfidentialTransferProofParameters = {
|
|
|
535
568
|
tokenAddress: string;
|
|
536
569
|
escrowSend?: TransferEscrowSend;
|
|
537
570
|
escrowClaimantLimbs?: TransferEscrowClaimantLimbs;
|
|
571
|
+
feeOutput?: FeeOutputSpec;
|
|
538
572
|
};
|
|
539
573
|
type PrepareConfidentialTransferProofResult = {
|
|
540
574
|
proof_hex: string;
|
|
@@ -552,7 +586,16 @@ interface FetchContractMerkleResult {
|
|
|
552
586
|
commitments: string[];
|
|
553
587
|
merkleRootHex: string;
|
|
554
588
|
updatedAt: number;
|
|
589
|
+
nodes?: StellarLeanImtNode[];
|
|
555
590
|
}
|
|
591
|
+
declare function persistFetchedMerkleState(input: {
|
|
592
|
+
poolContractId: string;
|
|
593
|
+
commitments: string[];
|
|
594
|
+
merkleRootHex: string;
|
|
595
|
+
cachedState: CachedPoolMerkleView | undefined;
|
|
596
|
+
poolMerkleState?: PoolMerkleStatePort;
|
|
597
|
+
}): Promise<FetchContractMerkleResult>;
|
|
598
|
+
|
|
556
599
|
/**
|
|
557
600
|
* Loads pool Merkle leaves without `get_commitments()`. That helper walks the
|
|
558
601
|
* whole tree in one simulate and exceeds the Soroban host budget on a live
|
|
@@ -564,7 +607,7 @@ declare function fetchAndMergeMerkleState(parameters: {
|
|
|
564
607
|
walletPublicKey: string;
|
|
565
608
|
transactEnvironment: StellarTransactEnvironment;
|
|
566
609
|
poolMerkleState?: PoolMerkleStatePort;
|
|
567
|
-
}): Promise<
|
|
610
|
+
}): Promise<Awaited<ReturnType<typeof persistFetchedMerkleState>>>;
|
|
568
611
|
declare function readLeafEphemeralHex(parameters: {
|
|
569
612
|
poolContractId: string;
|
|
570
613
|
walletPublicKey: string;
|
|
@@ -593,6 +636,7 @@ interface RequestKytPassageForPoolInteractionInput {
|
|
|
593
636
|
outputNoteEphemeralScalars?: string[];
|
|
594
637
|
decryptedAuditSlots?: DecryptedKytAuditSlot[];
|
|
595
638
|
applicationIdsPlaintext?: KytApplicationIdHints;
|
|
639
|
+
zkConfigNonce?: bigint;
|
|
596
640
|
networkPassphrase: string;
|
|
597
641
|
sorobanRpcUrl: string;
|
|
598
642
|
transactEnvironment: StellarTransactEnvironment;
|
|
@@ -710,4 +754,4 @@ declare function isEscrowPreparedOperation(prepared: StellarPreparedOperation):
|
|
|
710
754
|
declare function evaluateRequiredSubmissionMethod(prepared: StellarPreparedOperation, zkConfigNonce?: bigint): RequiredSubmissionMethodResult;
|
|
711
755
|
declare function requiredSubmissionMethod(prepared: StellarPreparedOperation, zkConfigNonce?: bigint): SubmissionMethod;
|
|
712
756
|
|
|
713
|
-
export { type AlignedDepositSlot, type BlindedRecipientTagChallengeFields, COMMITMENT_V2_ZK_NONCE, DEFAULT_STELLAR_ZK_CIRCUITS, DEFAULT_ZK_CONFIG_NONCE, ESCROW_SUBMISSION_REFUSAL, type EscrowOutputNoteCiphertextEvent, type EscrowSubmissionRefusal, EscrowSubmissionRefusedError, type KytApplicationIdHints, KytInspectError, type LoadBrowserAssetsInput, MIN_CONFIDENTIAL_TRANSFER_STROOPS, type PrepareRelayTransactPackageFromPreparedInput, type PrepareRelayTransactPackageInput, PrivacyPoolService, type ProofResult, type ProofWithChange, RELAY_SIGNAL_INDEX_ESCROW_RECIPIENT_HI, RELAY_SIGNAL_INDEX_ESCROW_RECIPIENT_LO, RELAY_SIGNAL_INDEX_NULLIFIER_0, RELAY_SIGNAL_INDEX_NULLIFIER_1, RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT, RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT_ASSET_HI, RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT_ASSET_LO, RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL, RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL_ASSET_HI, RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL_ASSET_LO, RELAY_SIGNAL_INDEX_STATE_ROOT, RELAY_SIGNAL_INDEX_WITHDRAW_ADDRESS_HI, RELAY_SIGNAL_INDEX_WITHDRAW_ADDRESS_LO, RELAY_TRANSACT_FIELD_BYTES, RELAY_TRANSACT_PACKAGE_VERSION_V1, RELAY_TRANSACT_SIGNAL_PREFIX_BYTES, RELAY_TRANSACT_SUPPORTED_SIGNAL_COUNT, type ReconstructedEscrowNote, type RelayKeyVersionHints, type RelayTransactPackageV1, type RelayTransactPackageVersion, type RelayTransactPublicLegContext, type RelayTransactSupportedProfile, type RequestKytPassageForPoolInteractionInput, type RequiredSubmissionMethodResult, SIX_BY_SIX_ZK_NONCE, STANDARD_ZK_CONFIG_NONCE, SUBMISSION_METHOD, type StellarBundledZkCircuitDefinition, type StellarCustomZkCircuitDefinition, type StellarKytEnvironment, type StellarTransactEnvironment, type StellarZkCircuitDefinition, type SubmissionMethod, type TransferEscrowClaimantLimbs, type TransferEscrowSend, type TransferRecipientExecutionContext, type TransferTemporaryRecipientKey, ZERO_STROOPS, assertEscrowSweepClaimant, assetLegToTokenAddress, attachEscrowAuthorization, attachPoolStatePorts, buildBlindedRecipientTagChallengeMessage, buildPoolTransactionAuditParameters, buildPrivateAddressSignMessage, configurePrivacyPoolService, createPrivacyPoolService, decodePrivateAddress, deriveEscrowRecipientFromStellarAddress, encodePrivateAddress, encodePrivateAddressFromHexCoordinates, evaluateRequiredSubmissionMethod, fetchAndMergeMerkleState, fetchEscrowOutputNoteEvents, finalizeSpendOperationAtExecute, frDecimalToPaddedBytes32, generateRandomDepositScalarHex, generateTemporaryRecipientPrivateAddress, getPrivacyPoolService, isEscrowPreparedOperation, loadDefaultStellarBrowserAssets, loadStellarBrowserAssets, optionalZkArtifactBaseUrl, parseAuditPublicKeyFromEnvHex, parseKytReasonCode, prepareConfidentialTransferProof, prepareConfidentialTransferProofDual, prepareEscrowSweepOperation, prepareRelayTransactPackage, prepareRelayTransactPackageFromPrepared, privateAddressSdk, readLeafEphemeralHex, readRelayTransactSupportedProfile, recipientPublicKeysDecimalFromPrivateAddress, reconstructEscrowNote, requestKytPassageForPoolInteraction, requiredSubmissionMethod, resolvePoolApplicationId, resolveZkConfigNonce, runTtlPreflight, submitSorobanConfidentialTransfer, submitSorobanDeposit, tokenAddressToAssetLeg, unsignedEscrowAuthorizationForSweep };
|
|
757
|
+
export { type AlignedDepositSlot, BINDING_ZK_NONCE, type BlindedRecipientTagChallengeFields, COMMITMENT_V2_ZK_NONCE, DEFAULT_STELLAR_ZK_CIRCUITS, DEFAULT_ZK_CONFIG_NONCE, ESCROW_SUBMISSION_REFUSAL, type EscrowOutputNoteCiphertextEvent, type EscrowSubmissionRefusal, EscrowSubmissionRefusedError, type KytApplicationIdHints, KytInspectError, type LoadBrowserAssetsInput, MIN_CONFIDENTIAL_TRANSFER_STROOPS, type PrepareRelayTransactPackageFromPreparedInput, type PrepareRelayTransactPackageInput, PrivacyPoolService, type ProofResult, type ProofWithChange, RELAY_SIGNAL_INDEX_ESCROW_RECIPIENT_HI, RELAY_SIGNAL_INDEX_ESCROW_RECIPIENT_LO, RELAY_SIGNAL_INDEX_NULLIFIER_0, RELAY_SIGNAL_INDEX_NULLIFIER_1, RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT, RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT_ASSET_HI, RELAY_SIGNAL_INDEX_PUBLIC_DEPOSIT_ASSET_LO, RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL, RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL_ASSET_HI, RELAY_SIGNAL_INDEX_PUBLIC_WITHDRAWAL_ASSET_LO, RELAY_SIGNAL_INDEX_STATE_ROOT, RELAY_SIGNAL_INDEX_WITHDRAW_ADDRESS_HI, RELAY_SIGNAL_INDEX_WITHDRAW_ADDRESS_LO, RELAY_TRANSACT_FIELD_BYTES, RELAY_TRANSACT_PACKAGE_VERSION_V1, RELAY_TRANSACT_SIGNAL_PREFIX_BYTES, RELAY_TRANSACT_SUPPORTED_SIGNAL_COUNT, type ReconstructedEscrowNote, type RelayKeyVersionHints, type RelayTransactPackageV1, type RelayTransactPackageVersion, type RelayTransactPublicLegContext, type RelayTransactSupportedProfile, type RequestKytPassageForPoolInteractionInput, type RequiredSubmissionMethodResult, SIX_BY_SIX_BINDING_ZK_NONCE, SIX_BY_SIX_ZK_NONCE, STANDARD_ZK_CONFIG_NONCE, SUBMISSION_METHOD, type StellarBundledZkCircuitDefinition, type StellarCustomZkCircuitDefinition, type StellarKytEnvironment, type StellarTransactEnvironment, type StellarZkCircuitDefinition, type SubmissionMethod, type TransferEscrowClaimantLimbs, type TransferEscrowSend, type TransferRecipientExecutionContext, type TransferTemporaryRecipientKey, ZERO_STROOPS, assertEscrowSweepClaimant, assetLegToTokenAddress, attachEscrowAuthorization, attachPoolStatePorts, buildBlindedRecipientTagChallengeMessage, buildPoolTransactionAuditParameters, buildPrivateAddressSignMessage, configurePrivacyPoolService, createPrivacyPoolService, decodePrivateAddress, deriveEscrowRecipientFromStellarAddress, encodePrivateAddress, encodePrivateAddressFromHexCoordinates, evaluateRequiredSubmissionMethod, fetchAndMergeMerkleState, fetchEscrowOutputNoteEvents, finalizeSpendOperationAtExecute, frDecimalToPaddedBytes32, generateRandomDepositScalarHex, generateTemporaryRecipientPrivateAddress, getPrivacyPoolService, isEscrowPreparedOperation, loadDefaultStellarBrowserAssets, loadStellarBrowserAssets, optionalZkArtifactBaseUrl, parseAuditPublicKeyFromEnvHex, parseKytReasonCode, prepareConfidentialTransferProof, prepareConfidentialTransferProofDual, prepareEscrowSweepOperation, prepareRelayTransactPackage, prepareRelayTransactPackageFromPrepared, privateAddressSdk, readLeafEphemeralHex, readRelayTransactSupportedProfile, recipientPublicKeysDecimalFromPrivateAddress, reconstructEscrowNote, requestKytPassageForPoolInteraction, requiredSubmissionMethod, resolvePoolApplicationId, resolveZkConfigNonce, runTtlPreflight, submitSorobanConfidentialTransfer, submitSorobanDeposit, tokenAddressToAssetLeg, unsignedEscrowAuthorizationForSweep };
|