@sip-protocol/sdk 0.11.1 → 0.12.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/dist/{TransportWebUSB-2KITI5HD.mjs → TransportWebUSB-TXDZJBGS.mjs} +12 -12
- package/dist/browser.d.mts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +864 -545
- package/dist/browser.mjs +13 -3
- package/dist/{chunk-L4RKPNIJ.mjs → chunk-4EHEBTKP.mjs} +132 -87
- package/dist/{chunk-7IUKXWDN.mjs → chunk-MKTCJPFH.mjs} +331 -94
- package/dist/{chunk-IBZVA5Y7.mjs → chunk-NMC5RNMV.mjs} +2 -2
- package/dist/{chunk-XGB3TDIC.mjs → chunk-S3F4CPQ5.mjs} +5 -1
- package/dist/{constants-DCJYTIU3.mjs → constants-NCGOQF7S.mjs} +1 -1
- package/dist/{dist-PYEXZNFD.mjs → dist-4KSUM2PU.mjs} +2 -2
- package/dist/{dist-IFHPYLDX.mjs → dist-4O5YILSN.mjs} +2 -2
- package/dist/{fulfillment_proof-ANHVPKTB.mjs → fulfillment_proof-WCEE5GGO.mjs} +1 -1
- package/dist/{funding_proof-ICFZ5LHY.mjs → funding_proof-X5IP4SG5.mjs} +1 -1
- package/dist/{index-DH5XRHYV.d.mts → index-B_fGN4Fk.d.mts} +796 -597
- package/dist/{index-mw7KGX5M.d.ts → index-rqQpCeVM.d.ts} +796 -597
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +864 -545
- package/dist/index.mjs +13 -3
- package/dist/proofs/halo2.mjs +1 -1
- package/dist/proofs/kimchi.mjs +1 -1
- package/dist/proofs/noir.mjs +1 -1
- package/dist/{solana-7QOA3HBZ.mjs → solana-VKZI66MK.mjs} +12 -2
- package/dist/{validity_proof-3POXLPNY.mjs → validity_proof-2GVV6GA6.mjs} +1 -1
- package/package.json +6 -5
- package/src/chains/solana/gasless-cashout.ts +331 -0
- package/src/chains/solana/index.ts +16 -0
- package/src/chains/solana/privacy-adapter.ts +1 -0
- package/src/chains/solana/providers/webhook.ts +1 -0
- package/src/chains/solana/relayer-fee.ts +39 -0
- package/src/chains/solana/scan.ts +11 -70
- package/src/chains/solana/stealth-scanner.ts +8 -0
- package/src/chains/solana/stealth-signer.ts +145 -0
- package/src/chains/solana/types.ts +2 -0
- package/src/index.ts +14 -0
- package/src/proofs/parallel/concurrency.ts +2 -2
- package/src/solana/jito-relayer.ts +40 -8
- package/src/wallet/solana/privacy-adapter.ts +29 -66
package/dist/index.js
CHANGED
|
@@ -5,11 +5,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
|
|
8
|
+
var __esm = (fn, res, err) => function __init() {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
10
15
|
};
|
|
11
16
|
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
-
|
|
17
|
+
try {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw mod = 0, e;
|
|
21
|
+
}
|
|
13
22
|
};
|
|
14
23
|
var __export = (target, all) => {
|
|
15
24
|
for (var name in all)
|
|
@@ -3148,6 +3157,77 @@ var init_utils2 = __esm({
|
|
|
3148
3157
|
}
|
|
3149
3158
|
});
|
|
3150
3159
|
|
|
3160
|
+
// src/chains/solana/stealth-signer.ts
|
|
3161
|
+
function modL(value) {
|
|
3162
|
+
const reduced = value % ED25519_ORDER;
|
|
3163
|
+
return reduced >= 0n ? reduced : reduced + ED25519_ORDER;
|
|
3164
|
+
}
|
|
3165
|
+
function signEd25519WithScalar(message, scalar) {
|
|
3166
|
+
const a = modL(bytesToBigIntLE(scalar));
|
|
3167
|
+
if (a === 0n) {
|
|
3168
|
+
throw new Error("Invalid stealth scalar: reduces to zero");
|
|
3169
|
+
}
|
|
3170
|
+
const A = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(a).toRawBytes();
|
|
3171
|
+
const prefix = (0, import_sha5123.sha512)(scalar).slice(32, 64);
|
|
3172
|
+
const r = modL(bytesToBigIntLE((0, import_sha5123.sha512)(new Uint8Array([...prefix, ...message]))));
|
|
3173
|
+
if (r === 0n) {
|
|
3174
|
+
throw new Error("Invalid nonce: reduces to zero");
|
|
3175
|
+
}
|
|
3176
|
+
const R = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(r).toRawBytes();
|
|
3177
|
+
const k = modL(bytesToBigIntLE((0, import_sha5123.sha512)(new Uint8Array([...R, ...A, ...message]))));
|
|
3178
|
+
const S = modL(r + k * a);
|
|
3179
|
+
return new Uint8Array([...R, ...bigIntToBytesLE(S, 32)]);
|
|
3180
|
+
}
|
|
3181
|
+
function deriveStealthSigner(params) {
|
|
3182
|
+
const {
|
|
3183
|
+
stealthAddress,
|
|
3184
|
+
ephemeralPublicKey,
|
|
3185
|
+
viewingPrivateKey,
|
|
3186
|
+
spendingPrivateKey,
|
|
3187
|
+
version = "2"
|
|
3188
|
+
} = params;
|
|
3189
|
+
const stealthAddressHex = solanaAddressToEd25519PublicKey(stealthAddress);
|
|
3190
|
+
const ephemeralPubKeyHex = solanaAddressToEd25519PublicKey(ephemeralPublicKey);
|
|
3191
|
+
const stealthAddressObj = {
|
|
3192
|
+
address: stealthAddressHex,
|
|
3193
|
+
ephemeralPublicKey: ephemeralPubKeyHex,
|
|
3194
|
+
viewTag: 0
|
|
3195
|
+
};
|
|
3196
|
+
const recovery = version === "1" ? deriveEd25519StealthPrivateKeyV1(stealthAddressObj, spendingPrivateKey, viewingPrivateKey) : deriveEd25519StealthPrivateKey(stealthAddressObj, spendingPrivateKey, viewingPrivateKey);
|
|
3197
|
+
const scalar = (0, import_utils18.hexToBytes)(recovery.privateKey.slice(2));
|
|
3198
|
+
const publicKey = new import_web35.PublicKey(stealthAddress);
|
|
3199
|
+
const expectedPubKeyBytes = publicKey.toBytes();
|
|
3200
|
+
const derivedPubKeyBytes = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(modL(bytesToBigIntLE(scalar))).toRawBytes();
|
|
3201
|
+
if (!derivedPubKeyBytes.every((b, i) => b === expectedPubKeyBytes[i])) {
|
|
3202
|
+
throw new Error(
|
|
3203
|
+
"Stealth key derivation failed: derived scalar does not produce expected public key. This may indicate incorrect spending/viewing keys or corrupted announcement data."
|
|
3204
|
+
);
|
|
3205
|
+
}
|
|
3206
|
+
return {
|
|
3207
|
+
publicKey,
|
|
3208
|
+
signMessage(message) {
|
|
3209
|
+
return signEd25519WithScalar(message, scalar);
|
|
3210
|
+
},
|
|
3211
|
+
signTransaction(transaction) {
|
|
3212
|
+
const message = transaction.serializeMessage();
|
|
3213
|
+
const signature = signEd25519WithScalar(message, scalar);
|
|
3214
|
+
transaction.addSignature(publicKey, Buffer.from(signature));
|
|
3215
|
+
}
|
|
3216
|
+
};
|
|
3217
|
+
}
|
|
3218
|
+
var import_web35, import_ed255194, import_sha5123, import_utils18;
|
|
3219
|
+
var init_stealth_signer = __esm({
|
|
3220
|
+
"src/chains/solana/stealth-signer.ts"() {
|
|
3221
|
+
"use strict";
|
|
3222
|
+
import_web35 = require("@solana/web3.js");
|
|
3223
|
+
import_ed255194 = require("@noble/curves/ed25519");
|
|
3224
|
+
import_sha5123 = require("@noble/hashes/sha512");
|
|
3225
|
+
import_utils18 = require("@noble/hashes/utils");
|
|
3226
|
+
init_stealth2();
|
|
3227
|
+
init_utils();
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
|
|
3151
3231
|
// src/chains/solana/scan.ts
|
|
3152
3232
|
async function scanForPayments(params) {
|
|
3153
3233
|
const {
|
|
@@ -3160,7 +3240,7 @@ async function scanForPayments(params) {
|
|
|
3160
3240
|
provider
|
|
3161
3241
|
} = params;
|
|
3162
3242
|
const results = [];
|
|
3163
|
-
const memoProgram = new
|
|
3243
|
+
const memoProgram = new import_web36.PublicKey(MEMO_PROGRAM_ID);
|
|
3164
3244
|
try {
|
|
3165
3245
|
const signatures = await connection.getSignaturesForAddress(
|
|
3166
3246
|
memoProgram,
|
|
@@ -3239,6 +3319,7 @@ async function scanForPayments(params) {
|
|
|
3239
3319
|
results.push({
|
|
3240
3320
|
stealthAddress: announcement.stealthAddress || "",
|
|
3241
3321
|
ephemeralPublicKey: announcement.ephemeralPublicKey,
|
|
3322
|
+
version: announcement.version,
|
|
3242
3323
|
amount,
|
|
3243
3324
|
mint: transferInfo.mint,
|
|
3244
3325
|
tokenSymbol,
|
|
@@ -3269,51 +3350,34 @@ async function claimStealthPayment(params) {
|
|
|
3269
3350
|
mint,
|
|
3270
3351
|
version = "2"
|
|
3271
3352
|
} = params;
|
|
3272
|
-
const stealthPubkeyForBalance = new
|
|
3353
|
+
const stealthPubkeyForBalance = new import_web36.PublicKey(stealthAddress);
|
|
3273
3354
|
const solBalance = await connection.getBalance(stealthPubkeyForBalance);
|
|
3274
3355
|
if (BigInt(solBalance) < MIN_SOL_FOR_FEES) {
|
|
3275
3356
|
throw new Error(
|
|
3276
3357
|
`Insufficient SOL for transaction fees. Stealth address has ${solBalance} lamports, needs at least ${MIN_SOL_FOR_FEES} lamports (~0.000005 SOL). Fund the stealth address with SOL before claiming.`
|
|
3277
3358
|
);
|
|
3278
3359
|
}
|
|
3279
|
-
const
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
const recovery = version === "1" ? deriveEd25519StealthPrivateKeyV1(stealthAddressObj, spendingPrivateKey, viewingPrivateKey) : deriveEd25519StealthPrivateKey(stealthAddressObj, spendingPrivateKey, viewingPrivateKey);
|
|
3288
|
-
const stealthPrivKeyBytes = (0, import_utils19.hexToBytes)(recovery.privateKey.slice(2));
|
|
3289
|
-
const stealthPubkey = new import_web35.PublicKey(stealthAddress);
|
|
3290
|
-
const expectedPubKeyBytes = stealthPubkey.toBytes();
|
|
3291
|
-
const scalarBigInt = bytesToBigIntLE2(stealthPrivKeyBytes);
|
|
3292
|
-
const ED25519_ORDER6 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
3293
|
-
let validScalar = scalarBigInt % ED25519_ORDER6;
|
|
3294
|
-
if (validScalar === 0n) validScalar = 1n;
|
|
3295
|
-
const derivedPubKeyBytes = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(validScalar).toRawBytes();
|
|
3296
|
-
if (!derivedPubKeyBytes.every((b, i) => b === expectedPubKeyBytes[i])) {
|
|
3297
|
-
throw new Error(
|
|
3298
|
-
"Stealth key derivation failed: derived private key does not produce expected public key. This may indicate incorrect spending/viewing keys or corrupted announcement data."
|
|
3299
|
-
);
|
|
3300
|
-
}
|
|
3301
|
-
const stealthKeypair = import_web35.Keypair.fromSecretKey(
|
|
3302
|
-
new Uint8Array([...stealthPrivKeyBytes, ...expectedPubKeyBytes])
|
|
3303
|
-
);
|
|
3360
|
+
const stealthSigner = deriveStealthSigner({
|
|
3361
|
+
stealthAddress,
|
|
3362
|
+
ephemeralPublicKey,
|
|
3363
|
+
viewingPrivateKey,
|
|
3364
|
+
spendingPrivateKey,
|
|
3365
|
+
version
|
|
3366
|
+
});
|
|
3367
|
+
const stealthPubkey = new import_web36.PublicKey(stealthAddress);
|
|
3304
3368
|
const stealthATA = await (0, import_spl_token3.getAssociatedTokenAddress)(
|
|
3305
3369
|
mint,
|
|
3306
3370
|
stealthPubkey,
|
|
3307
3371
|
true
|
|
3308
3372
|
);
|
|
3309
|
-
const destinationPubkey = new
|
|
3373
|
+
const destinationPubkey = new import_web36.PublicKey(destinationAddress);
|
|
3310
3374
|
const destinationATA = await (0, import_spl_token3.getAssociatedTokenAddress)(
|
|
3311
3375
|
mint,
|
|
3312
3376
|
destinationPubkey
|
|
3313
3377
|
);
|
|
3314
3378
|
const stealthAccount = await (0, import_spl_token3.getAccount)(connection, stealthATA);
|
|
3315
3379
|
const amount = stealthAccount.amount;
|
|
3316
|
-
const transaction = new
|
|
3380
|
+
const transaction = new import_web36.Transaction();
|
|
3317
3381
|
transaction.add(
|
|
3318
3382
|
(0, import_spl_token3.createTransferInstruction)(
|
|
3319
3383
|
stealthATA,
|
|
@@ -3326,7 +3390,7 @@ async function claimStealthPayment(params) {
|
|
|
3326
3390
|
transaction.recentBlockhash = blockhash;
|
|
3327
3391
|
transaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
3328
3392
|
transaction.feePayer = stealthPubkey;
|
|
3329
|
-
|
|
3393
|
+
stealthSigner.signTransaction(transaction);
|
|
3330
3394
|
const txSignature = await connection.sendRawTransaction(
|
|
3331
3395
|
transaction.serialize(),
|
|
3332
3396
|
{
|
|
@@ -3358,7 +3422,7 @@ async function getStealthBalance(connection, stealthAddress, mint, provider) {
|
|
|
3358
3422
|
}
|
|
3359
3423
|
}
|
|
3360
3424
|
try {
|
|
3361
|
-
const stealthPubkey = new
|
|
3425
|
+
const stealthPubkey = new import_web36.PublicKey(stealthAddress);
|
|
3362
3426
|
const ata = await (0, import_spl_token3.getAssociatedTokenAddress)(mint, stealthPubkey, true);
|
|
3363
3427
|
const account = await (0, import_spl_token3.getAccount)(connection, ata);
|
|
3364
3428
|
return account.amount;
|
|
@@ -3378,25 +3442,17 @@ function detectCluster4(endpoint) {
|
|
|
3378
3442
|
}
|
|
3379
3443
|
return "mainnet-beta";
|
|
3380
3444
|
}
|
|
3381
|
-
|
|
3382
|
-
let result = 0n;
|
|
3383
|
-
for (let i = bytes.length - 1; i >= 0; i--) {
|
|
3384
|
-
result = result << 8n | BigInt(bytes[i]);
|
|
3385
|
-
}
|
|
3386
|
-
return result;
|
|
3387
|
-
}
|
|
3388
|
-
var import_web35, import_spl_token3, import_utils19, import_ed255194, MIN_SOL_FOR_FEES;
|
|
3445
|
+
var import_web36, import_spl_token3, MIN_SOL_FOR_FEES;
|
|
3389
3446
|
var init_scan = __esm({
|
|
3390
3447
|
"src/chains/solana/scan.ts"() {
|
|
3391
3448
|
"use strict";
|
|
3392
|
-
|
|
3449
|
+
import_web36 = require("@solana/web3.js");
|
|
3393
3450
|
import_spl_token3 = require("@solana/spl-token");
|
|
3394
3451
|
init_stealth2();
|
|
3395
3452
|
init_types();
|
|
3396
3453
|
init_constants();
|
|
3397
3454
|
init_utils2();
|
|
3398
|
-
|
|
3399
|
-
import_ed255194 = require("@noble/curves/ed25519");
|
|
3455
|
+
init_stealth_signer();
|
|
3400
3456
|
MIN_SOL_FOR_FEES = 5000n;
|
|
3401
3457
|
}
|
|
3402
3458
|
});
|
|
@@ -3444,11 +3500,11 @@ async function fullHistoricalScan(options, recipients, scanOptions = {}, onProgr
|
|
|
3444
3500
|
}
|
|
3445
3501
|
return allPayments;
|
|
3446
3502
|
}
|
|
3447
|
-
var
|
|
3503
|
+
var import_web37, StealthScanner;
|
|
3448
3504
|
var init_stealth_scanner = __esm({
|
|
3449
3505
|
"src/chains/solana/stealth-scanner.ts"() {
|
|
3450
3506
|
"use strict";
|
|
3451
|
-
|
|
3507
|
+
import_web37 = require("@solana/web3.js");
|
|
3452
3508
|
init_stealth2();
|
|
3453
3509
|
init_types();
|
|
3454
3510
|
init_constants();
|
|
@@ -3519,7 +3575,7 @@ var init_stealth_scanner = __esm({
|
|
|
3519
3575
|
let scannedCount = 0;
|
|
3520
3576
|
let lastSignature;
|
|
3521
3577
|
let lastSlot;
|
|
3522
|
-
const memoProgram = new
|
|
3578
|
+
const memoProgram = new import_web37.PublicKey(MEMO_PROGRAM_ID);
|
|
3523
3579
|
try {
|
|
3524
3580
|
const signatures = await this.connection.getSignaturesForAddress(
|
|
3525
3581
|
memoProgram,
|
|
@@ -3587,7 +3643,7 @@ var init_stealth_scanner = __esm({
|
|
|
3587
3643
|
}
|
|
3588
3644
|
this.paymentCallback = onPayment;
|
|
3589
3645
|
this.errorCallback = onError ?? null;
|
|
3590
|
-
const memoProgram = new
|
|
3646
|
+
const memoProgram = new import_web37.PublicKey(MEMO_PROGRAM_ID);
|
|
3591
3647
|
this.subscriptionId = this.connection.onLogs(
|
|
3592
3648
|
memoProgram,
|
|
3593
3649
|
async (logs) => {
|
|
@@ -3689,6 +3745,7 @@ var init_stealth_scanner = __esm({
|
|
|
3689
3745
|
return {
|
|
3690
3746
|
stealthAddress: announcement.stealthAddress || "",
|
|
3691
3747
|
ephemeralPublicKey: announcement.ephemeralPublicKey,
|
|
3748
|
+
version: announcement.version,
|
|
3692
3749
|
viewTag: viewTagNumber,
|
|
3693
3750
|
amount,
|
|
3694
3751
|
mint: transferInfo.mint,
|
|
@@ -3710,10 +3767,10 @@ var init_stealth_scanner = __esm({
|
|
|
3710
3767
|
|
|
3711
3768
|
// src/chains/solana/ephemeral-keys.ts
|
|
3712
3769
|
function generateEphemeralKeypair() {
|
|
3713
|
-
const privateKeyBytes = (0,
|
|
3770
|
+
const privateKeyBytes = (0, import_utils22.randomBytes)(32);
|
|
3714
3771
|
const publicKeyBytes = import_ed255195.ed25519.getPublicKey(privateKeyBytes);
|
|
3715
|
-
const privateKey = `0x${(0,
|
|
3716
|
-
const publicKey = `0x${(0,
|
|
3772
|
+
const privateKey = `0x${(0, import_utils22.bytesToHex)(privateKeyBytes)}`;
|
|
3773
|
+
const publicKey = `0x${(0, import_utils22.bytesToHex)(publicKeyBytes)}`;
|
|
3717
3774
|
const publicKeyBase58 = ed25519PublicKeyToSolanaAddress(publicKey);
|
|
3718
3775
|
secureWipe(privateKeyBytes);
|
|
3719
3776
|
return {
|
|
@@ -3723,10 +3780,10 @@ function generateEphemeralKeypair() {
|
|
|
3723
3780
|
};
|
|
3724
3781
|
}
|
|
3725
3782
|
function generateManagedEphemeralKeypair() {
|
|
3726
|
-
const privateKeyBytes = (0,
|
|
3783
|
+
const privateKeyBytes = (0, import_utils22.randomBytes)(32);
|
|
3727
3784
|
const publicKeyBytes = import_ed255195.ed25519.getPublicKey(privateKeyBytes);
|
|
3728
|
-
const privateKeyHex = `0x${(0,
|
|
3729
|
-
const publicKeyHex = `0x${(0,
|
|
3785
|
+
const privateKeyHex = `0x${(0, import_utils22.bytesToHex)(privateKeyBytes)}`;
|
|
3786
|
+
const publicKeyHex = `0x${(0, import_utils22.bytesToHex)(publicKeyBytes)}`;
|
|
3730
3787
|
const publicKeyBase58 = ed25519PublicKeyToSolanaAddress(publicKeyHex);
|
|
3731
3788
|
let disposed = false;
|
|
3732
3789
|
const managed = {
|
|
@@ -3759,10 +3816,10 @@ function batchGenerateEphemeralKeypairs(options) {
|
|
|
3759
3816
|
throw new Error("count cannot exceed 1000 (security limit)");
|
|
3760
3817
|
}
|
|
3761
3818
|
const keypairs = [];
|
|
3762
|
-
let entropyState = entropyMixing ? (0,
|
|
3819
|
+
let entropyState = entropyMixing ? (0, import_utils22.randomBytes)(32) : null;
|
|
3763
3820
|
for (let i = 0; i < count; i++) {
|
|
3764
3821
|
if (entropyMixing && entropyState) {
|
|
3765
|
-
const extraEntropy = (0,
|
|
3822
|
+
const extraEntropy = (0, import_utils22.randomBytes)(32);
|
|
3766
3823
|
entropyState = (0, import_sha2566.sha256)(new Uint8Array([...entropyState, ...extraEntropy]));
|
|
3767
3824
|
}
|
|
3768
3825
|
keypairs.push(generateEphemeralKeypair());
|
|
@@ -3781,10 +3838,10 @@ function batchGenerateManagedEphemeralKeypairs(options) {
|
|
|
3781
3838
|
throw new Error("count cannot exceed 1000 (security limit)");
|
|
3782
3839
|
}
|
|
3783
3840
|
const keypairs = [];
|
|
3784
|
-
let entropyState = entropyMixing ? (0,
|
|
3841
|
+
let entropyState = entropyMixing ? (0, import_utils22.randomBytes)(32) : null;
|
|
3785
3842
|
for (let i = 0; i < count; i++) {
|
|
3786
3843
|
if (entropyMixing && entropyState) {
|
|
3787
|
-
const extraEntropy = (0,
|
|
3844
|
+
const extraEntropy = (0, import_utils22.randomBytes)(32);
|
|
3788
3845
|
entropyState = (0, import_sha2566.sha256)(new Uint8Array([...entropyState, ...extraEntropy]));
|
|
3789
3846
|
}
|
|
3790
3847
|
keypairs.push(generateManagedEphemeralKeypair());
|
|
@@ -3800,15 +3857,15 @@ function disposeEphemeralKeypairs(keypairs) {
|
|
|
3800
3857
|
}
|
|
3801
3858
|
}
|
|
3802
3859
|
function wipeEphemeralPrivateKey(privateKeyHex) {
|
|
3803
|
-
const bytes = (0,
|
|
3860
|
+
const bytes = (0, import_utils22.hexToBytes)(privateKeyHex.slice(2));
|
|
3804
3861
|
secureWipe(bytes);
|
|
3805
3862
|
}
|
|
3806
|
-
var import_ed255195,
|
|
3863
|
+
var import_ed255195, import_utils22, import_sha2566;
|
|
3807
3864
|
var init_ephemeral_keys = __esm({
|
|
3808
3865
|
"src/chains/solana/ephemeral-keys.ts"() {
|
|
3809
3866
|
"use strict";
|
|
3810
3867
|
import_ed255195 = require("@noble/curves/ed25519");
|
|
3811
|
-
|
|
3868
|
+
import_utils22 = require("@noble/hashes/utils");
|
|
3812
3869
|
import_sha2566 = require("@noble/hashes/sha256");
|
|
3813
3870
|
init_secure_memory();
|
|
3814
3871
|
init_stealth2();
|
|
@@ -4031,16 +4088,16 @@ var init_helius = __esm({
|
|
|
4031
4088
|
// src/chains/solana/providers/generic.ts
|
|
4032
4089
|
function validateSolanaAddress(address, paramName) {
|
|
4033
4090
|
try {
|
|
4034
|
-
return new
|
|
4091
|
+
return new import_web38.PublicKey(address);
|
|
4035
4092
|
} catch {
|
|
4036
4093
|
throw new ValidationError("invalid Solana address format", paramName, void 0, "SIP_2007" /* INVALID_ADDRESS */);
|
|
4037
4094
|
}
|
|
4038
4095
|
}
|
|
4039
|
-
var
|
|
4096
|
+
var import_web38, import_spl_token4, CLUSTER_ENDPOINTS, GenericProvider;
|
|
4040
4097
|
var init_generic = __esm({
|
|
4041
4098
|
"src/chains/solana/providers/generic.ts"() {
|
|
4042
4099
|
"use strict";
|
|
4043
|
-
|
|
4100
|
+
import_web38 = require("@solana/web3.js");
|
|
4044
4101
|
import_spl_token4 = require("@solana/spl-token");
|
|
4045
4102
|
init_errors();
|
|
4046
4103
|
init_constants();
|
|
@@ -4057,7 +4114,7 @@ var init_generic = __esm({
|
|
|
4057
4114
|
this.connection = config.connection;
|
|
4058
4115
|
} else {
|
|
4059
4116
|
const endpoint = config.endpoint ?? CLUSTER_ENDPOINTS[config.cluster ?? "mainnet-beta"];
|
|
4060
|
-
this.connection = new
|
|
4117
|
+
this.connection = new import_web38.Connection(endpoint, "confirmed");
|
|
4061
4118
|
}
|
|
4062
4119
|
}
|
|
4063
4120
|
/**
|
|
@@ -4153,7 +4210,7 @@ var init_generic = __esm({
|
|
|
4153
4210
|
// src/chains/solana/providers/quicknode.ts
|
|
4154
4211
|
function validateSolanaAddress2(address, paramName) {
|
|
4155
4212
|
try {
|
|
4156
|
-
return new
|
|
4213
|
+
return new import_web39.PublicKey(address);
|
|
4157
4214
|
} catch {
|
|
4158
4215
|
throw new ValidationError("invalid Solana address format", paramName, void 0, "SIP_2007" /* INVALID_ADDRESS */);
|
|
4159
4216
|
}
|
|
@@ -4163,11 +4220,11 @@ function getGrpcEndpoint(rpcEndpoint) {
|
|
|
4163
4220
|
url.port = "10000";
|
|
4164
4221
|
return url.origin + url.pathname.replace(/\/$/, "");
|
|
4165
4222
|
}
|
|
4166
|
-
var
|
|
4223
|
+
var import_web39, import_spl_token5, import_yellowstone_grpc, import_base, QuickNodeProvider;
|
|
4167
4224
|
var init_quicknode = __esm({
|
|
4168
4225
|
"src/chains/solana/providers/quicknode.ts"() {
|
|
4169
4226
|
"use strict";
|
|
4170
|
-
|
|
4227
|
+
import_web39 = require("@solana/web3.js");
|
|
4171
4228
|
import_spl_token5 = require("@solana/spl-token");
|
|
4172
4229
|
import_yellowstone_grpc = __toESM(require("@triton-one/yellowstone-grpc"));
|
|
4173
4230
|
import_base = require("@scure/base");
|
|
@@ -4202,7 +4259,7 @@ var init_quicknode = __esm({
|
|
|
4202
4259
|
"SIP_2001" /* INVALID_INPUT */
|
|
4203
4260
|
);
|
|
4204
4261
|
}
|
|
4205
|
-
this.connection = new
|
|
4262
|
+
this.connection = new import_web39.Connection(config.endpoint, "confirmed");
|
|
4206
4263
|
this.grpcEndpoint = getGrpcEndpoint(config.endpoint);
|
|
4207
4264
|
this.grpcEnabled = config.enableGrpc !== false;
|
|
4208
4265
|
}
|
|
@@ -4278,7 +4335,7 @@ var init_quicknode = __esm({
|
|
|
4278
4335
|
return cached;
|
|
4279
4336
|
}
|
|
4280
4337
|
try {
|
|
4281
|
-
const mintPubkey = new
|
|
4338
|
+
const mintPubkey = new import_web39.PublicKey(mint);
|
|
4282
4339
|
const mintInfo = await (0, import_spl_token5.getMint)(this.connection, mintPubkey);
|
|
4283
4340
|
const decimals = mintInfo.decimals;
|
|
4284
4341
|
this.mintDecimalsCache.set(mint, decimals);
|
|
@@ -4326,7 +4383,7 @@ var init_quicknode = __esm({
|
|
|
4326
4383
|
try {
|
|
4327
4384
|
const data = accountData.data;
|
|
4328
4385
|
if (data && data.length >= 72) {
|
|
4329
|
-
const mint = new
|
|
4386
|
+
const mint = new import_web39.PublicKey(data.slice(0, 32)).toBase58();
|
|
4330
4387
|
const amount = BigInt(
|
|
4331
4388
|
"0x" + Buffer.from(data.slice(64, 72)).reverse().toString("hex")
|
|
4332
4389
|
);
|
|
@@ -4428,16 +4485,16 @@ var init_quicknode = __esm({
|
|
|
4428
4485
|
// src/chains/solana/providers/triton.ts
|
|
4429
4486
|
function validateSolanaAddress3(address, paramName) {
|
|
4430
4487
|
try {
|
|
4431
|
-
return new
|
|
4488
|
+
return new import_web310.PublicKey(address);
|
|
4432
4489
|
} catch {
|
|
4433
4490
|
throw new ValidationError("invalid Solana address format", paramName, void 0, "SIP_2007" /* INVALID_ADDRESS */);
|
|
4434
4491
|
}
|
|
4435
4492
|
}
|
|
4436
|
-
var
|
|
4493
|
+
var import_web310, import_spl_token6, import_yellowstone_grpc2, import_base2, TRITON_RPC_ENDPOINTS, TRITON_GRPC_ENDPOINTS, TritonProvider;
|
|
4437
4494
|
var init_triton = __esm({
|
|
4438
4495
|
"src/chains/solana/providers/triton.ts"() {
|
|
4439
4496
|
"use strict";
|
|
4440
|
-
|
|
4497
|
+
import_web310 = require("@solana/web3.js");
|
|
4441
4498
|
import_spl_token6 = require("@solana/spl-token");
|
|
4442
4499
|
import_yellowstone_grpc2 = __toESM(require("@triton-one/yellowstone-grpc"));
|
|
4443
4500
|
import_base2 = require("@scure/base");
|
|
@@ -4474,7 +4531,7 @@ var init_triton = __esm({
|
|
|
4474
4531
|
const rpcEndpoint = config.endpoint ?? TRITON_RPC_ENDPOINTS[cluster];
|
|
4475
4532
|
const normalizedEndpoint = rpcEndpoint.replace(/\/$/, "");
|
|
4476
4533
|
const rpcUrl = normalizedEndpoint.includes("?") ? `${normalizedEndpoint}&x-token=${config.xToken}` : `${normalizedEndpoint}/${config.xToken}`;
|
|
4477
|
-
this.connection = new
|
|
4534
|
+
this.connection = new import_web310.Connection(rpcUrl, "confirmed");
|
|
4478
4535
|
this.grpcEndpoint = config.grpcEndpoint ?? TRITON_GRPC_ENDPOINTS[cluster];
|
|
4479
4536
|
this.xToken = config.xToken;
|
|
4480
4537
|
this.grpcEnabled = config.enableGrpc !== false;
|
|
@@ -4551,7 +4608,7 @@ var init_triton = __esm({
|
|
|
4551
4608
|
return cached;
|
|
4552
4609
|
}
|
|
4553
4610
|
try {
|
|
4554
|
-
const mintPubkey = new
|
|
4611
|
+
const mintPubkey = new import_web310.PublicKey(mint);
|
|
4555
4612
|
const mintInfo = await (0, import_spl_token6.getMint)(this.connection, mintPubkey);
|
|
4556
4613
|
const decimals = mintInfo.decimals;
|
|
4557
4614
|
this.mintDecimalsCache.set(mint, decimals);
|
|
@@ -4602,7 +4659,7 @@ var init_triton = __esm({
|
|
|
4602
4659
|
try {
|
|
4603
4660
|
const data = accountData.data;
|
|
4604
4661
|
if (data && data.length >= 72) {
|
|
4605
|
-
const mint = new
|
|
4662
|
+
const mint = new import_web310.PublicKey(data.slice(0, 32)).toBase58();
|
|
4606
4663
|
const amount = BigInt(
|
|
4607
4664
|
"0x" + Buffer.from(data.slice(64, 72)).reverse().toString("hex")
|
|
4608
4665
|
);
|
|
@@ -4759,7 +4816,7 @@ function verifyWebhookSignature(rawBody, signature, secret) {
|
|
|
4759
4816
|
}
|
|
4760
4817
|
try {
|
|
4761
4818
|
const encoder = new TextEncoder();
|
|
4762
|
-
const expectedSignature = (0,
|
|
4819
|
+
const expectedSignature = (0, import_utils24.bytesToHex)(
|
|
4763
4820
|
(0, import_hmac2.hmac)(import_sha2567.sha256, encoder.encode(secret), encoder.encode(rawBody))
|
|
4764
4821
|
);
|
|
4765
4822
|
if (signature.length !== expectedSignature.length) {
|
|
@@ -4938,6 +4995,7 @@ async function processRawTransaction(tx, viewingPrivateKey, spendingPublicKey, o
|
|
|
4938
4995
|
const payment = {
|
|
4939
4996
|
stealthAddress: announcement.stealthAddress || "",
|
|
4940
4997
|
ephemeralPublicKey: announcement.ephemeralPublicKey,
|
|
4998
|
+
version: announcement.version,
|
|
4941
4999
|
amount: transferInfo?.amount ?? 0n,
|
|
4942
5000
|
mint: transferInfo?.mint ?? "",
|
|
4943
5001
|
tokenSymbol: transferInfo?.mint ? getTokenSymbol(transferInfo.mint) : void 0,
|
|
@@ -4977,7 +5035,7 @@ async function processWebhookTransaction(transaction, viewingPrivateKey, spendin
|
|
|
4977
5035
|
);
|
|
4978
5036
|
return result.found ? result.payment ?? null : null;
|
|
4979
5037
|
}
|
|
4980
|
-
var import_hmac2, import_sha2567,
|
|
5038
|
+
var import_hmac2, import_sha2567, import_utils24;
|
|
4981
5039
|
var init_webhook = __esm({
|
|
4982
5040
|
"src/chains/solana/providers/webhook.ts"() {
|
|
4983
5041
|
"use strict";
|
|
@@ -4988,7 +5046,7 @@ var init_webhook = __esm({
|
|
|
4988
5046
|
init_errors();
|
|
4989
5047
|
import_hmac2 = require("@noble/hashes/hmac");
|
|
4990
5048
|
import_sha2567 = require("@noble/hashes/sha256");
|
|
4991
|
-
|
|
5049
|
+
import_utils24 = require("@noble/hashes/utils");
|
|
4992
5050
|
}
|
|
4993
5051
|
});
|
|
4994
5052
|
|
|
@@ -5421,11 +5479,11 @@ var init_providers = __esm({
|
|
|
5421
5479
|
function createSolanaPrivacyAdapter(config) {
|
|
5422
5480
|
return new SolanaPrivacyAdapter(config);
|
|
5423
5481
|
}
|
|
5424
|
-
var
|
|
5482
|
+
var import_web311, SolanaPrivacyAdapter;
|
|
5425
5483
|
var init_privacy_adapter = __esm({
|
|
5426
5484
|
"src/chains/solana/privacy-adapter.ts"() {
|
|
5427
5485
|
"use strict";
|
|
5428
|
-
|
|
5486
|
+
import_web311 = require("@solana/web3.js");
|
|
5429
5487
|
init_stealth2();
|
|
5430
5488
|
init_transfer();
|
|
5431
5489
|
init_scan();
|
|
@@ -5655,7 +5713,8 @@ var init_privacy_adapter = __esm({
|
|
|
5655
5713
|
viewingPrivateKey: params.viewingPrivateKey,
|
|
5656
5714
|
spendingPrivateKey: params.spendingPrivateKey,
|
|
5657
5715
|
destinationAddress: params.destinationAddress,
|
|
5658
|
-
mint: new
|
|
5716
|
+
mint: new import_web311.PublicKey(params.payment.mint),
|
|
5717
|
+
version: params.payment.version
|
|
5659
5718
|
});
|
|
5660
5719
|
}
|
|
5661
5720
|
/**
|
|
@@ -5894,7 +5953,7 @@ function generateH2() {
|
|
|
5894
5953
|
if (!point.equals(import_ed255197.ed25519.ExtendedPoint.ZERO)) {
|
|
5895
5954
|
const gBytes = G2.toRawBytes();
|
|
5896
5955
|
const hBytes = point.toRawBytes();
|
|
5897
|
-
if ((0,
|
|
5956
|
+
if ((0, import_utils26.bytesToHex)(gBytes) !== (0, import_utils26.bytesToHex)(hBytes)) {
|
|
5898
5957
|
return point;
|
|
5899
5958
|
}
|
|
5900
5959
|
}
|
|
@@ -5922,13 +5981,13 @@ function commitSolana(value, blinding) {
|
|
|
5922
5981
|
{ curveOrder: ED25519_ORDER2.toString(16) }
|
|
5923
5982
|
);
|
|
5924
5983
|
}
|
|
5925
|
-
const r = blinding ?? (0,
|
|
5984
|
+
const r = blinding ?? (0, import_utils26.randomBytes)(32);
|
|
5926
5985
|
if (r.length !== 32) {
|
|
5927
5986
|
throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
|
|
5928
5987
|
}
|
|
5929
5988
|
const rScalar = bytesToBigInt3(r) % ED25519_ORDER2;
|
|
5930
5989
|
if (rScalar === 0n) {
|
|
5931
|
-
return commitSolana(value, (0,
|
|
5990
|
+
return commitSolana(value, (0, import_utils26.randomBytes)(32));
|
|
5932
5991
|
}
|
|
5933
5992
|
let C;
|
|
5934
5993
|
if (value === 0n) {
|
|
@@ -5940,8 +5999,8 @@ function commitSolana(value, blinding) {
|
|
|
5940
5999
|
}
|
|
5941
6000
|
const rScalarBytes = bigIntToBytes3(rScalar, 32);
|
|
5942
6001
|
return {
|
|
5943
|
-
commitment: `0x${(0,
|
|
5944
|
-
blinding: `0x${(0,
|
|
6002
|
+
commitment: `0x${(0, import_utils26.bytesToHex)(C.toRawBytes())}`,
|
|
6003
|
+
blinding: `0x${(0, import_utils26.bytesToHex)(rScalarBytes)}`
|
|
5945
6004
|
};
|
|
5946
6005
|
}
|
|
5947
6006
|
function verifyOpeningSolana(commitment, value, blinding) {
|
|
@@ -6027,7 +6086,7 @@ function addCommitmentsSolana(c1, c2) {
|
|
|
6027
6086
|
}
|
|
6028
6087
|
const sum = point1.add(point2);
|
|
6029
6088
|
return {
|
|
6030
|
-
commitment: `0x${(0,
|
|
6089
|
+
commitment: `0x${(0, import_utils26.bytesToHex)(sum.toRawBytes())}`
|
|
6031
6090
|
};
|
|
6032
6091
|
}
|
|
6033
6092
|
function subtractCommitmentsSolana(c1, c2) {
|
|
@@ -6056,7 +6115,7 @@ function subtractCommitmentsSolana(c1, c2) {
|
|
|
6056
6115
|
};
|
|
6057
6116
|
}
|
|
6058
6117
|
return {
|
|
6059
|
-
commitment: `0x${(0,
|
|
6118
|
+
commitment: `0x${(0, import_utils26.bytesToHex)(diff.toRawBytes())}`
|
|
6060
6119
|
};
|
|
6061
6120
|
}
|
|
6062
6121
|
function addBlindingsSolana(b1, b2) {
|
|
@@ -6064,23 +6123,23 @@ function addBlindingsSolana(b1, b2) {
|
|
|
6064
6123
|
const r2 = bytesToBigInt3(hexToBytes9(b2.slice(2)));
|
|
6065
6124
|
const sum = (r1 + r2) % ED25519_ORDER2;
|
|
6066
6125
|
const sumBytes = bigIntToBytes3(sum, 32);
|
|
6067
|
-
return `0x${(0,
|
|
6126
|
+
return `0x${(0, import_utils26.bytesToHex)(sumBytes)}`;
|
|
6068
6127
|
}
|
|
6069
6128
|
function subtractBlindingsSolana(b1, b2) {
|
|
6070
6129
|
const r1 = bytesToBigInt3(hexToBytes9(b1.slice(2)));
|
|
6071
6130
|
const r2 = bytesToBigInt3(hexToBytes9(b2.slice(2)));
|
|
6072
6131
|
const diff = (r1 - r2 + ED25519_ORDER2) % ED25519_ORDER2;
|
|
6073
6132
|
const diffBytes = bigIntToBytes3(diff, 32);
|
|
6074
|
-
return `0x${(0,
|
|
6133
|
+
return `0x${(0, import_utils26.bytesToHex)(diffBytes)}`;
|
|
6075
6134
|
}
|
|
6076
6135
|
function getGeneratorsSolana() {
|
|
6077
6136
|
return {
|
|
6078
|
-
G: `0x${(0,
|
|
6079
|
-
H: `0x${(0,
|
|
6137
|
+
G: `0x${(0, import_utils26.bytesToHex)(G2.toRawBytes())}`,
|
|
6138
|
+
H: `0x${(0, import_utils26.bytesToHex)(H2.toRawBytes())}`
|
|
6080
6139
|
};
|
|
6081
6140
|
}
|
|
6082
6141
|
function generateBlindingSolana() {
|
|
6083
|
-
return `0x${(0,
|
|
6142
|
+
return `0x${(0, import_utils26.bytesToHex)((0, import_utils26.randomBytes)(32))}`;
|
|
6084
6143
|
}
|
|
6085
6144
|
function bytesToBigInt3(bytes) {
|
|
6086
6145
|
let result = 0n;
|
|
@@ -6105,13 +6164,13 @@ function hexToBytes9(hex) {
|
|
|
6105
6164
|
}
|
|
6106
6165
|
return bytes;
|
|
6107
6166
|
}
|
|
6108
|
-
var import_ed255197, import_sha22,
|
|
6167
|
+
var import_ed255197, import_sha22, import_utils26, H_DOMAIN2, G2, ED25519_ORDER2, ED25519_COFACTOR, MAX_SPL_AMOUNT, H2;
|
|
6109
6168
|
var init_commitment2 = __esm({
|
|
6110
6169
|
"src/chains/solana/commitment.ts"() {
|
|
6111
6170
|
"use strict";
|
|
6112
6171
|
import_ed255197 = require("@noble/curves/ed25519");
|
|
6113
6172
|
import_sha22 = require("@noble/hashes/sha2");
|
|
6114
|
-
|
|
6173
|
+
import_utils26 = require("@noble/hashes/utils");
|
|
6115
6174
|
init_errors();
|
|
6116
6175
|
init_validation();
|
|
6117
6176
|
H_DOMAIN2 = "SIP-SOLANA-PEDERSEN-GENERATOR-H-v1";
|
|
@@ -6131,7 +6190,7 @@ function generateViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
6131
6190
|
"spendingPrivateKey"
|
|
6132
6191
|
);
|
|
6133
6192
|
}
|
|
6134
|
-
const spendingBytes = (0,
|
|
6193
|
+
const spendingBytes = (0, import_utils27.hexToBytes)(spendingPrivateKey.slice(2));
|
|
6135
6194
|
if (spendingBytes.length !== 32) {
|
|
6136
6195
|
throw new ValidationError(
|
|
6137
6196
|
"spendingPrivateKey must be 32 bytes",
|
|
@@ -6142,15 +6201,15 @@ function generateViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
6142
6201
|
try {
|
|
6143
6202
|
viewingPrivateBytes = (0, import_hmac4.hmac)(
|
|
6144
6203
|
import_sha2568.sha256,
|
|
6145
|
-
(0,
|
|
6204
|
+
(0, import_utils27.utf8ToBytes)(VIEWING_KEY_CONTEXT2),
|
|
6146
6205
|
spendingBytes
|
|
6147
6206
|
);
|
|
6148
6207
|
const viewingPublicBytes = import_ed255198.ed25519.getPublicKey(viewingPrivateBytes);
|
|
6149
6208
|
const hashBytes = (0, import_sha2568.sha256)(viewingPublicBytes);
|
|
6150
6209
|
return {
|
|
6151
|
-
privateKey: `0x${(0,
|
|
6152
|
-
publicKey: `0x${(0,
|
|
6153
|
-
hash: `0x${(0,
|
|
6210
|
+
privateKey: `0x${(0, import_utils27.bytesToHex)(viewingPrivateBytes)}`,
|
|
6211
|
+
publicKey: `0x${(0, import_utils27.bytesToHex)(viewingPublicBytes)}`,
|
|
6212
|
+
hash: `0x${(0, import_utils27.bytesToHex)(hashBytes)}`,
|
|
6154
6213
|
label,
|
|
6155
6214
|
createdAt: Date.now()
|
|
6156
6215
|
};
|
|
@@ -6160,14 +6219,14 @@ function generateViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
6160
6219
|
}
|
|
6161
6220
|
}
|
|
6162
6221
|
function generateRandomViewingKey(label) {
|
|
6163
|
-
const privateBytes = (0,
|
|
6222
|
+
const privateBytes = (0, import_utils27.randomBytes)(32);
|
|
6164
6223
|
try {
|
|
6165
6224
|
const publicBytes = import_ed255198.ed25519.getPublicKey(privateBytes);
|
|
6166
6225
|
const hashBytes = (0, import_sha2568.sha256)(publicBytes);
|
|
6167
6226
|
return {
|
|
6168
|
-
privateKey: `0x${(0,
|
|
6169
|
-
publicKey: `0x${(0,
|
|
6170
|
-
hash: `0x${(0,
|
|
6227
|
+
privateKey: `0x${(0, import_utils27.bytesToHex)(privateBytes)}`,
|
|
6228
|
+
publicKey: `0x${(0, import_utils27.bytesToHex)(publicBytes)}`,
|
|
6229
|
+
hash: `0x${(0, import_utils27.bytesToHex)(hashBytes)}`,
|
|
6171
6230
|
label,
|
|
6172
6231
|
createdAt: Date.now()
|
|
6173
6232
|
};
|
|
@@ -6182,7 +6241,7 @@ function computeViewingKeyHash(viewingPublicKey) {
|
|
|
6182
6241
|
"viewingPublicKey"
|
|
6183
6242
|
);
|
|
6184
6243
|
}
|
|
6185
|
-
const publicBytes = (0,
|
|
6244
|
+
const publicBytes = (0, import_utils27.hexToBytes)(viewingPublicKey.slice(2));
|
|
6186
6245
|
if (publicBytes.length !== 32) {
|
|
6187
6246
|
throw new ValidationError(
|
|
6188
6247
|
"viewingPublicKey must be 32 bytes",
|
|
@@ -6190,7 +6249,7 @@ function computeViewingKeyHash(viewingPublicKey) {
|
|
|
6190
6249
|
);
|
|
6191
6250
|
}
|
|
6192
6251
|
const hashBytes = (0, import_sha2568.sha256)(publicBytes);
|
|
6193
|
-
return `0x${(0,
|
|
6252
|
+
return `0x${(0, import_utils27.bytesToHex)(hashBytes)}`;
|
|
6194
6253
|
}
|
|
6195
6254
|
function computeViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
6196
6255
|
if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
|
|
@@ -6199,7 +6258,7 @@ function computeViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
6199
6258
|
"viewingPrivateKey"
|
|
6200
6259
|
);
|
|
6201
6260
|
}
|
|
6202
|
-
const privateBytes = (0,
|
|
6261
|
+
const privateBytes = (0, import_utils27.hexToBytes)(viewingPrivateKey.slice(2));
|
|
6203
6262
|
if (privateBytes.length !== 32) {
|
|
6204
6263
|
throw new ValidationError(
|
|
6205
6264
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -6209,7 +6268,7 @@ function computeViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
6209
6268
|
try {
|
|
6210
6269
|
const publicBytes = import_ed255198.ed25519.getPublicKey(privateBytes);
|
|
6211
6270
|
const hashBytes = (0, import_sha2568.sha256)(publicBytes);
|
|
6212
|
-
return `0x${(0,
|
|
6271
|
+
return `0x${(0, import_utils27.bytesToHex)(hashBytes)}`;
|
|
6213
6272
|
} finally {
|
|
6214
6273
|
secureWipe(privateBytes);
|
|
6215
6274
|
}
|
|
@@ -6256,9 +6315,9 @@ function importViewingKey(exported) {
|
|
|
6256
6315
|
{ expected: computedHash, received: exported.hash }
|
|
6257
6316
|
);
|
|
6258
6317
|
}
|
|
6259
|
-
const privateBytes = (0,
|
|
6318
|
+
const privateBytes = (0, import_utils27.hexToBytes)(exported.privateKey.slice(2));
|
|
6260
6319
|
try {
|
|
6261
|
-
const derivedPublic = `0x${(0,
|
|
6320
|
+
const derivedPublic = `0x${(0, import_utils27.bytesToHex)(import_ed255198.ed25519.getPublicKey(privateBytes))}`;
|
|
6262
6321
|
if (derivedPublic !== exported.publicKey) {
|
|
6263
6322
|
throw new ValidationError(
|
|
6264
6323
|
"Public key does not match private key",
|
|
@@ -6277,10 +6336,10 @@ function importViewingKey(exported) {
|
|
|
6277
6336
|
};
|
|
6278
6337
|
}
|
|
6279
6338
|
function deriveEncryptionKey2(key, salt) {
|
|
6280
|
-
const keyBytes = (0,
|
|
6339
|
+
const keyBytes = (0, import_utils27.hexToBytes)(key.slice(2));
|
|
6281
6340
|
try {
|
|
6282
|
-
const hkdfSalt = salt ?? (0,
|
|
6283
|
-
return (0, import_hkdf2.hkdf)(import_sha2568.sha256, keyBytes, hkdfSalt, (0,
|
|
6341
|
+
const hkdfSalt = salt ?? (0, import_utils27.utf8ToBytes)(ENCRYPTION_DOMAIN2);
|
|
6342
|
+
return (0, import_hkdf2.hkdf)(import_sha2568.sha256, keyBytes, hkdfSalt, (0, import_utils27.utf8ToBytes)("encryption"), 32);
|
|
6284
6343
|
} finally {
|
|
6285
6344
|
secureWipe(keyBytes);
|
|
6286
6345
|
}
|
|
@@ -6288,13 +6347,13 @@ function deriveEncryptionKey2(key, salt) {
|
|
|
6288
6347
|
function encryptForViewing2(data, viewingKey) {
|
|
6289
6348
|
const encKey = deriveEncryptionKey2(viewingKey.privateKey);
|
|
6290
6349
|
try {
|
|
6291
|
-
const nonce = (0,
|
|
6292
|
-
const plaintext = (0,
|
|
6350
|
+
const nonce = (0, import_utils27.randomBytes)(NONCE_SIZE2);
|
|
6351
|
+
const plaintext = (0, import_utils27.utf8ToBytes)(JSON.stringify(data));
|
|
6293
6352
|
const cipher = (0, import_chacha2.xchacha20poly1305)(encKey, nonce);
|
|
6294
6353
|
const ciphertext = cipher.encrypt(plaintext);
|
|
6295
6354
|
return {
|
|
6296
|
-
ciphertext: `0x${(0,
|
|
6297
|
-
nonce: `0x${(0,
|
|
6355
|
+
ciphertext: `0x${(0, import_utils27.bytesToHex)(ciphertext)}`,
|
|
6356
|
+
nonce: `0x${(0, import_utils27.bytesToHex)(nonce)}`,
|
|
6298
6357
|
viewingKeyHash: viewingKey.hash
|
|
6299
6358
|
};
|
|
6300
6359
|
} finally {
|
|
@@ -6311,8 +6370,8 @@ function decryptWithViewing2(encrypted, viewingKey) {
|
|
|
6311
6370
|
}
|
|
6312
6371
|
const encKey = deriveEncryptionKey2(viewingKey.privateKey);
|
|
6313
6372
|
try {
|
|
6314
|
-
const ciphertext = (0,
|
|
6315
|
-
const nonce = (0,
|
|
6373
|
+
const ciphertext = (0, import_utils27.hexToBytes)(encrypted.ciphertext.slice(2));
|
|
6374
|
+
const nonce = (0, import_utils27.hexToBytes)(encrypted.nonce.slice(2));
|
|
6316
6375
|
if (nonce.length !== NONCE_SIZE2) {
|
|
6317
6376
|
throw new ValidationError(
|
|
6318
6377
|
`Invalid nonce length: ${nonce.length}. Expected: ${NONCE_SIZE2}`,
|
|
@@ -6362,15 +6421,15 @@ function deriveChildViewingKey(parentKey, childPath, label) {
|
|
|
6362
6421
|
if (!childPath || typeof childPath !== "string") {
|
|
6363
6422
|
throw new ValidationError("childPath must be a non-empty string", "childPath");
|
|
6364
6423
|
}
|
|
6365
|
-
const parentBytes = (0,
|
|
6424
|
+
const parentBytes = (0, import_utils27.hexToBytes)(parentKey.privateKey.slice(2));
|
|
6366
6425
|
try {
|
|
6367
|
-
const childBytes = (0, import_hmac4.hmac)(import_sha2568.sha256, (0,
|
|
6426
|
+
const childBytes = (0, import_hmac4.hmac)(import_sha2568.sha256, (0, import_utils27.utf8ToBytes)(childPath), parentBytes);
|
|
6368
6427
|
const publicBytes = import_ed255198.ed25519.getPublicKey(childBytes);
|
|
6369
6428
|
const hashBytes = (0, import_sha2568.sha256)(publicBytes);
|
|
6370
6429
|
const result = {
|
|
6371
|
-
privateKey: `0x${(0,
|
|
6372
|
-
publicKey: `0x${(0,
|
|
6373
|
-
hash: `0x${(0,
|
|
6430
|
+
privateKey: `0x${(0, import_utils27.bytesToHex)(childBytes)}`,
|
|
6431
|
+
publicKey: `0x${(0, import_utils27.bytesToHex)(publicBytes)}`,
|
|
6432
|
+
hash: `0x${(0, import_utils27.bytesToHex)(hashBytes)}`,
|
|
6374
6433
|
label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
|
|
6375
6434
|
createdAt: Date.now()
|
|
6376
6435
|
};
|
|
@@ -6387,7 +6446,7 @@ function getViewingPublicKey(viewingPrivateKey) {
|
|
|
6387
6446
|
"viewingPrivateKey"
|
|
6388
6447
|
);
|
|
6389
6448
|
}
|
|
6390
|
-
const privateBytes = (0,
|
|
6449
|
+
const privateBytes = (0, import_utils27.hexToBytes)(viewingPrivateKey.slice(2));
|
|
6391
6450
|
if (privateBytes.length !== 32) {
|
|
6392
6451
|
throw new ValidationError(
|
|
6393
6452
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -6396,12 +6455,12 @@ function getViewingPublicKey(viewingPrivateKey) {
|
|
|
6396
6455
|
}
|
|
6397
6456
|
try {
|
|
6398
6457
|
const publicBytes = import_ed255198.ed25519.getPublicKey(privateBytes);
|
|
6399
|
-
return `0x${(0,
|
|
6458
|
+
return `0x${(0, import_utils27.bytesToHex)(publicBytes)}`;
|
|
6400
6459
|
} finally {
|
|
6401
6460
|
secureWipe(privateBytes);
|
|
6402
6461
|
}
|
|
6403
6462
|
}
|
|
6404
|
-
var import_ed255198, import_sha2568, import_hmac4, import_hkdf2,
|
|
6463
|
+
var import_ed255198, import_sha2568, import_hmac4, import_hkdf2, import_utils27, import_chacha2, VIEWING_KEY_CONTEXT2, ENCRYPTION_DOMAIN2, NONCE_SIZE2, EXPORT_VERSION;
|
|
6405
6464
|
var init_viewing_key = __esm({
|
|
6406
6465
|
"src/chains/solana/viewing-key.ts"() {
|
|
6407
6466
|
"use strict";
|
|
@@ -6409,7 +6468,7 @@ var init_viewing_key = __esm({
|
|
|
6409
6468
|
import_sha2568 = require("@noble/hashes/sha256");
|
|
6410
6469
|
import_hmac4 = require("@noble/hashes/hmac");
|
|
6411
6470
|
import_hkdf2 = require("@noble/hashes/hkdf");
|
|
6412
|
-
|
|
6471
|
+
import_utils27 = require("@noble/hashes/utils");
|
|
6413
6472
|
import_chacha2 = require("@noble/ciphers/chacha.js");
|
|
6414
6473
|
init_errors();
|
|
6415
6474
|
init_validation();
|
|
@@ -6429,7 +6488,7 @@ function toAddress(pubkey) {
|
|
|
6429
6488
|
return (0, import_compat.fromLegacyPublicKey)(pubkey);
|
|
6430
6489
|
}
|
|
6431
6490
|
function toPublicKey(addr) {
|
|
6432
|
-
return new
|
|
6491
|
+
return new import_web312.PublicKey(addr);
|
|
6433
6492
|
}
|
|
6434
6493
|
function createAddress(base583) {
|
|
6435
6494
|
return (0, import_kit.address)(base583);
|
|
@@ -6447,7 +6506,7 @@ function createDualRpcClient(endpoint, wsEndpoint, commitment = "confirmed") {
|
|
|
6447
6506
|
const derivedWsEndpoint = wsEndpoint ?? deriveWsEndpoint(endpoint);
|
|
6448
6507
|
const rpc = (0, import_kit.createSolanaRpc)(endpoint);
|
|
6449
6508
|
const rpcSubscriptions = (0, import_kit.createSolanaRpcSubscriptions)(derivedWsEndpoint);
|
|
6450
|
-
const legacyConnection = new
|
|
6509
|
+
const legacyConnection = new import_web312.Connection(endpoint, {
|
|
6451
6510
|
commitment,
|
|
6452
6511
|
wsEndpoint: derivedWsEndpoint
|
|
6453
6512
|
});
|
|
@@ -6486,28 +6545,28 @@ function isAddress(value) {
|
|
|
6486
6545
|
return typeof value === "string" && value.length >= 32 && value.length <= 44;
|
|
6487
6546
|
}
|
|
6488
6547
|
function isPublicKey(value) {
|
|
6489
|
-
return value instanceof
|
|
6548
|
+
return value instanceof import_web312.PublicKey;
|
|
6490
6549
|
}
|
|
6491
6550
|
function normalizeAddress(input) {
|
|
6492
6551
|
let base583;
|
|
6493
|
-
if (input instanceof
|
|
6552
|
+
if (input instanceof import_web312.PublicKey) {
|
|
6494
6553
|
base583 = input.toBase58();
|
|
6495
6554
|
} else {
|
|
6496
6555
|
base583 = input;
|
|
6497
6556
|
}
|
|
6498
6557
|
return {
|
|
6499
6558
|
address: (0, import_kit.address)(base583),
|
|
6500
|
-
publicKey: new
|
|
6559
|
+
publicKey: new import_web312.PublicKey(base583),
|
|
6501
6560
|
base58: base583
|
|
6502
6561
|
};
|
|
6503
6562
|
}
|
|
6504
|
-
var import_kit, import_compat,
|
|
6563
|
+
var import_kit, import_compat, import_web312, LAMPORTS_PER_SOL2, RpcHelpers;
|
|
6505
6564
|
var init_kit_compat = __esm({
|
|
6506
6565
|
"src/chains/solana/kit-compat.ts"() {
|
|
6507
6566
|
"use strict";
|
|
6508
6567
|
import_kit = require("@solana/kit");
|
|
6509
6568
|
import_compat = require("@solana/compat");
|
|
6510
|
-
|
|
6569
|
+
import_web312 = require("@solana/web3.js");
|
|
6511
6570
|
LAMPORTS_PER_SOL2 = 1000000000n;
|
|
6512
6571
|
RpcHelpers = {
|
|
6513
6572
|
/**
|
|
@@ -10787,7 +10846,7 @@ var require_dist = __commonJS({
|
|
|
10787
10846
|
var http = __importStar(require("http"));
|
|
10788
10847
|
var https_1 = require("https");
|
|
10789
10848
|
__exportStar(require_helpers3(), exports2);
|
|
10790
|
-
var INTERNAL = Symbol("AgentBaseInternalState");
|
|
10849
|
+
var INTERNAL = /* @__PURE__ */ Symbol("AgentBaseInternalState");
|
|
10791
10850
|
var Agent = class extends http.Agent {
|
|
10792
10851
|
constructor(opts) {
|
|
10793
10852
|
super(opts);
|
|
@@ -12395,12 +12454,12 @@ function createClusterClient(cluster, options = {}) {
|
|
|
12395
12454
|
...options
|
|
12396
12455
|
});
|
|
12397
12456
|
}
|
|
12398
|
-
var import_kit2,
|
|
12457
|
+
var import_kit2, import_web313, RPCErrorType, SolanaRPCClient, RPC_ENDPOINTS;
|
|
12399
12458
|
var init_rpc_client = __esm({
|
|
12400
12459
|
"src/chains/solana/rpc-client.ts"() {
|
|
12401
12460
|
"use strict";
|
|
12402
12461
|
import_kit2 = require("@solana/kit");
|
|
12403
|
-
|
|
12462
|
+
import_web313 = require("@solana/web3.js");
|
|
12404
12463
|
init_kit_compat();
|
|
12405
12464
|
init_proxy();
|
|
12406
12465
|
RPCErrorType = /* @__PURE__ */ ((RPCErrorType2) => {
|
|
@@ -12513,7 +12572,7 @@ var init_rpc_client = __esm({
|
|
|
12513
12572
|
return {
|
|
12514
12573
|
rpc: (0, import_kit2.createSolanaRpc)(endpoint),
|
|
12515
12574
|
rpcSubscriptions: (0, import_kit2.createSolanaRpcSubscriptions)(wsEndpoint),
|
|
12516
|
-
legacyConnection: new
|
|
12575
|
+
legacyConnection: new import_web313.Connection(endpoint, connectionOptions),
|
|
12517
12576
|
endpoint
|
|
12518
12577
|
};
|
|
12519
12578
|
}
|
|
@@ -12585,7 +12644,7 @@ var init_rpc_client = __esm({
|
|
|
12585
12644
|
...sendOptions
|
|
12586
12645
|
} = options;
|
|
12587
12646
|
let txToSend = transaction;
|
|
12588
|
-
if (this.usePriorityFees && !skipPriorityFee && transaction instanceof
|
|
12647
|
+
if (this.usePriorityFees && !skipPriorityFee && transaction instanceof import_web313.Transaction) {
|
|
12589
12648
|
txToSend = await this.addPriorityFee(
|
|
12590
12649
|
transaction,
|
|
12591
12650
|
priorityFeeMicroLamports,
|
|
@@ -12728,14 +12787,14 @@ var init_rpc_client = __esm({
|
|
|
12728
12787
|
const estimate = await this.estimatePriorityFee(transaction);
|
|
12729
12788
|
feeToUse = estimate.microLamportsPerComputeUnit;
|
|
12730
12789
|
}
|
|
12731
|
-
const modifiedTx = new
|
|
12790
|
+
const modifiedTx = new import_web313.Transaction();
|
|
12732
12791
|
modifiedTx.add(
|
|
12733
|
-
|
|
12792
|
+
import_web313.ComputeBudgetProgram.setComputeUnitLimit({
|
|
12734
12793
|
units: computeUnitLimit ?? 2e5
|
|
12735
12794
|
})
|
|
12736
12795
|
);
|
|
12737
12796
|
modifiedTx.add(
|
|
12738
|
-
|
|
12797
|
+
import_web313.ComputeBudgetProgram.setComputeUnitPrice({
|
|
12739
12798
|
microLamports: feeToUse
|
|
12740
12799
|
})
|
|
12741
12800
|
);
|
|
@@ -13025,9 +13084,9 @@ function estimateComputeUnits(instructions) {
|
|
|
13025
13084
|
units += 3e4;
|
|
13026
13085
|
} else if (programId === MEMO_PROGRAM_ID) {
|
|
13027
13086
|
units += 2e3;
|
|
13028
|
-
} else if (programId ===
|
|
13087
|
+
} else if (programId === import_web314.SystemProgram.programId.toBase58()) {
|
|
13029
13088
|
units += 3e3;
|
|
13030
|
-
} else if (programId ===
|
|
13089
|
+
} else if (programId === import_web314.ComputeBudgetProgram.programId.toBase58()) {
|
|
13031
13090
|
units += 500;
|
|
13032
13091
|
}
|
|
13033
13092
|
}
|
|
@@ -13047,11 +13106,11 @@ function calculatePriorityFee(priority) {
|
|
|
13047
13106
|
return 1e3;
|
|
13048
13107
|
}
|
|
13049
13108
|
}
|
|
13050
|
-
var
|
|
13109
|
+
var import_web314, import_spl_token7, DEFAULT_COMPUTE_UNITS, DEFAULT_PRIORITY_FEE, MIN_COMPUTE_UNITS, MAX_COMPUTE_UNITS, ShieldedTransactionType, ShieldedTransactionBuilder;
|
|
13051
13110
|
var init_transaction_builder = __esm({
|
|
13052
13111
|
"src/chains/solana/transaction-builder.ts"() {
|
|
13053
13112
|
"use strict";
|
|
13054
|
-
|
|
13113
|
+
import_web314 = require("@solana/web3.js");
|
|
13055
13114
|
import_spl_token7 = require("@solana/spl-token");
|
|
13056
13115
|
init_stealth2();
|
|
13057
13116
|
init_types();
|
|
@@ -13106,14 +13165,14 @@ var init_transaction_builder = __esm({
|
|
|
13106
13165
|
}
|
|
13107
13166
|
const { stealthAddress } = generateEd25519StealthAddress(recipientMetaAddress);
|
|
13108
13167
|
const stealthAddressBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
|
|
13109
|
-
const stealthPubkey = new
|
|
13168
|
+
const stealthPubkey = new import_web314.PublicKey(stealthAddressBase58);
|
|
13110
13169
|
const ephemeralPubkeyBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.ephemeralPublicKey);
|
|
13111
13170
|
const stealthATA = await (0, import_spl_token7.getAssociatedTokenAddress)(mint, stealthPubkey, true);
|
|
13112
13171
|
const instructions = [];
|
|
13113
13172
|
if (this.priorityFee > 0) {
|
|
13114
13173
|
instructions.push(
|
|
13115
|
-
|
|
13116
|
-
|
|
13174
|
+
import_web314.ComputeBudgetProgram.setComputeUnitLimit({ units: this.computeUnits }),
|
|
13175
|
+
import_web314.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
|
|
13117
13176
|
);
|
|
13118
13177
|
}
|
|
13119
13178
|
let needsAtaCreation = false;
|
|
@@ -13145,9 +13204,9 @@ var init_transaction_builder = __esm({
|
|
|
13145
13204
|
stealthAddressBase58
|
|
13146
13205
|
);
|
|
13147
13206
|
instructions.push(
|
|
13148
|
-
new
|
|
13207
|
+
new import_web314.TransactionInstruction({
|
|
13149
13208
|
keys: [],
|
|
13150
|
-
programId: new
|
|
13209
|
+
programId: new import_web314.PublicKey(MEMO_PROGRAM_ID),
|
|
13151
13210
|
data: Buffer.from(memoContent, "utf-8")
|
|
13152
13211
|
})
|
|
13153
13212
|
);
|
|
@@ -13179,17 +13238,17 @@ var init_transaction_builder = __esm({
|
|
|
13179
13238
|
}
|
|
13180
13239
|
const { stealthAddress } = generateEd25519StealthAddress(recipientMetaAddress);
|
|
13181
13240
|
const stealthAddressBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
|
|
13182
|
-
const stealthPubkey = new
|
|
13241
|
+
const stealthPubkey = new import_web314.PublicKey(stealthAddressBase58);
|
|
13183
13242
|
const ephemeralPubkeyBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.ephemeralPublicKey);
|
|
13184
13243
|
const instructions = [];
|
|
13185
13244
|
if (this.priorityFee > 0) {
|
|
13186
13245
|
instructions.push(
|
|
13187
|
-
|
|
13188
|
-
|
|
13246
|
+
import_web314.ComputeBudgetProgram.setComputeUnitLimit({ units: this.computeUnits }),
|
|
13247
|
+
import_web314.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
|
|
13189
13248
|
);
|
|
13190
13249
|
}
|
|
13191
13250
|
instructions.push(
|
|
13192
|
-
|
|
13251
|
+
import_web314.SystemProgram.transfer({
|
|
13193
13252
|
fromPubkey: sender,
|
|
13194
13253
|
toPubkey: stealthPubkey,
|
|
13195
13254
|
lamports: amount
|
|
@@ -13202,9 +13261,9 @@ var init_transaction_builder = __esm({
|
|
|
13202
13261
|
stealthAddressBase58
|
|
13203
13262
|
);
|
|
13204
13263
|
instructions.push(
|
|
13205
|
-
new
|
|
13264
|
+
new import_web314.TransactionInstruction({
|
|
13206
13265
|
keys: [],
|
|
13207
|
-
programId: new
|
|
13266
|
+
programId: new import_web314.PublicKey(MEMO_PROGRAM_ID),
|
|
13208
13267
|
data: Buffer.from(memoContent, "utf-8")
|
|
13209
13268
|
})
|
|
13210
13269
|
);
|
|
@@ -13237,8 +13296,8 @@ var init_transaction_builder = __esm({
|
|
|
13237
13296
|
);
|
|
13238
13297
|
if (this.priorityFee > 0) {
|
|
13239
13298
|
instructions.push(
|
|
13240
|
-
|
|
13241
|
-
|
|
13299
|
+
import_web314.ComputeBudgetProgram.setComputeUnitLimit({ units: batchComputeUnits }),
|
|
13300
|
+
import_web314.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
|
|
13242
13301
|
);
|
|
13243
13302
|
}
|
|
13244
13303
|
for (const transfer of transfers) {
|
|
@@ -13247,7 +13306,7 @@ var init_transaction_builder = __esm({
|
|
|
13247
13306
|
}
|
|
13248
13307
|
const { stealthAddress } = generateEd25519StealthAddress(transfer.recipientMetaAddress);
|
|
13249
13308
|
const stealthAddressBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
|
|
13250
|
-
const stealthPubkey = new
|
|
13309
|
+
const stealthPubkey = new import_web314.PublicKey(stealthAddressBase58);
|
|
13251
13310
|
const ephemeralPubkeyBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.ephemeralPublicKey);
|
|
13252
13311
|
const stealthATA = await (0, import_spl_token7.getAssociatedTokenAddress)(mint, stealthPubkey, true);
|
|
13253
13312
|
try {
|
|
@@ -13286,9 +13345,9 @@ var init_transaction_builder = __esm({
|
|
|
13286
13345
|
stealthAddressBase58
|
|
13287
13346
|
);
|
|
13288
13347
|
instructions.push(
|
|
13289
|
-
new
|
|
13348
|
+
new import_web314.TransactionInstruction({
|
|
13290
13349
|
keys: [],
|
|
13291
|
-
programId: new
|
|
13350
|
+
programId: new import_web314.PublicKey(MEMO_PROGRAM_ID),
|
|
13292
13351
|
data: Buffer.from(memoContent, "utf-8")
|
|
13293
13352
|
})
|
|
13294
13353
|
);
|
|
@@ -13320,12 +13379,12 @@ var init_transaction_builder = __esm({
|
|
|
13320
13379
|
const priorityFee = BigInt(Math.ceil(effectiveComputeUnits * this.priorityFee / 1e6));
|
|
13321
13380
|
const estimatedFee = baseFee + priorityFee;
|
|
13322
13381
|
if (this.useVersioned) {
|
|
13323
|
-
const messageV0 = new
|
|
13382
|
+
const messageV0 = new import_web314.TransactionMessage({
|
|
13324
13383
|
payerKey: this.feePayer,
|
|
13325
13384
|
recentBlockhash: blockhash,
|
|
13326
13385
|
instructions
|
|
13327
13386
|
}).compileToV0Message(this.lookupTables.length > 0 ? this.lookupTables : void 0);
|
|
13328
|
-
const versionedTransaction = new
|
|
13387
|
+
const versionedTransaction = new import_web314.VersionedTransaction(messageV0);
|
|
13329
13388
|
return {
|
|
13330
13389
|
type,
|
|
13331
13390
|
versionedTransaction,
|
|
@@ -13336,7 +13395,7 @@ var init_transaction_builder = __esm({
|
|
|
13336
13395
|
estimatedFee
|
|
13337
13396
|
};
|
|
13338
13397
|
} else {
|
|
13339
|
-
const transaction = new
|
|
13398
|
+
const transaction = new import_web314.Transaction();
|
|
13340
13399
|
transaction.recentBlockhash = blockhash;
|
|
13341
13400
|
transaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
13342
13401
|
transaction.feePayer = this.feePayer;
|
|
@@ -13381,9 +13440,9 @@ var init_transaction_builder = __esm({
|
|
|
13381
13440
|
deserializeSignedTransaction(serialized, isVersioned) {
|
|
13382
13441
|
const buffer = Buffer.from(serialized, "base64");
|
|
13383
13442
|
if (isVersioned) {
|
|
13384
|
-
return
|
|
13443
|
+
return import_web314.VersionedTransaction.deserialize(buffer);
|
|
13385
13444
|
} else {
|
|
13386
|
-
return
|
|
13445
|
+
return import_web314.Transaction.from(buffer);
|
|
13387
13446
|
}
|
|
13388
13447
|
}
|
|
13389
13448
|
// ─── Configuration ────────────────────────────────────────────────────────────
|
|
@@ -13455,9 +13514,9 @@ async function shieldedTransfer(params) {
|
|
|
13455
13514
|
const stealthResult = generateEd25519StealthAddress(recipientMeta);
|
|
13456
13515
|
const stealthAddr = stealthResult.stealthAddress;
|
|
13457
13516
|
const stealthPubkey = ed25519PublicKeyToSolanaAddress(stealthAddr.address);
|
|
13458
|
-
const stealthAccountPubkey = new
|
|
13517
|
+
const stealthAccountPubkey = new import_web315.PublicKey(stealthPubkey);
|
|
13459
13518
|
const { commitment, blinding } = commit(amount);
|
|
13460
|
-
const commitmentBytes = (0,
|
|
13519
|
+
const commitmentBytes = (0, import_utils28.hexToBytes)(commitment.slice(2));
|
|
13461
13520
|
if (commitmentBytes.length !== 33) {
|
|
13462
13521
|
throw new ValidationError(
|
|
13463
13522
|
`Invalid commitment size: ${commitmentBytes.length}, expected 33`,
|
|
@@ -13465,21 +13524,21 @@ async function shieldedTransfer(params) {
|
|
|
13465
13524
|
);
|
|
13466
13525
|
}
|
|
13467
13526
|
const ephemeralPubkeyHex = stealthAddr.ephemeralPublicKey;
|
|
13468
|
-
const ephemeralPubkeyBytes = (0,
|
|
13527
|
+
const ephemeralPubkeyBytes = (0, import_utils28.hexToBytes)(ephemeralPubkeyHex.slice(2));
|
|
13469
13528
|
const ephemeralPubkey33 = new Uint8Array(33);
|
|
13470
13529
|
ephemeralPubkey33[0] = 2;
|
|
13471
13530
|
ephemeralPubkey33.set(ephemeralPubkeyBytes.slice(0, 32), 1);
|
|
13472
|
-
const viewingKeyBytes = (0,
|
|
13531
|
+
const viewingKeyBytes = (0, import_utils28.hexToBytes)(recipientMeta.viewingKey.slice(2));
|
|
13473
13532
|
const viewingKeyHash = (0, import_sha23.sha256)(viewingKeyBytes);
|
|
13474
13533
|
const encryptedAmount = encryptAmount(amount, recipientMeta.viewingKey);
|
|
13475
|
-
const encryptedAmountBytes = (0,
|
|
13534
|
+
const encryptedAmountBytes = (0, import_utils28.hexToBytes)(encryptedAmount.slice(2));
|
|
13476
13535
|
const mockProof = createMockProof(commitment, amount, blinding);
|
|
13477
13536
|
const configAccount = await connection.getAccountInfo(CONFIG_PDA);
|
|
13478
13537
|
if (!configAccount) {
|
|
13479
13538
|
throw new ValidationError("SIP Privacy program not initialized", "config");
|
|
13480
13539
|
}
|
|
13481
13540
|
const totalTransfers = configAccount.data.readBigUInt64LE(43);
|
|
13482
|
-
const [transferRecordPda] =
|
|
13541
|
+
const [transferRecordPda] = import_web315.PublicKey.findProgramAddressSync(
|
|
13483
13542
|
[
|
|
13484
13543
|
TRANSFER_RECORD_SEED,
|
|
13485
13544
|
sender.toBuffer(),
|
|
@@ -13496,19 +13555,19 @@ async function shieldedTransfer(params) {
|
|
|
13496
13555
|
proof: mockProof,
|
|
13497
13556
|
actualAmount: amount
|
|
13498
13557
|
});
|
|
13499
|
-
const instruction = new
|
|
13558
|
+
const instruction = new import_web315.TransactionInstruction({
|
|
13500
13559
|
keys: [
|
|
13501
13560
|
{ pubkey: CONFIG_PDA, isSigner: false, isWritable: true },
|
|
13502
13561
|
{ pubkey: transferRecordPda, isSigner: false, isWritable: true },
|
|
13503
13562
|
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
13504
13563
|
{ pubkey: stealthAccountPubkey, isSigner: false, isWritable: true },
|
|
13505
13564
|
{ pubkey: FEE_COLLECTOR, isSigner: false, isWritable: true },
|
|
13506
|
-
{ pubkey:
|
|
13565
|
+
{ pubkey: import_web315.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
13507
13566
|
],
|
|
13508
13567
|
programId: SIP_PRIVACY_PROGRAM_ID,
|
|
13509
13568
|
data: instructionData
|
|
13510
13569
|
});
|
|
13511
|
-
const transaction = new
|
|
13570
|
+
const transaction = new import_web315.Transaction();
|
|
13512
13571
|
transaction.add(instruction);
|
|
13513
13572
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
13514
13573
|
transaction.recentBlockhash = blockhash;
|
|
@@ -13528,7 +13587,7 @@ async function shieldedTransfer(params) {
|
|
|
13528
13587
|
ephemeralPublicKey: ephemeralPubkeyHex,
|
|
13529
13588
|
commitment,
|
|
13530
13589
|
viewTag: `0x${stealthAddr.viewTag.toString(16).padStart(2, "0")}`,
|
|
13531
|
-
viewingKeyHash: `0x${(0,
|
|
13590
|
+
viewingKeyHash: `0x${(0, import_utils28.bytesToHex)(viewingKeyHash)}`,
|
|
13532
13591
|
explorerUrl: `https://solscan.io/tx/${signature}?cluster=${cluster}`
|
|
13533
13592
|
};
|
|
13534
13593
|
}
|
|
@@ -13575,12 +13634,12 @@ function buildShieldedTransferData(params) {
|
|
|
13575
13634
|
}
|
|
13576
13635
|
function createMockProof(commitment, amount, blinding) {
|
|
13577
13636
|
const proof = new Uint8Array(128);
|
|
13578
|
-
const commitmentBytes = (0,
|
|
13637
|
+
const commitmentBytes = (0, import_utils28.hexToBytes)(commitment.slice(2));
|
|
13579
13638
|
const inputHash = (0, import_sha23.sha256)(
|
|
13580
13639
|
new Uint8Array([
|
|
13581
13640
|
...commitmentBytes,
|
|
13582
13641
|
...bigintToLeBytes(amount),
|
|
13583
|
-
...(0,
|
|
13642
|
+
...(0, import_utils28.hexToBytes)(blinding.slice(2))
|
|
13584
13643
|
])
|
|
13585
13644
|
);
|
|
13586
13645
|
proof.set(inputHash, 0);
|
|
@@ -13604,30 +13663,30 @@ async function getCluster(connection) {
|
|
|
13604
13663
|
}
|
|
13605
13664
|
function encryptAmount(amount, viewingKey) {
|
|
13606
13665
|
const amountBytes = bigintToLeBytes(amount);
|
|
13607
|
-
const keyHash = (0, import_sha23.sha256)((0,
|
|
13666
|
+
const keyHash = (0, import_sha23.sha256)((0, import_utils28.hexToBytes)(viewingKey.slice(2)));
|
|
13608
13667
|
const encrypted = new Uint8Array(amountBytes.length);
|
|
13609
13668
|
for (let i = 0; i < amountBytes.length; i++) {
|
|
13610
13669
|
encrypted[i] = amountBytes[i] ^ keyHash[i];
|
|
13611
13670
|
}
|
|
13612
|
-
return `0x${(0,
|
|
13671
|
+
return `0x${(0, import_utils28.bytesToHex)(encrypted)}`;
|
|
13613
13672
|
}
|
|
13614
|
-
var
|
|
13673
|
+
var import_web315, import_sha23, import_utils28, SIP_PRIVACY_PROGRAM_ID, CONFIG_PDA, FEE_COLLECTOR, TRANSFER_RECORD_SEED, SHIELDED_TRANSFER_DISCRIMINATOR;
|
|
13615
13674
|
var init_anchor_transfer = __esm({
|
|
13616
13675
|
"src/chains/solana/anchor-transfer.ts"() {
|
|
13617
13676
|
"use strict";
|
|
13618
|
-
|
|
13677
|
+
import_web315 = require("@solana/web3.js");
|
|
13619
13678
|
import_sha23 = require("@noble/hashes/sha2");
|
|
13620
|
-
|
|
13679
|
+
import_utils28 = require("@noble/hashes/utils");
|
|
13621
13680
|
init_errors();
|
|
13622
13681
|
init_commitment();
|
|
13623
13682
|
init_stealth2();
|
|
13624
|
-
SIP_PRIVACY_PROGRAM_ID = new
|
|
13683
|
+
SIP_PRIVACY_PROGRAM_ID = new import_web315.PublicKey(
|
|
13625
13684
|
"S1PMFspo4W6BYKHWkHNF7kZ3fnqibEXg3LQjxepS9at"
|
|
13626
13685
|
);
|
|
13627
|
-
CONFIG_PDA = new
|
|
13686
|
+
CONFIG_PDA = new import_web315.PublicKey(
|
|
13628
13687
|
"BVawZkppFewygA5nxdrLma4ThKx8Th7bW4KTCkcWTZwZ"
|
|
13629
13688
|
);
|
|
13630
|
-
FEE_COLLECTOR = new
|
|
13689
|
+
FEE_COLLECTOR = new import_web315.PublicKey(
|
|
13631
13690
|
"S1P6j1yeTm6zkewQVeihrTZvmfoHABRkHDhabWTuWMd"
|
|
13632
13691
|
);
|
|
13633
13692
|
TRANSFER_RECORD_SEED = Buffer.from("transfer_record");
|
|
@@ -13650,24 +13709,24 @@ function createVerifyInstructionData(proof, publicInputs) {
|
|
|
13650
13709
|
}
|
|
13651
13710
|
function formatFundingInputs(params) {
|
|
13652
13711
|
return [
|
|
13653
|
-
(0,
|
|
13712
|
+
(0, import_utils29.hexToBytes)(params.commitmentHash.slice(2)),
|
|
13654
13713
|
bigintToBytes32(params.minimumRequired),
|
|
13655
|
-
(0,
|
|
13714
|
+
(0, import_utils29.hexToBytes)(params.assetId.slice(2))
|
|
13656
13715
|
];
|
|
13657
13716
|
}
|
|
13658
13717
|
function formatOwnershipInputs(params) {
|
|
13659
13718
|
return [
|
|
13660
|
-
(0,
|
|
13661
|
-
(0,
|
|
13662
|
-
(0,
|
|
13719
|
+
(0, import_utils29.hexToBytes)(params.stealthPubkey.slice(2)),
|
|
13720
|
+
(0, import_utils29.hexToBytes)(params.ephemeralPubkey.slice(2)),
|
|
13721
|
+
(0, import_utils29.hexToBytes)(params.nullifier.slice(2))
|
|
13663
13722
|
];
|
|
13664
13723
|
}
|
|
13665
13724
|
function toPublicKey2(input) {
|
|
13666
|
-
return typeof input === "string" ? new
|
|
13725
|
+
return typeof input === "string" ? new import_web316.PublicKey(input) : input;
|
|
13667
13726
|
}
|
|
13668
13727
|
function toBytes(input) {
|
|
13669
13728
|
if (typeof input === "string") {
|
|
13670
|
-
return (0,
|
|
13729
|
+
return (0, import_utils29.hexToBytes)(input.startsWith("0x") ? input.slice(2) : input);
|
|
13671
13730
|
}
|
|
13672
13731
|
return input;
|
|
13673
13732
|
}
|
|
@@ -13680,13 +13739,13 @@ function bigintToBytes32(value) {
|
|
|
13680
13739
|
}
|
|
13681
13740
|
return bytes;
|
|
13682
13741
|
}
|
|
13683
|
-
var
|
|
13742
|
+
var import_web316, import_utils29, ProofType, DEFAULT_COMPUTE_UNITS2, PROOF_SIZE, SunspotVerifier;
|
|
13684
13743
|
var init_sunspot_verifier = __esm({
|
|
13685
13744
|
"src/chains/solana/sunspot-verifier.ts"() {
|
|
13686
13745
|
"use strict";
|
|
13687
|
-
|
|
13746
|
+
import_web316 = require("@solana/web3.js");
|
|
13688
13747
|
init_errors();
|
|
13689
|
-
|
|
13748
|
+
import_utils29 = require("@noble/hashes/utils");
|
|
13690
13749
|
ProofType = /* @__PURE__ */ ((ProofType2) => {
|
|
13691
13750
|
ProofType2["Funding"] = "funding";
|
|
13692
13751
|
ProofType2["Ownership"] = "ownership";
|
|
@@ -13801,14 +13860,14 @@ var init_sunspot_verifier = __esm({
|
|
|
13801
13860
|
proofBytes,
|
|
13802
13861
|
...publicInputBytes.map((b) => Buffer.from(b))
|
|
13803
13862
|
]);
|
|
13804
|
-
const transaction = new
|
|
13863
|
+
const transaction = new import_web316.Transaction();
|
|
13805
13864
|
transaction.add(
|
|
13806
|
-
|
|
13865
|
+
import_web316.ComputeBudgetProgram.setComputeUnitLimit({
|
|
13807
13866
|
units: this.config.computeUnits
|
|
13808
13867
|
})
|
|
13809
13868
|
);
|
|
13810
13869
|
transaction.add(
|
|
13811
|
-
new
|
|
13870
|
+
new import_web316.TransactionInstruction({
|
|
13812
13871
|
keys: [],
|
|
13813
13872
|
// Verifier programs typically don't need accounts
|
|
13814
13873
|
programId: verifierProgram,
|
|
@@ -13906,6 +13965,202 @@ var init_sunspot_verifier = __esm({
|
|
|
13906
13965
|
}
|
|
13907
13966
|
});
|
|
13908
13967
|
|
|
13968
|
+
// src/chains/solana/relayer-fee.ts
|
|
13969
|
+
function computeRelayerFee(amount, config) {
|
|
13970
|
+
if (!Number.isInteger(config.bps) || config.bps < 0) {
|
|
13971
|
+
throw new Error("bps must be a non-negative integer");
|
|
13972
|
+
}
|
|
13973
|
+
if (amount < 0n) {
|
|
13974
|
+
throw new Error("amount must be a non-negative bigint");
|
|
13975
|
+
}
|
|
13976
|
+
if (typeof config.flatFloor !== "bigint" || config.flatFloor < 0n) {
|
|
13977
|
+
throw new Error("flatFloor must be a non-negative bigint");
|
|
13978
|
+
}
|
|
13979
|
+
const bpsFee = amount * BigInt(config.bps) / 10000n;
|
|
13980
|
+
return bpsFee > config.flatFloor ? bpsFee : config.flatFloor;
|
|
13981
|
+
}
|
|
13982
|
+
var init_relayer_fee = __esm({
|
|
13983
|
+
"src/chains/solana/relayer-fee.ts"() {
|
|
13984
|
+
"use strict";
|
|
13985
|
+
}
|
|
13986
|
+
});
|
|
13987
|
+
|
|
13988
|
+
// src/chains/solana/gasless-cashout.ts
|
|
13989
|
+
async function buildGaslessCashout(params) {
|
|
13990
|
+
const {
|
|
13991
|
+
connection,
|
|
13992
|
+
stealthAddress,
|
|
13993
|
+
ephemeralPublicKey,
|
|
13994
|
+
viewingPrivateKey,
|
|
13995
|
+
spendingPrivateKey,
|
|
13996
|
+
destinationAddress,
|
|
13997
|
+
mint,
|
|
13998
|
+
relayerPublicKey,
|
|
13999
|
+
relayerFeeAccount,
|
|
14000
|
+
feeConfig,
|
|
14001
|
+
version = "2"
|
|
14002
|
+
} = params;
|
|
14003
|
+
const stealthSigner = deriveStealthSigner({
|
|
14004
|
+
stealthAddress,
|
|
14005
|
+
ephemeralPublicKey,
|
|
14006
|
+
viewingPrivateKey,
|
|
14007
|
+
spendingPrivateKey,
|
|
14008
|
+
version
|
|
14009
|
+
});
|
|
14010
|
+
const stealthPubkey = stealthSigner.publicKey;
|
|
14011
|
+
const stealthATA = await (0, import_spl_token8.getAssociatedTokenAddress)(mint, stealthPubkey, true);
|
|
14012
|
+
const destinationPubkey = new import_web317.PublicKey(destinationAddress);
|
|
14013
|
+
const destinationATA = await (0, import_spl_token8.getAssociatedTokenAddress)(mint, destinationPubkey);
|
|
14014
|
+
if (destinationATA.equals(stealthATA)) {
|
|
14015
|
+
throw new Error(
|
|
14016
|
+
"destinationAddress resolves to the stealth token account; choose a different destination"
|
|
14017
|
+
);
|
|
14018
|
+
}
|
|
14019
|
+
let feeAccount;
|
|
14020
|
+
try {
|
|
14021
|
+
feeAccount = await (0, import_spl_token8.getAccount)(connection, relayerFeeAccount);
|
|
14022
|
+
} catch {
|
|
14023
|
+
throw new Error("relayerFeeAccount does not exist or is not a token account");
|
|
14024
|
+
}
|
|
14025
|
+
if (!feeAccount.mint.equals(mint)) {
|
|
14026
|
+
throw new Error("relayerFeeAccount is not an associated token account for the given mint");
|
|
14027
|
+
}
|
|
14028
|
+
let balanceResp;
|
|
14029
|
+
try {
|
|
14030
|
+
balanceResp = await connection.getTokenAccountBalance(stealthATA);
|
|
14031
|
+
} catch {
|
|
14032
|
+
throw new Error(
|
|
14033
|
+
`Stealth token account ${stealthATA.toBase58()} for mint ${mint.toBase58()} does not exist or holds no balance; nothing to cash out`
|
|
14034
|
+
);
|
|
14035
|
+
}
|
|
14036
|
+
const grossAmount = BigInt(balanceResp.value.amount);
|
|
14037
|
+
const relayerFee = computeRelayerFee(grossAmount, feeConfig);
|
|
14038
|
+
if (relayerFee >= grossAmount) {
|
|
14039
|
+
throw new Error(
|
|
14040
|
+
`Relayer fee (${relayerFee}) equals or exceeds the claim amount (${grossAmount}); nothing left to forward`
|
|
14041
|
+
);
|
|
14042
|
+
}
|
|
14043
|
+
const netAmount = grossAmount - relayerFee;
|
|
14044
|
+
const transaction = new import_web317.Transaction();
|
|
14045
|
+
transaction.add(
|
|
14046
|
+
(0, import_spl_token8.createAssociatedTokenAccountIdempotentInstruction)(
|
|
14047
|
+
relayerPublicKey,
|
|
14048
|
+
// payer (relayer pays rent)
|
|
14049
|
+
destinationATA,
|
|
14050
|
+
destinationPubkey,
|
|
14051
|
+
mint
|
|
14052
|
+
)
|
|
14053
|
+
);
|
|
14054
|
+
transaction.add(
|
|
14055
|
+
(0, import_spl_token8.createTransferInstruction)(stealthATA, relayerFeeAccount, stealthPubkey, relayerFee)
|
|
14056
|
+
);
|
|
14057
|
+
transaction.add(
|
|
14058
|
+
(0, import_spl_token8.createTransferInstruction)(stealthATA, destinationATA, stealthPubkey, netAmount)
|
|
14059
|
+
);
|
|
14060
|
+
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
|
|
14061
|
+
transaction.recentBlockhash = blockhash;
|
|
14062
|
+
transaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
14063
|
+
transaction.feePayer = relayerPublicKey;
|
|
14064
|
+
stealthSigner.signTransaction(transaction);
|
|
14065
|
+
return {
|
|
14066
|
+
transaction,
|
|
14067
|
+
stealthAddress,
|
|
14068
|
+
destinationAddress,
|
|
14069
|
+
grossAmount,
|
|
14070
|
+
relayerFee,
|
|
14071
|
+
netAmount,
|
|
14072
|
+
blockhash,
|
|
14073
|
+
lastValidBlockHeight
|
|
14074
|
+
};
|
|
14075
|
+
}
|
|
14076
|
+
function detectCluster5(endpoint) {
|
|
14077
|
+
if (endpoint.includes("devnet")) {
|
|
14078
|
+
return "devnet";
|
|
14079
|
+
}
|
|
14080
|
+
if (endpoint.includes("testnet")) {
|
|
14081
|
+
return "testnet";
|
|
14082
|
+
}
|
|
14083
|
+
if (endpoint.includes("localhost") || endpoint.includes("127.0.0.1")) {
|
|
14084
|
+
return "localnet";
|
|
14085
|
+
}
|
|
14086
|
+
return "mainnet-beta";
|
|
14087
|
+
}
|
|
14088
|
+
async function submitGaslessCashout(params) {
|
|
14089
|
+
const { connection, build, relayerKeypair, jitoRelayer, tipLamports } = params;
|
|
14090
|
+
const { transaction, netAmount, relayerFee, destinationAddress } = build;
|
|
14091
|
+
if (!transaction.feePayer || !transaction.feePayer.equals(relayerKeypair.publicKey)) {
|
|
14092
|
+
throw new Error("relayerKeypair does not match the transaction fee-payer");
|
|
14093
|
+
}
|
|
14094
|
+
const relayerAlreadySigned = transaction.signatures.some(
|
|
14095
|
+
(s) => s.publicKey.equals(relayerKeypair.publicKey) && s.signature !== null
|
|
14096
|
+
);
|
|
14097
|
+
if (!relayerAlreadySigned) {
|
|
14098
|
+
transaction.partialSign(relayerKeypair);
|
|
14099
|
+
}
|
|
14100
|
+
const cluster = detectCluster5(connection.rpcEndpoint);
|
|
14101
|
+
if (jitoRelayer) {
|
|
14102
|
+
const relayed = await jitoRelayer.relayTransaction({
|
|
14103
|
+
transaction,
|
|
14104
|
+
tipLamports,
|
|
14105
|
+
tipPayer: relayerKeypair,
|
|
14106
|
+
waitForConfirmation: true
|
|
14107
|
+
});
|
|
14108
|
+
if (relayed.status !== "confirmed") {
|
|
14109
|
+
throw new Error(
|
|
14110
|
+
`Gasless cash-out via Jito did not confirm (status: ${relayed.status})` + (relayed.error ? `: ${relayed.error}` : "")
|
|
14111
|
+
);
|
|
14112
|
+
}
|
|
14113
|
+
if (!relayed.signature) {
|
|
14114
|
+
throw new Error("Gasless cash-out via Jito returned an empty transaction signature");
|
|
14115
|
+
}
|
|
14116
|
+
return {
|
|
14117
|
+
txSignature: relayed.signature,
|
|
14118
|
+
destinationAddress,
|
|
14119
|
+
amount: netAmount,
|
|
14120
|
+
relayerFee,
|
|
14121
|
+
explorerUrl: getExplorerUrl(relayed.signature, cluster),
|
|
14122
|
+
// Report the TRUE path: the relayer may have fallen back to direct submission.
|
|
14123
|
+
viaJito: relayed.relayed
|
|
14124
|
+
};
|
|
14125
|
+
}
|
|
14126
|
+
const txSignature = await connection.sendRawTransaction(transaction.serialize(), {
|
|
14127
|
+
skipPreflight: false,
|
|
14128
|
+
preflightCommitment: "confirmed"
|
|
14129
|
+
});
|
|
14130
|
+
const confirmation = await connection.confirmTransaction(
|
|
14131
|
+
{
|
|
14132
|
+
signature: txSignature,
|
|
14133
|
+
blockhash: build.blockhash,
|
|
14134
|
+
lastValidBlockHeight: build.lastValidBlockHeight
|
|
14135
|
+
},
|
|
14136
|
+
"confirmed"
|
|
14137
|
+
);
|
|
14138
|
+
if (confirmation.value.err) {
|
|
14139
|
+
throw new Error(
|
|
14140
|
+
`Gasless cash-out landed but failed on-chain: ${JSON.stringify(confirmation.value.err)}`
|
|
14141
|
+
);
|
|
14142
|
+
}
|
|
14143
|
+
return {
|
|
14144
|
+
txSignature,
|
|
14145
|
+
destinationAddress,
|
|
14146
|
+
amount: netAmount,
|
|
14147
|
+
relayerFee,
|
|
14148
|
+
explorerUrl: getExplorerUrl(txSignature, cluster),
|
|
14149
|
+
viaJito: false
|
|
14150
|
+
};
|
|
14151
|
+
}
|
|
14152
|
+
var import_web317, import_spl_token8;
|
|
14153
|
+
var init_gasless_cashout = __esm({
|
|
14154
|
+
"src/chains/solana/gasless-cashout.ts"() {
|
|
14155
|
+
"use strict";
|
|
14156
|
+
import_web317 = require("@solana/web3.js");
|
|
14157
|
+
import_spl_token8 = require("@solana/spl-token");
|
|
14158
|
+
init_stealth_signer();
|
|
14159
|
+
init_relayer_fee();
|
|
14160
|
+
init_constants();
|
|
14161
|
+
}
|
|
14162
|
+
});
|
|
14163
|
+
|
|
13909
14164
|
// src/chains/solana/index.ts
|
|
13910
14165
|
var solana_exports = {};
|
|
13911
14166
|
__export(solana_exports, {
|
|
@@ -13952,10 +14207,12 @@ __export(solana_exports, {
|
|
|
13952
14207
|
batchGetTokenBalances: () => batchGetTokenBalances,
|
|
13953
14208
|
batchResolveTokenMetadata: () => batchResolveTokenMetadata,
|
|
13954
14209
|
batchScanForRecipients: () => batchScanForRecipients,
|
|
14210
|
+
buildGaslessCashout: () => buildGaslessCashout,
|
|
13955
14211
|
calculatePriorityFee: () => calculatePriorityFee,
|
|
13956
14212
|
claimStealthPayment: () => claimStealthPayment,
|
|
13957
14213
|
commitSPLToken: () => commitSPLToken,
|
|
13958
14214
|
commitSolana: () => commitSolana,
|
|
14215
|
+
computeRelayerFee: () => computeRelayerFee,
|
|
13959
14216
|
computeViewingKeyHash: () => computeViewingKeyHash,
|
|
13960
14217
|
computeViewingKeyHashFromPrivate: () => computeViewingKeyHashFromPrivate,
|
|
13961
14218
|
createAddress: () => createAddress,
|
|
@@ -13976,6 +14233,7 @@ __export(solana_exports, {
|
|
|
13976
14233
|
decryptWithViewing: () => decryptWithViewing2,
|
|
13977
14234
|
deriveChildViewingKey: () => deriveChildViewingKey,
|
|
13978
14235
|
deriveSolanaStealthKeys: () => deriveSolanaStealthKeys,
|
|
14236
|
+
deriveStealthSigner: () => deriveStealthSigner,
|
|
13979
14237
|
deriveViewingKeyFromSpending: () => deriveViewingKeyFromSpending,
|
|
13980
14238
|
disposeEphemeralKeypairs: () => disposeEphemeralKeypairs,
|
|
13981
14239
|
encryptForViewing: () => encryptForViewing2,
|
|
@@ -14025,7 +14283,9 @@ __export(solana_exports, {
|
|
|
14025
14283
|
sendPrivateSPLTransfer: () => sendPrivateSPLTransfer,
|
|
14026
14284
|
sendSOLTransfer: () => sendSOLTransfer,
|
|
14027
14285
|
shieldedTransfer: () => shieldedTransfer,
|
|
14286
|
+
signEd25519WithScalar: () => signEd25519WithScalar,
|
|
14028
14287
|
solToLamports: () => solToLamports,
|
|
14288
|
+
submitGaslessCashout: () => submitGaslessCashout,
|
|
14029
14289
|
subtractBlindingsSolana: () => subtractBlindingsSolana,
|
|
14030
14290
|
subtractCommitmentsSolana: () => subtractCommitmentsSolana,
|
|
14031
14291
|
toAddress: () => toAddress,
|
|
@@ -14069,6 +14329,9 @@ var init_solana = __esm({
|
|
|
14069
14329
|
init_anchor_transfer();
|
|
14070
14330
|
init_kit_compat();
|
|
14071
14331
|
init_sunspot_verifier();
|
|
14332
|
+
init_gasless_cashout();
|
|
14333
|
+
init_relayer_fee();
|
|
14334
|
+
init_stealth_signer();
|
|
14072
14335
|
}
|
|
14073
14336
|
});
|
|
14074
14337
|
|
|
@@ -14519,10 +14782,10 @@ var init_lib_es2 = __esm({
|
|
|
14519
14782
|
}
|
|
14520
14783
|
});
|
|
14521
14784
|
|
|
14522
|
-
// ../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.
|
|
14785
|
+
// ../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.3/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js
|
|
14523
14786
|
var import_events, DEFAULT_LOG_TYPE, Transport;
|
|
14524
14787
|
var init_Transport = __esm({
|
|
14525
|
-
"../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.
|
|
14788
|
+
"../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.3/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js"() {
|
|
14526
14789
|
"use strict";
|
|
14527
14790
|
import_events = __toESM(require("events"));
|
|
14528
14791
|
init_lib_es();
|
|
@@ -14851,7 +15114,7 @@ var init_Transport = __esm({
|
|
|
14851
15114
|
}
|
|
14852
15115
|
});
|
|
14853
15116
|
|
|
14854
|
-
// ../../node_modules/.pnpm/@ledgerhq+devices@8.
|
|
15117
|
+
// ../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/hid-framing.js
|
|
14855
15118
|
function asUInt16BE(value) {
|
|
14856
15119
|
const b = Buffer.alloc(2);
|
|
14857
15120
|
b.writeUInt16BE(value, 0);
|
|
@@ -14859,7 +15122,7 @@ function asUInt16BE(value) {
|
|
|
14859
15122
|
}
|
|
14860
15123
|
var Tag, initialAcc, createHIDframing, hid_framing_default;
|
|
14861
15124
|
var init_hid_framing = __esm({
|
|
14862
|
-
"../../node_modules/.pnpm/@ledgerhq+devices@8.
|
|
15125
|
+
"../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/hid-framing.js"() {
|
|
14863
15126
|
"use strict";
|
|
14864
15127
|
init_lib_es();
|
|
14865
15128
|
Tag = 5;
|
|
@@ -16195,7 +16458,7 @@ var require_range = __commonJS({
|
|
|
16195
16458
|
var require_comparator = __commonJS({
|
|
16196
16459
|
"../../node_modules/.pnpm/semver@7.7.3/node_modules/semver/classes/comparator.js"(exports2, module2) {
|
|
16197
16460
|
"use strict";
|
|
16198
|
-
var ANY = Symbol("SemVer ANY");
|
|
16461
|
+
var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
|
|
16199
16462
|
var Comparator = class _Comparator {
|
|
16200
16463
|
static get ANY() {
|
|
16201
16464
|
return ANY;
|
|
@@ -16874,10 +17137,10 @@ var require_semver2 = __commonJS({
|
|
|
16874
17137
|
}
|
|
16875
17138
|
});
|
|
16876
17139
|
|
|
16877
|
-
// ../../node_modules/.pnpm/@ledgerhq+devices@8.
|
|
17140
|
+
// ../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/index.js
|
|
16878
17141
|
var import_semver, DeviceModelId, devices, productMap, devicesList, ledgerUSBVendorId, identifyUSBProductId, bluetoothServices, serviceUuidToInfos;
|
|
16879
17142
|
var init_lib_es3 = __esm({
|
|
16880
|
-
"../../node_modules/.pnpm/@ledgerhq+devices@8.
|
|
17143
|
+
"../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/index.js"() {
|
|
16881
17144
|
"use strict";
|
|
16882
17145
|
import_semver = __toESM(require_semver2());
|
|
16883
17146
|
(function(DeviceModelId2) {
|
|
@@ -16936,7 +17199,7 @@ var init_lib_es3 = __esm({
|
|
|
16936
17199
|
usbOnly: true,
|
|
16937
17200
|
memorySize: 1533 * 1024,
|
|
16938
17201
|
masks: [856686592],
|
|
16939
|
-
getBlockSize: (_firmwareVersion) =>
|
|
17202
|
+
getBlockSize: (_firmwareVersion) => 512
|
|
16940
17203
|
},
|
|
16941
17204
|
[DeviceModelId.apex]: {
|
|
16942
17205
|
id: DeviceModelId.apex,
|
|
@@ -16946,7 +17209,7 @@ var init_lib_es3 = __esm({
|
|
|
16946
17209
|
usbOnly: false,
|
|
16947
17210
|
memorySize: 1533 * 1024,
|
|
16948
17211
|
masks: [859832320],
|
|
16949
|
-
getBlockSize: (_firmwareVersion) =>
|
|
17212
|
+
getBlockSize: (_firmwareVersion) => 512,
|
|
16950
17213
|
bluetoothSpec: [
|
|
16951
17214
|
{
|
|
16952
17215
|
serviceUuid: "13d63400-2c97-8004-0000-4c6564676572",
|
|
@@ -16964,7 +17227,7 @@ var init_lib_es3 = __esm({
|
|
|
16964
17227
|
usbOnly: false,
|
|
16965
17228
|
memorySize: 1533 * 1024,
|
|
16966
17229
|
masks: [857735168],
|
|
16967
|
-
getBlockSize: (_firmwareVersion) =>
|
|
17230
|
+
getBlockSize: (_firmwareVersion) => 512,
|
|
16968
17231
|
bluetoothSpec: [
|
|
16969
17232
|
{
|
|
16970
17233
|
serviceUuid: "13d63400-2c97-6004-0000-4c6564676572",
|
|
@@ -16982,7 +17245,7 @@ var init_lib_es3 = __esm({
|
|
|
16982
17245
|
usbOnly: false,
|
|
16983
17246
|
memorySize: 1533 * 1024,
|
|
16984
17247
|
masks: [858783744],
|
|
16985
|
-
getBlockSize: (_firmwareVersion) =>
|
|
17248
|
+
getBlockSize: (_firmwareVersion) => 512,
|
|
16986
17249
|
bluetoothSpec: [
|
|
16987
17250
|
{
|
|
16988
17251
|
serviceUuid: "13d63400-2c97-3004-0000-4c6564676572",
|
|
@@ -17030,7 +17293,7 @@ var init_lib_es3 = __esm({
|
|
|
17030
17293
|
}
|
|
17031
17294
|
});
|
|
17032
17295
|
|
|
17033
|
-
// ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.
|
|
17296
|
+
// ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/webusb.js
|
|
17034
17297
|
async function requestLedgerDevice() {
|
|
17035
17298
|
const device = await navigator.usb.requestDevice({
|
|
17036
17299
|
filters: ledgerDevices
|
|
@@ -17049,7 +17312,7 @@ async function getFirstLedgerDevice() {
|
|
|
17049
17312
|
}
|
|
17050
17313
|
var ledgerDevices, isSupported;
|
|
17051
17314
|
var init_webusb = __esm({
|
|
17052
|
-
"../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.
|
|
17315
|
+
"../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/webusb.js"() {
|
|
17053
17316
|
"use strict";
|
|
17054
17317
|
init_lib_es3();
|
|
17055
17318
|
ledgerDevices = [
|
|
@@ -17061,7 +17324,7 @@ var init_webusb = __esm({
|
|
|
17061
17324
|
}
|
|
17062
17325
|
});
|
|
17063
17326
|
|
|
17064
|
-
// ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.
|
|
17327
|
+
// ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/TransportWebUSB.js
|
|
17065
17328
|
var TransportWebUSB_exports = {};
|
|
17066
17329
|
__export(TransportWebUSB_exports, {
|
|
17067
17330
|
default: () => TransportWebUSB
|
|
@@ -17075,7 +17338,7 @@ async function gracefullyResetDevice(device) {
|
|
|
17075
17338
|
}
|
|
17076
17339
|
var configurationValue, endpointNumber, TransportWebUSB;
|
|
17077
17340
|
var init_TransportWebUSB = __esm({
|
|
17078
|
-
"../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.
|
|
17341
|
+
"../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/TransportWebUSB.js"() {
|
|
17079
17342
|
"use strict";
|
|
17080
17343
|
init_Transport();
|
|
17081
17344
|
init_hid_framing();
|
|
@@ -18236,7 +18499,7 @@ __export(index_exports, {
|
|
|
18236
18499
|
NEARIntentsAdapter: () => NEARIntentsAdapter,
|
|
18237
18500
|
NEARIntentsBackend: () => NEARIntentsBackend,
|
|
18238
18501
|
NEAR_DEFAULT_GAS: () => DEFAULT_GAS,
|
|
18239
|
-
NEAR_ED25519_ORDER: () =>
|
|
18502
|
+
NEAR_ED25519_ORDER: () => ED25519_ORDER4,
|
|
18240
18503
|
NEAR_EXPLORER_URLS: () => NEAR_EXPLORER_URLS,
|
|
18241
18504
|
NEAR_FEE_CONTRACTS: () => NEAR_FEE_CONTRACTS,
|
|
18242
18505
|
NEAR_IMPLICIT_ACCOUNT_LENGTH: () => NEAR_IMPLICIT_ACCOUNT_LENGTH,
|
|
@@ -18346,6 +18609,7 @@ __export(index_exports, {
|
|
|
18346
18609
|
bpsToPercent: () => bpsToPercent,
|
|
18347
18610
|
browserBytesToHex: () => bytesToHex18,
|
|
18348
18611
|
browserHexToBytes: () => hexToBytes15,
|
|
18612
|
+
buildGaslessCashout: () => buildGaslessCashout,
|
|
18349
18613
|
cacheKeyGenerator: () => cacheKeyGenerator,
|
|
18350
18614
|
calculateFeeForSwap: () => calculateFeeForSwap,
|
|
18351
18615
|
calculatePrivacyScore: () => calculatePrivacyScore,
|
|
@@ -18367,6 +18631,7 @@ __export(index_exports, {
|
|
|
18367
18631
|
computeAttestationHash: () => computeAttestationHash,
|
|
18368
18632
|
computeNEARViewingKeyHash: () => computeNEARViewingKeyHash,
|
|
18369
18633
|
computeNEARViewingKeyHashFromPrivate: () => computeNEARViewingKeyHashFromPrivate,
|
|
18634
|
+
computeRelayerFee: () => computeRelayerFee,
|
|
18370
18635
|
computeTweakedKey: () => computeTweakedKey,
|
|
18371
18636
|
configureLogger: () => configureLogger,
|
|
18372
18637
|
convertFromSIP: () => convertFromSIP,
|
|
@@ -18470,6 +18735,7 @@ __export(index_exports, {
|
|
|
18470
18735
|
deriveSecp256k1StealthPrivateKeyV1: () => deriveSecp256k1StealthPrivateKeyV1,
|
|
18471
18736
|
deriveStealthPrivateKey: () => deriveStealthPrivateKey,
|
|
18472
18737
|
deriveStealthPrivateKeyV1: () => deriveStealthPrivateKeyV1,
|
|
18738
|
+
deriveStealthSigner: () => deriveStealthSigner,
|
|
18473
18739
|
deriveSuiStealthPrivateKey: () => deriveSuiStealthPrivateKey,
|
|
18474
18740
|
deriveTraditionalNullifier: () => deriveTraditionalNullifier,
|
|
18475
18741
|
deriveViewingKey: () => deriveViewingKey,
|
|
@@ -18661,11 +18927,13 @@ __export(index_exports, {
|
|
|
18661
18927
|
serializePayment: () => serializePayment,
|
|
18662
18928
|
setLogLevel: () => setLogLevel,
|
|
18663
18929
|
signAttestationMessage: () => signAttestationMessage,
|
|
18930
|
+
signEd25519WithScalar: () => signEd25519WithScalar,
|
|
18664
18931
|
silenceLogger: () => silenceLogger,
|
|
18665
18932
|
solanaAddressToEd25519PublicKey: () => solanaAddressToEd25519PublicKey,
|
|
18666
18933
|
solanaOptimizations: () => optimizations_exports,
|
|
18667
18934
|
solanaPublicKeyToHex: () => solanaPublicKeyToHex,
|
|
18668
18935
|
stealthKeyToCosmosAddress: () => stealthKeyToCosmosAddress,
|
|
18936
|
+
submitGaslessCashout: () => submitGaslessCashout,
|
|
18669
18937
|
subtractBlindings: () => subtractBlindings,
|
|
18670
18938
|
subtractBlindingsNEAR: () => subtractBlindingsNEAR,
|
|
18671
18939
|
subtractCommitments: () => subtractCommitments,
|
|
@@ -21342,7 +21610,7 @@ var SIP = class {
|
|
|
21342
21610
|
}
|
|
21343
21611
|
const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await Promise.resolve().then(() => (init_solana(), solana_exports));
|
|
21344
21612
|
const { PublicKey: SolanaPublicKey } = await import("@solana/web3.js");
|
|
21345
|
-
const { getAssociatedTokenAddress:
|
|
21613
|
+
const { getAssociatedTokenAddress: getAssociatedTokenAddress9 } = await import("@solana/spl-token");
|
|
21346
21614
|
const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await Promise.resolve().then(() => (init_constants(), constants_exports));
|
|
21347
21615
|
let mint;
|
|
21348
21616
|
if (params.token in SOLANA_TOKEN_MINTS3) {
|
|
@@ -21350,7 +21618,7 @@ var SIP = class {
|
|
|
21350
21618
|
} else {
|
|
21351
21619
|
mint = new SolanaPublicKey(params.token);
|
|
21352
21620
|
}
|
|
21353
|
-
const senderTokenAccount = await
|
|
21621
|
+
const senderTokenAccount = await getAssociatedTokenAddress9(
|
|
21354
21622
|
mint,
|
|
21355
21623
|
params.sender
|
|
21356
21624
|
);
|
|
@@ -21399,7 +21667,7 @@ init_stealth2();
|
|
|
21399
21667
|
// src/cosmos/stealth.ts
|
|
21400
21668
|
var import_sha2569 = require("@noble/hashes/sha256");
|
|
21401
21669
|
var import_ripemd160 = require("@noble/hashes/ripemd160");
|
|
21402
|
-
var
|
|
21670
|
+
var import_utils30 = require("@noble/hashes/utils");
|
|
21403
21671
|
var import_base3 = require("@scure/base");
|
|
21404
21672
|
init_stealth2();
|
|
21405
21673
|
init_errors();
|
|
@@ -21483,14 +21751,14 @@ var CosmosStealthService = class {
|
|
|
21483
21751
|
);
|
|
21484
21752
|
}
|
|
21485
21753
|
const metaAddress = {
|
|
21486
|
-
spendingKey: `0x${(0,
|
|
21487
|
-
viewingKey: `0x${(0,
|
|
21754
|
+
spendingKey: `0x${(0, import_utils30.bytesToHex)(spendingPubKey)}`,
|
|
21755
|
+
viewingKey: `0x${(0, import_utils30.bytesToHex)(viewingPubKey)}`,
|
|
21488
21756
|
chain: "ethereum"
|
|
21489
21757
|
// Use ethereum for secp256k1 generation
|
|
21490
21758
|
};
|
|
21491
21759
|
const { stealthAddress, sharedSecret } = generateStealthAddress(metaAddress);
|
|
21492
21760
|
const cosmosAddress = this.stealthKeyToCosmosAddress(
|
|
21493
|
-
(0,
|
|
21761
|
+
(0, import_utils30.hexToBytes)(stealthAddress.address.slice(2)),
|
|
21494
21762
|
CHAIN_PREFIXES[chain]
|
|
21495
21763
|
);
|
|
21496
21764
|
return {
|
|
@@ -21518,8 +21786,8 @@ var CosmosStealthService = class {
|
|
|
21518
21786
|
* ```
|
|
21519
21787
|
*/
|
|
21520
21788
|
generateStealthAddressFromMeta(recipientMetaAddress, chain) {
|
|
21521
|
-
const spendingPubKey = (0,
|
|
21522
|
-
const viewingPubKey = (0,
|
|
21789
|
+
const spendingPubKey = (0, import_utils30.hexToBytes)(recipientMetaAddress.spendingKey.slice(2));
|
|
21790
|
+
const viewingPubKey = (0, import_utils30.hexToBytes)(recipientMetaAddress.viewingKey.slice(2));
|
|
21523
21791
|
return this.generateStealthAddress(spendingPubKey, viewingPubKey, chain);
|
|
21524
21792
|
}
|
|
21525
21793
|
/**
|
|
@@ -21697,7 +21965,7 @@ function isValidCosmosAddress(address, expectedChain) {
|
|
|
21697
21965
|
}
|
|
21698
21966
|
|
|
21699
21967
|
// src/cosmos/ibc-stealth.ts
|
|
21700
|
-
var
|
|
21968
|
+
var import_utils31 = require("@noble/hashes/utils");
|
|
21701
21969
|
var import_secp256k14 = require("@noble/curves/secp256k1");
|
|
21702
21970
|
var import_sha25610 = require("@noble/hashes/sha256");
|
|
21703
21971
|
init_errors();
|
|
@@ -21721,7 +21989,7 @@ var ProofGenerationError = class extends Error {
|
|
|
21721
21989
|
|
|
21722
21990
|
// src/proofs/mock.ts
|
|
21723
21991
|
var import_sha25611 = require("@noble/hashes/sha256");
|
|
21724
|
-
var
|
|
21992
|
+
var import_utils32 = require("@noble/hashes/utils");
|
|
21725
21993
|
init_errors();
|
|
21726
21994
|
var log3 = createLogger("proofs/mock");
|
|
21727
21995
|
var MOCK_PROOF_PREFIX = "0x4d4f434b";
|
|
@@ -21898,16 +22166,16 @@ var MockProofProvider = class {
|
|
|
21898
22166
|
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
21899
22167
|
);
|
|
21900
22168
|
const hash2 = (0, import_sha25611.sha256)(new TextEncoder().encode(input));
|
|
21901
|
-
const random = (0,
|
|
22169
|
+
const random = (0, import_utils32.randomBytes)(16);
|
|
21902
22170
|
const combined = new Uint8Array(4 + hash2.length + random.length);
|
|
21903
22171
|
combined.set(new TextEncoder().encode("MOCK"), 0);
|
|
21904
22172
|
combined.set(hash2, 4);
|
|
21905
22173
|
combined.set(random, 4 + hash2.length);
|
|
21906
|
-
return `${MOCK_PROOF_PREFIX}${(0,
|
|
22174
|
+
return `${MOCK_PROOF_PREFIX}${(0, import_utils32.bytesToHex)(combined.slice(4))}`;
|
|
21907
22175
|
}
|
|
21908
22176
|
hashToHex(data) {
|
|
21909
22177
|
const hash2 = (0, import_sha25611.sha256)(new TextEncoder().encode(data));
|
|
21910
|
-
return `0x${(0,
|
|
22178
|
+
return `0x${(0, import_utils32.bytesToHex)(hash2)}`;
|
|
21911
22179
|
}
|
|
21912
22180
|
};
|
|
21913
22181
|
|
|
@@ -22374,46 +22642,46 @@ var ComplianceProofProvider = class {
|
|
|
22374
22642
|
}
|
|
22375
22643
|
async hashViewingKey(viewingKey) {
|
|
22376
22644
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22377
|
-
const { bytesToHex:
|
|
22645
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22378
22646
|
const keyString = typeof viewingKey === "string" ? viewingKey : JSON.stringify(viewingKey);
|
|
22379
22647
|
const encoder = new TextEncoder();
|
|
22380
22648
|
const keyBytes = encoder.encode(keyString);
|
|
22381
|
-
return
|
|
22649
|
+
return bytesToHex64(sha25642(keyBytes));
|
|
22382
22650
|
}
|
|
22383
22651
|
async computeDecryptionCommitment(viewingKey, encryptedData) {
|
|
22384
22652
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22385
|
-
const { bytesToHex:
|
|
22653
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22386
22654
|
const keyHash = await this.hashViewingKey(viewingKey);
|
|
22387
22655
|
const keyBytes = this.hexToBytes(keyHash);
|
|
22388
22656
|
const preimage = new Uint8Array([...keyBytes, ...encryptedData.slice(0, 32)]);
|
|
22389
|
-
return
|
|
22657
|
+
return bytesToHex64(sha25642(preimage));
|
|
22390
22658
|
}
|
|
22391
22659
|
async computeAuditorHash(auditorPublicKey, transactionHash) {
|
|
22392
22660
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22393
|
-
const { bytesToHex:
|
|
22661
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22394
22662
|
const auditorBytes = this.hexToBytes(auditorPublicKey.replace("0x", "").padStart(64, "0"));
|
|
22395
22663
|
const txBytes = this.hexToBytes(transactionHash.replace("0x", "").padStart(64, "0"));
|
|
22396
22664
|
const preimage = new Uint8Array([...auditorBytes, ...txBytes]);
|
|
22397
|
-
return
|
|
22665
|
+
return bytesToHex64(sha25642(preimage));
|
|
22398
22666
|
}
|
|
22399
22667
|
async computeAddressCommitment(address, blinding) {
|
|
22400
22668
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22401
|
-
const { bytesToHex:
|
|
22669
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22402
22670
|
const addressBytes = this.hexToBytes(address.replace("0x", "").padStart(64, "0"));
|
|
22403
22671
|
const preimage = new Uint8Array([...addressBytes, ...blinding.slice(0, 32)]);
|
|
22404
|
-
return
|
|
22672
|
+
return bytesToHex64(sha25642(preimage));
|
|
22405
22673
|
}
|
|
22406
22674
|
async computeNonMembershipProof(senderAddress, recipientAddress, _sanctionsListRoot) {
|
|
22407
22675
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22408
|
-
const { bytesToHex:
|
|
22676
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22409
22677
|
const senderBytes = this.hexToBytes(senderAddress.replace("0x", "").padStart(64, "0"));
|
|
22410
22678
|
const recipientBytes = this.hexToBytes(recipientAddress.replace("0x", "").padStart(64, "0"));
|
|
22411
22679
|
const preimage = new Uint8Array([...senderBytes, ...recipientBytes]);
|
|
22412
|
-
return
|
|
22680
|
+
return bytesToHex64(sha25642(preimage));
|
|
22413
22681
|
}
|
|
22414
22682
|
async computeBalanceCommitment(balance, blinding) {
|
|
22415
22683
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22416
|
-
const { bytesToHex:
|
|
22684
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22417
22685
|
const balanceBytes = new Uint8Array(8);
|
|
22418
22686
|
let v = balance;
|
|
22419
22687
|
for (let i = 7; i >= 0; i--) {
|
|
@@ -22421,11 +22689,11 @@ var ComplianceProofProvider = class {
|
|
|
22421
22689
|
v = v >> 8n;
|
|
22422
22690
|
}
|
|
22423
22691
|
const preimage = new Uint8Array([...balanceBytes, ...blinding.slice(0, 32)]);
|
|
22424
|
-
return
|
|
22692
|
+
return bytesToHex64(sha25642(preimage));
|
|
22425
22693
|
}
|
|
22426
22694
|
async generateComplianceProofBytes(type, publicInputs) {
|
|
22427
22695
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22428
|
-
const { bytesToHex:
|
|
22696
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22429
22697
|
const circuitId = COMPLIANCE_CIRCUIT_IDS[type];
|
|
22430
22698
|
const encoder = new TextEncoder();
|
|
22431
22699
|
const inputBytes = publicInputs.flatMap((pi) => Array.from(this.hexToBytes(pi.replace("0x", ""))));
|
|
@@ -22436,7 +22704,7 @@ var ComplianceProofProvider = class {
|
|
|
22436
22704
|
const hash2 = sha25642(preimage);
|
|
22437
22705
|
let proofBytes = "";
|
|
22438
22706
|
for (let i = 0; i < 8; i++) {
|
|
22439
|
-
proofBytes +=
|
|
22707
|
+
proofBytes += bytesToHex64(sha25642(new Uint8Array([...hash2, i])));
|
|
22440
22708
|
}
|
|
22441
22709
|
return proofBytes;
|
|
22442
22710
|
}
|
|
@@ -22464,7 +22732,7 @@ var ComplianceProofProvider = class {
|
|
|
22464
22732
|
};
|
|
22465
22733
|
|
|
22466
22734
|
// src/proofs/aggregator.ts
|
|
22467
|
-
var
|
|
22735
|
+
var import_utils33 = require("@noble/hashes/utils");
|
|
22468
22736
|
var import_types13 = require("@sip-protocol/types");
|
|
22469
22737
|
var DEFAULT_AGGREGATOR_CONFIG = {
|
|
22470
22738
|
maxProofs: 100,
|
|
@@ -22482,8 +22750,8 @@ var DEFAULT_AGGREGATOR_CONFIG = {
|
|
|
22482
22750
|
verbose: false
|
|
22483
22751
|
};
|
|
22484
22752
|
function generateId(prefix) {
|
|
22485
|
-
const bytes = (0,
|
|
22486
|
-
return `${prefix}-${(0,
|
|
22753
|
+
const bytes = (0, import_utils33.randomBytes)(8);
|
|
22754
|
+
return `${prefix}-${(0, import_utils33.bytesToHex)(bytes)}`;
|
|
22487
22755
|
}
|
|
22488
22756
|
function computeProofHash(proofs) {
|
|
22489
22757
|
const data = proofs.map((p) => p.proof).join("");
|
|
@@ -22883,10 +23151,10 @@ var ProofAggregator = class {
|
|
|
22883
23151
|
async simulateRecursiveMerge(proofs, targetSystem, depth) {
|
|
22884
23152
|
await delay(proofs.length * 50);
|
|
22885
23153
|
const combinedInputs = proofs.flatMap((p) => p.publicInputs);
|
|
22886
|
-
const proofBytes = (0,
|
|
23154
|
+
const proofBytes = (0, import_utils33.randomBytes)(256);
|
|
22887
23155
|
return {
|
|
22888
23156
|
id: generateId(`recursive-${depth}`),
|
|
22889
|
-
proof: `0x${(0,
|
|
23157
|
+
proof: `0x${(0, import_utils33.bytesToHex)(proofBytes)}`,
|
|
22890
23158
|
publicInputs: combinedInputs.slice(0, 10),
|
|
22891
23159
|
metadata: {
|
|
22892
23160
|
system: targetSystem,
|
|
@@ -23101,7 +23369,7 @@ function createProofAggregator(config) {
|
|
|
23101
23369
|
}
|
|
23102
23370
|
|
|
23103
23371
|
// src/proofs/verifier.ts
|
|
23104
|
-
var
|
|
23372
|
+
var import_utils34 = require("@noble/hashes/utils");
|
|
23105
23373
|
var DEFAULT_PIPELINE_CONFIG = {
|
|
23106
23374
|
enableParallel: true,
|
|
23107
23375
|
maxConcurrent: 4,
|
|
@@ -23115,7 +23383,7 @@ var DEFAULT_PIPELINE_CONFIG = {
|
|
|
23115
23383
|
generateVerificationProof: false
|
|
23116
23384
|
};
|
|
23117
23385
|
function generateId2(prefix) {
|
|
23118
|
-
return `${prefix}-${(0,
|
|
23386
|
+
return `${prefix}-${(0, import_utils34.bytesToHex)((0, import_utils34.randomBytes)(8))}`;
|
|
23119
23387
|
}
|
|
23120
23388
|
function computeLinkHash(sourceProof, targetProof) {
|
|
23121
23389
|
const combinedData = sourceProof.proof + targetProof.proof;
|
|
@@ -24095,7 +24363,7 @@ function createCrossSystemValidator(options) {
|
|
|
24095
24363
|
}
|
|
24096
24364
|
|
|
24097
24365
|
// src/proofs/orchestrator.ts
|
|
24098
|
-
var
|
|
24366
|
+
var import_utils35 = require("@noble/hashes/utils");
|
|
24099
24367
|
var import_types14 = require("@sip-protocol/types");
|
|
24100
24368
|
var DEFAULT_ORCHESTRATOR_CONFIG = {
|
|
24101
24369
|
maxRetries: 3,
|
|
@@ -24151,7 +24419,7 @@ var BUILTIN_TEMPLATES = [
|
|
|
24151
24419
|
}
|
|
24152
24420
|
];
|
|
24153
24421
|
function generateId3(prefix) {
|
|
24154
|
-
return `${prefix}-${(0,
|
|
24422
|
+
return `${prefix}-${(0, import_utils35.bytesToHex)((0, import_utils35.randomBytes)(8))}`;
|
|
24155
24423
|
}
|
|
24156
24424
|
function delay2(ms) {
|
|
24157
24425
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -24702,12 +24970,12 @@ var IncompatibleSystemsError = class extends ProofCompositionError {
|
|
|
24702
24970
|
};
|
|
24703
24971
|
|
|
24704
24972
|
// src/proofs/composer/base.ts
|
|
24705
|
-
var import_utils35 = require("@noble/hashes/utils");
|
|
24706
24973
|
var import_utils36 = require("@noble/hashes/utils");
|
|
24974
|
+
var import_utils37 = require("@noble/hashes/utils");
|
|
24707
24975
|
var import_types16 = require("@sip-protocol/types");
|
|
24708
24976
|
function generateId4(prefix) {
|
|
24709
|
-
const bytes = (0,
|
|
24710
|
-
return `${prefix}-${(0,
|
|
24977
|
+
const bytes = (0, import_utils36.randomBytes)(8);
|
|
24978
|
+
return `${prefix}-${(0, import_utils37.bytesToHex)(bytes)}`;
|
|
24711
24979
|
}
|
|
24712
24980
|
function computeProofHash2(proofs) {
|
|
24713
24981
|
const data = proofs.map((p) => p.proof).join("");
|
|
@@ -25352,7 +25620,7 @@ var BaseProofComposer = class {
|
|
|
25352
25620
|
};
|
|
25353
25621
|
|
|
25354
25622
|
// src/proofs/providers/halo2.ts
|
|
25355
|
-
var
|
|
25623
|
+
var import_utils38 = require("@noble/hashes/utils");
|
|
25356
25624
|
var import_types17 = require("@sip-protocol/types");
|
|
25357
25625
|
var DEFAULT_HALO2_CONFIG = {
|
|
25358
25626
|
artifactsPath: "",
|
|
@@ -25553,8 +25821,8 @@ var Halo2Provider = class {
|
|
|
25553
25821
|
async generateMockProof(request, circuit) {
|
|
25554
25822
|
const simulatedTimeMs = Math.min(100 + circuit.k * 10, 2e3);
|
|
25555
25823
|
await this.delay(simulatedTimeMs);
|
|
25556
|
-
const proofBytes = (0,
|
|
25557
|
-
const proofHex = `0x${(0,
|
|
25824
|
+
const proofBytes = (0, import_utils38.randomBytes)(256);
|
|
25825
|
+
const proofHex = `0x${(0, import_utils38.bytesToHex)(proofBytes)}`;
|
|
25558
25826
|
const publicInputs = Object.values(request.publicInputs).map((v) => {
|
|
25559
25827
|
if (typeof v === "string" && v.startsWith("0x")) {
|
|
25560
25828
|
return v;
|
|
@@ -25565,7 +25833,7 @@ var Halo2Provider = class {
|
|
|
25565
25833
|
return `0x${Buffer.from(String(v)).toString("hex")}`;
|
|
25566
25834
|
});
|
|
25567
25835
|
return {
|
|
25568
|
-
id: `halo2-proof-${Date.now()}-${(0,
|
|
25836
|
+
id: `halo2-proof-${Date.now()}-${(0, import_utils38.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
|
|
25569
25837
|
proof: proofHex,
|
|
25570
25838
|
publicInputs,
|
|
25571
25839
|
metadata: {
|
|
@@ -25633,7 +25901,7 @@ var Halo2Provider = class {
|
|
|
25633
25901
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
25634
25902
|
}
|
|
25635
25903
|
generateProviderId() {
|
|
25636
|
-
return (0,
|
|
25904
|
+
return (0, import_utils38.bytesToHex)((0, import_utils38.randomBytes)(4));
|
|
25637
25905
|
}
|
|
25638
25906
|
};
|
|
25639
25907
|
function createHalo2Provider(config) {
|
|
@@ -25664,7 +25932,7 @@ function createOrchardProvider() {
|
|
|
25664
25932
|
}
|
|
25665
25933
|
|
|
25666
25934
|
// src/proofs/providers/kimchi.ts
|
|
25667
|
-
var
|
|
25935
|
+
var import_utils39 = require("@noble/hashes/utils");
|
|
25668
25936
|
var import_types18 = require("@sip-protocol/types");
|
|
25669
25937
|
var DEFAULT_KIMCHI_CONFIG = {
|
|
25670
25938
|
circuits: [],
|
|
@@ -25813,7 +26081,7 @@ var KimchiProvider = class {
|
|
|
25813
26081
|
console.log(`[KimchiProvider] Compiling circuit: ${circuitId}`);
|
|
25814
26082
|
}
|
|
25815
26083
|
await this.delay(100 + circuit.gateCount * 0.1);
|
|
25816
|
-
const vkHash = `0x${(0,
|
|
26084
|
+
const vkHash = `0x${(0, import_utils39.bytesToHex)((0, import_utils39.randomBytes)(32))}`;
|
|
25817
26085
|
this._compiledCircuits.set(circuitId, {
|
|
25818
26086
|
compiled: true,
|
|
25819
26087
|
vkHash
|
|
@@ -25879,8 +26147,8 @@ var KimchiProvider = class {
|
|
|
25879
26147
|
async generateMockProof(request, circuit) {
|
|
25880
26148
|
const simulatedTimeMs = Math.min(200 + circuit.gateCount * 0.5, 5e3);
|
|
25881
26149
|
await this.delay(simulatedTimeMs);
|
|
25882
|
-
const proofBytes = (0,
|
|
25883
|
-
const proofHex = `0x${(0,
|
|
26150
|
+
const proofBytes = (0, import_utils39.randomBytes)(KIMCHI_PROOF_SIZE);
|
|
26151
|
+
const proofHex = `0x${(0, import_utils39.bytesToHex)(proofBytes)}`;
|
|
25884
26152
|
const publicInputs = Object.values(request.publicInputs).map((v) => {
|
|
25885
26153
|
if (typeof v === "string" && v.startsWith("0x")) {
|
|
25886
26154
|
return v;
|
|
@@ -25892,7 +26160,7 @@ var KimchiProvider = class {
|
|
|
25892
26160
|
});
|
|
25893
26161
|
const vkHash = this._compiledCircuits.get(request.circuitId)?.vkHash;
|
|
25894
26162
|
return {
|
|
25895
|
-
id: `kimchi-proof-${Date.now()}-${(0,
|
|
26163
|
+
id: `kimchi-proof-${Date.now()}-${(0, import_utils39.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
|
|
25896
26164
|
proof: proofHex,
|
|
25897
26165
|
publicInputs,
|
|
25898
26166
|
verificationKey: vkHash,
|
|
@@ -25985,11 +26253,11 @@ var KimchiProvider = class {
|
|
|
25985
26253
|
console.log(`[KimchiProvider] Merging ${proofs.length} proofs recursively`);
|
|
25986
26254
|
}
|
|
25987
26255
|
await this.delay(proofs.length * 100);
|
|
25988
|
-
const mergedProofBytes = (0,
|
|
26256
|
+
const mergedProofBytes = (0, import_utils39.randomBytes)(KIMCHI_PROOF_SIZE);
|
|
25989
26257
|
const combinedInputs = proofs.flatMap((p) => p.publicInputs);
|
|
25990
26258
|
return {
|
|
25991
26259
|
id: `kimchi-merged-${Date.now()}`,
|
|
25992
|
-
proof: `0x${(0,
|
|
26260
|
+
proof: `0x${(0, import_utils39.bytesToHex)(mergedProofBytes)}`,
|
|
25993
26261
|
publicInputs: combinedInputs.slice(0, 10),
|
|
25994
26262
|
// Limit public inputs
|
|
25995
26263
|
metadata: {
|
|
@@ -26010,7 +26278,7 @@ var KimchiProvider = class {
|
|
|
26010
26278
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
26011
26279
|
}
|
|
26012
26280
|
generateProviderId() {
|
|
26013
|
-
return (0,
|
|
26281
|
+
return (0, import_utils39.bytesToHex)((0, import_utils39.randomBytes)(4));
|
|
26014
26282
|
}
|
|
26015
26283
|
};
|
|
26016
26284
|
function createKimchiProvider(config) {
|
|
@@ -27121,7 +27389,7 @@ var DEFAULT_WARMING_CONFIG = {
|
|
|
27121
27389
|
|
|
27122
27390
|
// src/proofs/cache/key-generator.ts
|
|
27123
27391
|
var import_sha25612 = require("@noble/hashes/sha256");
|
|
27124
|
-
var
|
|
27392
|
+
var import_utils40 = require("@noble/hashes/utils");
|
|
27125
27393
|
var KEY_SEPARATOR = ":";
|
|
27126
27394
|
var KEY_PREFIX = "sip-proof";
|
|
27127
27395
|
var KEY_VERSION = "v1";
|
|
@@ -27143,7 +27411,7 @@ function canonicalize(value) {
|
|
|
27143
27411
|
return value.toString();
|
|
27144
27412
|
}
|
|
27145
27413
|
if (value instanceof Uint8Array) {
|
|
27146
|
-
return `bytes:${(0,
|
|
27414
|
+
return `bytes:${(0, import_utils40.bytesToHex)(value)}`;
|
|
27147
27415
|
}
|
|
27148
27416
|
if (Array.isArray(value)) {
|
|
27149
27417
|
return `[${value.map(canonicalize).join(",")}]`;
|
|
@@ -27206,7 +27474,7 @@ var CacheKeyGenerator = class {
|
|
|
27206
27474
|
hashInputs(inputs) {
|
|
27207
27475
|
const canonical = canonicalize(inputs);
|
|
27208
27476
|
const hash2 = (0, import_sha25612.sha256)(new TextEncoder().encode(canonical));
|
|
27209
|
-
return (0,
|
|
27477
|
+
return (0, import_utils40.bytesToHex)(hash2);
|
|
27210
27478
|
}
|
|
27211
27479
|
/**
|
|
27212
27480
|
* Generate a cache key from raw inputs
|
|
@@ -28651,11 +28919,11 @@ var CHAIN_NUMERIC_IDS = {
|
|
|
28651
28919
|
// src/oracle/verification.ts
|
|
28652
28920
|
var import_ed255199 = require("@noble/curves/ed25519");
|
|
28653
28921
|
var import_sha25614 = require("@noble/hashes/sha256");
|
|
28654
|
-
var
|
|
28922
|
+
var import_utils42 = require("@noble/hashes/utils");
|
|
28655
28923
|
|
|
28656
28924
|
// src/oracle/serialization.ts
|
|
28657
28925
|
var import_sha25613 = require("@noble/hashes/sha256");
|
|
28658
|
-
var
|
|
28926
|
+
var import_utils41 = require("@noble/hashes/utils");
|
|
28659
28927
|
init_errors();
|
|
28660
28928
|
function serializeAttestationMessage(message) {
|
|
28661
28929
|
const buffer = new Uint8Array(197);
|
|
@@ -28699,19 +28967,19 @@ function deserializeAttestationMessage(bytes) {
|
|
|
28699
28967
|
const version = bytes[offset++];
|
|
28700
28968
|
const chainId = view.getUint32(offset, false);
|
|
28701
28969
|
offset += 4;
|
|
28702
|
-
const intentHash = `0x${(0,
|
|
28970
|
+
const intentHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28703
28971
|
offset += 32;
|
|
28704
|
-
const recipient = `0x${(0,
|
|
28972
|
+
const recipient = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28705
28973
|
offset += 32;
|
|
28706
28974
|
const amount = bytesToBigint(bytes.slice(offset, offset + 16));
|
|
28707
28975
|
offset += 16;
|
|
28708
|
-
const assetId = `0x${(0,
|
|
28976
|
+
const assetId = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28709
28977
|
offset += 32;
|
|
28710
|
-
const txHash = `0x${(0,
|
|
28978
|
+
const txHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28711
28979
|
offset += 32;
|
|
28712
28980
|
const blockNumber = view.getBigUint64(offset, false);
|
|
28713
28981
|
offset += 8;
|
|
28714
|
-
const blockHash = `0x${(0,
|
|
28982
|
+
const blockHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28715
28983
|
offset += 32;
|
|
28716
28984
|
const timestamp = Number(view.getBigUint64(offset, false));
|
|
28717
28985
|
return {
|
|
@@ -28728,7 +28996,7 @@ function deserializeAttestationMessage(bytes) {
|
|
|
28728
28996
|
};
|
|
28729
28997
|
}
|
|
28730
28998
|
function computeAttestationHash(message) {
|
|
28731
|
-
const domain = (0,
|
|
28999
|
+
const domain = (0, import_utils41.utf8ToBytes)(ORACLE_DOMAIN);
|
|
28732
29000
|
const messageBytes = serializeAttestationMessage(message);
|
|
28733
29001
|
const toHash = new Uint8Array(domain.length + messageBytes.length);
|
|
28734
29002
|
toHash.set(domain, 0);
|
|
@@ -28744,7 +29012,7 @@ function getChainNumericId(chain) {
|
|
|
28744
29012
|
}
|
|
28745
29013
|
function normalizeToBytes(hex, length, field) {
|
|
28746
29014
|
const stripped = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
28747
|
-
const bytes = (0,
|
|
29015
|
+
const bytes = (0, import_utils41.hexToBytes)(stripped);
|
|
28748
29016
|
if (bytes.length === length) {
|
|
28749
29017
|
return bytes;
|
|
28750
29018
|
}
|
|
@@ -28777,9 +29045,9 @@ function bytesToBigint(bytes) {
|
|
|
28777
29045
|
|
|
28778
29046
|
// src/oracle/verification.ts
|
|
28779
29047
|
function deriveOracleId(publicKey) {
|
|
28780
|
-
const keyBytes = typeof publicKey === "string" ? (0,
|
|
29048
|
+
const keyBytes = typeof publicKey === "string" ? (0, import_utils42.hexToBytes)(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey) : publicKey;
|
|
28781
29049
|
const hash2 = (0, import_sha25614.sha256)(keyBytes);
|
|
28782
|
-
return `0x${(0,
|
|
29050
|
+
return `0x${(0, import_utils42.bytesToHex)(hash2)}`;
|
|
28783
29051
|
}
|
|
28784
29052
|
function verifyAttestation(attestation, registry) {
|
|
28785
29053
|
const { message, signatures } = attestation;
|
|
@@ -28809,10 +29077,10 @@ function verifyAttestation(attestation, registry) {
|
|
|
28809
29077
|
continue;
|
|
28810
29078
|
}
|
|
28811
29079
|
try {
|
|
28812
|
-
const publicKeyBytes = (0,
|
|
29080
|
+
const publicKeyBytes = (0, import_utils42.hexToBytes)(
|
|
28813
29081
|
oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
|
|
28814
29082
|
);
|
|
28815
|
-
const signatureBytes = (0,
|
|
29083
|
+
const signatureBytes = (0, import_utils42.hexToBytes)(
|
|
28816
29084
|
sig.signature.startsWith("0x") ? sig.signature.slice(2) : sig.signature
|
|
28817
29085
|
);
|
|
28818
29086
|
const isValid = import_ed255199.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
|
|
@@ -28837,10 +29105,10 @@ function verifyAttestation(attestation, registry) {
|
|
|
28837
29105
|
}
|
|
28838
29106
|
function verifyOracleSignature(signature, messageHash, oracle) {
|
|
28839
29107
|
try {
|
|
28840
|
-
const publicKeyBytes = (0,
|
|
29108
|
+
const publicKeyBytes = (0, import_utils42.hexToBytes)(
|
|
28841
29109
|
oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
|
|
28842
29110
|
);
|
|
28843
|
-
const signatureBytes = (0,
|
|
29111
|
+
const signatureBytes = (0, import_utils42.hexToBytes)(
|
|
28844
29112
|
signature.signature.startsWith("0x") ? signature.signature.slice(2) : signature.signature
|
|
28845
29113
|
);
|
|
28846
29114
|
return import_ed255199.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
|
|
@@ -28854,7 +29122,7 @@ function signAttestationMessage(messageHash, privateKey) {
|
|
|
28854
29122
|
const oracleId = deriveOracleId(publicKey);
|
|
28855
29123
|
return {
|
|
28856
29124
|
oracleId,
|
|
28857
|
-
signature: `0x${(0,
|
|
29125
|
+
signature: `0x${(0, import_utils42.bytesToHex)(signature)}`
|
|
28858
29126
|
};
|
|
28859
29127
|
}
|
|
28860
29128
|
function createOracleRegistry(config = {}) {
|
|
@@ -29096,7 +29364,7 @@ var import_types87 = require("@sip-protocol/types");
|
|
|
29096
29364
|
|
|
29097
29365
|
// src/solver/mock-solver.ts
|
|
29098
29366
|
var import_types24 = require("@sip-protocol/types");
|
|
29099
|
-
var
|
|
29367
|
+
var import_utils43 = require("@noble/hashes/utils");
|
|
29100
29368
|
var MockSolver = class {
|
|
29101
29369
|
info;
|
|
29102
29370
|
capabilities;
|
|
@@ -29178,7 +29446,7 @@ var MockSolver = class {
|
|
|
29178
29446
|
const spreadAmount = baseOutput * BigInt(Math.floor(this.spreadPercent * 1e4)) / 10000n;
|
|
29179
29447
|
const outputAmount = baseOutput + spreadAmount;
|
|
29180
29448
|
const feeAmount = outputAmount * BigInt(Math.floor(this.feePercent * 1e4)) / 10000n;
|
|
29181
|
-
const quoteId = `quote-${(0,
|
|
29449
|
+
const quoteId = `quote-${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(8))}`;
|
|
29182
29450
|
const now = Math.floor(Date.now() / 1e3);
|
|
29183
29451
|
const quote = {
|
|
29184
29452
|
quoteId,
|
|
@@ -29189,7 +29457,7 @@ var MockSolver = class {
|
|
|
29189
29457
|
expiry: now + 60,
|
|
29190
29458
|
// Quote valid for 1 minute
|
|
29191
29459
|
fee: feeAmount,
|
|
29192
|
-
signature: `0x${(0,
|
|
29460
|
+
signature: `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(64))}`,
|
|
29193
29461
|
// Mock signature
|
|
29194
29462
|
validUntil: now + 60,
|
|
29195
29463
|
estimatedGas: 200000n
|
|
@@ -29226,7 +29494,7 @@ var MockSolver = class {
|
|
|
29226
29494
|
error: status.error
|
|
29227
29495
|
};
|
|
29228
29496
|
}
|
|
29229
|
-
const txHash = `0x${(0,
|
|
29497
|
+
const txHash = `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(32))}`;
|
|
29230
29498
|
status.status = "completed";
|
|
29231
29499
|
status.txHash = txHash;
|
|
29232
29500
|
return {
|
|
@@ -29236,10 +29504,10 @@ var MockSolver = class {
|
|
|
29236
29504
|
txHash: intent.privacyLevel === "transparent" ? txHash : void 0,
|
|
29237
29505
|
fulfillmentProof: {
|
|
29238
29506
|
type: "fulfillment",
|
|
29239
|
-
proof: `0x${(0,
|
|
29507
|
+
proof: `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(128))}`,
|
|
29240
29508
|
publicInputs: [
|
|
29241
|
-
`0x${(0,
|
|
29242
|
-
`0x${(0,
|
|
29509
|
+
`0x${(0, import_utils43.bytesToHex)(new TextEncoder().encode(intent.intentId))}`,
|
|
29510
|
+
`0x${(0, import_utils43.bytesToHex)(new TextEncoder().encode(quote.quoteId))}`
|
|
29243
29511
|
]
|
|
29244
29512
|
},
|
|
29245
29513
|
fulfilledAt: Math.floor(Date.now() / 1e3)
|
|
@@ -29798,6 +30066,7 @@ var SmartRouter = class {
|
|
|
29798
30066
|
log4.warn({ backend, error }, "Backend failed");
|
|
29799
30067
|
});
|
|
29800
30068
|
}
|
|
30069
|
+
registry;
|
|
29801
30070
|
cache;
|
|
29802
30071
|
tracker;
|
|
29803
30072
|
backendTimeoutMs;
|
|
@@ -30804,7 +31073,7 @@ function createZcashNativeBackend(config) {
|
|
|
30804
31073
|
var import_types27 = require("@sip-protocol/types");
|
|
30805
31074
|
init_stealth2();
|
|
30806
31075
|
init_errors();
|
|
30807
|
-
var
|
|
31076
|
+
var import_utils44 = require("@noble/hashes/utils");
|
|
30808
31077
|
var DEFAULT_GAS_FEES = {
|
|
30809
31078
|
ethereum: 21000n * 50n * 1000000000n,
|
|
30810
31079
|
// 21k gas * 50 gwei = 0.00105 ETH
|
|
@@ -30863,6 +31132,8 @@ var ZcashRPCError = class extends Error {
|
|
|
30863
31132
|
this.data = data;
|
|
30864
31133
|
this.name = "ZcashRPCError";
|
|
30865
31134
|
}
|
|
31135
|
+
code;
|
|
31136
|
+
data;
|
|
30866
31137
|
/**
|
|
30867
31138
|
* Check if error is due to insufficient funds
|
|
30868
31139
|
*/
|
|
@@ -32140,7 +32411,7 @@ var import_types89 = require("@sip-protocol/types");
|
|
|
32140
32411
|
// src/bitcoin/taproot.ts
|
|
32141
32412
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
32142
32413
|
var import_sha25615 = require("@noble/hashes/sha256");
|
|
32143
|
-
var
|
|
32414
|
+
var import_utils46 = require("@noble/hashes/utils");
|
|
32144
32415
|
init_errors();
|
|
32145
32416
|
init_validation();
|
|
32146
32417
|
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
@@ -32197,16 +32468,16 @@ function computeTweakedKey(internalKey, merkleRoot) {
|
|
|
32197
32468
|
}
|
|
32198
32469
|
const tweakData = merkleRoot ? new Uint8Array([...internalKey, ...merkleRoot]) : internalKey;
|
|
32199
32470
|
const tweak = taggedHash("TapTweak", tweakData);
|
|
32200
|
-
const tweakScalar = BigInt("0x" + (0,
|
|
32471
|
+
const tweakScalar = BigInt("0x" + (0, import_utils46.bytesToHex)(tweak)) % import_secp256k15.secp256k1.CURVE.n;
|
|
32201
32472
|
const internalPoint = import_secp256k15.secp256k1.ProjectivePoint.fromHex(
|
|
32202
|
-
"02" + (0,
|
|
32473
|
+
"02" + (0, import_utils46.bytesToHex)(internalKey)
|
|
32203
32474
|
);
|
|
32204
32475
|
const tweakPoint = import_secp256k15.secp256k1.ProjectivePoint.BASE.multiply(tweakScalar);
|
|
32205
32476
|
const tweakedPoint = internalPoint.add(tweakPoint);
|
|
32206
32477
|
const tweakedKeyBytes = tweakedPoint.toRawBytes(false);
|
|
32207
32478
|
const xOnly = tweakedKeyBytes.slice(1, 33);
|
|
32208
32479
|
const yCoord = tweakedKeyBytes.slice(33, 65);
|
|
32209
|
-
const yBigInt = BigInt("0x" + (0,
|
|
32480
|
+
const yBigInt = BigInt("0x" + (0, import_utils46.bytesToHex)(yCoord));
|
|
32210
32481
|
const parity = Number(yBigInt & 1n);
|
|
32211
32482
|
return {
|
|
32212
32483
|
tweakedKey: xOnly,
|
|
@@ -32236,9 +32507,9 @@ function createTaprootOutput(internalKey, scripts) {
|
|
|
32236
32507
|
}
|
|
32237
32508
|
const { tweakedKey, parity } = computeTweakedKey(internalKey, merkleRoot);
|
|
32238
32509
|
return {
|
|
32239
|
-
tweakedKey: `0x${(0,
|
|
32240
|
-
internalKey: `0x${(0,
|
|
32241
|
-
merkleRoot: merkleRoot ? `0x${(0,
|
|
32510
|
+
tweakedKey: `0x${(0, import_utils46.bytesToHex)(tweakedKey)}`,
|
|
32511
|
+
internalKey: `0x${(0, import_utils46.bytesToHex)(internalKey)}`,
|
|
32512
|
+
merkleRoot: merkleRoot ? `0x${(0, import_utils46.bytesToHex)(merkleRoot)}` : void 0,
|
|
32242
32513
|
parity
|
|
32243
32514
|
};
|
|
32244
32515
|
}
|
|
@@ -32371,10 +32642,10 @@ function createKeySpendOnlyOutput(privateKey, network = "mainnet") {
|
|
|
32371
32642
|
if (!isValidPrivateKey(privateKey)) {
|
|
32372
32643
|
throw new ValidationError("privateKey must be a valid 32-byte hex string", "privateKey");
|
|
32373
32644
|
}
|
|
32374
|
-
const privKeyBytes = (0,
|
|
32645
|
+
const privKeyBytes = (0, import_utils46.hexToBytes)(privateKey.slice(2));
|
|
32375
32646
|
const internalKey = getXOnlyPublicKey(privKeyBytes);
|
|
32376
32647
|
const output = createTaprootOutput(internalKey);
|
|
32377
|
-
const tweakedKeyBytes = (0,
|
|
32648
|
+
const tweakedKeyBytes = (0, import_utils46.hexToBytes)(output.tweakedKey.slice(2));
|
|
32378
32649
|
const address = taprootAddress(tweakedKeyBytes, network);
|
|
32379
32650
|
return {
|
|
32380
32651
|
output,
|
|
@@ -32400,11 +32671,11 @@ function schnorrSignHex(message, privateKey, auxRand) {
|
|
|
32400
32671
|
if (auxRand && !isValidHex(auxRand)) {
|
|
32401
32672
|
throw new ValidationError("auxRand must be a hex string", "auxRand");
|
|
32402
32673
|
}
|
|
32403
|
-
const messageBytes = (0,
|
|
32404
|
-
const privateKeyBytes = (0,
|
|
32405
|
-
const auxRandBytes = auxRand ? (0,
|
|
32674
|
+
const messageBytes = (0, import_utils46.hexToBytes)(message.slice(2));
|
|
32675
|
+
const privateKeyBytes = (0, import_utils46.hexToBytes)(privateKey.slice(2));
|
|
32676
|
+
const auxRandBytes = auxRand ? (0, import_utils46.hexToBytes)(auxRand.slice(2)) : void 0;
|
|
32406
32677
|
const signature = schnorrSign(messageBytes, privateKeyBytes, auxRandBytes);
|
|
32407
|
-
return `0x${(0,
|
|
32678
|
+
return `0x${(0, import_utils46.bytesToHex)(signature)}`;
|
|
32408
32679
|
}
|
|
32409
32680
|
function schnorrVerifyHex(signature, message, publicKey) {
|
|
32410
32681
|
if (!isValidHex(signature)) {
|
|
@@ -32416,23 +32687,23 @@ function schnorrVerifyHex(signature, message, publicKey) {
|
|
|
32416
32687
|
if (!isValidHex(publicKey)) {
|
|
32417
32688
|
throw new ValidationError("publicKey must be a hex string", "publicKey");
|
|
32418
32689
|
}
|
|
32419
|
-
const signatureBytes = (0,
|
|
32420
|
-
const messageBytes = (0,
|
|
32421
|
-
const publicKeyBytes = (0,
|
|
32690
|
+
const signatureBytes = (0, import_utils46.hexToBytes)(signature.slice(2));
|
|
32691
|
+
const messageBytes = (0, import_utils46.hexToBytes)(message.slice(2));
|
|
32692
|
+
const publicKeyBytes = (0, import_utils46.hexToBytes)(publicKey.slice(2));
|
|
32422
32693
|
return schnorrVerify(signatureBytes, messageBytes, publicKeyBytes);
|
|
32423
32694
|
}
|
|
32424
32695
|
|
|
32425
32696
|
// src/bitcoin/silent-payments.ts
|
|
32426
32697
|
var import_secp256k16 = require("@noble/curves/secp256k1");
|
|
32427
32698
|
var import_sha25616 = require("@noble/hashes/sha256");
|
|
32428
|
-
var
|
|
32699
|
+
var import_utils47 = require("@noble/hashes/utils");
|
|
32429
32700
|
init_errors();
|
|
32430
32701
|
init_validation();
|
|
32431
32702
|
|
|
32432
32703
|
// src/payment/payment.ts
|
|
32433
32704
|
var import_types32 = require("@sip-protocol/types");
|
|
32434
32705
|
var import_sha25617 = require("@noble/hashes/sha256");
|
|
32435
|
-
var
|
|
32706
|
+
var import_utils48 = require("@noble/hashes/utils");
|
|
32436
32707
|
var import_chacha3 = require("@noble/ciphers/chacha.js");
|
|
32437
32708
|
var import_hkdf3 = require("@noble/hashes/hkdf");
|
|
32438
32709
|
init_stealth2();
|
|
@@ -32932,8 +33203,8 @@ async function createShieldedPayment(params, options) {
|
|
|
32932
33203
|
let viewingKeyHash;
|
|
32933
33204
|
if (viewingKey) {
|
|
32934
33205
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
32935
|
-
const keyBytes = (0,
|
|
32936
|
-
viewingKeyHash = `0x${(0,
|
|
33206
|
+
const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
|
|
33207
|
+
viewingKeyHash = `0x${(0, import_utils48.bytesToHex)((0, import_sha25617.sha256)(keyBytes))}`;
|
|
32937
33208
|
}
|
|
32938
33209
|
const privacyConfig = getPrivacyConfig(
|
|
32939
33210
|
privacy,
|
|
@@ -32973,7 +33244,7 @@ async function createShieldedPayment(params, options) {
|
|
|
32973
33244
|
if (privacy !== import_types32.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
|
|
32974
33245
|
const hexToUint8 = (hex) => {
|
|
32975
33246
|
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
32976
|
-
return (0,
|
|
33247
|
+
return (0, import_utils48.hexToBytes)(cleanHex);
|
|
32977
33248
|
};
|
|
32978
33249
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
32979
33250
|
balance: amount,
|
|
@@ -33000,17 +33271,17 @@ async function createShieldedPayment(params, options) {
|
|
|
33000
33271
|
}
|
|
33001
33272
|
function encryptMemo(memo, viewingKey) {
|
|
33002
33273
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
33003
|
-
const keyBytes = (0,
|
|
33274
|
+
const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
|
|
33004
33275
|
const encKey = (0, import_hkdf3.hkdf)(import_sha25617.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
33005
33276
|
try {
|
|
33006
|
-
const nonce = (0,
|
|
33277
|
+
const nonce = (0, import_utils48.randomBytes)(24);
|
|
33007
33278
|
const cipher = (0, import_chacha3.xchacha20poly1305)(encKey, nonce);
|
|
33008
33279
|
const plaintext = new TextEncoder().encode(memo);
|
|
33009
33280
|
const ciphertext = cipher.encrypt(plaintext);
|
|
33010
33281
|
const result = new Uint8Array(nonce.length + ciphertext.length);
|
|
33011
33282
|
result.set(nonce);
|
|
33012
33283
|
result.set(ciphertext, nonce.length);
|
|
33013
|
-
return `0x${(0,
|
|
33284
|
+
return `0x${(0, import_utils48.bytesToHex)(result)}`;
|
|
33014
33285
|
} finally {
|
|
33015
33286
|
secureWipe(keyBytes);
|
|
33016
33287
|
secureWipe(encKey);
|
|
@@ -33018,11 +33289,11 @@ function encryptMemo(memo, viewingKey) {
|
|
|
33018
33289
|
}
|
|
33019
33290
|
function decryptMemo(encryptedMemo, viewingKey) {
|
|
33020
33291
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
33021
|
-
const keyBytes = (0,
|
|
33292
|
+
const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
|
|
33022
33293
|
const encKey = (0, import_hkdf3.hkdf)(import_sha25617.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
33023
33294
|
try {
|
|
33024
33295
|
const dataHex = encryptedMemo.startsWith("0x") ? encryptedMemo.slice(2) : encryptedMemo;
|
|
33025
|
-
const data = (0,
|
|
33296
|
+
const data = (0, import_utils48.hexToBytes)(dataHex);
|
|
33026
33297
|
const nonce = data.slice(0, 24);
|
|
33027
33298
|
const ciphertext = data.slice(24);
|
|
33028
33299
|
const cipher = (0, import_chacha3.xchacha20poly1305)(encKey, nonce);
|
|
@@ -33072,7 +33343,7 @@ function getPaymentSummary(payment) {
|
|
|
33072
33343
|
var import_types33 = require("@sip-protocol/types");
|
|
33073
33344
|
var import_secp256k17 = require("@noble/curves/secp256k1");
|
|
33074
33345
|
var import_sha25618 = require("@noble/hashes/sha256");
|
|
33075
|
-
var
|
|
33346
|
+
var import_utils49 = require("@noble/hashes/utils");
|
|
33076
33347
|
init_errors();
|
|
33077
33348
|
init_validation();
|
|
33078
33349
|
init_secure_memory();
|
|
@@ -33566,12 +33837,12 @@ var Treasury = class _Treasury {
|
|
|
33566
33837
|
}
|
|
33567
33838
|
};
|
|
33568
33839
|
function generateTreasuryId() {
|
|
33569
|
-
const bytes = (0,
|
|
33570
|
-
return `treasury_${(0,
|
|
33840
|
+
const bytes = (0, import_utils49.randomBytes)(16);
|
|
33841
|
+
return `treasury_${(0, import_utils49.bytesToHex)(bytes)}`;
|
|
33571
33842
|
}
|
|
33572
33843
|
function generateProposalId() {
|
|
33573
|
-
const bytes = (0,
|
|
33574
|
-
return `prop_${(0,
|
|
33844
|
+
const bytes = (0, import_utils49.randomBytes)(16);
|
|
33845
|
+
return `prop_${(0, import_utils49.bytesToHex)(bytes)}`;
|
|
33575
33846
|
}
|
|
33576
33847
|
function computeProposalHash(proposal) {
|
|
33577
33848
|
const data = JSON.stringify({
|
|
@@ -33587,7 +33858,7 @@ function computeProposalHash(proposal) {
|
|
|
33587
33858
|
}
|
|
33588
33859
|
function signMessage(messageHash, privateKey) {
|
|
33589
33860
|
const keyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
33590
|
-
const keyBytes = (0,
|
|
33861
|
+
const keyBytes = (0, import_utils49.hexToBytes)(keyHex);
|
|
33591
33862
|
try {
|
|
33592
33863
|
const signature = import_secp256k17.secp256k1.sign(messageHash, keyBytes);
|
|
33593
33864
|
return `0x${signature.toCompactHex()}`;
|
|
@@ -33599,8 +33870,8 @@ function verifySignature(messageHash, signature, publicKey) {
|
|
|
33599
33870
|
const sigHex = signature.startsWith("0x") ? signature.slice(2) : signature;
|
|
33600
33871
|
const pubKeyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
33601
33872
|
try {
|
|
33602
|
-
const sigBytes = (0,
|
|
33603
|
-
const pubKeyBytes = (0,
|
|
33873
|
+
const sigBytes = (0, import_utils49.hexToBytes)(sigHex);
|
|
33874
|
+
const pubKeyBytes = (0, import_utils49.hexToBytes)(pubKeyHex);
|
|
33604
33875
|
return import_secp256k17.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
|
|
33605
33876
|
} catch {
|
|
33606
33877
|
return false;
|
|
@@ -33759,7 +34030,7 @@ function validateBatchProposalParams(params, config) {
|
|
|
33759
34030
|
|
|
33760
34031
|
// src/compliance/compliance-manager.ts
|
|
33761
34032
|
var import_types34 = require("@sip-protocol/types");
|
|
33762
|
-
var
|
|
34033
|
+
var import_utils50 = require("@noble/hashes/utils");
|
|
33763
34034
|
init_errors();
|
|
33764
34035
|
var DEFAULTS2 = {
|
|
33765
34036
|
riskThreshold: 70,
|
|
@@ -34507,7 +34778,7 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
34507
34778
|
}
|
|
34508
34779
|
};
|
|
34509
34780
|
function generateId5(prefix) {
|
|
34510
|
-
return `${prefix}_${(0,
|
|
34781
|
+
return `${prefix}_${(0, import_utils50.bytesToHex)((0, import_utils50.randomBytes)(12))}`;
|
|
34511
34782
|
}
|
|
34512
34783
|
function validateRegisterAuditorParams(params) {
|
|
34513
34784
|
if (!params.organization?.trim()) {
|
|
@@ -34596,7 +34867,7 @@ function validateReportParams(params) {
|
|
|
34596
34867
|
|
|
34597
34868
|
// src/compliance/reports.ts
|
|
34598
34869
|
var import_sha25619 = require("@noble/hashes/sha256");
|
|
34599
|
-
var
|
|
34870
|
+
var import_utils51 = require("@noble/hashes/utils");
|
|
34600
34871
|
init_errors();
|
|
34601
34872
|
|
|
34602
34873
|
// src/compliance/pdf.ts
|
|
@@ -34898,12 +35169,12 @@ var ComplianceReporter = class {
|
|
|
34898
35169
|
normalizeViewingKey(viewingKey) {
|
|
34899
35170
|
if (typeof viewingKey === "string") {
|
|
34900
35171
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
34901
|
-
const keyBytes = (0,
|
|
35172
|
+
const keyBytes = (0, import_utils51.hexToBytes)(keyHex);
|
|
34902
35173
|
const hashBytes = (0, import_sha25619.sha256)(keyBytes);
|
|
34903
35174
|
return {
|
|
34904
35175
|
key: `0x${keyHex}`,
|
|
34905
35176
|
path: "m/0",
|
|
34906
|
-
hash: `0x${(0,
|
|
35177
|
+
hash: `0x${(0, import_utils51.bytesToHex)(hashBytes)}`
|
|
34907
35178
|
};
|
|
34908
35179
|
}
|
|
34909
35180
|
return viewingKey;
|
|
@@ -35285,7 +35556,7 @@ var ComplianceReporter = class {
|
|
|
35285
35556
|
|
|
35286
35557
|
// src/compliance/conditional.ts
|
|
35287
35558
|
var import_sha25620 = require("@noble/hashes/sha256");
|
|
35288
|
-
var
|
|
35559
|
+
var import_utils52 = require("@noble/hashes/utils");
|
|
35289
35560
|
var import_chacha4 = require("@noble/ciphers/chacha.js");
|
|
35290
35561
|
init_errors();
|
|
35291
35562
|
var ConditionalDisclosure = class {
|
|
@@ -35352,8 +35623,8 @@ var ConditionalDisclosure = class {
|
|
|
35352
35623
|
params.commitment,
|
|
35353
35624
|
revealAfterSeconds
|
|
35354
35625
|
);
|
|
35355
|
-
const nonce = (0,
|
|
35356
|
-
const viewingKeyBytes = (0,
|
|
35626
|
+
const nonce = (0, import_utils52.randomBytes)(24);
|
|
35627
|
+
const viewingKeyBytes = (0, import_utils52.hexToBytes)(params.viewingKey.slice(2));
|
|
35357
35628
|
const cipher = (0, import_chacha4.xchacha20poly1305)(encryptionKey, nonce);
|
|
35358
35629
|
const encryptedKey = cipher.encrypt(viewingKeyBytes);
|
|
35359
35630
|
const commitmentData = new Uint8Array([
|
|
@@ -35362,10 +35633,10 @@ var ConditionalDisclosure = class {
|
|
|
35362
35633
|
]);
|
|
35363
35634
|
const commitmentHash = (0, import_sha25620.sha256)(commitmentData);
|
|
35364
35635
|
return {
|
|
35365
|
-
encryptedKey: "0x" + (0,
|
|
35366
|
-
nonce: "0x" + (0,
|
|
35636
|
+
encryptedKey: "0x" + (0, import_utils52.bytesToHex)(encryptedKey),
|
|
35637
|
+
nonce: "0x" + (0, import_utils52.bytesToHex)(nonce),
|
|
35367
35638
|
revealAfter: revealAfterSeconds,
|
|
35368
|
-
verificationCommitment: "0x" + (0,
|
|
35639
|
+
verificationCommitment: "0x" + (0, import_utils52.bytesToHex)(commitmentHash),
|
|
35369
35640
|
encryptionCommitment: params.commitment,
|
|
35370
35641
|
type
|
|
35371
35642
|
};
|
|
@@ -35442,11 +35713,11 @@ var ConditionalDisclosure = class {
|
|
|
35442
35713
|
timeLock.encryptionCommitment,
|
|
35443
35714
|
timeLock.revealAfter
|
|
35444
35715
|
);
|
|
35445
|
-
const nonce = (0,
|
|
35446
|
-
const encryptedData = (0,
|
|
35716
|
+
const nonce = (0, import_utils52.hexToBytes)(timeLock.nonce.slice(2));
|
|
35717
|
+
const encryptedData = (0, import_utils52.hexToBytes)(timeLock.encryptedKey.slice(2));
|
|
35447
35718
|
const cipher = (0, import_chacha4.xchacha20poly1305)(encryptionKey, nonce);
|
|
35448
35719
|
const decryptedBytes = cipher.decrypt(encryptedData);
|
|
35449
|
-
const viewingKey = "0x" + (0,
|
|
35720
|
+
const viewingKey = "0x" + (0, import_utils52.bytesToHex)(decryptedBytes);
|
|
35450
35721
|
return {
|
|
35451
35722
|
unlocked: true,
|
|
35452
35723
|
viewingKey
|
|
@@ -35477,13 +35748,13 @@ var ConditionalDisclosure = class {
|
|
|
35477
35748
|
*/
|
|
35478
35749
|
verifyCommitment(timeLock, viewingKey) {
|
|
35479
35750
|
try {
|
|
35480
|
-
const viewingKeyBytes = (0,
|
|
35751
|
+
const viewingKeyBytes = (0, import_utils52.hexToBytes)(viewingKey.slice(2));
|
|
35481
35752
|
const commitmentData = new Uint8Array([
|
|
35482
35753
|
...viewingKeyBytes,
|
|
35483
35754
|
...this._numberToBytes(timeLock.revealAfter)
|
|
35484
35755
|
]);
|
|
35485
35756
|
const expectedCommitment = (0, import_sha25620.sha256)(commitmentData);
|
|
35486
|
-
const actualCommitment = (0,
|
|
35757
|
+
const actualCommitment = (0, import_utils52.hexToBytes)(timeLock.verificationCommitment.slice(2));
|
|
35487
35758
|
if (expectedCommitment.length !== actualCommitment.length) {
|
|
35488
35759
|
return false;
|
|
35489
35760
|
}
|
|
@@ -35502,7 +35773,7 @@ var ConditionalDisclosure = class {
|
|
|
35502
35773
|
* @private
|
|
35503
35774
|
*/
|
|
35504
35775
|
_deriveEncryptionKey(commitment, revealAfter) {
|
|
35505
|
-
const commitmentBytes = (0,
|
|
35776
|
+
const commitmentBytes = (0, import_utils52.hexToBytes)(commitment.slice(2));
|
|
35506
35777
|
const timeBytes = this._numberToBytes(revealAfter);
|
|
35507
35778
|
const combined = new Uint8Array([...commitmentBytes, ...timeBytes]);
|
|
35508
35779
|
const key = (0, import_sha25620.sha256)(combined);
|
|
@@ -35534,14 +35805,14 @@ var ConditionalDisclosure = class {
|
|
|
35534
35805
|
// src/compliance/conditional-threshold.ts
|
|
35535
35806
|
var import_secp256k18 = require("@noble/curves/secp256k1");
|
|
35536
35807
|
var import_sha25621 = require("@noble/hashes/sha256");
|
|
35537
|
-
var
|
|
35808
|
+
var import_utils53 = require("@noble/hashes/utils");
|
|
35538
35809
|
init_commitment();
|
|
35539
35810
|
init_errors();
|
|
35540
35811
|
var CURVE_ORDER2 = import_secp256k18.secp256k1.CURVE.n;
|
|
35541
35812
|
|
|
35542
35813
|
// src/compliance/threshold.ts
|
|
35543
35814
|
var import_sha25622 = require("@noble/hashes/sha256");
|
|
35544
|
-
var
|
|
35815
|
+
var import_utils54 = require("@noble/hashes/utils");
|
|
35545
35816
|
init_errors();
|
|
35546
35817
|
var FIELD_PRIME = 2n ** 256n - 189n;
|
|
35547
35818
|
var ThresholdViewingKey = class {
|
|
@@ -35725,7 +35996,7 @@ var ThresholdViewingKey = class {
|
|
|
35725
35996
|
* Convert viewing key to secret (bigint)
|
|
35726
35997
|
*/
|
|
35727
35998
|
static viewingKeyToSecret(viewingKey) {
|
|
35728
|
-
const bytes = (0,
|
|
35999
|
+
const bytes = (0, import_utils54.hexToBytes)(viewingKey.slice(2));
|
|
35729
36000
|
let secret = 0n;
|
|
35730
36001
|
for (let i = 0; i < bytes.length; i++) {
|
|
35731
36002
|
secret = secret << 8n | BigInt(bytes[i]);
|
|
@@ -35759,7 +36030,7 @@ var ThresholdViewingKey = class {
|
|
|
35759
36030
|
* Generate a random field element
|
|
35760
36031
|
*/
|
|
35761
36032
|
static randomFieldElement() {
|
|
35762
|
-
const bytes = (0,
|
|
36033
|
+
const bytes = (0, import_utils54.randomBytes)(32);
|
|
35763
36034
|
let value = 0n;
|
|
35764
36035
|
for (let i = 0; i < bytes.length; i++) {
|
|
35765
36036
|
value = value << 8n | BigInt(bytes[i]);
|
|
@@ -35784,8 +36055,8 @@ var ThresholdViewingKey = class {
|
|
|
35784
36055
|
*/
|
|
35785
36056
|
static createCommitment(secret, coefficients) {
|
|
35786
36057
|
const data = [secret, ...coefficients].map((c) => c.toString(16).padStart(64, "0")).join("");
|
|
35787
|
-
const hash2 = (0, import_sha25622.sha256)((0,
|
|
35788
|
-
return (0,
|
|
36058
|
+
const hash2 = (0, import_sha25622.sha256)((0, import_utils54.hexToBytes)(data));
|
|
36059
|
+
return (0, import_utils54.bytesToHex)(hash2);
|
|
35789
36060
|
}
|
|
35790
36061
|
/**
|
|
35791
36062
|
* Encode share as string: "x:y:len:commitment"
|
|
@@ -35909,9 +36180,9 @@ var ThresholdViewingKey = class {
|
|
|
35909
36180
|
|
|
35910
36181
|
// src/compliance/derivation.ts
|
|
35911
36182
|
var import_sha25623 = require("@noble/hashes/sha256");
|
|
35912
|
-
var
|
|
36183
|
+
var import_sha5124 = require("@noble/hashes/sha512");
|
|
35913
36184
|
var import_hmac5 = require("@noble/hashes/hmac");
|
|
35914
|
-
var
|
|
36185
|
+
var import_utils55 = require("@noble/hashes/utils");
|
|
35915
36186
|
init_errors();
|
|
35916
36187
|
init_secure_memory();
|
|
35917
36188
|
var AuditorType = /* @__PURE__ */ ((AuditorType2) => {
|
|
@@ -36010,7 +36281,7 @@ var AuditorKeyDerivation = class {
|
|
|
36010
36281
|
auditorType
|
|
36011
36282
|
// auditorType (non-hardened)
|
|
36012
36283
|
];
|
|
36013
|
-
const masterData = (0, import_hmac5.hmac)(
|
|
36284
|
+
const masterData = (0, import_hmac5.hmac)(import_sha5124.sha512, (0, import_utils55.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
|
|
36014
36285
|
let currentKey = new Uint8Array(masterData.slice(0, 32));
|
|
36015
36286
|
let chainCode = new Uint8Array(masterData.slice(32, 64));
|
|
36016
36287
|
try {
|
|
@@ -36023,9 +36294,9 @@ var AuditorKeyDerivation = class {
|
|
|
36023
36294
|
currentKey = new Uint8Array(derived.key);
|
|
36024
36295
|
chainCode = new Uint8Array(derived.chainCode);
|
|
36025
36296
|
}
|
|
36026
|
-
const keyHex = `0x${(0,
|
|
36297
|
+
const keyHex = `0x${(0, import_utils55.bytesToHex)(currentKey)}`;
|
|
36027
36298
|
const hashBytes = (0, import_sha25623.sha256)(currentKey);
|
|
36028
|
-
const hash2 = `0x${(0,
|
|
36299
|
+
const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
|
|
36029
36300
|
const viewingKey = {
|
|
36030
36301
|
key: keyHex,
|
|
36031
36302
|
path,
|
|
@@ -36092,7 +36363,7 @@ var AuditorKeyDerivation = class {
|
|
|
36092
36363
|
account | this.HARDENED
|
|
36093
36364
|
// account' (hardened)
|
|
36094
36365
|
];
|
|
36095
|
-
const masterData = (0, import_hmac5.hmac)(
|
|
36366
|
+
const masterData = (0, import_hmac5.hmac)(import_sha5124.sha512, (0, import_utils55.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
|
|
36096
36367
|
let commonKey = new Uint8Array(masterData.slice(0, 32));
|
|
36097
36368
|
let commonChainCode = new Uint8Array(masterData.slice(32, 64));
|
|
36098
36369
|
try {
|
|
@@ -36109,9 +36380,9 @@ var AuditorKeyDerivation = class {
|
|
|
36109
36380
|
for (const auditorType of uniqueTypes) {
|
|
36110
36381
|
const derived = this.deriveChildKey(commonKey, commonChainCode, auditorType);
|
|
36111
36382
|
try {
|
|
36112
|
-
const keyHex = `0x${(0,
|
|
36383
|
+
const keyHex = `0x${(0, import_utils55.bytesToHex)(derived.key)}`;
|
|
36113
36384
|
const hashBytes = (0, import_sha25623.sha256)(derived.key);
|
|
36114
|
-
const hash2 = `0x${(0,
|
|
36385
|
+
const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
|
|
36115
36386
|
const path = this.derivePath(auditorType, account);
|
|
36116
36387
|
const viewingKey = {
|
|
36117
36388
|
key: keyHex,
|
|
@@ -36176,7 +36447,7 @@ var AuditorKeyDerivation = class {
|
|
|
36176
36447
|
}
|
|
36177
36448
|
const indexView = new DataView(data.buffer, 33, 4);
|
|
36178
36449
|
indexView.setUint32(0, index, false);
|
|
36179
|
-
const hmacResult = (0, import_hmac5.hmac)(
|
|
36450
|
+
const hmacResult = (0, import_hmac5.hmac)(import_sha5124.sha512, chainCode, data);
|
|
36180
36451
|
const childKey = new Uint8Array(hmacResult.slice(0, 32));
|
|
36181
36452
|
const childChainCode = new Uint8Array(hmacResult.slice(32, 64));
|
|
36182
36453
|
return {
|
|
@@ -36234,8 +36505,8 @@ var AuditorKeyDerivation = class {
|
|
|
36234
36505
|
// src/compliance/range-sas.ts
|
|
36235
36506
|
var import_sha25624 = require("@noble/hashes/sha256");
|
|
36236
36507
|
var import_hmac6 = require("@noble/hashes/hmac");
|
|
36237
|
-
var
|
|
36238
|
-
var
|
|
36508
|
+
var import_sha5125 = require("@noble/hashes/sha512");
|
|
36509
|
+
var import_utils56 = require("@noble/hashes/utils");
|
|
36239
36510
|
init_errors();
|
|
36240
36511
|
init_secure_memory();
|
|
36241
36512
|
var AttestationSchema = /* @__PURE__ */ ((AttestationSchema2) => {
|
|
@@ -36471,16 +36742,16 @@ var AttestationGatedDisclosure = class {
|
|
|
36471
36742
|
*/
|
|
36472
36743
|
deriveKeyFromAttestation(attestation) {
|
|
36473
36744
|
const masterKeyHex = this.config.masterViewingKey.key.startsWith("0x") ? this.config.masterViewingKey.key.slice(2) : this.config.masterViewingKey.key;
|
|
36474
|
-
const masterKeyBytes = (0,
|
|
36475
|
-
const derivationData = (0,
|
|
36745
|
+
const masterKeyBytes = (0, import_utils56.hexToBytes)(masterKeyHex);
|
|
36746
|
+
const derivationData = (0, import_utils56.utf8ToBytes)(
|
|
36476
36747
|
`SIP-RANGE-SAS:${attestation.uid}:${attestation.subject}:${attestation.schema}:${attestation.signature}`
|
|
36477
36748
|
);
|
|
36478
|
-
const derived = (0, import_hmac6.hmac)(
|
|
36749
|
+
const derived = (0, import_hmac6.hmac)(import_sha5125.sha512, masterKeyBytes, derivationData);
|
|
36479
36750
|
const keyBytes = derived.slice(0, 32);
|
|
36480
36751
|
try {
|
|
36481
|
-
const key = `0x${(0,
|
|
36752
|
+
const key = `0x${(0, import_utils56.bytesToHex)(keyBytes)}`;
|
|
36482
36753
|
const hashBytes = (0, import_sha25624.sha256)(keyBytes);
|
|
36483
|
-
const hash2 = `0x${(0,
|
|
36754
|
+
const hash2 = `0x${(0, import_utils56.bytesToHex)(hashBytes)}`;
|
|
36484
36755
|
return {
|
|
36485
36756
|
key,
|
|
36486
36757
|
path: `${this.config.masterViewingKey.path}/sas/${attestation.uid.slice(0, 8)}`,
|
|
@@ -36572,13 +36843,13 @@ async function verifyAttestationSignature(attestation, options = {}) {
|
|
|
36572
36843
|
const signedMessage = constructAttestationMessage(attestation);
|
|
36573
36844
|
try {
|
|
36574
36845
|
const { ed25519: ed2551918 } = await import("@noble/curves/ed25519");
|
|
36575
|
-
const signatureBytes = (0,
|
|
36846
|
+
const signatureBytes = (0, import_utils56.hexToBytes)(
|
|
36576
36847
|
attestation.signature.startsWith("0x") ? attestation.signature.slice(2) : attestation.signature
|
|
36577
36848
|
);
|
|
36578
|
-
const publicKeyBytes = (0,
|
|
36849
|
+
const publicKeyBytes = (0, import_utils56.hexToBytes)(
|
|
36579
36850
|
issuerPublicKey.startsWith("0x") ? issuerPublicKey.slice(2) : issuerPublicKey
|
|
36580
36851
|
);
|
|
36581
|
-
const messageBytes = (0,
|
|
36852
|
+
const messageBytes = (0, import_utils56.utf8ToBytes)(signedMessage);
|
|
36582
36853
|
return ed2551918.verify(signatureBytes, messageBytes, publicKeyBytes);
|
|
36583
36854
|
} catch (error) {
|
|
36584
36855
|
console.warn(`[Range SAS] Signature verification error: ${error}`);
|
|
@@ -36735,11 +37006,11 @@ async function fetchWalletAttestations(walletAddress, options = {}) {
|
|
|
36735
37006
|
|
|
36736
37007
|
// src/compliance/fireblocks.ts
|
|
36737
37008
|
var import_sha25625 = require("@noble/hashes/sha256");
|
|
36738
|
-
var
|
|
37009
|
+
var import_utils57 = require("@noble/hashes/utils");
|
|
36739
37010
|
|
|
36740
37011
|
// src/auction/sealed-bid.ts
|
|
36741
37012
|
init_commitment();
|
|
36742
|
-
var
|
|
37013
|
+
var import_utils58 = require("@noble/hashes/utils");
|
|
36743
37014
|
init_errors();
|
|
36744
37015
|
var SealedBidAuction = class {
|
|
36745
37016
|
/**
|
|
@@ -36817,7 +37088,7 @@ var SealedBidAuction = class {
|
|
|
36817
37088
|
);
|
|
36818
37089
|
}
|
|
36819
37090
|
}
|
|
36820
|
-
const salt = params.salt ?? (0,
|
|
37091
|
+
const salt = params.salt ?? (0, import_utils58.randomBytes)(32);
|
|
36821
37092
|
const { commitment, blinding } = commit(params.amount, salt);
|
|
36822
37093
|
const sealedBid = {
|
|
36823
37094
|
auctionId: params.auctionId,
|
|
@@ -36961,7 +37232,7 @@ var SealedBidAuction = class {
|
|
|
36961
37232
|
* ```
|
|
36962
37233
|
*/
|
|
36963
37234
|
revealBid(bid, amount, salt) {
|
|
36964
|
-
const saltHex = `0x${(0,
|
|
37235
|
+
const saltHex = `0x${(0, import_utils58.bytesToHex)(salt)}`;
|
|
36965
37236
|
const isValid = this.verifyBid({
|
|
36966
37237
|
commitment: bid.commitment,
|
|
36967
37238
|
amount,
|
|
@@ -37448,7 +37719,7 @@ function createSealedBidAuction() {
|
|
|
37448
37719
|
// src/governance/private-vote.ts
|
|
37449
37720
|
var import_sha25626 = require("@noble/hashes/sha256");
|
|
37450
37721
|
var import_hkdf4 = require("@noble/hashes/hkdf");
|
|
37451
|
-
var
|
|
37722
|
+
var import_utils59 = require("@noble/hashes/utils");
|
|
37452
37723
|
var import_chacha5 = require("@noble/ciphers/chacha.js");
|
|
37453
37724
|
init_errors();
|
|
37454
37725
|
init_secure_memory();
|
|
@@ -37489,7 +37760,7 @@ var PrivateVoting = class {
|
|
|
37489
37760
|
const { proposalId, choice, weight, encryptionKey, voter = "anonymous" } = params;
|
|
37490
37761
|
const derivedKey = this.deriveEncryptionKey(encryptionKey, proposalId);
|
|
37491
37762
|
try {
|
|
37492
|
-
const nonce = (0,
|
|
37763
|
+
const nonce = (0, import_utils59.randomBytes)(NONCE_SIZE3);
|
|
37493
37764
|
const voteData = {
|
|
37494
37765
|
proposalId,
|
|
37495
37766
|
choice,
|
|
@@ -37497,14 +37768,14 @@ var PrivateVoting = class {
|
|
|
37497
37768
|
voter,
|
|
37498
37769
|
timestamp: Date.now()
|
|
37499
37770
|
};
|
|
37500
|
-
const plaintext = (0,
|
|
37771
|
+
const plaintext = (0, import_utils59.utf8ToBytes)(JSON.stringify(voteData));
|
|
37501
37772
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
|
|
37502
37773
|
const ciphertext = cipher.encrypt(plaintext);
|
|
37503
|
-
const keyHash = (0, import_sha25626.sha256)((0,
|
|
37774
|
+
const keyHash = (0, import_sha25626.sha256)((0, import_utils59.hexToBytes)(encryptionKey.slice(2)));
|
|
37504
37775
|
return {
|
|
37505
|
-
ciphertext: `0x${(0,
|
|
37506
|
-
nonce: `0x${(0,
|
|
37507
|
-
encryptionKeyHash: `0x${(0,
|
|
37776
|
+
ciphertext: `0x${(0, import_utils59.bytesToHex)(ciphertext)}`,
|
|
37777
|
+
nonce: `0x${(0, import_utils59.bytesToHex)(nonce)}`,
|
|
37778
|
+
encryptionKeyHash: `0x${(0, import_utils59.bytesToHex)(keyHash)}`,
|
|
37508
37779
|
proposalId,
|
|
37509
37780
|
voter,
|
|
37510
37781
|
timestamp: voteData.timestamp
|
|
@@ -37550,8 +37821,8 @@ var PrivateVoting = class {
|
|
|
37550
37821
|
}
|
|
37551
37822
|
const derivedKey = this.deriveEncryptionKey(decryptionKey, vote.proposalId);
|
|
37552
37823
|
try {
|
|
37553
|
-
const keyHash = (0, import_sha25626.sha256)((0,
|
|
37554
|
-
const expectedKeyHash = `0x${(0,
|
|
37824
|
+
const keyHash = (0, import_sha25626.sha256)((0, import_utils59.hexToBytes)(decryptionKey.slice(2)));
|
|
37825
|
+
const expectedKeyHash = `0x${(0, import_utils59.bytesToHex)(keyHash)}`;
|
|
37555
37826
|
if (vote.encryptionKeyHash !== expectedKeyHash) {
|
|
37556
37827
|
throw new CryptoError(
|
|
37557
37828
|
"Decryption key hash mismatch - this key cannot decrypt this vote",
|
|
@@ -37560,9 +37831,9 @@ var PrivateVoting = class {
|
|
|
37560
37831
|
);
|
|
37561
37832
|
}
|
|
37562
37833
|
const nonceHex = vote.nonce.startsWith("0x") ? vote.nonce.slice(2) : vote.nonce;
|
|
37563
|
-
const nonce = (0,
|
|
37834
|
+
const nonce = (0, import_utils59.hexToBytes)(nonceHex);
|
|
37564
37835
|
const ciphertextHex = vote.ciphertext.startsWith("0x") ? vote.ciphertext.slice(2) : vote.ciphertext;
|
|
37565
|
-
const ciphertext = (0,
|
|
37836
|
+
const ciphertext = (0, import_utils59.hexToBytes)(ciphertextHex);
|
|
37566
37837
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
|
|
37567
37838
|
let plaintext;
|
|
37568
37839
|
try {
|
|
@@ -37651,10 +37922,10 @@ var PrivateVoting = class {
|
|
|
37651
37922
|
*/
|
|
37652
37923
|
deriveEncryptionKey(key, proposalId) {
|
|
37653
37924
|
const keyHex = key.startsWith("0x") ? key.slice(2) : key;
|
|
37654
|
-
const keyBytes = (0,
|
|
37925
|
+
const keyBytes = (0, import_utils59.hexToBytes)(keyHex);
|
|
37655
37926
|
try {
|
|
37656
|
-
const salt = (0,
|
|
37657
|
-
const info = (0,
|
|
37927
|
+
const salt = (0, import_utils59.utf8ToBytes)(VOTE_ENCRYPTION_DOMAIN);
|
|
37928
|
+
const info = (0, import_utils59.utf8ToBytes)(proposalId);
|
|
37658
37929
|
return (0, import_hkdf4.hkdf)(import_sha25626.sha256, keyBytes, salt, info, 32);
|
|
37659
37930
|
} finally {
|
|
37660
37931
|
secureWipe(keyBytes);
|
|
@@ -37800,21 +38071,21 @@ var PrivateVoting = class {
|
|
|
37800
38071
|
const blindings = {};
|
|
37801
38072
|
for (const [choice, weights] of Object.entries(votesByChoice)) {
|
|
37802
38073
|
const totalWeight = weights.reduce((sum, w) => sum + w, 0n);
|
|
37803
|
-
const { commitment, blinding } = commit(totalWeight, (0,
|
|
38074
|
+
const { commitment, blinding } = commit(totalWeight, (0, import_utils59.hexToBytes)(generateBlinding().slice(2)));
|
|
37804
38075
|
tallies[choice] = commitment;
|
|
37805
38076
|
blindings[choice] = blinding;
|
|
37806
38077
|
}
|
|
37807
38078
|
const encryptedBlindings = {};
|
|
37808
38079
|
for (const [choice, blinding] of Object.entries(blindings)) {
|
|
37809
|
-
const nonce = (0,
|
|
38080
|
+
const nonce = (0, import_utils59.randomBytes)(NONCE_SIZE3);
|
|
37810
38081
|
const derivedKey = this.deriveEncryptionKey(decryptionKey, `${proposalId}-tally-${choice}`);
|
|
37811
38082
|
try {
|
|
37812
38083
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
|
|
37813
|
-
const blindingBytes = (0,
|
|
38084
|
+
const blindingBytes = (0, import_utils59.hexToBytes)(blinding.slice(2));
|
|
37814
38085
|
const ciphertext = cipher.encrypt(blindingBytes);
|
|
37815
38086
|
encryptedBlindings[choice] = {
|
|
37816
|
-
ciphertext: `0x${(0,
|
|
37817
|
-
nonce: `0x${(0,
|
|
38087
|
+
ciphertext: `0x${(0, import_utils59.bytesToHex)(ciphertext)}`,
|
|
38088
|
+
nonce: `0x${(0, import_utils59.bytesToHex)(nonce)}`
|
|
37818
38089
|
};
|
|
37819
38090
|
} finally {
|
|
37820
38091
|
secureWipe(derivedKey);
|
|
@@ -37907,9 +38178,9 @@ var PrivateVoting = class {
|
|
|
37907
38178
|
}
|
|
37908
38179
|
let reconstructedKey = null;
|
|
37909
38180
|
try {
|
|
37910
|
-
reconstructedKey = (0,
|
|
38181
|
+
reconstructedKey = (0, import_utils59.hexToBytes)(decryptionShares[0].share.slice(2));
|
|
37911
38182
|
for (let i = 1; i < decryptionShares.length; i++) {
|
|
37912
|
-
const shareBytes = (0,
|
|
38183
|
+
const shareBytes = (0, import_utils59.hexToBytes)(decryptionShares[i].share.slice(2));
|
|
37913
38184
|
if (shareBytes.length !== reconstructedKey.length) {
|
|
37914
38185
|
throw new ValidationError(
|
|
37915
38186
|
"all decryption shares must have the same length",
|
|
@@ -37922,7 +38193,7 @@ var PrivateVoting = class {
|
|
|
37922
38193
|
reconstructedKey[j] ^= shareBytes[j];
|
|
37923
38194
|
}
|
|
37924
38195
|
}
|
|
37925
|
-
const reconstructedKeyHex = `0x${(0,
|
|
38196
|
+
const reconstructedKeyHex = `0x${(0, import_utils59.bytesToHex)(reconstructedKey)}`;
|
|
37926
38197
|
const results = {};
|
|
37927
38198
|
for (const [choice, commitmentPoint] of Object.entries(tally.tallies)) {
|
|
37928
38199
|
const encBlinding = tally.encryptedBlindings[choice];
|
|
@@ -37939,11 +38210,11 @@ var PrivateVoting = class {
|
|
|
37939
38210
|
);
|
|
37940
38211
|
let blindingFactor;
|
|
37941
38212
|
try {
|
|
37942
|
-
const nonceBytes = (0,
|
|
37943
|
-
const ciphertextBytes = (0,
|
|
38213
|
+
const nonceBytes = (0, import_utils59.hexToBytes)(encBlinding.nonce.slice(2));
|
|
38214
|
+
const ciphertextBytes = (0, import_utils59.hexToBytes)(encBlinding.ciphertext.slice(2));
|
|
37944
38215
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonceBytes);
|
|
37945
38216
|
const blindingBytes = cipher.decrypt(ciphertextBytes);
|
|
37946
|
-
blindingFactor = `0x${(0,
|
|
38217
|
+
blindingFactor = `0x${(0, import_utils59.bytesToHex)(blindingBytes)}`;
|
|
37947
38218
|
} catch (e) {
|
|
37948
38219
|
throw new CryptoError(
|
|
37949
38220
|
"failed to decrypt blinding factor",
|
|
@@ -37963,7 +38234,7 @@ var PrivateVoting = class {
|
|
|
37963
38234
|
try {
|
|
37964
38235
|
const { commitment: testCommit } = commit(
|
|
37965
38236
|
value,
|
|
37966
|
-
(0,
|
|
38237
|
+
(0, import_utils59.hexToBytes)(blindingFactor.slice(2))
|
|
37967
38238
|
);
|
|
37968
38239
|
if (testCommit === commitmentPoint) {
|
|
37969
38240
|
results[choice] = value;
|
|
@@ -38166,7 +38437,7 @@ function createPrivateVoting() {
|
|
|
38166
38437
|
var import_sha25627 = require("@noble/hashes/sha256");
|
|
38167
38438
|
var import_ed2551910 = require("@noble/curves/ed25519");
|
|
38168
38439
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
38169
|
-
var
|
|
38440
|
+
var import_utils60 = require("@noble/hashes/utils");
|
|
38170
38441
|
init_stealth2();
|
|
38171
38442
|
init_errors();
|
|
38172
38443
|
init_validation();
|
|
@@ -38256,22 +38527,22 @@ var PrivateNFT = class {
|
|
|
38256
38527
|
try {
|
|
38257
38528
|
const message = this.createProofMessage(ownership, challenge);
|
|
38258
38529
|
const messageHash = (0, import_sha25627.sha256)(new TextEncoder().encode(message));
|
|
38259
|
-
const privateKeyBytes = (0,
|
|
38530
|
+
const privateKeyBytes = (0, import_utils60.hexToBytes)(stealthPrivateKey.slice(2));
|
|
38260
38531
|
const signature = import_secp256k19.secp256k1.sign(messageHash, privateKeyBytes);
|
|
38261
38532
|
const zkProof = {
|
|
38262
38533
|
type: "ownership",
|
|
38263
|
-
proof: `0x${(0,
|
|
38534
|
+
proof: `0x${(0, import_utils60.bytesToHex)(signature.toCompactRawBytes())}`,
|
|
38264
38535
|
publicInputs: [
|
|
38265
|
-
`0x${(0,
|
|
38536
|
+
`0x${(0, import_utils60.bytesToHex)(messageHash)}`
|
|
38266
38537
|
]
|
|
38267
38538
|
};
|
|
38268
|
-
const stealthHashBytes = (0, import_sha25627.sha256)((0,
|
|
38539
|
+
const stealthHashBytes = (0, import_sha25627.sha256)((0, import_utils60.hexToBytes)(ownership.ownerStealth.address.slice(2)));
|
|
38269
38540
|
return {
|
|
38270
38541
|
nftContract: ownership.nftContract,
|
|
38271
38542
|
tokenId: ownership.tokenId,
|
|
38272
38543
|
challenge,
|
|
38273
38544
|
proof: zkProof,
|
|
38274
|
-
stealthHash: `0x${(0,
|
|
38545
|
+
stealthHash: `0x${(0, import_utils60.bytesToHex)(stealthHashBytes)}`,
|
|
38275
38546
|
timestamp: Date.now()
|
|
38276
38547
|
};
|
|
38277
38548
|
} catch (e) {
|
|
@@ -38313,9 +38584,9 @@ var PrivateNFT = class {
|
|
|
38313
38584
|
verifyOwnership(proof) {
|
|
38314
38585
|
try {
|
|
38315
38586
|
this.validateOwnershipProof(proof);
|
|
38316
|
-
const signatureBytes = (0,
|
|
38587
|
+
const signatureBytes = (0, import_utils60.hexToBytes)(proof.proof.proof.slice(2));
|
|
38317
38588
|
const signature = import_secp256k19.secp256k1.Signature.fromCompact(signatureBytes);
|
|
38318
|
-
const messageHash = (0,
|
|
38589
|
+
const messageHash = (0, import_utils60.hexToBytes)(proof.proof.publicInputs[0].slice(2));
|
|
38319
38590
|
if (signatureBytes.length !== 64) {
|
|
38320
38591
|
return {
|
|
38321
38592
|
valid: false,
|
|
@@ -38412,12 +38683,12 @@ var PrivateNFT = class {
|
|
|
38412
38683
|
chain: nft.chain,
|
|
38413
38684
|
timestamp: Date.now()
|
|
38414
38685
|
};
|
|
38415
|
-
const previousOwnerHashBytes = (0, import_sha25627.sha256)((0,
|
|
38686
|
+
const previousOwnerHashBytes = (0, import_sha25627.sha256)((0, import_utils60.hexToBytes)(nft.ownerStealth.address.slice(2)));
|
|
38416
38687
|
const transfer = {
|
|
38417
38688
|
nftContract: nft.nftContract,
|
|
38418
38689
|
tokenId: nft.tokenId,
|
|
38419
38690
|
newOwnerStealth,
|
|
38420
|
-
previousOwnerHash: `0x${(0,
|
|
38691
|
+
previousOwnerHash: `0x${(0, import_utils60.bytesToHex)(previousOwnerHashBytes)}`,
|
|
38421
38692
|
chain: nft.chain,
|
|
38422
38693
|
timestamp: Date.now()
|
|
38423
38694
|
};
|
|
@@ -38484,9 +38755,9 @@ var PrivateNFT = class {
|
|
|
38484
38755
|
);
|
|
38485
38756
|
}
|
|
38486
38757
|
const ownedNFTs = [];
|
|
38487
|
-
const viewingKeyHex = `0x${(0,
|
|
38488
|
-
const ed25519SpendingPubHex = `0x${(0,
|
|
38489
|
-
const secp256k1SpendingPubHex = `0x${(0,
|
|
38758
|
+
const viewingKeyHex = `0x${(0, import_utils60.bytesToHex)(viewingKey)}`;
|
|
38759
|
+
const ed25519SpendingPubHex = `0x${(0, import_utils60.bytesToHex)(import_ed2551910.ed25519.getPublicKey(scanKey))}`;
|
|
38760
|
+
const secp256k1SpendingPubHex = `0x${(0, import_utils60.bytesToHex)(import_secp256k19.secp256k1.getPublicKey(scanKey, true))}`;
|
|
38490
38761
|
for (const transfer of transfers) {
|
|
38491
38762
|
try {
|
|
38492
38763
|
if (!transfer || typeof transfer !== "object") {
|
|
@@ -39928,7 +40199,7 @@ function createMockSolanaAdapter(config = {}) {
|
|
|
39928
40199
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
39929
40200
|
var import_ed2551911 = require("@noble/curves/ed25519");
|
|
39930
40201
|
init_stealth2();
|
|
39931
|
-
|
|
40202
|
+
init_utils();
|
|
39932
40203
|
|
|
39933
40204
|
// src/wallet/ethereum/adapter.ts
|
|
39934
40205
|
var import_types41 = require("@sip-protocol/types");
|
|
@@ -41033,7 +41304,7 @@ var import_types64 = require("@sip-protocol/types");
|
|
|
41033
41304
|
// src/wallet/near/adapter.ts
|
|
41034
41305
|
var import_ed2551913 = require("@noble/curves/ed25519");
|
|
41035
41306
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
41036
|
-
var
|
|
41307
|
+
var import_utils63 = require("@noble/hashes/utils");
|
|
41037
41308
|
var import_types66 = require("@sip-protocol/types");
|
|
41038
41309
|
|
|
41039
41310
|
// src/chains/near/stealth.ts
|
|
@@ -41240,16 +41511,16 @@ function validateNEARStealthAddress(stealthAddress) {
|
|
|
41240
41511
|
}
|
|
41241
41512
|
|
|
41242
41513
|
// src/wallet/near/adapter.ts
|
|
41243
|
-
var
|
|
41514
|
+
var ED25519_ORDER3 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
41244
41515
|
|
|
41245
41516
|
// src/wallet/near/wallet-selector.ts
|
|
41246
41517
|
var import_sha27 = require("@noble/hashes/sha2");
|
|
41247
|
-
var
|
|
41518
|
+
var import_utils65 = require("@noble/hashes/utils");
|
|
41248
41519
|
var import_ed2551915 = require("@noble/curves/ed25519");
|
|
41249
41520
|
|
|
41250
41521
|
// src/chains/near/implicit-account.ts
|
|
41251
41522
|
var import_ed2551914 = require("@noble/curves/ed25519");
|
|
41252
|
-
var
|
|
41523
|
+
var import_utils64 = require("@noble/hashes/utils");
|
|
41253
41524
|
init_errors();
|
|
41254
41525
|
init_validation();
|
|
41255
41526
|
|
|
@@ -41293,12 +41564,12 @@ function createAnnouncementMemo2(ephemeralPublicKey, viewTag) {
|
|
|
41293
41564
|
|
|
41294
41565
|
// src/wallet/near/my-near-wallet.ts
|
|
41295
41566
|
var import_sha28 = require("@noble/hashes/sha2");
|
|
41296
|
-
var
|
|
41567
|
+
var import_utils66 = require("@noble/hashes/utils");
|
|
41297
41568
|
var import_ed2551916 = require("@noble/curves/ed25519");
|
|
41298
41569
|
|
|
41299
41570
|
// src/wallet/near/meteor-wallet.ts
|
|
41300
41571
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
41301
|
-
var
|
|
41572
|
+
var import_utils67 = require("@noble/hashes/utils");
|
|
41302
41573
|
var import_ed2551917 = require("@noble/curves/ed25519");
|
|
41303
41574
|
|
|
41304
41575
|
// src/wallet/hardware/types.ts
|
|
@@ -41911,7 +42182,7 @@ function createLedgerAdapter(config) {
|
|
|
41911
42182
|
// src/wallet/hardware/ledger-privacy.ts
|
|
41912
42183
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
41913
42184
|
var import_sha25628 = require("@noble/hashes/sha256");
|
|
41914
|
-
var
|
|
42185
|
+
var import_utils68 = require("@noble/hashes/utils");
|
|
41915
42186
|
var import_types70 = require("@sip-protocol/types");
|
|
41916
42187
|
|
|
41917
42188
|
// src/wallet/hardware/trezor.ts
|
|
@@ -42354,7 +42625,7 @@ function createTrezorAdapter(config) {
|
|
|
42354
42625
|
|
|
42355
42626
|
// src/wallet/hardware/mock.ts
|
|
42356
42627
|
var import_types74 = require("@sip-protocol/types");
|
|
42357
|
-
var
|
|
42628
|
+
var import_utils69 = require("@noble/hashes/utils");
|
|
42358
42629
|
var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
42359
42630
|
chain;
|
|
42360
42631
|
name = "mock-ledger";
|
|
@@ -42599,15 +42870,15 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
42599
42870
|
}
|
|
42600
42871
|
}
|
|
42601
42872
|
generateMockAddress(index) {
|
|
42602
|
-
const bytes = (0,
|
|
42873
|
+
const bytes = (0, import_utils69.randomBytes)(20);
|
|
42603
42874
|
bytes[0] = index;
|
|
42604
|
-
return `0x${(0,
|
|
42875
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
42605
42876
|
}
|
|
42606
42877
|
generateMockPublicKey(index) {
|
|
42607
|
-
const bytes = (0,
|
|
42878
|
+
const bytes = (0, import_utils69.randomBytes)(33);
|
|
42608
42879
|
bytes[0] = 2;
|
|
42609
42880
|
bytes[1] = index;
|
|
42610
|
-
return `0x${(0,
|
|
42881
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
42611
42882
|
}
|
|
42612
42883
|
generateMockSignature(data) {
|
|
42613
42884
|
const sig = new Uint8Array(65);
|
|
@@ -42616,7 +42887,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
42616
42887
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 11;
|
|
42617
42888
|
}
|
|
42618
42889
|
sig[64] = 27;
|
|
42619
|
-
return `0x${(0,
|
|
42890
|
+
return `0x${(0, import_utils69.bytesToHex)(sig)}`;
|
|
42620
42891
|
}
|
|
42621
42892
|
delay(ms) {
|
|
42622
42893
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -42805,15 +43076,15 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
42805
43076
|
}
|
|
42806
43077
|
}
|
|
42807
43078
|
generateMockAddress(index) {
|
|
42808
|
-
const bytes = (0,
|
|
43079
|
+
const bytes = (0, import_utils69.randomBytes)(20);
|
|
42809
43080
|
bytes[0] = index + 100;
|
|
42810
|
-
return `0x${(0,
|
|
43081
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
42811
43082
|
}
|
|
42812
43083
|
generateMockPublicKey(index) {
|
|
42813
|
-
const bytes = (0,
|
|
43084
|
+
const bytes = (0, import_utils69.randomBytes)(33);
|
|
42814
43085
|
bytes[0] = 3;
|
|
42815
43086
|
bytes[1] = index + 100;
|
|
42816
|
-
return `0x${(0,
|
|
43087
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
42817
43088
|
}
|
|
42818
43089
|
generateMockSignature(data) {
|
|
42819
43090
|
const sig = new Uint8Array(65);
|
|
@@ -42822,7 +43093,7 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
42822
43093
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 17;
|
|
42823
43094
|
}
|
|
42824
43095
|
sig[64] = 28;
|
|
42825
|
-
return `0x${(0,
|
|
43096
|
+
return `0x${(0, import_utils69.bytesToHex)(sig)}`;
|
|
42826
43097
|
}
|
|
42827
43098
|
delay(ms) {
|
|
42828
43099
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -42842,7 +43113,7 @@ var import_types77 = require("@sip-protocol/types");
|
|
|
42842
43113
|
init_solana();
|
|
42843
43114
|
|
|
42844
43115
|
// src/solana/noir-verifier.ts
|
|
42845
|
-
var
|
|
43116
|
+
var import_web318 = require("@solana/web3.js");
|
|
42846
43117
|
|
|
42847
43118
|
// src/solana/noir-verifier-types.ts
|
|
42848
43119
|
init_endpoints();
|
|
@@ -42933,6 +43204,8 @@ var SolanaNoirError = class extends Error {
|
|
|
42933
43204
|
this.details = details;
|
|
42934
43205
|
this.name = "SolanaNoirError";
|
|
42935
43206
|
}
|
|
43207
|
+
code;
|
|
43208
|
+
details;
|
|
42936
43209
|
};
|
|
42937
43210
|
var MAX_PROOF_SIZE_BYTES = 4096;
|
|
42938
43211
|
var MAX_PUBLIC_INPUTS = 32;
|
|
@@ -42967,7 +43240,7 @@ var SolanaNoirVerifier = class {
|
|
|
42967
43240
|
commitment: config.commitment ?? "confirmed",
|
|
42968
43241
|
maxComputeUnits: config.maxComputeUnits ?? 4e5
|
|
42969
43242
|
};
|
|
42970
|
-
this.connection = new
|
|
43243
|
+
this.connection = new import_web318.Connection(this.config.rpcUrl, this.config.commitment);
|
|
42971
43244
|
}
|
|
42972
43245
|
/**
|
|
42973
43246
|
* Get the Solana connection
|
|
@@ -43219,16 +43492,16 @@ var SolanaNoirVerifier = class {
|
|
|
43219
43492
|
error: `Proof requires ${computeUnits} CU, max is ${this.config.maxComputeUnits}`
|
|
43220
43493
|
};
|
|
43221
43494
|
}
|
|
43222
|
-
const transaction = new
|
|
43495
|
+
const transaction = new import_web318.Transaction();
|
|
43223
43496
|
transaction.add(
|
|
43224
|
-
|
|
43497
|
+
import_web318.ComputeBudgetProgram.setComputeUnitLimit({ units: this.config.maxComputeUnits })
|
|
43225
43498
|
);
|
|
43226
43499
|
transaction.add(instruction);
|
|
43227
43500
|
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash(
|
|
43228
43501
|
this.config.commitment
|
|
43229
43502
|
);
|
|
43230
43503
|
transaction.recentBlockhash = blockhash;
|
|
43231
|
-
transaction.feePayer = new
|
|
43504
|
+
transaction.feePayer = new import_web318.PublicKey(wallet.publicKey.toBase58());
|
|
43232
43505
|
const signedTransaction = await wallet.signTransaction(transaction);
|
|
43233
43506
|
const signature = await this.connection.sendRawTransaction(signedTransaction.serialize());
|
|
43234
43507
|
const confirmation = await this.connection.confirmTransaction(
|
|
@@ -43270,8 +43543,8 @@ var SolanaNoirVerifier = class {
|
|
|
43270
43543
|
*/
|
|
43271
43544
|
createSunspotVerifyInstruction(proof, programId) {
|
|
43272
43545
|
const serialized = this.serializeProofForSunspot(proof);
|
|
43273
|
-
return new
|
|
43274
|
-
programId: new
|
|
43546
|
+
return new import_web318.TransactionInstruction({
|
|
43547
|
+
programId: new import_web318.PublicKey(programId),
|
|
43275
43548
|
keys: [],
|
|
43276
43549
|
// Sunspot verifiers don't require any accounts
|
|
43277
43550
|
data: serialized
|
|
@@ -43445,8 +43718,8 @@ var SolanaNoirVerifier = class {
|
|
|
43445
43718
|
}
|
|
43446
43719
|
async hashBytes(bytes) {
|
|
43447
43720
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
43448
|
-
const { bytesToHex:
|
|
43449
|
-
return
|
|
43721
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
43722
|
+
return bytesToHex64(sha25642(bytes));
|
|
43450
43723
|
}
|
|
43451
43724
|
hexToBytes(hex) {
|
|
43452
43725
|
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
@@ -43483,8 +43756,8 @@ function createMainnetVerifier(config = {}) {
|
|
|
43483
43756
|
}
|
|
43484
43757
|
|
|
43485
43758
|
// src/solana/jito-relayer.ts
|
|
43486
|
-
var
|
|
43487
|
-
var
|
|
43759
|
+
var import_web319 = require("@solana/web3.js");
|
|
43760
|
+
var import_bs58 = __toESM(require("bs58"));
|
|
43488
43761
|
var JITO_BLOCK_ENGINES = {
|
|
43489
43762
|
mainnet: {
|
|
43490
43763
|
amsterdam: "https://amsterdam.mainnet.block-engine.jito.wtf/api/v1",
|
|
@@ -43533,8 +43806,10 @@ var JitoRelayerError = class extends Error {
|
|
|
43533
43806
|
this.details = details;
|
|
43534
43807
|
this.name = "JitoRelayerError";
|
|
43535
43808
|
}
|
|
43809
|
+
code;
|
|
43810
|
+
details;
|
|
43536
43811
|
};
|
|
43537
|
-
var JitoRelayer = class {
|
|
43812
|
+
var JitoRelayer = class _JitoRelayer {
|
|
43538
43813
|
connection;
|
|
43539
43814
|
blockEngineUrl;
|
|
43540
43815
|
defaultTipLamports;
|
|
@@ -43543,7 +43818,7 @@ var JitoRelayer = class {
|
|
|
43543
43818
|
submissionTimeout;
|
|
43544
43819
|
constructor(config = {}) {
|
|
43545
43820
|
this.blockEngineUrl = config.blockEngineUrl ?? JITO_BLOCK_ENGINES.mainnet.ny;
|
|
43546
|
-
this.connection = new
|
|
43821
|
+
this.connection = new import_web319.Connection(
|
|
43547
43822
|
config.rpcUrl ?? "https://api.mainnet-beta.solana.com",
|
|
43548
43823
|
"confirmed"
|
|
43549
43824
|
);
|
|
@@ -43552,6 +43827,11 @@ var JitoRelayer = class {
|
|
|
43552
43827
|
this.maxRetries = config.maxRetries ?? JITO_DEFAULTS.maxRetries;
|
|
43553
43828
|
this.submissionTimeout = config.submissionTimeout ?? JITO_DEFAULTS.submissionTimeout;
|
|
43554
43829
|
}
|
|
43830
|
+
// ─── Static Helpers ─────────────────────────────────────────────────────────
|
|
43831
|
+
/** Encode a 64-byte ed25519 signature as a base58 string (Solana canonical form). */
|
|
43832
|
+
static encodeSignature(sig) {
|
|
43833
|
+
return import_bs58.default.encode(sig);
|
|
43834
|
+
}
|
|
43555
43835
|
// ─── Public Methods ─────────────────────────────────────────────────────────
|
|
43556
43836
|
/**
|
|
43557
43837
|
* Submit a bundle of transactions to Jito
|
|
@@ -43603,11 +43883,11 @@ var JitoRelayer = class {
|
|
|
43603
43883
|
}
|
|
43604
43884
|
}
|
|
43605
43885
|
const signatures = bundleTransactions.map((tx) => {
|
|
43606
|
-
if (tx instanceof
|
|
43607
|
-
return
|
|
43608
|
-
} else {
|
|
43609
|
-
return tx.signature?.toString() ?? "";
|
|
43886
|
+
if (tx instanceof import_web319.VersionedTransaction) {
|
|
43887
|
+
return _JitoRelayer.encodeSignature(tx.signatures[0]);
|
|
43610
43888
|
}
|
|
43889
|
+
const sig = tx.signature;
|
|
43890
|
+
return sig ? _JitoRelayer.encodeSignature(sig) : "";
|
|
43611
43891
|
});
|
|
43612
43892
|
if (request.waitForConfirmation) {
|
|
43613
43893
|
const status = await this.waitForBundleConfirmation(bundleId, lastValidBlockHeight);
|
|
@@ -43639,13 +43919,30 @@ var JitoRelayer = class {
|
|
|
43639
43919
|
async relayTransaction(request) {
|
|
43640
43920
|
this.log("Relaying transaction");
|
|
43641
43921
|
try {
|
|
43922
|
+
if (request.tipPayer) {
|
|
43923
|
+
const bundle = await this.submitBundle({
|
|
43924
|
+
transactions: [request.transaction],
|
|
43925
|
+
tipLamports: request.tipLamports,
|
|
43926
|
+
tipPayer: request.tipPayer,
|
|
43927
|
+
waitForConfirmation: request.waitForConfirmation
|
|
43928
|
+
});
|
|
43929
|
+
return {
|
|
43930
|
+
signature: bundle.signatures[bundle.signatures.length - 1] ?? "",
|
|
43931
|
+
bundleId: bundle.bundleId,
|
|
43932
|
+
status: bundle.status === "landed" ? "confirmed" : bundle.status === "submitted" ? "submitted" : "failed",
|
|
43933
|
+
slot: bundle.slot,
|
|
43934
|
+
error: bundle.error,
|
|
43935
|
+
relayed: true
|
|
43936
|
+
};
|
|
43937
|
+
}
|
|
43642
43938
|
const serializedTx = Buffer.from(request.transaction.serialize()).toString("base64");
|
|
43643
43939
|
const bundleId = await this.sendBundle([serializedTx]);
|
|
43644
43940
|
let signature;
|
|
43645
|
-
if (request.transaction instanceof
|
|
43646
|
-
signature =
|
|
43941
|
+
if (request.transaction instanceof import_web319.VersionedTransaction) {
|
|
43942
|
+
signature = _JitoRelayer.encodeSignature(request.transaction.signatures[0]);
|
|
43647
43943
|
} else {
|
|
43648
|
-
|
|
43944
|
+
const sig = request.transaction.signature;
|
|
43945
|
+
signature = sig ? _JitoRelayer.encodeSignature(sig) : "";
|
|
43649
43946
|
}
|
|
43650
43947
|
if (request.waitForConfirmation) {
|
|
43651
43948
|
const { lastValidBlockHeight } = await this.connection.getLatestBlockhash();
|
|
@@ -43695,7 +43992,7 @@ var JitoRelayer = class {
|
|
|
43695
43992
|
*/
|
|
43696
43993
|
getRandomTipAccount() {
|
|
43697
43994
|
const index = Math.floor(Math.random() * JITO_TIP_ACCOUNTS.length);
|
|
43698
|
-
return new
|
|
43995
|
+
return new import_web319.PublicKey(JITO_TIP_ACCOUNTS[index]);
|
|
43699
43996
|
}
|
|
43700
43997
|
// ─── Private Methods ────────────────────────────────────────────────────────
|
|
43701
43998
|
/**
|
|
@@ -43703,7 +44000,7 @@ var JitoRelayer = class {
|
|
|
43703
44000
|
*/
|
|
43704
44001
|
createTipInstruction(payer, tipLamports) {
|
|
43705
44002
|
const tipAccount = this.getRandomTipAccount();
|
|
43706
|
-
return
|
|
44003
|
+
return import_web319.SystemProgram.transfer({
|
|
43707
44004
|
fromPubkey: payer,
|
|
43708
44005
|
toPubkey: tipAccount,
|
|
43709
44006
|
lamports: tipLamports
|
|
@@ -43713,7 +44010,7 @@ var JitoRelayer = class {
|
|
|
43713
44010
|
* Prepare transactions for bundle submission
|
|
43714
44011
|
*/
|
|
43715
44012
|
async prepareBundleTransactions(transactions, tipInstruction, tipPayer, blockhash) {
|
|
43716
|
-
const tipTx = new
|
|
44013
|
+
const tipTx = new import_web319.Transaction();
|
|
43717
44014
|
tipTx.add(tipInstruction);
|
|
43718
44015
|
tipTx.recentBlockhash = blockhash;
|
|
43719
44016
|
tipTx.feePayer = tipPayer.publicKey;
|
|
@@ -43868,15 +44165,15 @@ function createMainnetRelayer(rpcUrl) {
|
|
|
43868
44165
|
// src/chains/near/commitment.ts
|
|
43869
44166
|
var import_ed2551918 = require("@noble/curves/ed25519");
|
|
43870
44167
|
var import_sha210 = require("@noble/hashes/sha2");
|
|
43871
|
-
var
|
|
44168
|
+
var import_utils70 = require("@noble/hashes/utils");
|
|
43872
44169
|
init_errors();
|
|
43873
44170
|
init_validation();
|
|
43874
44171
|
var H_DOMAIN3 = "SIP-NEAR-PEDERSEN-GENERATOR-H-v1";
|
|
43875
44172
|
var G3 = import_ed2551918.ed25519.ExtendedPoint.BASE;
|
|
43876
|
-
var
|
|
44173
|
+
var ED25519_ORDER4 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
43877
44174
|
var ED25519_COFACTOR2 = 8n;
|
|
43878
44175
|
var MAX_NEAR_AMOUNT = 2n ** 128n - 1n;
|
|
43879
|
-
var MAX_COMMITMENT_VALUE =
|
|
44176
|
+
var MAX_COMMITMENT_VALUE = ED25519_ORDER4 - 1n;
|
|
43880
44177
|
var H3 = generateH3();
|
|
43881
44178
|
function generateH3() {
|
|
43882
44179
|
let counter = 0;
|
|
@@ -43889,7 +44186,7 @@ function generateH3() {
|
|
|
43889
44186
|
if (!point.equals(import_ed2551918.ed25519.ExtendedPoint.ZERO)) {
|
|
43890
44187
|
const gBytes = G3.toRawBytes();
|
|
43891
44188
|
const hBytes = point.toRawBytes();
|
|
43892
|
-
if ((0,
|
|
44189
|
+
if ((0, import_utils70.bytesToHex)(gBytes) !== (0, import_utils70.bytesToHex)(hBytes)) {
|
|
43893
44190
|
return point;
|
|
43894
44191
|
}
|
|
43895
44192
|
}
|
|
@@ -43933,20 +44230,20 @@ function commitNEAR(value, blinding) {
|
|
|
43933
44230
|
if (value < 0n) {
|
|
43934
44231
|
throw new ValidationError("must be non-negative", "value");
|
|
43935
44232
|
}
|
|
43936
|
-
if (value >=
|
|
44233
|
+
if (value >= ED25519_ORDER4) {
|
|
43937
44234
|
throw new ValidationError(
|
|
43938
44235
|
"must be less than curve order",
|
|
43939
44236
|
"value",
|
|
43940
|
-
{ curveOrder:
|
|
44237
|
+
{ curveOrder: ED25519_ORDER4.toString(16) }
|
|
43941
44238
|
);
|
|
43942
44239
|
}
|
|
43943
|
-
const r = blinding ?? (0,
|
|
44240
|
+
const r = blinding ?? (0, import_utils70.randomBytes)(32);
|
|
43944
44241
|
if (r.length !== 32) {
|
|
43945
44242
|
throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
|
|
43946
44243
|
}
|
|
43947
|
-
const rScalar = bytesToBigInt4(r) %
|
|
44244
|
+
const rScalar = bytesToBigInt4(r) % ED25519_ORDER4;
|
|
43948
44245
|
if (rScalar === 0n) {
|
|
43949
|
-
return commitNEAR(value, (0,
|
|
44246
|
+
return commitNEAR(value, (0, import_utils70.randomBytes)(32));
|
|
43950
44247
|
}
|
|
43951
44248
|
let C;
|
|
43952
44249
|
if (value === 0n) {
|
|
@@ -43958,8 +44255,8 @@ function commitNEAR(value, blinding) {
|
|
|
43958
44255
|
}
|
|
43959
44256
|
const rScalarBytes = bigIntToBytes4(rScalar, 32);
|
|
43960
44257
|
return {
|
|
43961
|
-
commitment: `0x${(0,
|
|
43962
|
-
blinding: `0x${(0,
|
|
44258
|
+
commitment: `0x${(0, import_utils70.bytesToHex)(C.toRawBytes())}`,
|
|
44259
|
+
blinding: `0x${(0, import_utils70.bytesToHex)(rScalarBytes)}`
|
|
43963
44260
|
};
|
|
43964
44261
|
}
|
|
43965
44262
|
function verifyOpeningNEAR(commitment, value, blinding) {
|
|
@@ -43967,7 +44264,7 @@ function verifyOpeningNEAR(commitment, value, blinding) {
|
|
|
43967
44264
|
const commitmentBytes = hexToBytes38(commitment.slice(2));
|
|
43968
44265
|
const C = import_ed2551918.ed25519.ExtendedPoint.fromHex(commitmentBytes);
|
|
43969
44266
|
const blindingBytes = hexToBytes38(blinding.slice(2));
|
|
43970
|
-
const rScalar = bytesToBigInt4(blindingBytes) %
|
|
44267
|
+
const rScalar = bytesToBigInt4(blindingBytes) % ED25519_ORDER4;
|
|
43971
44268
|
let expected;
|
|
43972
44269
|
if (value === 0n) {
|
|
43973
44270
|
expected = H3.multiply(rScalar);
|
|
@@ -43991,7 +44288,7 @@ function commitNEP141Token(amount, tokenContract, decimals, blinding) {
|
|
|
43991
44288
|
{ max: MAX_NEAR_AMOUNT.toString() }
|
|
43992
44289
|
);
|
|
43993
44290
|
}
|
|
43994
|
-
if (amount >=
|
|
44291
|
+
if (amount >= ED25519_ORDER4) {
|
|
43995
44292
|
throw new ValidationError(
|
|
43996
44293
|
"Amount exceeds maximum committable value (curve order)",
|
|
43997
44294
|
"amount",
|
|
@@ -44052,7 +44349,7 @@ function addCommitmentsNEAR(c1, c2) {
|
|
|
44052
44349
|
}
|
|
44053
44350
|
const sum = point1.add(point2);
|
|
44054
44351
|
return {
|
|
44055
|
-
commitment: `0x${(0,
|
|
44352
|
+
commitment: `0x${(0, import_utils70.bytesToHex)(sum.toRawBytes())}`
|
|
44056
44353
|
};
|
|
44057
44354
|
}
|
|
44058
44355
|
function subtractCommitmentsNEAR(c1, c2) {
|
|
@@ -44081,7 +44378,7 @@ function subtractCommitmentsNEAR(c1, c2) {
|
|
|
44081
44378
|
};
|
|
44082
44379
|
}
|
|
44083
44380
|
return {
|
|
44084
|
-
commitment: `0x${(0,
|
|
44381
|
+
commitment: `0x${(0, import_utils70.bytesToHex)(diff.toRawBytes())}`
|
|
44085
44382
|
};
|
|
44086
44383
|
}
|
|
44087
44384
|
function addBlindingsNEAR(b1, b2) {
|
|
@@ -44095,9 +44392,9 @@ function addBlindingsNEAR(b1, b2) {
|
|
|
44095
44392
|
const b2Bytes = hexToBytes38(b2.slice(2));
|
|
44096
44393
|
const b1Scalar = bytesToBigInt4(b1Bytes);
|
|
44097
44394
|
const b2Scalar = bytesToBigInt4(b2Bytes);
|
|
44098
|
-
const sum = (b1Scalar + b2Scalar) %
|
|
44395
|
+
const sum = (b1Scalar + b2Scalar) % ED25519_ORDER4;
|
|
44099
44396
|
const sumBytes = bigIntToBytes4(sum, 32);
|
|
44100
|
-
return `0x${(0,
|
|
44397
|
+
return `0x${(0, import_utils70.bytesToHex)(sumBytes)}`;
|
|
44101
44398
|
}
|
|
44102
44399
|
function subtractBlindingsNEAR(b1, b2) {
|
|
44103
44400
|
if (!isValidHex(b1)) {
|
|
@@ -44110,24 +44407,24 @@ function subtractBlindingsNEAR(b1, b2) {
|
|
|
44110
44407
|
const b2Bytes = hexToBytes38(b2.slice(2));
|
|
44111
44408
|
const b1Scalar = bytesToBigInt4(b1Bytes);
|
|
44112
44409
|
const b2Scalar = bytesToBigInt4(b2Bytes);
|
|
44113
|
-
const diff = (b1Scalar - b2Scalar +
|
|
44410
|
+
const diff = (b1Scalar - b2Scalar + ED25519_ORDER4) % ED25519_ORDER4;
|
|
44114
44411
|
const diffBytes = bigIntToBytes4(diff, 32);
|
|
44115
|
-
return `0x${(0,
|
|
44412
|
+
return `0x${(0, import_utils70.bytesToHex)(diffBytes)}`;
|
|
44116
44413
|
}
|
|
44117
44414
|
function getGeneratorsNEAR() {
|
|
44118
44415
|
return {
|
|
44119
|
-
G: `0x${(0,
|
|
44120
|
-
H: `0x${(0,
|
|
44416
|
+
G: `0x${(0, import_utils70.bytesToHex)(G3.toRawBytes())}`,
|
|
44417
|
+
H: `0x${(0, import_utils70.bytesToHex)(H3.toRawBytes())}`
|
|
44121
44418
|
};
|
|
44122
44419
|
}
|
|
44123
44420
|
function generateBlindingNEAR() {
|
|
44124
|
-
const bytes = (0,
|
|
44125
|
-
const scalar = bytesToBigInt4(bytes) %
|
|
44421
|
+
const bytes = (0, import_utils70.randomBytes)(32);
|
|
44422
|
+
const scalar = bytesToBigInt4(bytes) % ED25519_ORDER4;
|
|
44126
44423
|
if (scalar === 0n) {
|
|
44127
44424
|
return generateBlindingNEAR();
|
|
44128
44425
|
}
|
|
44129
44426
|
const scalarBytes = bigIntToBytes4(scalar, 32);
|
|
44130
|
-
return `0x${(0,
|
|
44427
|
+
return `0x${(0, import_utils70.bytesToHex)(scalarBytes)}`;
|
|
44131
44428
|
}
|
|
44132
44429
|
|
|
44133
44430
|
// src/chains/near/viewing-key.ts
|
|
@@ -44135,7 +44432,7 @@ var import_ed2551919 = require("@noble/curves/ed25519");
|
|
|
44135
44432
|
var import_sha25629 = require("@noble/hashes/sha256");
|
|
44136
44433
|
var import_hmac7 = require("@noble/hashes/hmac");
|
|
44137
44434
|
var import_hkdf5 = require("@noble/hashes/hkdf");
|
|
44138
|
-
var
|
|
44435
|
+
var import_utils71 = require("@noble/hashes/utils");
|
|
44139
44436
|
var import_chacha6 = require("@noble/ciphers/chacha.js");
|
|
44140
44437
|
init_errors();
|
|
44141
44438
|
init_validation();
|
|
@@ -44151,7 +44448,7 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
44151
44448
|
"spendingPrivateKey"
|
|
44152
44449
|
);
|
|
44153
44450
|
}
|
|
44154
|
-
const spendingBytes = (0,
|
|
44451
|
+
const spendingBytes = (0, import_utils71.hexToBytes)(spendingPrivateKey.slice(2));
|
|
44155
44452
|
if (spendingBytes.length !== 32) {
|
|
44156
44453
|
throw new ValidationError(
|
|
44157
44454
|
"spendingPrivateKey must be 32 bytes",
|
|
@@ -44162,15 +44459,15 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
44162
44459
|
try {
|
|
44163
44460
|
viewingPrivateBytes = (0, import_hmac7.hmac)(
|
|
44164
44461
|
import_sha25629.sha256,
|
|
44165
|
-
(0,
|
|
44462
|
+
(0, import_utils71.utf8ToBytes)(VIEWING_KEY_CONTEXT3),
|
|
44166
44463
|
spendingBytes
|
|
44167
44464
|
);
|
|
44168
44465
|
const viewingPublicBytes = import_ed2551919.ed25519.getPublicKey(viewingPrivateBytes);
|
|
44169
44466
|
const hashBytes = (0, import_sha25629.sha256)(viewingPublicBytes);
|
|
44170
44467
|
return {
|
|
44171
|
-
privateKey: `0x${(0,
|
|
44172
|
-
publicKey: `0x${(0,
|
|
44173
|
-
hash: `0x${(0,
|
|
44468
|
+
privateKey: `0x${(0, import_utils71.bytesToHex)(viewingPrivateBytes)}`,
|
|
44469
|
+
publicKey: `0x${(0, import_utils71.bytesToHex)(viewingPublicBytes)}`,
|
|
44470
|
+
hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
|
|
44174
44471
|
label,
|
|
44175
44472
|
createdAt: Date.now()
|
|
44176
44473
|
};
|
|
@@ -44180,14 +44477,14 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
44180
44477
|
}
|
|
44181
44478
|
}
|
|
44182
44479
|
function generateRandomNEARViewingKey(label) {
|
|
44183
|
-
const privateBytes = (0,
|
|
44480
|
+
const privateBytes = (0, import_utils71.randomBytes)(32);
|
|
44184
44481
|
try {
|
|
44185
44482
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
|
|
44186
44483
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44187
44484
|
return {
|
|
44188
|
-
privateKey: `0x${(0,
|
|
44189
|
-
publicKey: `0x${(0,
|
|
44190
|
-
hash: `0x${(0,
|
|
44485
|
+
privateKey: `0x${(0, import_utils71.bytesToHex)(privateBytes)}`,
|
|
44486
|
+
publicKey: `0x${(0, import_utils71.bytesToHex)(publicBytes)}`,
|
|
44487
|
+
hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
|
|
44191
44488
|
label,
|
|
44192
44489
|
createdAt: Date.now()
|
|
44193
44490
|
};
|
|
@@ -44202,7 +44499,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
|
|
|
44202
44499
|
"viewingPublicKey"
|
|
44203
44500
|
);
|
|
44204
44501
|
}
|
|
44205
|
-
const publicBytes = (0,
|
|
44502
|
+
const publicBytes = (0, import_utils71.hexToBytes)(viewingPublicKey.slice(2));
|
|
44206
44503
|
if (publicBytes.length !== 32) {
|
|
44207
44504
|
throw new ValidationError(
|
|
44208
44505
|
"viewingPublicKey must be 32 bytes",
|
|
@@ -44210,7 +44507,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
|
|
|
44210
44507
|
);
|
|
44211
44508
|
}
|
|
44212
44509
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44213
|
-
return `0x${(0,
|
|
44510
|
+
return `0x${(0, import_utils71.bytesToHex)(hashBytes)}`;
|
|
44214
44511
|
}
|
|
44215
44512
|
function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
44216
44513
|
if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
|
|
@@ -44219,7 +44516,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
44219
44516
|
"viewingPrivateKey"
|
|
44220
44517
|
);
|
|
44221
44518
|
}
|
|
44222
|
-
const privateBytes = (0,
|
|
44519
|
+
const privateBytes = (0, import_utils71.hexToBytes)(viewingPrivateKey.slice(2));
|
|
44223
44520
|
if (privateBytes.length !== 32) {
|
|
44224
44521
|
throw new ValidationError(
|
|
44225
44522
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -44229,7 +44526,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
44229
44526
|
try {
|
|
44230
44527
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
|
|
44231
44528
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44232
|
-
return `0x${(0,
|
|
44529
|
+
return `0x${(0, import_utils71.bytesToHex)(hashBytes)}`;
|
|
44233
44530
|
} finally {
|
|
44234
44531
|
secureWipe(privateBytes);
|
|
44235
44532
|
}
|
|
@@ -44276,9 +44573,9 @@ function importNEARViewingKey(exported) {
|
|
|
44276
44573
|
{ expected: computedHash, received: exported.hash }
|
|
44277
44574
|
);
|
|
44278
44575
|
}
|
|
44279
|
-
const privateBytes = (0,
|
|
44576
|
+
const privateBytes = (0, import_utils71.hexToBytes)(exported.privateKey.slice(2));
|
|
44280
44577
|
try {
|
|
44281
|
-
const derivedPublic = `0x${(0,
|
|
44578
|
+
const derivedPublic = `0x${(0, import_utils71.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
|
|
44282
44579
|
if (derivedPublic !== exported.publicKey) {
|
|
44283
44580
|
throw new ValidationError(
|
|
44284
44581
|
"Public key does not match private key",
|
|
@@ -44297,10 +44594,10 @@ function importNEARViewingKey(exported) {
|
|
|
44297
44594
|
};
|
|
44298
44595
|
}
|
|
44299
44596
|
function deriveEncryptionKey3(key, salt) {
|
|
44300
|
-
const keyBytes = (0,
|
|
44597
|
+
const keyBytes = (0, import_utils71.hexToBytes)(key.slice(2));
|
|
44301
44598
|
try {
|
|
44302
|
-
const hkdfSalt = salt ?? (0,
|
|
44303
|
-
return (0, import_hkdf5.hkdf)(import_sha25629.sha256, keyBytes, hkdfSalt, (0,
|
|
44599
|
+
const hkdfSalt = salt ?? (0, import_utils71.utf8ToBytes)(ENCRYPTION_DOMAIN3);
|
|
44600
|
+
return (0, import_hkdf5.hkdf)(import_sha25629.sha256, keyBytes, hkdfSalt, (0, import_utils71.utf8ToBytes)("encryption"), 32);
|
|
44304
44601
|
} finally {
|
|
44305
44602
|
secureWipe(keyBytes);
|
|
44306
44603
|
}
|
|
@@ -44308,13 +44605,13 @@ function deriveEncryptionKey3(key, salt) {
|
|
|
44308
44605
|
function encryptForNEARViewing(data, viewingKey) {
|
|
44309
44606
|
const encKey = deriveEncryptionKey3(viewingKey.privateKey);
|
|
44310
44607
|
try {
|
|
44311
|
-
const nonce = (0,
|
|
44312
|
-
const plaintext = (0,
|
|
44608
|
+
const nonce = (0, import_utils71.randomBytes)(NONCE_SIZE4);
|
|
44609
|
+
const plaintext = (0, import_utils71.utf8ToBytes)(JSON.stringify(data));
|
|
44313
44610
|
const cipher = (0, import_chacha6.xchacha20poly1305)(encKey, nonce);
|
|
44314
44611
|
const ciphertext = cipher.encrypt(plaintext);
|
|
44315
44612
|
return {
|
|
44316
|
-
ciphertext: `0x${(0,
|
|
44317
|
-
nonce: `0x${(0,
|
|
44613
|
+
ciphertext: `0x${(0, import_utils71.bytesToHex)(ciphertext)}`,
|
|
44614
|
+
nonce: `0x${(0, import_utils71.bytesToHex)(nonce)}`,
|
|
44318
44615
|
viewingKeyHash: viewingKey.hash
|
|
44319
44616
|
};
|
|
44320
44617
|
} finally {
|
|
@@ -44331,8 +44628,8 @@ function decryptWithNEARViewing(encrypted, viewingKey) {
|
|
|
44331
44628
|
}
|
|
44332
44629
|
const encKey = deriveEncryptionKey3(viewingKey.privateKey);
|
|
44333
44630
|
try {
|
|
44334
|
-
const ciphertext = (0,
|
|
44335
|
-
const nonce = (0,
|
|
44631
|
+
const ciphertext = (0, import_utils71.hexToBytes)(encrypted.ciphertext.slice(2));
|
|
44632
|
+
const nonce = (0, import_utils71.hexToBytes)(encrypted.nonce.slice(2));
|
|
44336
44633
|
if (nonce.length !== NONCE_SIZE4) {
|
|
44337
44634
|
throw new ValidationError(
|
|
44338
44635
|
`Invalid nonce length: ${nonce.length}. Expected: ${NONCE_SIZE4}`,
|
|
@@ -44382,15 +44679,15 @@ function deriveNEARChildViewingKey(parentKey, childPath, label) {
|
|
|
44382
44679
|
if (!childPath || typeof childPath !== "string") {
|
|
44383
44680
|
throw new ValidationError("childPath must be a non-empty string", "childPath");
|
|
44384
44681
|
}
|
|
44385
|
-
const parentBytes = (0,
|
|
44682
|
+
const parentBytes = (0, import_utils71.hexToBytes)(parentKey.privateKey.slice(2));
|
|
44386
44683
|
try {
|
|
44387
|
-
const childBytes = (0, import_hmac7.hmac)(import_sha25629.sha256, (0,
|
|
44684
|
+
const childBytes = (0, import_hmac7.hmac)(import_sha25629.sha256, (0, import_utils71.utf8ToBytes)(childPath), parentBytes);
|
|
44388
44685
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(childBytes);
|
|
44389
44686
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44390
44687
|
const result = {
|
|
44391
|
-
privateKey: `0x${(0,
|
|
44392
|
-
publicKey: `0x${(0,
|
|
44393
|
-
hash: `0x${(0,
|
|
44688
|
+
privateKey: `0x${(0, import_utils71.bytesToHex)(childBytes)}`,
|
|
44689
|
+
publicKey: `0x${(0, import_utils71.bytesToHex)(publicBytes)}`,
|
|
44690
|
+
hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
|
|
44394
44691
|
label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
|
|
44395
44692
|
createdAt: Date.now()
|
|
44396
44693
|
};
|
|
@@ -44407,7 +44704,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
|
|
|
44407
44704
|
"viewingPrivateKey"
|
|
44408
44705
|
);
|
|
44409
44706
|
}
|
|
44410
|
-
const privateBytes = (0,
|
|
44707
|
+
const privateBytes = (0, import_utils71.hexToBytes)(viewingPrivateKey.slice(2));
|
|
44411
44708
|
if (privateBytes.length !== 32) {
|
|
44412
44709
|
throw new ValidationError(
|
|
44413
44710
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -44416,7 +44713,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
|
|
|
44416
44713
|
}
|
|
44417
44714
|
try {
|
|
44418
44715
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
|
|
44419
|
-
return `0x${(0,
|
|
44716
|
+
return `0x${(0, import_utils71.bytesToHex)(publicBytes)}`;
|
|
44420
44717
|
} finally {
|
|
44421
44718
|
secureWipe(privateBytes);
|
|
44422
44719
|
}
|
|
@@ -44451,9 +44748,9 @@ function validateNEARViewingKey(viewingKey) {
|
|
|
44451
44748
|
{ expected: computedHash, received: viewingKey.hash }
|
|
44452
44749
|
);
|
|
44453
44750
|
}
|
|
44454
|
-
const privateBytes = (0,
|
|
44751
|
+
const privateBytes = (0, import_utils71.hexToBytes)(viewingKey.privateKey.slice(2));
|
|
44455
44752
|
try {
|
|
44456
|
-
const derivedPublic = `0x${(0,
|
|
44753
|
+
const derivedPublic = `0x${(0, import_utils71.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
|
|
44457
44754
|
if (derivedPublic !== viewingKey.publicKey) {
|
|
44458
44755
|
throw new ValidationError(
|
|
44459
44756
|
"publicKey does not match privateKey",
|
|
@@ -44468,11 +44765,11 @@ function validateNEARViewingKey(viewingKey) {
|
|
|
44468
44765
|
|
|
44469
44766
|
// src/chains/near/resolver.ts
|
|
44470
44767
|
var import_ed2551920 = require("@noble/curves/ed25519");
|
|
44471
|
-
var
|
|
44768
|
+
var import_utils72 = require("@noble/hashes/utils");
|
|
44472
44769
|
init_errors();
|
|
44473
44770
|
init_validation();
|
|
44474
44771
|
function nearSpendingPublicFromPrivate(spendingPrivateKey) {
|
|
44475
|
-
return `0x${(0,
|
|
44772
|
+
return `0x${(0, import_utils72.bytesToHex)(import_ed2551920.ed25519.getPublicKey((0, import_utils72.hexToBytes)(spendingPrivateKey.slice(2))))}`;
|
|
44476
44773
|
}
|
|
44477
44774
|
function createNEARAnnouncementCache() {
|
|
44478
44775
|
const entries = [];
|
|
@@ -44513,6 +44810,8 @@ var NEARRpcClient = class {
|
|
|
44513
44810
|
this.rpcUrl = rpcUrl;
|
|
44514
44811
|
this.timeout = timeout;
|
|
44515
44812
|
}
|
|
44813
|
+
rpcUrl;
|
|
44814
|
+
timeout;
|
|
44516
44815
|
async call(method, params) {
|
|
44517
44816
|
const controller = new AbortController();
|
|
44518
44817
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
@@ -44723,7 +45022,7 @@ var NEARStealthScanner = class {
|
|
|
44723
45022
|
nearSpendingPublicFromPrivate(recipient.spendingPrivateKey)
|
|
44724
45023
|
);
|
|
44725
45024
|
if (isMatch) {
|
|
44726
|
-
const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : (0,
|
|
45025
|
+
const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : (0, import_utils72.bytesToHex)((0, import_utils72.hexToBytes)(stealthPublicKey.slice(2)));
|
|
44727
45026
|
let amount = metadata?.amount ?? 0n;
|
|
44728
45027
|
if (amount === 0n && isImplicitAccount(stealthAddress)) {
|
|
44729
45028
|
try {
|
|
@@ -45173,6 +45472,9 @@ var AllBackendsFailedError = class _AllBackendsFailedError extends Error {
|
|
|
45173
45472
|
this.params = params;
|
|
45174
45473
|
Object.setPrototypeOf(this, _AllBackendsFailedError.prototype);
|
|
45175
45474
|
}
|
|
45475
|
+
attemptedBackends;
|
|
45476
|
+
errors;
|
|
45477
|
+
params;
|
|
45176
45478
|
name = "AllBackendsFailedError";
|
|
45177
45479
|
/**
|
|
45178
45480
|
* Get formatted error summary
|
|
@@ -45828,6 +46130,10 @@ var RateLimitExceededError = class extends Error {
|
|
|
45828
46130
|
this.requestedTokens = requestedTokens;
|
|
45829
46131
|
this.retryAfterMs = retryAfterMs;
|
|
45830
46132
|
}
|
|
46133
|
+
backend;
|
|
46134
|
+
availableTokens;
|
|
46135
|
+
requestedTokens;
|
|
46136
|
+
retryAfterMs;
|
|
45831
46137
|
name = "RateLimitExceededError";
|
|
45832
46138
|
};
|
|
45833
46139
|
var QueueFullError = class extends Error {
|
|
@@ -45839,6 +46145,9 @@ var QueueFullError = class extends Error {
|
|
|
45839
46145
|
this.queueSize = queueSize;
|
|
45840
46146
|
this.maxQueueSize = maxQueueSize;
|
|
45841
46147
|
}
|
|
46148
|
+
backend;
|
|
46149
|
+
queueSize;
|
|
46150
|
+
maxQueueSize;
|
|
45842
46151
|
name = "QueueFullError";
|
|
45843
46152
|
};
|
|
45844
46153
|
var AcquireTimeoutError = class extends Error {
|
|
@@ -45847,6 +46156,8 @@ var AcquireTimeoutError = class extends Error {
|
|
|
45847
46156
|
this.backend = backend;
|
|
45848
46157
|
this.timeoutMs = timeoutMs;
|
|
45849
46158
|
}
|
|
46159
|
+
backend;
|
|
46160
|
+
timeoutMs;
|
|
45850
46161
|
name = "AcquireTimeoutError";
|
|
45851
46162
|
};
|
|
45852
46163
|
var RateLimiter = class {
|
|
@@ -47098,7 +47409,7 @@ function createPrivacyLogger(moduleName, config = {}) {
|
|
|
47098
47409
|
}
|
|
47099
47410
|
|
|
47100
47411
|
// src/privacy-backends/privacycash.ts
|
|
47101
|
-
var
|
|
47412
|
+
var import_utils73 = require("@noble/hashes/utils");
|
|
47102
47413
|
var privacyCashLogger = createPrivacyLogger("PrivacyCash");
|
|
47103
47414
|
var DEFAULT_ANONYMITY_SET = 50;
|
|
47104
47415
|
var BASE_COST_LAMPORTS = BigInt(1e7);
|
|
@@ -47128,7 +47439,7 @@ var PRIVACYCASH_CAPABILITIES = {
|
|
|
47128
47439
|
|
|
47129
47440
|
// src/privacy-backends/shadowwire.ts
|
|
47130
47441
|
var import_shadowwire = require("@radr/shadowwire");
|
|
47131
|
-
var
|
|
47442
|
+
var import_utils74 = require("@noble/hashes/utils");
|
|
47132
47443
|
var SHADOWWIRE_TOKEN_MINTS = {
|
|
47133
47444
|
SOL: "So11111111111111111111111111111111111111112",
|
|
47134
47445
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
@@ -47187,8 +47498,8 @@ var COST_PER_ENCRYPTED_INPUT_WEI = BigInt("1000000000000000");
|
|
|
47187
47498
|
|
|
47188
47499
|
// src/privacy-backends/magicblock.ts
|
|
47189
47500
|
var import_ephemeral_rollups_sdk = require("@magicblock-labs/ephemeral-rollups-sdk");
|
|
47190
|
-
var
|
|
47191
|
-
var
|
|
47501
|
+
var import_web320 = require("@solana/web3.js");
|
|
47502
|
+
var import_utils75 = require("@noble/hashes/utils");
|
|
47192
47503
|
var magicBlockLogger = createPrivacyLogger("MagicBlock");
|
|
47193
47504
|
|
|
47194
47505
|
// src/privacy-backends/cspl-types.ts
|
|
@@ -47878,7 +48189,7 @@ var CSPLClient = class {
|
|
|
47878
48189
|
|
|
47879
48190
|
// src/privacy-backends/private-swap.ts
|
|
47880
48191
|
var import_sha25630 = require("@noble/hashes/sha256");
|
|
47881
|
-
var
|
|
48192
|
+
var import_utils76 = require("@noble/hashes/utils");
|
|
47882
48193
|
|
|
47883
48194
|
// src/privacy-backends/cspl-token.ts
|
|
47884
48195
|
var CSPLTokenService = class {
|
|
@@ -50485,6 +50796,7 @@ var ProductionSafetyError = class extends Error {
|
|
|
50485
50796
|
this.errors = errors;
|
|
50486
50797
|
this.name = "ProductionSafetyError";
|
|
50487
50798
|
}
|
|
50799
|
+
errors;
|
|
50488
50800
|
};
|
|
50489
50801
|
function validateProductionConfig(config, options = {}) {
|
|
50490
50802
|
const isProduction = isProductionEnvironment();
|
|
@@ -50589,7 +50901,7 @@ init_proxy();
|
|
|
50589
50901
|
// src/sync/oblivious.ts
|
|
50590
50902
|
var import_sha211 = require("@noble/hashes/sha2");
|
|
50591
50903
|
var import_hmac8 = require("@noble/hashes/hmac");
|
|
50592
|
-
var
|
|
50904
|
+
var import_utils77 = require("@noble/hashes/utils");
|
|
50593
50905
|
init_secure_memory();
|
|
50594
50906
|
var DEFAULT_SYNC_CONFIG = {
|
|
50595
50907
|
maxBatchSize: 1e3,
|
|
@@ -50600,7 +50912,7 @@ var DEFAULT_SYNC_CONFIG = {
|
|
|
50600
50912
|
parallelSync: true
|
|
50601
50913
|
};
|
|
50602
50914
|
function generateSyncRandomness(epoch, durationSeconds = DEFAULT_SYNC_CONFIG.epochDurationSeconds) {
|
|
50603
|
-
const value = (0,
|
|
50915
|
+
const value = (0, import_utils77.randomBytes)(32);
|
|
50604
50916
|
const expiresAt = Date.now() + durationSeconds * 1e3;
|
|
50605
50917
|
return {
|
|
50606
50918
|
value,
|
|
@@ -50616,21 +50928,21 @@ function getCurrentEpoch(epochDurationSeconds = DEFAULT_SYNC_CONFIG.epochDuratio
|
|
|
50616
50928
|
}
|
|
50617
50929
|
var OBLIVIOUS_NULLIFIER_DOMAIN = "SIP-OBLIVIOUS-NULLIFIER-V1";
|
|
50618
50930
|
function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
50619
|
-
const commitmentBytes = (0,
|
|
50931
|
+
const commitmentBytes = (0, import_utils77.hexToBytes)(
|
|
50620
50932
|
noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
|
|
50621
50933
|
);
|
|
50622
|
-
const keyBytes = (0,
|
|
50934
|
+
const keyBytes = (0, import_utils77.hexToBytes)(
|
|
50623
50935
|
spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
|
|
50624
50936
|
);
|
|
50625
50937
|
try {
|
|
50626
|
-
const domain = (0,
|
|
50938
|
+
const domain = (0, import_utils77.utf8ToBytes)(OBLIVIOUS_NULLIFIER_DOMAIN);
|
|
50627
50939
|
const message = new Uint8Array(domain.length + commitmentBytes.length + syncRandomness.value.length);
|
|
50628
50940
|
message.set(domain, 0);
|
|
50629
50941
|
message.set(commitmentBytes, domain.length);
|
|
50630
50942
|
message.set(syncRandomness.value, domain.length + commitmentBytes.length);
|
|
50631
50943
|
const nullifierBytes = (0, import_hmac8.hmac)(import_sha211.sha256, keyBytes, message);
|
|
50632
50944
|
return {
|
|
50633
|
-
nullifier: `0x${(0,
|
|
50945
|
+
nullifier: `0x${(0, import_utils77.bytesToHex)(nullifierBytes)}`,
|
|
50634
50946
|
epoch: syncRandomness.epoch,
|
|
50635
50947
|
chainId: "default"
|
|
50636
50948
|
// Will be set by caller
|
|
@@ -50640,15 +50952,15 @@ function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
|
50640
50952
|
}
|
|
50641
50953
|
}
|
|
50642
50954
|
function deriveTraditionalNullifier(noteCommitment, spendingKey) {
|
|
50643
|
-
const commitmentBytes = (0,
|
|
50955
|
+
const commitmentBytes = (0, import_utils77.hexToBytes)(
|
|
50644
50956
|
noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
|
|
50645
50957
|
);
|
|
50646
|
-
const keyBytes = (0,
|
|
50958
|
+
const keyBytes = (0, import_utils77.hexToBytes)(
|
|
50647
50959
|
spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
|
|
50648
50960
|
);
|
|
50649
50961
|
try {
|
|
50650
50962
|
const nullifierBytes = (0, import_hmac8.hmac)(import_sha211.sha256, keyBytes, commitmentBytes);
|
|
50651
|
-
return `0x${(0,
|
|
50963
|
+
return `0x${(0, import_utils77.bytesToHex)(nullifierBytes)}`;
|
|
50652
50964
|
} finally {
|
|
50653
50965
|
secureWipe(keyBytes);
|
|
50654
50966
|
}
|
|
@@ -50693,7 +51005,7 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
|
|
|
50693
51005
|
for (let e = startEpoch; e <= endEpoch; e++) {
|
|
50694
51006
|
epochs.push(e);
|
|
50695
51007
|
}
|
|
50696
|
-
const keyBytes = (0,
|
|
51008
|
+
const keyBytes = (0, import_utils77.hexToBytes)(
|
|
50697
51009
|
masterViewingKey.startsWith("0x") ? masterViewingKey.slice(2) : masterViewingKey
|
|
50698
51010
|
);
|
|
50699
51011
|
const windowData = new Uint8Array(16);
|
|
@@ -50704,11 +51016,11 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
|
|
|
50704
51016
|
const keyHash = (0, import_sha211.sha256)(derivedKey);
|
|
50705
51017
|
secureWipe(keyBytes);
|
|
50706
51018
|
return {
|
|
50707
|
-
viewingKey: `0x${(0,
|
|
51019
|
+
viewingKey: `0x${(0, import_utils77.bytesToHex)(derivedKey)}`,
|
|
50708
51020
|
windowStart: startTime,
|
|
50709
51021
|
windowEnd: endTime,
|
|
50710
51022
|
epochs,
|
|
50711
|
-
hash: `0x${(0,
|
|
51023
|
+
hash: `0x${(0, import_utils77.bytesToHex)(keyHash)}`
|
|
50712
51024
|
};
|
|
50713
51025
|
}
|
|
50714
51026
|
function isNoteInWindow(_note, _windowedKey) {
|
|
@@ -50731,10 +51043,12 @@ var ObliviousSyncError = class extends Error {
|
|
|
50731
51043
|
this.context = context;
|
|
50732
51044
|
this.name = "ObliviousSyncError";
|
|
50733
51045
|
}
|
|
51046
|
+
code;
|
|
51047
|
+
context;
|
|
50734
51048
|
};
|
|
50735
51049
|
|
|
50736
51050
|
// src/sync/mock-provider.ts
|
|
50737
|
-
var
|
|
51051
|
+
var import_utils78 = require("@noble/hashes/utils");
|
|
50738
51052
|
var DEFAULT_MOCK_CONFIG = {
|
|
50739
51053
|
chains: ["ethereum", "solana", "near"],
|
|
50740
51054
|
latencyMs: 100,
|
|
@@ -50831,7 +51145,7 @@ var MockObliviousSyncProvider = class {
|
|
|
50831
51145
|
merkleProofs,
|
|
50832
51146
|
syncHeight: this.config.blockHeight,
|
|
50833
51147
|
timestamp: Date.now(),
|
|
50834
|
-
queryHash: `0x${(0,
|
|
51148
|
+
queryHash: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`
|
|
50835
51149
|
};
|
|
50836
51150
|
}
|
|
50837
51151
|
async getCurrentHeight(chainId) {
|
|
@@ -50912,23 +51226,23 @@ var MockObliviousSyncProvider = class {
|
|
|
50912
51226
|
generateMockNote(blockRange) {
|
|
50913
51227
|
const blockNumber = blockRange.startBlock + BigInt(Math.floor(Math.random() * Number(blockRange.endBlock - blockRange.startBlock)));
|
|
50914
51228
|
return {
|
|
50915
|
-
commitment: `0x${(0,
|
|
50916
|
-
encryptedData: `0x${(0,
|
|
51229
|
+
commitment: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`,
|
|
51230
|
+
encryptedData: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(128))}`,
|
|
50917
51231
|
blockNumber,
|
|
50918
|
-
txHash: `0x${(0,
|
|
51232
|
+
txHash: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`,
|
|
50919
51233
|
chainId: blockRange.chainId
|
|
50920
51234
|
};
|
|
50921
51235
|
}
|
|
50922
51236
|
generateMockMerkleProof(leaf) {
|
|
50923
51237
|
const siblings = [];
|
|
50924
51238
|
for (let i = 0; i < 20; i++) {
|
|
50925
|
-
siblings.push(`0x${(0,
|
|
51239
|
+
siblings.push(`0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`);
|
|
50926
51240
|
}
|
|
50927
51241
|
return {
|
|
50928
51242
|
leaf,
|
|
50929
51243
|
siblings,
|
|
50930
51244
|
index: BigInt(Math.floor(Math.random() * 1e6)),
|
|
50931
|
-
root: `0x${(0,
|
|
51245
|
+
root: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`
|
|
50932
51246
|
};
|
|
50933
51247
|
}
|
|
50934
51248
|
};
|
|
@@ -52718,6 +53032,7 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
|
|
|
52718
53032
|
bpsToPercent,
|
|
52719
53033
|
browserBytesToHex,
|
|
52720
53034
|
browserHexToBytes,
|
|
53035
|
+
buildGaslessCashout,
|
|
52721
53036
|
cacheKeyGenerator,
|
|
52722
53037
|
calculateFeeForSwap,
|
|
52723
53038
|
calculatePrivacyScore,
|
|
@@ -52739,6 +53054,7 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
|
|
|
52739
53054
|
computeAttestationHash,
|
|
52740
53055
|
computeNEARViewingKeyHash,
|
|
52741
53056
|
computeNEARViewingKeyHashFromPrivate,
|
|
53057
|
+
computeRelayerFee,
|
|
52742
53058
|
computeTweakedKey,
|
|
52743
53059
|
configureLogger,
|
|
52744
53060
|
convertFromSIP,
|
|
@@ -52842,6 +53158,7 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
|
|
|
52842
53158
|
deriveSecp256k1StealthPrivateKeyV1,
|
|
52843
53159
|
deriveStealthPrivateKey,
|
|
52844
53160
|
deriveStealthPrivateKeyV1,
|
|
53161
|
+
deriveStealthSigner,
|
|
52845
53162
|
deriveSuiStealthPrivateKey,
|
|
52846
53163
|
deriveTraditionalNullifier,
|
|
52847
53164
|
deriveViewingKey,
|
|
@@ -53033,11 +53350,13 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
|
|
|
53033
53350
|
serializePayment,
|
|
53034
53351
|
setLogLevel,
|
|
53035
53352
|
signAttestationMessage,
|
|
53353
|
+
signEd25519WithScalar,
|
|
53036
53354
|
silenceLogger,
|
|
53037
53355
|
solanaAddressToEd25519PublicKey,
|
|
53038
53356
|
solanaOptimizations,
|
|
53039
53357
|
solanaPublicKeyToHex,
|
|
53040
53358
|
stealthKeyToCosmosAddress,
|
|
53359
|
+
submitGaslessCashout,
|
|
53041
53360
|
subtractBlindings,
|
|
53042
53361
|
subtractBlindingsNEAR,
|
|
53043
53362
|
subtractCommitments,
|