@veilo/sdk-core 0.3.3 → 0.5.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/LICENSE +15 -0
- package/README.md +289 -1262
- package/dist/cjs/accounts/admin.d.ts +84 -0
- package/dist/cjs/accounts/admin.js +208 -0
- package/dist/cjs/accounts/errors.d.ts +6 -0
- package/dist/cjs/accounts/errors.js +98 -0
- package/dist/cjs/accounts/index.d.ts +4 -0
- package/dist/cjs/accounts/index.js +20 -0
- package/dist/cjs/accounts/pdas.d.ts +23 -0
- package/dist/cjs/accounts/pdas.js +44 -0
- package/dist/cjs/accounts/queries.d.ts +41 -0
- package/dist/cjs/accounts/queries.js +95 -0
- package/dist/cjs/client.d.ts +2 -407
- package/dist/cjs/client.js +17 -912
- package/dist/cjs/cloak/client.d.ts +28 -0
- package/dist/cjs/cloak/client.js +68 -0
- package/dist/cjs/cloak/errors.d.ts +13 -0
- package/dist/cjs/cloak/errors.js +25 -0
- package/dist/cjs/cloak/helpers.d.ts +6 -0
- package/dist/cjs/cloak/helpers.js +35 -0
- package/dist/cjs/cloak/index.d.ts +6 -0
- package/dist/cjs/cloak/index.js +24 -0
- package/dist/cjs/cloak/polling.d.ts +7 -0
- package/dist/cjs/cloak/polling.js +66 -0
- package/dist/cjs/cloak/transport.d.ts +15 -0
- package/dist/cjs/cloak/transport.js +119 -0
- package/dist/cjs/cloak/types.d.ts +188 -0
- package/dist/cjs/cloak/types.js +5 -0
- package/dist/cjs/cloak.d.ts +1 -0
- package/dist/cjs/cloak.js +18 -0
- package/dist/cjs/compactNote.d.ts +128 -0
- package/dist/cjs/compactNote.js +191 -0
- package/dist/cjs/events.d.ts +1 -1
- package/dist/cjs/events.js +2 -2
- package/dist/cjs/idl/privacy_pool.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool.js +15218 -0
- package/dist/cjs/index.d.ts +17 -13
- package/dist/cjs/index.js +43 -30
- package/dist/cjs/merkle.d.ts +13 -0
- package/dist/cjs/merkle.js +31 -8
- package/dist/cjs/notes/encryption.d.ts +41 -0
- package/dist/cjs/notes/encryption.js +75 -0
- package/dist/cjs/notes/index.d.ts +5 -0
- package/dist/cjs/notes/index.js +21 -0
- package/dist/cjs/notes/mailbox.d.ts +70 -0
- package/dist/cjs/notes/mailbox.js +164 -0
- package/dist/cjs/notes/model.d.ts +91 -0
- package/dist/cjs/notes/model.js +109 -0
- package/dist/cjs/notes/nullifier.d.ts +27 -0
- package/dist/cjs/notes/nullifier.js +45 -0
- package/dist/cjs/notes/recovery.d.ts +10 -0
- package/dist/cjs/notes/recovery.js +31 -0
- package/dist/cjs/program.d.ts +11 -0
- package/dist/cjs/program.js +26 -3
- package/dist/cjs/proof.d.ts +1 -183
- package/dist/cjs/proof.js +16 -290
- package/dist/cjs/proofs/encoding.d.ts +17 -0
- package/dist/cjs/proofs/encoding.js +72 -0
- package/dist/cjs/proofs/formatting.d.ts +6 -0
- package/dist/cjs/proofs/formatting.js +34 -0
- package/dist/cjs/proofs/index.d.ts +5 -0
- package/dist/cjs/proofs/index.js +21 -0
- package/dist/cjs/proofs/swap.d.ts +87 -0
- package/dist/cjs/proofs/swap.js +144 -0
- package/dist/cjs/proofs/transaction.d.ts +28 -0
- package/dist/cjs/proofs/transaction.js +110 -0
- package/dist/cjs/proofs/types.d.ts +70 -0
- package/dist/cjs/proofs/types.js +2 -0
- package/dist/cjs/prover.d.ts +4 -1
- package/dist/cjs/prover.js +12 -2
- package/dist/cjs/random.d.ts +16 -0
- package/dist/cjs/random.js +28 -0
- package/dist/cjs/relayer/client.d.ts +61 -0
- package/dist/cjs/relayer/client.js +151 -0
- package/dist/cjs/relayer/crypto.d.ts +5 -0
- package/dist/cjs/relayer/crypto.js +26 -0
- package/dist/cjs/relayer/encoding.d.ts +2 -0
- package/dist/cjs/relayer/encoding.js +23 -0
- package/dist/cjs/relayer/errors.d.ts +7 -0
- package/dist/cjs/relayer/errors.js +17 -0
- package/dist/cjs/relayer/index.d.ts +3 -0
- package/dist/cjs/relayer/index.js +19 -0
- package/dist/cjs/relayer/transport.d.ts +17 -0
- package/dist/cjs/relayer/transport.js +63 -0
- package/dist/cjs/relayer/types.d.ts +276 -0
- package/dist/cjs/relayer/types.js +5 -0
- package/dist/cjs/relayer.d.ts +1 -295
- package/dist/cjs/relayer.js +15 -243
- package/dist/cjs/shield/alt.d.ts +87 -0
- package/dist/cjs/shield/alt.js +194 -0
- package/dist/cjs/shield/computeBudget.d.ts +61 -0
- package/dist/cjs/shield/computeBudget.js +64 -0
- package/dist/cjs/shield/errors.d.ts +58 -0
- package/dist/cjs/shield/errors.js +121 -0
- package/dist/cjs/shield/finalize.d.ts +45 -0
- package/dist/cjs/shield/finalize.js +119 -0
- package/dist/cjs/shield/index.d.ts +35 -0
- package/dist/cjs/shield/index.js +68 -0
- package/dist/cjs/shield/ix.d.ts +54 -0
- package/dist/cjs/shield/ix.js +119 -0
- package/dist/cjs/shield/owner.d.ts +36 -0
- package/dist/cjs/shield/owner.js +127 -0
- package/dist/cjs/shield/ports.d.ts +43 -0
- package/dist/cjs/shield/ports.js +153 -0
- package/dist/cjs/shield/preflight.d.ts +30 -0
- package/dist/cjs/shield/preflight.js +154 -0
- package/dist/cjs/shield/shield.d.ts +68 -0
- package/dist/cjs/shield/shield.js +500 -0
- package/dist/cjs/shield/types.d.ts +202 -0
- package/dist/cjs/shield/types.js +2 -0
- package/dist/cjs/transactions/deposit.d.ts +94 -0
- package/dist/cjs/transactions/deposit.js +234 -0
- package/dist/cjs/transactions/index.d.ts +7 -0
- package/dist/cjs/transactions/index.js +26 -0
- package/dist/cjs/transactions/swap.d.ts +71 -0
- package/dist/cjs/transactions/swap.js +184 -0
- package/dist/cjs/transactions/transact.d.ts +34 -0
- package/dist/cjs/transactions/transact.js +146 -0
- package/dist/cjs/transactions/transfer.d.ts +51 -0
- package/dist/cjs/transactions/transfer.js +106 -0
- package/dist/cjs/transactions/withdraw.d.ts +52 -0
- package/dist/cjs/transactions/withdraw.js +104 -0
- package/dist/cjs/utxo.d.ts +1 -215
- package/dist/cjs/utxo.js +15 -391
- package/dist/esm/accounts/admin.d.ts +84 -0
- package/dist/esm/accounts/admin.js +165 -0
- package/dist/esm/accounts/errors.d.ts +6 -0
- package/dist/esm/accounts/errors.js +95 -0
- package/dist/esm/accounts/index.d.ts +4 -0
- package/dist/esm/accounts/index.js +4 -0
- package/dist/esm/accounts/pdas.d.ts +23 -0
- package/dist/esm/accounts/pdas.js +38 -0
- package/dist/esm/accounts/queries.d.ts +41 -0
- package/dist/esm/accounts/queries.js +88 -0
- package/dist/esm/client.d.ts +2 -0
- package/dist/esm/client.js +3 -887
- package/dist/esm/cloak/client.d.ts +28 -0
- package/dist/esm/cloak/client.js +64 -0
- package/dist/esm/cloak/errors.d.ts +13 -0
- package/dist/esm/cloak/errors.js +21 -0
- package/dist/esm/cloak/helpers.d.ts +6 -0
- package/dist/esm/cloak/helpers.js +31 -0
- package/dist/esm/cloak/index.d.ts +6 -0
- package/dist/esm/cloak/index.js +6 -0
- package/dist/esm/cloak/polling.d.ts +7 -0
- package/dist/esm/cloak/polling.js +63 -0
- package/dist/esm/cloak/transport.d.ts +15 -0
- package/dist/esm/cloak/transport.js +115 -0
- package/dist/esm/cloak/types.d.ts +188 -0
- package/dist/esm/cloak/types.js +4 -0
- package/dist/esm/cloak.d.ts +1 -0
- package/dist/esm/cloak.js +2 -0
- package/dist/esm/compactNote.d.ts +128 -0
- package/dist/esm/compactNote.js +179 -0
- package/dist/esm/config.d.ts +82 -0
- package/dist/esm/events.d.ts +77 -0
- package/dist/esm/events.js +1 -1
- package/dist/esm/idl/privacy_pool.d.ts +5 -0
- package/dist/esm/idl/privacy_pool.js +15216 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.js +20 -11
- package/dist/esm/merkle.d.ts +77 -0
- package/dist/esm/merkle.js +23 -1
- package/dist/esm/notes/encryption.d.ts +41 -0
- package/dist/esm/notes/encryption.js +67 -0
- package/dist/esm/notes/index.d.ts +5 -0
- package/dist/esm/notes/index.js +5 -0
- package/dist/esm/notes/mailbox.d.ts +70 -0
- package/dist/esm/notes/mailbox.js +154 -0
- package/dist/esm/notes/model.d.ts +91 -0
- package/dist/esm/notes/model.js +99 -0
- package/dist/esm/notes/nullifier.d.ts +27 -0
- package/dist/esm/notes/nullifier.js +40 -0
- package/dist/esm/notes/recovery.d.ts +10 -0
- package/dist/esm/notes/recovery.js +28 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/poseidon.d.ts +29 -0
- package/dist/esm/program.d.ts +37 -0
- package/dist/esm/program.js +23 -1
- package/dist/esm/proof.d.ts +1 -0
- package/dist/esm/proof.js +2 -281
- package/dist/esm/proofs/encoding.d.ts +17 -0
- package/dist/esm/proofs/encoding.js +68 -0
- package/dist/esm/proofs/formatting.d.ts +6 -0
- package/dist/esm/proofs/formatting.js +31 -0
- package/dist/esm/proofs/index.d.ts +5 -0
- package/dist/esm/proofs/index.js +5 -0
- package/dist/esm/proofs/swap.d.ts +87 -0
- package/dist/esm/proofs/swap.js +138 -0
- package/dist/esm/proofs/transaction.d.ts +28 -0
- package/dist/esm/proofs/transaction.js +105 -0
- package/dist/esm/proofs/types.d.ts +70 -0
- package/dist/esm/proofs/types.js +1 -0
- package/dist/esm/prover.d.ts +57 -0
- package/dist/esm/prover.js +10 -1
- package/dist/esm/random.d.ts +16 -0
- package/dist/esm/random.js +21 -0
- package/dist/esm/relayer/client.d.ts +61 -0
- package/dist/esm/relayer/client.js +144 -0
- package/dist/esm/relayer/crypto.d.ts +5 -0
- package/dist/esm/relayer/crypto.js +20 -0
- package/dist/esm/relayer/encoding.d.ts +2 -0
- package/dist/esm/relayer/encoding.js +19 -0
- package/dist/esm/relayer/errors.d.ts +7 -0
- package/dist/esm/relayer/errors.js +13 -0
- package/dist/esm/relayer/index.d.ts +3 -0
- package/dist/esm/relayer/index.js +3 -0
- package/dist/esm/relayer/transport.d.ts +17 -0
- package/dist/esm/relayer/transport.js +59 -0
- package/dist/esm/relayer/types.d.ts +276 -0
- package/dist/esm/relayer/types.js +4 -0
- package/dist/esm/relayer.d.ts +1 -0
- package/dist/esm/relayer.js +2 -238
- package/dist/esm/retry.d.ts +32 -0
- package/dist/esm/shield/alt.d.ts +87 -0
- package/dist/esm/shield/alt.js +186 -0
- package/dist/esm/shield/computeBudget.d.ts +61 -0
- package/dist/esm/shield/computeBudget.js +61 -0
- package/dist/esm/shield/errors.d.ts +58 -0
- package/dist/esm/shield/errors.js +115 -0
- package/dist/esm/shield/finalize.d.ts +45 -0
- package/dist/esm/shield/finalize.js +83 -0
- package/dist/esm/shield/index.d.ts +35 -0
- package/dist/esm/shield/index.js +32 -0
- package/dist/esm/shield/ix.d.ts +54 -0
- package/dist/esm/shield/ix.js +82 -0
- package/dist/esm/shield/owner.d.ts +36 -0
- package/dist/esm/shield/owner.js +123 -0
- package/dist/esm/shield/ports.d.ts +43 -0
- package/dist/esm/shield/ports.js +147 -0
- package/dist/esm/shield/preflight.d.ts +30 -0
- package/dist/esm/shield/preflight.js +151 -0
- package/dist/esm/shield/shield.d.ts +68 -0
- package/dist/esm/shield/shield.js +493 -0
- package/dist/esm/shield/types.d.ts +202 -0
- package/dist/esm/shield/types.js +1 -0
- package/dist/esm/transactions/deposit.d.ts +94 -0
- package/dist/esm/transactions/deposit.js +198 -0
- package/dist/esm/transactions/index.d.ts +7 -0
- package/dist/esm/transactions/index.js +7 -0
- package/dist/esm/transactions/swap.d.ts +71 -0
- package/dist/esm/transactions/swap.js +144 -0
- package/dist/esm/transactions/transact.d.ts +34 -0
- package/dist/esm/transactions/transact.js +110 -0
- package/dist/esm/transactions/transfer.d.ts +51 -0
- package/dist/esm/transactions/transfer.js +103 -0
- package/dist/esm/transactions/withdraw.d.ts +52 -0
- package/dist/esm/transactions/withdraw.js +101 -0
- package/dist/esm/utxo.d.ts +1 -0
- package/dist/esm/utxo.js +2 -372
- package/package.json +111 -15
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Keypair for UTXO ownership.
|
|
4
|
+
* Public key is derived via Poseidon: pubkey = Poseidon(privateKey)
|
|
5
|
+
*/
|
|
6
|
+
export type Keypair = {
|
|
7
|
+
privateKey: bigint;
|
|
8
|
+
publicKey: bigint;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* UTXO structure matching the circuit's UTXOCommitment template.
|
|
12
|
+
* commitment = Poseidon(amount, pubkey, blinding, mintAddress)
|
|
13
|
+
*/
|
|
14
|
+
export type UTXO = {
|
|
15
|
+
/** Amount in lamports/token units */
|
|
16
|
+
amount: bigint;
|
|
17
|
+
/** Owner's public key (derived from private key via Poseidon) */
|
|
18
|
+
pubkey: bigint;
|
|
19
|
+
/** Random blinding factor for commitment privacy */
|
|
20
|
+
blinding: bigint;
|
|
21
|
+
/** Token mint address as field element */
|
|
22
|
+
mintAddress: bigint;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Serialized UTXO with precomputed commitment and optional ownership data.
|
|
26
|
+
*/
|
|
27
|
+
export type SerializedUTXO = UTXO & {
|
|
28
|
+
/** 32-byte commitment: Poseidon(amount, pubkey, blinding, mintAddress) */
|
|
29
|
+
commitment: Uint8Array;
|
|
30
|
+
/** Private key for spending (only present for owned UTXOs) */
|
|
31
|
+
privateKey?: bigint;
|
|
32
|
+
/** Leaf index in the Merkle tree (set after insertion) */
|
|
33
|
+
pathIndex?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Input UTXO with Merkle proof data for spending.
|
|
37
|
+
*/
|
|
38
|
+
export type InputUTXO = SerializedUTXO & {
|
|
39
|
+
/** Leaf index in the Merkle tree */
|
|
40
|
+
pathIndex: number;
|
|
41
|
+
/** Merkle path elements (sibling hashes from leaf to root) */
|
|
42
|
+
pathElements: Uint8Array[];
|
|
43
|
+
/** Private key for nullifier derivation */
|
|
44
|
+
privateKey: bigint;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Generate a random keypair.
|
|
48
|
+
* Private key is a random 32-byte scalar.
|
|
49
|
+
* Public key is derived via Poseidon: pubkey = Poseidon(privateKey)
|
|
50
|
+
*/
|
|
51
|
+
export declare function generateKeypair(): Keypair;
|
|
52
|
+
/**
|
|
53
|
+
* Derive public key from private key.
|
|
54
|
+
* Matches circuit's Keypair template: publicKey = Poseidon(privateKey)
|
|
55
|
+
*/
|
|
56
|
+
export declare function derivePublicKey(privateKey: bigint): bigint;
|
|
57
|
+
/**
|
|
58
|
+
* Create keypair from a known private key.
|
|
59
|
+
*/
|
|
60
|
+
export declare function keypairFromPrivateKey(privateKey: bigint): Keypair;
|
|
61
|
+
/**
|
|
62
|
+
* Compute UTXO commitment.
|
|
63
|
+
* Matches circuit's UTXOCommitment template:
|
|
64
|
+
* commitment = Poseidon(amount, pubkey, blinding, mintAddress)
|
|
65
|
+
*/
|
|
66
|
+
export declare function commitUTXO(utxo: UTXO): Uint8Array;
|
|
67
|
+
/**
|
|
68
|
+
* Create a random UTXO with the given parameters.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createUTXO(params: {
|
|
71
|
+
amount: bigint;
|
|
72
|
+
pubkey: bigint;
|
|
73
|
+
mintAddress: PublicKey;
|
|
74
|
+
}): SerializedUTXO;
|
|
75
|
+
/**
|
|
76
|
+
* Create a UTXO with a specified private key (for owned UTXOs).
|
|
77
|
+
*/
|
|
78
|
+
export declare function createOwnedUTXO(params: {
|
|
79
|
+
amount: bigint;
|
|
80
|
+
privateKey: bigint;
|
|
81
|
+
mintAddress: PublicKey;
|
|
82
|
+
}): SerializedUTXO;
|
|
83
|
+
/**
|
|
84
|
+
* Create a zero UTXO (for deposits where no input exists).
|
|
85
|
+
* Zero UTXOs have amount=0 and are used as placeholders in 2-in-2-out transactions.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createZeroUTXO(pubkey: bigint, mintAddress: PublicKey): SerializedUTXO;
|
|
88
|
+
/**
|
|
89
|
+
* Create a zero UTXO with private key (for owned zero UTXOs).
|
|
90
|
+
*/
|
|
91
|
+
export declare function createOwnedZeroUTXO(privateKey: bigint, mintAddress: PublicKey): SerializedUTXO;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateKeypair = generateKeypair;
|
|
4
|
+
exports.derivePublicKey = derivePublicKey;
|
|
5
|
+
exports.keypairFromPrivateKey = keypairFromPrivateKey;
|
|
6
|
+
exports.commitUTXO = commitUTXO;
|
|
7
|
+
exports.createUTXO = createUTXO;
|
|
8
|
+
exports.createOwnedUTXO = createOwnedUTXO;
|
|
9
|
+
exports.createZeroUTXO = createZeroUTXO;
|
|
10
|
+
exports.createOwnedZeroUTXO = createOwnedZeroUTXO;
|
|
11
|
+
const random_js_1 = require("../random.js");
|
|
12
|
+
const poseidon_js_1 = require("../poseidon.js");
|
|
13
|
+
// -----------------------------------------------------------------------------
|
|
14
|
+
// Keypair Functions
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Generate a random keypair.
|
|
18
|
+
* Private key is a random 32-byte scalar.
|
|
19
|
+
* Public key is derived via Poseidon: pubkey = Poseidon(privateKey)
|
|
20
|
+
*/
|
|
21
|
+
function generateKeypair() {
|
|
22
|
+
const privateKeyBytes = new Uint8Array((0, random_js_1.randomBytes)(32));
|
|
23
|
+
const privateKey = (0, poseidon_js_1.bytesToBigIntBE)(privateKeyBytes) % poseidon_js_1.BN254_FR_MODULUS;
|
|
24
|
+
const publicKey = derivePublicKey(privateKey);
|
|
25
|
+
return { privateKey, publicKey };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Derive public key from private key.
|
|
29
|
+
* Matches circuit's Keypair template: publicKey = Poseidon(privateKey)
|
|
30
|
+
*/
|
|
31
|
+
function derivePublicKey(privateKey) {
|
|
32
|
+
return (0, poseidon_js_1.poseidon1)(privateKey);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create keypair from a known private key.
|
|
36
|
+
*/
|
|
37
|
+
function keypairFromPrivateKey(privateKey) {
|
|
38
|
+
return {
|
|
39
|
+
privateKey: privateKey % poseidon_js_1.BN254_FR_MODULUS,
|
|
40
|
+
publicKey: derivePublicKey(privateKey % poseidon_js_1.BN254_FR_MODULUS),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// -----------------------------------------------------------------------------
|
|
44
|
+
// UTXO Commitment Functions
|
|
45
|
+
// -----------------------------------------------------------------------------
|
|
46
|
+
/**
|
|
47
|
+
* Compute UTXO commitment.
|
|
48
|
+
* Matches circuit's UTXOCommitment template:
|
|
49
|
+
* commitment = Poseidon(amount, pubkey, blinding, mintAddress)
|
|
50
|
+
*/
|
|
51
|
+
function commitUTXO(utxo) {
|
|
52
|
+
const commitment = (0, poseidon_js_1.poseidon4)(utxo.amount, utxo.pubkey, utxo.blinding, utxo.mintAddress);
|
|
53
|
+
return (0, poseidon_js_1.bigIntToBytesBE)(commitment);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a random UTXO with the given parameters.
|
|
57
|
+
*/
|
|
58
|
+
function createUTXO(params) {
|
|
59
|
+
const blindingBytes = new Uint8Array((0, random_js_1.randomBytes)(32));
|
|
60
|
+
const blinding = (0, poseidon_js_1.bytesToBigIntBE)(blindingBytes) % poseidon_js_1.BN254_FR_MODULUS;
|
|
61
|
+
const utxo = {
|
|
62
|
+
amount: params.amount,
|
|
63
|
+
pubkey: params.pubkey,
|
|
64
|
+
blinding,
|
|
65
|
+
mintAddress: (0, poseidon_js_1.pubkeyToField)(params.mintAddress),
|
|
66
|
+
};
|
|
67
|
+
const commitment = commitUTXO(utxo);
|
|
68
|
+
return {
|
|
69
|
+
...utxo,
|
|
70
|
+
commitment,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a UTXO with a specified private key (for owned UTXOs).
|
|
75
|
+
*/
|
|
76
|
+
function createOwnedUTXO(params) {
|
|
77
|
+
const keypair = keypairFromPrivateKey(params.privateKey);
|
|
78
|
+
const utxo = createUTXO({
|
|
79
|
+
amount: params.amount,
|
|
80
|
+
pubkey: keypair.publicKey,
|
|
81
|
+
mintAddress: params.mintAddress,
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
...utxo,
|
|
85
|
+
privateKey: keypair.privateKey,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a zero UTXO (for deposits where no input exists).
|
|
90
|
+
* Zero UTXOs have amount=0 and are used as placeholders in 2-in-2-out transactions.
|
|
91
|
+
*/
|
|
92
|
+
function createZeroUTXO(pubkey, mintAddress) {
|
|
93
|
+
return createUTXO({
|
|
94
|
+
amount: 0n,
|
|
95
|
+
pubkey,
|
|
96
|
+
mintAddress,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Create a zero UTXO with private key (for owned zero UTXOs).
|
|
101
|
+
*/
|
|
102
|
+
function createOwnedZeroUTXO(privateKey, mintAddress) {
|
|
103
|
+
const keypair = keypairFromPrivateKey(privateKey);
|
|
104
|
+
const utxo = createZeroUTXO(keypair.publicKey, mintAddress);
|
|
105
|
+
return {
|
|
106
|
+
...utxo,
|
|
107
|
+
privateKey: keypair.privateKey,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InputUTXO, SerializedUTXO } from "./model.js";
|
|
2
|
+
/**
|
|
3
|
+
* Compute signature for nullifier derivation.
|
|
4
|
+
* Matches circuit's Signature template:
|
|
5
|
+
* signature = Poseidon(privateKey, commitment, pathIndex)
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeSignature(privateKey: bigint, commitment: bigint, pathIndex: bigint): bigint;
|
|
8
|
+
/**
|
|
9
|
+
* Derive nullifier for a UTXO.
|
|
10
|
+
* Matches circuit's UTXONullifier template:
|
|
11
|
+
* signature = Poseidon(privateKey, commitment, pathIndex)
|
|
12
|
+
* nullifier = Poseidon(commitment, pathIndex, signature)
|
|
13
|
+
*
|
|
14
|
+
* The signature-based nullifier ensures only the private key holder can spend.
|
|
15
|
+
*/
|
|
16
|
+
export declare function deriveNullifier(utxo: SerializedUTXO, pathIndex: number, privateKey: bigint): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Convert InputUTXO to the format expected by the circuit.
|
|
19
|
+
*/
|
|
20
|
+
export declare function inputUTXOToCircuitFormat(input: InputUTXO): {
|
|
21
|
+
amount: bigint;
|
|
22
|
+
pubkey: bigint;
|
|
23
|
+
blinding: bigint;
|
|
24
|
+
pathElements: bigint[];
|
|
25
|
+
pathIndex: number;
|
|
26
|
+
privateKey: bigint;
|
|
27
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeSignature = computeSignature;
|
|
4
|
+
exports.deriveNullifier = deriveNullifier;
|
|
5
|
+
exports.inputUTXOToCircuitFormat = inputUTXOToCircuitFormat;
|
|
6
|
+
const poseidon_js_1 = require("../poseidon.js");
|
|
7
|
+
// -----------------------------------------------------------------------------
|
|
8
|
+
// Nullifier Functions
|
|
9
|
+
// -----------------------------------------------------------------------------
|
|
10
|
+
/**
|
|
11
|
+
* Compute signature for nullifier derivation.
|
|
12
|
+
* Matches circuit's Signature template:
|
|
13
|
+
* signature = Poseidon(privateKey, commitment, pathIndex)
|
|
14
|
+
*/
|
|
15
|
+
function computeSignature(privateKey, commitment, pathIndex) {
|
|
16
|
+
return (0, poseidon_js_1.poseidon3)(privateKey, commitment, pathIndex);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Derive nullifier for a UTXO.
|
|
20
|
+
* Matches circuit's UTXONullifier template:
|
|
21
|
+
* signature = Poseidon(privateKey, commitment, pathIndex)
|
|
22
|
+
* nullifier = Poseidon(commitment, pathIndex, signature)
|
|
23
|
+
*
|
|
24
|
+
* The signature-based nullifier ensures only the private key holder can spend.
|
|
25
|
+
*/
|
|
26
|
+
function deriveNullifier(utxo, pathIndex, privateKey) {
|
|
27
|
+
const commitment = (0, poseidon_js_1.bytesToBigIntBE)(utxo.commitment) % poseidon_js_1.BN254_FR_MODULUS;
|
|
28
|
+
const pathIndexField = BigInt(pathIndex) % poseidon_js_1.BN254_FR_MODULUS;
|
|
29
|
+
const signature = computeSignature(privateKey, commitment, pathIndexField);
|
|
30
|
+
const nullifier = (0, poseidon_js_1.poseidon3)(commitment, pathIndexField, signature);
|
|
31
|
+
return (0, poseidon_js_1.bigIntToBytesBE)(nullifier);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert InputUTXO to the format expected by the circuit.
|
|
35
|
+
*/
|
|
36
|
+
function inputUTXOToCircuitFormat(input) {
|
|
37
|
+
return {
|
|
38
|
+
amount: input.amount,
|
|
39
|
+
pubkey: input.pubkey,
|
|
40
|
+
blinding: input.blinding,
|
|
41
|
+
pathElements: input.pathElements.map((e) => (0, poseidon_js_1.bytesToBigIntBE)(e) % poseidon_js_1.BN254_FR_MODULUS),
|
|
42
|
+
pathIndex: input.pathIndex,
|
|
43
|
+
privateKey: input.privateKey,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DecryptedNote } from "./mailbox.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fetch all encrypted notes for a wallet from the relayer's Blind Mailbox endpoint
|
|
4
|
+
* and decrypt them using the wallet's secret key.
|
|
5
|
+
*
|
|
6
|
+
* @param walletPublicKey Base58 wallet address used to query the relayer
|
|
7
|
+
* @param walletSecretKey Full 64-byte keypair.secretKey for decryption
|
|
8
|
+
* @param relayerUrl Relayer base URL (e.g. "https://relay.veilo.app")
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchAndDecryptNotes(walletPublicKey: string, walletSecretKey: Uint8Array, relayerUrl: string): Promise<DecryptedNote[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchAndDecryptNotes = fetchAndDecryptNotes;
|
|
4
|
+
const mailbox_js_1 = require("./mailbox.js");
|
|
5
|
+
/**
|
|
6
|
+
* Fetch all encrypted notes for a wallet from the relayer's Blind Mailbox endpoint
|
|
7
|
+
* and decrypt them using the wallet's secret key.
|
|
8
|
+
*
|
|
9
|
+
* @param walletPublicKey Base58 wallet address used to query the relayer
|
|
10
|
+
* @param walletSecretKey Full 64-byte keypair.secretKey for decryption
|
|
11
|
+
* @param relayerUrl Relayer base URL (e.g. "https://relay.veilo.app")
|
|
12
|
+
*/
|
|
13
|
+
async function fetchAndDecryptNotes(walletPublicKey, walletSecretKey, relayerUrl) {
|
|
14
|
+
const resp = await fetch(`${relayerUrl}/api/notes?recipientPublicKey=${walletPublicKey}`);
|
|
15
|
+
if (!resp.ok) {
|
|
16
|
+
throw new Error(`fetchAndDecryptNotes: ${resp.status} ${resp.statusText}`);
|
|
17
|
+
}
|
|
18
|
+
const { notes } = (await resp.json());
|
|
19
|
+
const results = [];
|
|
20
|
+
for (const note of notes) {
|
|
21
|
+
try {
|
|
22
|
+
const epk = Buffer.from(note.ephemeralPublicKey, "base64");
|
|
23
|
+
const decrypted = (0, mailbox_js_1.decryptBlindMailboxNote)(walletSecretKey, new Uint8Array(epk), note.encryptedBlob);
|
|
24
|
+
results.push(decrypted);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Note not for this key or corrupted — skip silently
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return results;
|
|
31
|
+
}
|
package/dist/cjs/program.d.ts
CHANGED
|
@@ -24,3 +24,14 @@ export declare const PRIVACY_POOL_PROGRAM_ID: PublicKey;
|
|
|
24
24
|
export declare function createVeiloProgram(connection: Connection, wallet: Wallet, opts?: {
|
|
25
25
|
commitment?: "processed" | "confirmed" | "finalized";
|
|
26
26
|
}): Program;
|
|
27
|
+
/**
|
|
28
|
+
* Create a `Program` for reading on-chain accounts, with no wallet.
|
|
29
|
+
*
|
|
30
|
+
* The shield path never signs, so requiring a `Wallet` just to decode a
|
|
31
|
+
* `MerkleTreeAccount` would force integrators to invent a dummy one. This is
|
|
32
|
+
* safe for `program.account.*.fetch` and the coders; anything that would submit
|
|
33
|
+
* a transaction will fail, which is the intent.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createReadonlyVeiloProgram(connection: Connection, opts?: {
|
|
36
|
+
commitment?: "processed" | "confirmed" | "finalized";
|
|
37
|
+
}): Program;
|
package/dist/cjs/program.js
CHANGED
|
@@ -5,13 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PRIVACY_POOL_PROGRAM_ID = exports.PRIVACY_POOL_IDL = void 0;
|
|
7
7
|
exports.createVeiloProgram = createVeiloProgram;
|
|
8
|
+
exports.createReadonlyVeiloProgram = createReadonlyVeiloProgram;
|
|
8
9
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
10
|
const web3_js_1 = require("@solana/web3.js");
|
|
10
|
-
const
|
|
11
|
+
const privacy_pool_js_1 = __importDefault(require("./idl/privacy_pool.js"));
|
|
11
12
|
// Re-export so consumers can access the raw IDL if needed
|
|
12
|
-
exports.PRIVACY_POOL_IDL =
|
|
13
|
+
exports.PRIVACY_POOL_IDL = privacy_pool_js_1.default;
|
|
13
14
|
/** Deployed program ID extracted from the bundled IDL. */
|
|
14
|
-
exports.PRIVACY_POOL_PROGRAM_ID = new web3_js_1.PublicKey(
|
|
15
|
+
exports.PRIVACY_POOL_PROGRAM_ID = new web3_js_1.PublicKey(privacy_pool_js_1.default.address);
|
|
15
16
|
/**
|
|
16
17
|
* Create an Anchor `Program` instance for the Veilo Privacy Pool.
|
|
17
18
|
*
|
|
@@ -36,3 +37,25 @@ function createVeiloProgram(connection, wallet, opts) {
|
|
|
36
37
|
});
|
|
37
38
|
return new anchor_1.Program(exports.PRIVACY_POOL_IDL, provider);
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a `Program` for reading on-chain accounts, with no wallet.
|
|
42
|
+
*
|
|
43
|
+
* The shield path never signs, so requiring a `Wallet` just to decode a
|
|
44
|
+
* `MerkleTreeAccount` would force integrators to invent a dummy one. This is
|
|
45
|
+
* safe for `program.account.*.fetch` and the coders; anything that would submit
|
|
46
|
+
* a transaction will fail, which is the intent.
|
|
47
|
+
*/
|
|
48
|
+
function createReadonlyVeiloProgram(connection, opts) {
|
|
49
|
+
const provider = new anchor_1.AnchorProvider(connection,
|
|
50
|
+
// No signing surface: reads only.
|
|
51
|
+
{
|
|
52
|
+
publicKey: web3_js_1.PublicKey.default,
|
|
53
|
+
signTransaction: () => {
|
|
54
|
+
throw new Error("createReadonlyVeiloProgram: this program cannot sign");
|
|
55
|
+
},
|
|
56
|
+
signAllTransactions: () => {
|
|
57
|
+
throw new Error("createReadonlyVeiloProgram: this program cannot sign");
|
|
58
|
+
},
|
|
59
|
+
}, { commitment: opts?.commitment ?? "confirmed" });
|
|
60
|
+
return new anchor_1.Program(exports.PRIVACY_POOL_IDL, provider);
|
|
61
|
+
}
|
package/dist/cjs/proof.d.ts
CHANGED
|
@@ -1,183 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { SerializedUTXO, InputUTXO } from "./utxo";
|
|
3
|
-
/**
|
|
4
|
-
* External data that gets hashed into ext_data_hash.
|
|
5
|
-
* These are public parameters that affect financial flows.
|
|
6
|
-
*/
|
|
7
|
-
export type ExtData = {
|
|
8
|
-
/** Who receives withdrawal (for withdrawals) */
|
|
9
|
-
recipient: PublicKey;
|
|
10
|
-
/** Who submits tx and gets fee */
|
|
11
|
-
relayer: PublicKey;
|
|
12
|
-
/** Fee to relayer in lamports/token units */
|
|
13
|
-
fee: bigint;
|
|
14
|
-
/** Refund to user in lamports/token units (for gas compensation) */
|
|
15
|
-
refund: bigint;
|
|
16
|
-
/** Claimant key committed into the proof */
|
|
17
|
-
claimant: PublicKey;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Transaction circuit inputs (8 public inputs, many private inputs).
|
|
21
|
-
* This structure is used to prepare inputs for the snarkjs prover.
|
|
22
|
-
*/
|
|
23
|
-
export type TransactionCircuitInputs = {
|
|
24
|
-
/** Merkle root of UTXO tree */
|
|
25
|
-
root: Uint8Array;
|
|
26
|
-
/** Net deposit/withdrawal amount (positive = deposit, negative = withdrawal) */
|
|
27
|
-
publicAmount: bigint;
|
|
28
|
-
/** Hash of external data (recipient, relayer, fee, refund) */
|
|
29
|
-
extDataHash: Uint8Array;
|
|
30
|
-
/** Token mint address */
|
|
31
|
-
mintAddress: PublicKey;
|
|
32
|
-
/** Nullifiers for the two input UTXOs */
|
|
33
|
-
inputNullifiers: [Uint8Array, Uint8Array];
|
|
34
|
-
/** Commitments for the two output UTXOs */
|
|
35
|
-
outputCommitments: [Uint8Array, Uint8Array];
|
|
36
|
-
inAmount: [bigint, bigint];
|
|
37
|
-
inPubkey: [bigint, bigint];
|
|
38
|
-
inBlinding: [bigint, bigint];
|
|
39
|
-
inPathIndex: [number, number];
|
|
40
|
-
inPathElements: [bigint[], bigint[]];
|
|
41
|
-
inPrivateKey: [bigint, bigint];
|
|
42
|
-
outAmount: [bigint, bigint];
|
|
43
|
-
outPubkey: [bigint, bigint];
|
|
44
|
-
outBlinding: [bigint, bigint];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Proof structure matching the on-chain TransactionProof struct.
|
|
48
|
-
* Total size: 256 bytes (64 + 128 + 64)
|
|
49
|
-
*/
|
|
50
|
-
export type TransactionProofStruct = {
|
|
51
|
-
/** G1 point A (64 bytes) */
|
|
52
|
-
proofA: number[];
|
|
53
|
-
/** G2 point B (128 bytes) */
|
|
54
|
-
proofB: number[];
|
|
55
|
-
/** G1 point C (64 bytes) */
|
|
56
|
-
proofC: number[];
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Shape of a Groth16 proof produced by snarkjs.
|
|
60
|
-
*/
|
|
61
|
-
export type RawProof = {
|
|
62
|
-
pi_a: [string, string, string];
|
|
63
|
-
pi_b: [[string, string], [string, string], [string, string]];
|
|
64
|
-
pi_c: [string, string, string];
|
|
65
|
-
protocol: string;
|
|
66
|
-
curve: string;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Proof builder function type - takes circuit inputs and returns a raw snarkjs proof.
|
|
70
|
-
*/
|
|
71
|
-
export type TransactionProofBuilder = (inputs: TransactionCircuitInputs) => Promise<RawProof>;
|
|
72
|
-
/**
|
|
73
|
-
* Compute the external data hash.
|
|
74
|
-
* Matches on-chain computation:
|
|
75
|
-
* hash1 = Poseidon(recipient, relayer)
|
|
76
|
-
* hash2 = Poseidon(fee, refund)
|
|
77
|
-
* extDataHash = Poseidon(hash1, hash2, claimant)
|
|
78
|
-
*/
|
|
79
|
-
export declare function computeExtDataHash(extData: ExtData): Uint8Array;
|
|
80
|
-
/**
|
|
81
|
-
* Convert i64 to field element (handles negative via modular arithmetic).
|
|
82
|
-
* For negative values, we add the field modulus to get the equivalent positive representation.
|
|
83
|
-
*/
|
|
84
|
-
export declare function i64ToField(value: bigint): bigint;
|
|
85
|
-
/**
|
|
86
|
-
* Prepare transaction circuit inputs from high-level parameters.
|
|
87
|
-
* This converts the SDK types into the format expected by the circuit.
|
|
88
|
-
*/
|
|
89
|
-
export declare function prepareTransactionInputs(params: {
|
|
90
|
-
inputUTXOs: [InputUTXO, InputUTXO];
|
|
91
|
-
outputUTXOs: [SerializedUTXO, SerializedUTXO];
|
|
92
|
-
root: Uint8Array;
|
|
93
|
-
publicAmount: bigint;
|
|
94
|
-
extData: ExtData;
|
|
95
|
-
mintAddress: PublicKey;
|
|
96
|
-
}): TransactionCircuitInputs;
|
|
97
|
-
/**
|
|
98
|
-
* Turn a snarkjs Groth16 proof into 256 bytes:
|
|
99
|
-
* A(G1) | B(G2) | C(G1)
|
|
100
|
-
* where:
|
|
101
|
-
* A = (ax, ay) -> 64 bytes
|
|
102
|
-
* B = (bx1, bx0, by1, by0) -> 128 bytes (swapped pairs for alt_bn128)
|
|
103
|
-
* C = (cx, cy) -> 64 bytes
|
|
104
|
-
*
|
|
105
|
-
* Each field element is encoded as 32-byte BE to match the on-chain verifier.
|
|
106
|
-
* We ignore the extra projective/z components snarkjs keeps.
|
|
107
|
-
*/
|
|
108
|
-
export declare function packProofToBytes(proof: RawProof): Uint8Array;
|
|
109
|
-
/**
|
|
110
|
-
* Encode a snarkjs proof into the TransactionProofStruct format expected by the on-chain program.
|
|
111
|
-
*/
|
|
112
|
-
export declare function encodeSnarkjsProofToTransactionProof(proof: RawProof): TransactionProofStruct;
|
|
113
|
-
/**
|
|
114
|
-
* Convert TransactionCircuitInputs to the format expected by snarkjs.groth16.fullProve().
|
|
115
|
-
* All values are converted to strings (snarkjs expects string inputs for field elements).
|
|
116
|
-
*/
|
|
117
|
-
export declare function formatInputsForSnarkjs(inputs: TransactionCircuitInputs): Record<string, any>;
|
|
118
|
-
/**
|
|
119
|
-
* Swap circuit inputs. Matches the signal shape declared by swap.circom's
|
|
120
|
-
* main component (see zk-circuits/swap.circom lines 208-238). Unlike the
|
|
121
|
-
* transaction circuit, the swap circuit distinguishes a "change" output
|
|
122
|
-
* (same mint as source) from a "dest" output (dest mint) and takes a
|
|
123
|
-
* swap-specific params hash and swapAmount alongside the usual inputs.
|
|
124
|
-
*/
|
|
125
|
-
export type SwapCircuitInputs = {
|
|
126
|
-
sourceRoot: Uint8Array;
|
|
127
|
-
swapParamsHash: Uint8Array;
|
|
128
|
-
extDataHash: Uint8Array;
|
|
129
|
-
sourceMint: PublicKey;
|
|
130
|
-
destMint: PublicKey;
|
|
131
|
-
inputNullifiers: [Uint8Array, Uint8Array];
|
|
132
|
-
changeCommitment: Uint8Array;
|
|
133
|
-
destCommitment: Uint8Array;
|
|
134
|
-
swapAmount: bigint;
|
|
135
|
-
inAmount: [bigint, bigint];
|
|
136
|
-
inPubkey: [bigint, bigint];
|
|
137
|
-
inBlinding: [bigint, bigint];
|
|
138
|
-
inPathIndex: [number, number];
|
|
139
|
-
inPathElements: [bigint[], bigint[]];
|
|
140
|
-
inPrivateKey: [bigint, bigint];
|
|
141
|
-
changeAmount: bigint;
|
|
142
|
-
changePubkey: bigint;
|
|
143
|
-
changeBlinding: bigint;
|
|
144
|
-
destAmount: bigint;
|
|
145
|
-
destPubkey: bigint;
|
|
146
|
-
destBlinding: bigint;
|
|
147
|
-
minAmountOut: bigint;
|
|
148
|
-
deadline: bigint;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Convert SwapCircuitInputs into the shape expected by
|
|
152
|
-
* snarkjs.groth16.fullProve() for swap.circom. Every value is emitted as a
|
|
153
|
-
* decimal string (or string array) because snarkjs only accepts field
|
|
154
|
-
* elements as strings.
|
|
155
|
-
*
|
|
156
|
-
* Mirrors `generateSwapProof` in
|
|
157
|
-
* relayer-server/src/controllers/swap.helpers.ts so SDK-side swap proofs
|
|
158
|
-
* verify against the same circuit the relayer uses.
|
|
159
|
-
*/
|
|
160
|
-
export declare function formatSwapInputsForSnarkjs(inputs: SwapCircuitInputs): Record<string, any>;
|
|
161
|
-
/**
|
|
162
|
-
* Compute the swap params hash that the swap circuit and on-chain program verify.
|
|
163
|
-
* Mirrors relayer-server/src/controllers/swap.helpers.ts `computeSwapParamsHash`.
|
|
164
|
-
*
|
|
165
|
-
* Circuit formula (swap.circom lines 293-307):
|
|
166
|
-
* mintPairHash = Poseidon(sourceMint, destMint)
|
|
167
|
-
* swapTermsHash = Poseidon(minAmountOut, deadline, destAmount)
|
|
168
|
-
* swapParamsHash = Poseidon(mintPairHash, swapTermsHash)
|
|
169
|
-
*
|
|
170
|
-
* @param sourceMint Source pool mint
|
|
171
|
-
* @param destMint Destination pool mint
|
|
172
|
-
* @param minAmountOut Minimum accepted output amount (slippage protected)
|
|
173
|
-
* @param deadline Unix timestamp deadline (i64, 0 = no deadline)
|
|
174
|
-
* @param destAmount Actual amount committed to destination UTXO (≥ minAmountOut -
|
|
175
|
-
* relayerFee). If omitted, defaults to minAmountOut.
|
|
176
|
-
*/
|
|
177
|
-
export declare function computeSwapParamsHash(sourceMint: PublicKey, destMint: PublicKey, minAmountOut: bigint, deadline: bigint, destAmount?: bigint): Uint8Array;
|
|
178
|
-
/**
|
|
179
|
-
* Compute the swap data hash committed on-chain for Jupiter instruction integrity.
|
|
180
|
-
* SHA-256 of the raw Jupiter swap instruction data bytes.
|
|
181
|
-
* Mirrors relayer-server/src/controllers/swap.helpers.ts `computeSwapDataHash`.
|
|
182
|
-
*/
|
|
183
|
-
export declare function computeSwapDataHash(swapData: Uint8Array | Buffer): Uint8Array;
|
|
1
|
+
export * from "./proofs/index.js";
|