@sip-protocol/sdk 0.11.0 → 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 +868 -545
- package/dist/browser.mjs +17 -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-Cwo3WhxX.d.mts → index-B_fGN4Fk.d.mts} +806 -597
- package/dist/{index-X8qPQdp6.d.ts → index-rqQpCeVM.d.ts} +806 -597
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +868 -545
- package/dist/index.mjs +17 -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 +16 -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/browser.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();
|
|
@@ -18237,7 +18500,7 @@ __export(browser_exports, {
|
|
|
18237
18500
|
NEARIntentsAdapter: () => NEARIntentsAdapter,
|
|
18238
18501
|
NEARIntentsBackend: () => NEARIntentsBackend,
|
|
18239
18502
|
NEAR_DEFAULT_GAS: () => DEFAULT_GAS,
|
|
18240
|
-
NEAR_ED25519_ORDER: () =>
|
|
18503
|
+
NEAR_ED25519_ORDER: () => ED25519_ORDER4,
|
|
18241
18504
|
NEAR_EXPLORER_URLS: () => NEAR_EXPLORER_URLS,
|
|
18242
18505
|
NEAR_FEE_CONTRACTS: () => NEAR_FEE_CONTRACTS,
|
|
18243
18506
|
NEAR_IMPLICIT_ACCOUNT_LENGTH: () => NEAR_IMPLICIT_ACCOUNT_LENGTH,
|
|
@@ -18287,6 +18550,8 @@ __export(browser_exports, {
|
|
|
18287
18550
|
SIPError: () => SIPError,
|
|
18288
18551
|
SIPNativeBackend: () => SIPNativeBackend,
|
|
18289
18552
|
SIP_MEMO_PREFIX: () => SIP_MEMO_PREFIX,
|
|
18553
|
+
SIP_MEMO_PREFIX_ANY: () => SIP_MEMO_PREFIX_ANY,
|
|
18554
|
+
SIP_MEMO_PREFIX_V2: () => SIP_MEMO_PREFIX_V2,
|
|
18290
18555
|
SIP_VERSION: () => import_types84.SIP_VERSION,
|
|
18291
18556
|
SOLANA_EXPLORER_URLS: () => SOLANA_EXPLORER_URLS,
|
|
18292
18557
|
SOLANA_RPC_ENDPOINTS: () => SOLANA_RPC_ENDPOINTS3,
|
|
@@ -18346,6 +18611,7 @@ __export(browser_exports, {
|
|
|
18346
18611
|
bpsToPercent: () => bpsToPercent,
|
|
18347
18612
|
browserBytesToHex: () => bytesToHex18,
|
|
18348
18613
|
browserHexToBytes: () => hexToBytes15,
|
|
18614
|
+
buildGaslessCashout: () => buildGaslessCashout,
|
|
18349
18615
|
cacheKeyGenerator: () => cacheKeyGenerator,
|
|
18350
18616
|
calculateFeeForSwap: () => calculateFeeForSwap,
|
|
18351
18617
|
calculatePrivacyScore: () => calculatePrivacyScore,
|
|
@@ -18368,6 +18634,7 @@ __export(browser_exports, {
|
|
|
18368
18634
|
computeAttestationHash: () => computeAttestationHash,
|
|
18369
18635
|
computeNEARViewingKeyHash: () => computeNEARViewingKeyHash,
|
|
18370
18636
|
computeNEARViewingKeyHashFromPrivate: () => computeNEARViewingKeyHashFromPrivate,
|
|
18637
|
+
computeRelayerFee: () => computeRelayerFee,
|
|
18371
18638
|
computeTweakedKey: () => computeTweakedKey,
|
|
18372
18639
|
configureLogger: () => configureLogger,
|
|
18373
18640
|
convertFromSIP: () => convertFromSIP,
|
|
@@ -18472,6 +18739,7 @@ __export(browser_exports, {
|
|
|
18472
18739
|
deriveSecp256k1StealthPrivateKeyV1: () => deriveSecp256k1StealthPrivateKeyV1,
|
|
18473
18740
|
deriveStealthPrivateKey: () => deriveStealthPrivateKey,
|
|
18474
18741
|
deriveStealthPrivateKeyV1: () => deriveStealthPrivateKeyV1,
|
|
18742
|
+
deriveStealthSigner: () => deriveStealthSigner,
|
|
18475
18743
|
deriveSuiStealthPrivateKey: () => deriveSuiStealthPrivateKey,
|
|
18476
18744
|
deriveTraditionalNullifier: () => deriveTraditionalNullifier,
|
|
18477
18745
|
deriveViewingKey: () => deriveViewingKey,
|
|
@@ -18669,11 +18937,13 @@ __export(browser_exports, {
|
|
|
18669
18937
|
serializePayment: () => serializePayment,
|
|
18670
18938
|
setLogLevel: () => setLogLevel,
|
|
18671
18939
|
signAttestationMessage: () => signAttestationMessage,
|
|
18940
|
+
signEd25519WithScalar: () => signEd25519WithScalar,
|
|
18672
18941
|
silenceLogger: () => silenceLogger,
|
|
18673
18942
|
solanaAddressToEd25519PublicKey: () => solanaAddressToEd25519PublicKey,
|
|
18674
18943
|
solanaOptimizations: () => optimizations_exports,
|
|
18675
18944
|
solanaPublicKeyToHex: () => solanaPublicKeyToHex,
|
|
18676
18945
|
stealthKeyToCosmosAddress: () => stealthKeyToCosmosAddress,
|
|
18946
|
+
submitGaslessCashout: () => submitGaslessCashout,
|
|
18677
18947
|
subtractBlindings: () => subtractBlindings,
|
|
18678
18948
|
subtractBlindingsNEAR: () => subtractBlindingsNEAR,
|
|
18679
18949
|
subtractCommitments: () => subtractCommitments,
|
|
@@ -21355,7 +21625,7 @@ var SIP = class {
|
|
|
21355
21625
|
}
|
|
21356
21626
|
const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await Promise.resolve().then(() => (init_solana(), solana_exports));
|
|
21357
21627
|
const { PublicKey: SolanaPublicKey } = await import("@solana/web3.js");
|
|
21358
|
-
const { getAssociatedTokenAddress:
|
|
21628
|
+
const { getAssociatedTokenAddress: getAssociatedTokenAddress9 } = await import("@solana/spl-token");
|
|
21359
21629
|
const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await Promise.resolve().then(() => (init_constants(), constants_exports));
|
|
21360
21630
|
let mint;
|
|
21361
21631
|
if (params.token in SOLANA_TOKEN_MINTS3) {
|
|
@@ -21363,7 +21633,7 @@ var SIP = class {
|
|
|
21363
21633
|
} else {
|
|
21364
21634
|
mint = new SolanaPublicKey(params.token);
|
|
21365
21635
|
}
|
|
21366
|
-
const senderTokenAccount = await
|
|
21636
|
+
const senderTokenAccount = await getAssociatedTokenAddress9(
|
|
21367
21637
|
mint,
|
|
21368
21638
|
params.sender
|
|
21369
21639
|
);
|
|
@@ -21412,7 +21682,7 @@ init_stealth2();
|
|
|
21412
21682
|
// src/cosmos/stealth.ts
|
|
21413
21683
|
var import_sha2569 = require("@noble/hashes/sha256");
|
|
21414
21684
|
var import_ripemd160 = require("@noble/hashes/ripemd160");
|
|
21415
|
-
var
|
|
21685
|
+
var import_utils30 = require("@noble/hashes/utils");
|
|
21416
21686
|
var import_base3 = require("@scure/base");
|
|
21417
21687
|
init_stealth2();
|
|
21418
21688
|
init_errors();
|
|
@@ -21496,14 +21766,14 @@ var CosmosStealthService = class {
|
|
|
21496
21766
|
);
|
|
21497
21767
|
}
|
|
21498
21768
|
const metaAddress = {
|
|
21499
|
-
spendingKey: `0x${(0,
|
|
21500
|
-
viewingKey: `0x${(0,
|
|
21769
|
+
spendingKey: `0x${(0, import_utils30.bytesToHex)(spendingPubKey)}`,
|
|
21770
|
+
viewingKey: `0x${(0, import_utils30.bytesToHex)(viewingPubKey)}`,
|
|
21501
21771
|
chain: "ethereum"
|
|
21502
21772
|
// Use ethereum for secp256k1 generation
|
|
21503
21773
|
};
|
|
21504
21774
|
const { stealthAddress, sharedSecret } = generateStealthAddress(metaAddress);
|
|
21505
21775
|
const cosmosAddress = this.stealthKeyToCosmosAddress(
|
|
21506
|
-
(0,
|
|
21776
|
+
(0, import_utils30.hexToBytes)(stealthAddress.address.slice(2)),
|
|
21507
21777
|
CHAIN_PREFIXES[chain]
|
|
21508
21778
|
);
|
|
21509
21779
|
return {
|
|
@@ -21531,8 +21801,8 @@ var CosmosStealthService = class {
|
|
|
21531
21801
|
* ```
|
|
21532
21802
|
*/
|
|
21533
21803
|
generateStealthAddressFromMeta(recipientMetaAddress, chain) {
|
|
21534
|
-
const spendingPubKey = (0,
|
|
21535
|
-
const viewingPubKey = (0,
|
|
21804
|
+
const spendingPubKey = (0, import_utils30.hexToBytes)(recipientMetaAddress.spendingKey.slice(2));
|
|
21805
|
+
const viewingPubKey = (0, import_utils30.hexToBytes)(recipientMetaAddress.viewingKey.slice(2));
|
|
21536
21806
|
return this.generateStealthAddress(spendingPubKey, viewingPubKey, chain);
|
|
21537
21807
|
}
|
|
21538
21808
|
/**
|
|
@@ -21710,7 +21980,7 @@ function isValidCosmosAddress(address, expectedChain) {
|
|
|
21710
21980
|
}
|
|
21711
21981
|
|
|
21712
21982
|
// src/cosmos/ibc-stealth.ts
|
|
21713
|
-
var
|
|
21983
|
+
var import_utils31 = require("@noble/hashes/utils");
|
|
21714
21984
|
var import_secp256k14 = require("@noble/curves/secp256k1");
|
|
21715
21985
|
var import_sha25610 = require("@noble/hashes/sha256");
|
|
21716
21986
|
init_errors();
|
|
@@ -21734,7 +22004,7 @@ var ProofGenerationError = class extends Error {
|
|
|
21734
22004
|
|
|
21735
22005
|
// src/proofs/mock.ts
|
|
21736
22006
|
var import_sha25611 = require("@noble/hashes/sha256");
|
|
21737
|
-
var
|
|
22007
|
+
var import_utils32 = require("@noble/hashes/utils");
|
|
21738
22008
|
init_errors();
|
|
21739
22009
|
var log3 = createLogger("proofs/mock");
|
|
21740
22010
|
var MOCK_PROOF_PREFIX = "0x4d4f434b";
|
|
@@ -21911,16 +22181,16 @@ var MockProofProvider = class {
|
|
|
21911
22181
|
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
21912
22182
|
);
|
|
21913
22183
|
const hash2 = (0, import_sha25611.sha256)(new TextEncoder().encode(input));
|
|
21914
|
-
const random = (0,
|
|
22184
|
+
const random = (0, import_utils32.randomBytes)(16);
|
|
21915
22185
|
const combined = new Uint8Array(4 + hash2.length + random.length);
|
|
21916
22186
|
combined.set(new TextEncoder().encode("MOCK"), 0);
|
|
21917
22187
|
combined.set(hash2, 4);
|
|
21918
22188
|
combined.set(random, 4 + hash2.length);
|
|
21919
|
-
return `${MOCK_PROOF_PREFIX}${(0,
|
|
22189
|
+
return `${MOCK_PROOF_PREFIX}${(0, import_utils32.bytesToHex)(combined.slice(4))}`;
|
|
21920
22190
|
}
|
|
21921
22191
|
hashToHex(data) {
|
|
21922
22192
|
const hash2 = (0, import_sha25611.sha256)(new TextEncoder().encode(data));
|
|
21923
|
-
return `0x${(0,
|
|
22193
|
+
return `0x${(0, import_utils32.bytesToHex)(hash2)}`;
|
|
21924
22194
|
}
|
|
21925
22195
|
};
|
|
21926
22196
|
|
|
@@ -22655,46 +22925,46 @@ var ComplianceProofProvider = class {
|
|
|
22655
22925
|
}
|
|
22656
22926
|
async hashViewingKey(viewingKey) {
|
|
22657
22927
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22658
|
-
const { bytesToHex:
|
|
22928
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22659
22929
|
const keyString = typeof viewingKey === "string" ? viewingKey : JSON.stringify(viewingKey);
|
|
22660
22930
|
const encoder = new TextEncoder();
|
|
22661
22931
|
const keyBytes = encoder.encode(keyString);
|
|
22662
|
-
return
|
|
22932
|
+
return bytesToHex64(sha25642(keyBytes));
|
|
22663
22933
|
}
|
|
22664
22934
|
async computeDecryptionCommitment(viewingKey, encryptedData) {
|
|
22665
22935
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22666
|
-
const { bytesToHex:
|
|
22936
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22667
22937
|
const keyHash = await this.hashViewingKey(viewingKey);
|
|
22668
22938
|
const keyBytes = this.hexToBytes(keyHash);
|
|
22669
22939
|
const preimage = new Uint8Array([...keyBytes, ...encryptedData.slice(0, 32)]);
|
|
22670
|
-
return
|
|
22940
|
+
return bytesToHex64(sha25642(preimage));
|
|
22671
22941
|
}
|
|
22672
22942
|
async computeAuditorHash(auditorPublicKey, transactionHash) {
|
|
22673
22943
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22674
|
-
const { bytesToHex:
|
|
22944
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22675
22945
|
const auditorBytes = this.hexToBytes(auditorPublicKey.replace("0x", "").padStart(64, "0"));
|
|
22676
22946
|
const txBytes = this.hexToBytes(transactionHash.replace("0x", "").padStart(64, "0"));
|
|
22677
22947
|
const preimage = new Uint8Array([...auditorBytes, ...txBytes]);
|
|
22678
|
-
return
|
|
22948
|
+
return bytesToHex64(sha25642(preimage));
|
|
22679
22949
|
}
|
|
22680
22950
|
async computeAddressCommitment(address, blinding) {
|
|
22681
22951
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22682
|
-
const { bytesToHex:
|
|
22952
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22683
22953
|
const addressBytes = this.hexToBytes(address.replace("0x", "").padStart(64, "0"));
|
|
22684
22954
|
const preimage = new Uint8Array([...addressBytes, ...blinding.slice(0, 32)]);
|
|
22685
|
-
return
|
|
22955
|
+
return bytesToHex64(sha25642(preimage));
|
|
22686
22956
|
}
|
|
22687
22957
|
async computeNonMembershipProof(senderAddress, recipientAddress, _sanctionsListRoot) {
|
|
22688
22958
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22689
|
-
const { bytesToHex:
|
|
22959
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22690
22960
|
const senderBytes = this.hexToBytes(senderAddress.replace("0x", "").padStart(64, "0"));
|
|
22691
22961
|
const recipientBytes = this.hexToBytes(recipientAddress.replace("0x", "").padStart(64, "0"));
|
|
22692
22962
|
const preimage = new Uint8Array([...senderBytes, ...recipientBytes]);
|
|
22693
|
-
return
|
|
22963
|
+
return bytesToHex64(sha25642(preimage));
|
|
22694
22964
|
}
|
|
22695
22965
|
async computeBalanceCommitment(balance, blinding) {
|
|
22696
22966
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22697
|
-
const { bytesToHex:
|
|
22967
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22698
22968
|
const balanceBytes = new Uint8Array(8);
|
|
22699
22969
|
let v = balance;
|
|
22700
22970
|
for (let i = 7; i >= 0; i--) {
|
|
@@ -22702,11 +22972,11 @@ var ComplianceProofProvider = class {
|
|
|
22702
22972
|
v = v >> 8n;
|
|
22703
22973
|
}
|
|
22704
22974
|
const preimage = new Uint8Array([...balanceBytes, ...blinding.slice(0, 32)]);
|
|
22705
|
-
return
|
|
22975
|
+
return bytesToHex64(sha25642(preimage));
|
|
22706
22976
|
}
|
|
22707
22977
|
async generateComplianceProofBytes(type, publicInputs) {
|
|
22708
22978
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
22709
|
-
const { bytesToHex:
|
|
22979
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
22710
22980
|
const circuitId = COMPLIANCE_CIRCUIT_IDS[type];
|
|
22711
22981
|
const encoder = new TextEncoder();
|
|
22712
22982
|
const inputBytes = publicInputs.flatMap((pi) => Array.from(this.hexToBytes(pi.replace("0x", ""))));
|
|
@@ -22717,7 +22987,7 @@ var ComplianceProofProvider = class {
|
|
|
22717
22987
|
const hash2 = sha25642(preimage);
|
|
22718
22988
|
let proofBytes = "";
|
|
22719
22989
|
for (let i = 0; i < 8; i++) {
|
|
22720
|
-
proofBytes +=
|
|
22990
|
+
proofBytes += bytesToHex64(sha25642(new Uint8Array([...hash2, i])));
|
|
22721
22991
|
}
|
|
22722
22992
|
return proofBytes;
|
|
22723
22993
|
}
|
|
@@ -22745,7 +23015,7 @@ var ComplianceProofProvider = class {
|
|
|
22745
23015
|
};
|
|
22746
23016
|
|
|
22747
23017
|
// src/proofs/aggregator.ts
|
|
22748
|
-
var
|
|
23018
|
+
var import_utils33 = require("@noble/hashes/utils");
|
|
22749
23019
|
var import_types13 = require("@sip-protocol/types");
|
|
22750
23020
|
var DEFAULT_AGGREGATOR_CONFIG = {
|
|
22751
23021
|
maxProofs: 100,
|
|
@@ -22763,8 +23033,8 @@ var DEFAULT_AGGREGATOR_CONFIG = {
|
|
|
22763
23033
|
verbose: false
|
|
22764
23034
|
};
|
|
22765
23035
|
function generateId(prefix) {
|
|
22766
|
-
const bytes = (0,
|
|
22767
|
-
return `${prefix}-${(0,
|
|
23036
|
+
const bytes = (0, import_utils33.randomBytes)(8);
|
|
23037
|
+
return `${prefix}-${(0, import_utils33.bytesToHex)(bytes)}`;
|
|
22768
23038
|
}
|
|
22769
23039
|
function computeProofHash(proofs) {
|
|
22770
23040
|
const data = proofs.map((p) => p.proof).join("");
|
|
@@ -23164,10 +23434,10 @@ var ProofAggregator = class {
|
|
|
23164
23434
|
async simulateRecursiveMerge(proofs, targetSystem, depth) {
|
|
23165
23435
|
await delay(proofs.length * 50);
|
|
23166
23436
|
const combinedInputs = proofs.flatMap((p) => p.publicInputs);
|
|
23167
|
-
const proofBytes = (0,
|
|
23437
|
+
const proofBytes = (0, import_utils33.randomBytes)(256);
|
|
23168
23438
|
return {
|
|
23169
23439
|
id: generateId(`recursive-${depth}`),
|
|
23170
|
-
proof: `0x${(0,
|
|
23440
|
+
proof: `0x${(0, import_utils33.bytesToHex)(proofBytes)}`,
|
|
23171
23441
|
publicInputs: combinedInputs.slice(0, 10),
|
|
23172
23442
|
metadata: {
|
|
23173
23443
|
system: targetSystem,
|
|
@@ -23382,7 +23652,7 @@ function createProofAggregator(config) {
|
|
|
23382
23652
|
}
|
|
23383
23653
|
|
|
23384
23654
|
// src/proofs/verifier.ts
|
|
23385
|
-
var
|
|
23655
|
+
var import_utils34 = require("@noble/hashes/utils");
|
|
23386
23656
|
var DEFAULT_PIPELINE_CONFIG = {
|
|
23387
23657
|
enableParallel: true,
|
|
23388
23658
|
maxConcurrent: 4,
|
|
@@ -23396,7 +23666,7 @@ var DEFAULT_PIPELINE_CONFIG = {
|
|
|
23396
23666
|
generateVerificationProof: false
|
|
23397
23667
|
};
|
|
23398
23668
|
function generateId2(prefix) {
|
|
23399
|
-
return `${prefix}-${(0,
|
|
23669
|
+
return `${prefix}-${(0, import_utils34.bytesToHex)((0, import_utils34.randomBytes)(8))}`;
|
|
23400
23670
|
}
|
|
23401
23671
|
function computeLinkHash(sourceProof, targetProof) {
|
|
23402
23672
|
const combinedData = sourceProof.proof + targetProof.proof;
|
|
@@ -24376,7 +24646,7 @@ function createCrossSystemValidator(options) {
|
|
|
24376
24646
|
}
|
|
24377
24647
|
|
|
24378
24648
|
// src/proofs/orchestrator.ts
|
|
24379
|
-
var
|
|
24649
|
+
var import_utils35 = require("@noble/hashes/utils");
|
|
24380
24650
|
var import_types14 = require("@sip-protocol/types");
|
|
24381
24651
|
var DEFAULT_ORCHESTRATOR_CONFIG = {
|
|
24382
24652
|
maxRetries: 3,
|
|
@@ -24432,7 +24702,7 @@ var BUILTIN_TEMPLATES = [
|
|
|
24432
24702
|
}
|
|
24433
24703
|
];
|
|
24434
24704
|
function generateId3(prefix) {
|
|
24435
|
-
return `${prefix}-${(0,
|
|
24705
|
+
return `${prefix}-${(0, import_utils35.bytesToHex)((0, import_utils35.randomBytes)(8))}`;
|
|
24436
24706
|
}
|
|
24437
24707
|
function delay2(ms) {
|
|
24438
24708
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -24983,12 +25253,12 @@ var IncompatibleSystemsError = class extends ProofCompositionError {
|
|
|
24983
25253
|
};
|
|
24984
25254
|
|
|
24985
25255
|
// src/proofs/composer/base.ts
|
|
24986
|
-
var import_utils35 = require("@noble/hashes/utils");
|
|
24987
25256
|
var import_utils36 = require("@noble/hashes/utils");
|
|
25257
|
+
var import_utils37 = require("@noble/hashes/utils");
|
|
24988
25258
|
var import_types16 = require("@sip-protocol/types");
|
|
24989
25259
|
function generateId4(prefix) {
|
|
24990
|
-
const bytes = (0,
|
|
24991
|
-
return `${prefix}-${(0,
|
|
25260
|
+
const bytes = (0, import_utils36.randomBytes)(8);
|
|
25261
|
+
return `${prefix}-${(0, import_utils37.bytesToHex)(bytes)}`;
|
|
24992
25262
|
}
|
|
24993
25263
|
function computeProofHash2(proofs) {
|
|
24994
25264
|
const data = proofs.map((p) => p.proof).join("");
|
|
@@ -25633,7 +25903,7 @@ var BaseProofComposer = class {
|
|
|
25633
25903
|
};
|
|
25634
25904
|
|
|
25635
25905
|
// src/proofs/providers/halo2.ts
|
|
25636
|
-
var
|
|
25906
|
+
var import_utils38 = require("@noble/hashes/utils");
|
|
25637
25907
|
var import_types17 = require("@sip-protocol/types");
|
|
25638
25908
|
var DEFAULT_HALO2_CONFIG = {
|
|
25639
25909
|
artifactsPath: "",
|
|
@@ -25834,8 +26104,8 @@ var Halo2Provider = class {
|
|
|
25834
26104
|
async generateMockProof(request, circuit) {
|
|
25835
26105
|
const simulatedTimeMs = Math.min(100 + circuit.k * 10, 2e3);
|
|
25836
26106
|
await this.delay(simulatedTimeMs);
|
|
25837
|
-
const proofBytes = (0,
|
|
25838
|
-
const proofHex = `0x${(0,
|
|
26107
|
+
const proofBytes = (0, import_utils38.randomBytes)(256);
|
|
26108
|
+
const proofHex = `0x${(0, import_utils38.bytesToHex)(proofBytes)}`;
|
|
25839
26109
|
const publicInputs = Object.values(request.publicInputs).map((v) => {
|
|
25840
26110
|
if (typeof v === "string" && v.startsWith("0x")) {
|
|
25841
26111
|
return v;
|
|
@@ -25846,7 +26116,7 @@ var Halo2Provider = class {
|
|
|
25846
26116
|
return `0x${Buffer.from(String(v)).toString("hex")}`;
|
|
25847
26117
|
});
|
|
25848
26118
|
return {
|
|
25849
|
-
id: `halo2-proof-${Date.now()}-${(0,
|
|
26119
|
+
id: `halo2-proof-${Date.now()}-${(0, import_utils38.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
|
|
25850
26120
|
proof: proofHex,
|
|
25851
26121
|
publicInputs,
|
|
25852
26122
|
metadata: {
|
|
@@ -25914,7 +26184,7 @@ var Halo2Provider = class {
|
|
|
25914
26184
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
25915
26185
|
}
|
|
25916
26186
|
generateProviderId() {
|
|
25917
|
-
return (0,
|
|
26187
|
+
return (0, import_utils38.bytesToHex)((0, import_utils38.randomBytes)(4));
|
|
25918
26188
|
}
|
|
25919
26189
|
};
|
|
25920
26190
|
function createHalo2Provider(config) {
|
|
@@ -25945,7 +26215,7 @@ function createOrchardProvider() {
|
|
|
25945
26215
|
}
|
|
25946
26216
|
|
|
25947
26217
|
// src/proofs/providers/kimchi.ts
|
|
25948
|
-
var
|
|
26218
|
+
var import_utils39 = require("@noble/hashes/utils");
|
|
25949
26219
|
var import_types18 = require("@sip-protocol/types");
|
|
25950
26220
|
var DEFAULT_KIMCHI_CONFIG = {
|
|
25951
26221
|
circuits: [],
|
|
@@ -26094,7 +26364,7 @@ var KimchiProvider = class {
|
|
|
26094
26364
|
console.log(`[KimchiProvider] Compiling circuit: ${circuitId}`);
|
|
26095
26365
|
}
|
|
26096
26366
|
await this.delay(100 + circuit.gateCount * 0.1);
|
|
26097
|
-
const vkHash = `0x${(0,
|
|
26367
|
+
const vkHash = `0x${(0, import_utils39.bytesToHex)((0, import_utils39.randomBytes)(32))}`;
|
|
26098
26368
|
this._compiledCircuits.set(circuitId, {
|
|
26099
26369
|
compiled: true,
|
|
26100
26370
|
vkHash
|
|
@@ -26160,8 +26430,8 @@ var KimchiProvider = class {
|
|
|
26160
26430
|
async generateMockProof(request, circuit) {
|
|
26161
26431
|
const simulatedTimeMs = Math.min(200 + circuit.gateCount * 0.5, 5e3);
|
|
26162
26432
|
await this.delay(simulatedTimeMs);
|
|
26163
|
-
const proofBytes = (0,
|
|
26164
|
-
const proofHex = `0x${(0,
|
|
26433
|
+
const proofBytes = (0, import_utils39.randomBytes)(KIMCHI_PROOF_SIZE);
|
|
26434
|
+
const proofHex = `0x${(0, import_utils39.bytesToHex)(proofBytes)}`;
|
|
26165
26435
|
const publicInputs = Object.values(request.publicInputs).map((v) => {
|
|
26166
26436
|
if (typeof v === "string" && v.startsWith("0x")) {
|
|
26167
26437
|
return v;
|
|
@@ -26173,7 +26443,7 @@ var KimchiProvider = class {
|
|
|
26173
26443
|
});
|
|
26174
26444
|
const vkHash = this._compiledCircuits.get(request.circuitId)?.vkHash;
|
|
26175
26445
|
return {
|
|
26176
|
-
id: `kimchi-proof-${Date.now()}-${(0,
|
|
26446
|
+
id: `kimchi-proof-${Date.now()}-${(0, import_utils39.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
|
|
26177
26447
|
proof: proofHex,
|
|
26178
26448
|
publicInputs,
|
|
26179
26449
|
verificationKey: vkHash,
|
|
@@ -26266,11 +26536,11 @@ var KimchiProvider = class {
|
|
|
26266
26536
|
console.log(`[KimchiProvider] Merging ${proofs.length} proofs recursively`);
|
|
26267
26537
|
}
|
|
26268
26538
|
await this.delay(proofs.length * 100);
|
|
26269
|
-
const mergedProofBytes = (0,
|
|
26539
|
+
const mergedProofBytes = (0, import_utils39.randomBytes)(KIMCHI_PROOF_SIZE);
|
|
26270
26540
|
const combinedInputs = proofs.flatMap((p) => p.publicInputs);
|
|
26271
26541
|
return {
|
|
26272
26542
|
id: `kimchi-merged-${Date.now()}`,
|
|
26273
|
-
proof: `0x${(0,
|
|
26543
|
+
proof: `0x${(0, import_utils39.bytesToHex)(mergedProofBytes)}`,
|
|
26274
26544
|
publicInputs: combinedInputs.slice(0, 10),
|
|
26275
26545
|
// Limit public inputs
|
|
26276
26546
|
metadata: {
|
|
@@ -26291,7 +26561,7 @@ var KimchiProvider = class {
|
|
|
26291
26561
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
26292
26562
|
}
|
|
26293
26563
|
generateProviderId() {
|
|
26294
|
-
return (0,
|
|
26564
|
+
return (0, import_utils39.bytesToHex)((0, import_utils39.randomBytes)(4));
|
|
26295
26565
|
}
|
|
26296
26566
|
};
|
|
26297
26567
|
function createKimchiProvider(config) {
|
|
@@ -27402,7 +27672,7 @@ var DEFAULT_WARMING_CONFIG = {
|
|
|
27402
27672
|
|
|
27403
27673
|
// src/proofs/cache/key-generator.ts
|
|
27404
27674
|
var import_sha25612 = require("@noble/hashes/sha256");
|
|
27405
|
-
var
|
|
27675
|
+
var import_utils40 = require("@noble/hashes/utils");
|
|
27406
27676
|
var KEY_SEPARATOR = ":";
|
|
27407
27677
|
var KEY_PREFIX = "sip-proof";
|
|
27408
27678
|
var KEY_VERSION = "v1";
|
|
@@ -27424,7 +27694,7 @@ function canonicalize(value) {
|
|
|
27424
27694
|
return value.toString();
|
|
27425
27695
|
}
|
|
27426
27696
|
if (value instanceof Uint8Array) {
|
|
27427
|
-
return `bytes:${(0,
|
|
27697
|
+
return `bytes:${(0, import_utils40.bytesToHex)(value)}`;
|
|
27428
27698
|
}
|
|
27429
27699
|
if (Array.isArray(value)) {
|
|
27430
27700
|
return `[${value.map(canonicalize).join(",")}]`;
|
|
@@ -27487,7 +27757,7 @@ var CacheKeyGenerator = class {
|
|
|
27487
27757
|
hashInputs(inputs) {
|
|
27488
27758
|
const canonical = canonicalize(inputs);
|
|
27489
27759
|
const hash2 = (0, import_sha25612.sha256)(new TextEncoder().encode(canonical));
|
|
27490
|
-
return (0,
|
|
27760
|
+
return (0, import_utils40.bytesToHex)(hash2);
|
|
27491
27761
|
}
|
|
27492
27762
|
/**
|
|
27493
27763
|
* Generate a cache key from raw inputs
|
|
@@ -28932,11 +29202,11 @@ var CHAIN_NUMERIC_IDS = {
|
|
|
28932
29202
|
// src/oracle/verification.ts
|
|
28933
29203
|
var import_ed255199 = require("@noble/curves/ed25519");
|
|
28934
29204
|
var import_sha25614 = require("@noble/hashes/sha256");
|
|
28935
|
-
var
|
|
29205
|
+
var import_utils42 = require("@noble/hashes/utils");
|
|
28936
29206
|
|
|
28937
29207
|
// src/oracle/serialization.ts
|
|
28938
29208
|
var import_sha25613 = require("@noble/hashes/sha256");
|
|
28939
|
-
var
|
|
29209
|
+
var import_utils41 = require("@noble/hashes/utils");
|
|
28940
29210
|
init_errors();
|
|
28941
29211
|
function serializeAttestationMessage(message) {
|
|
28942
29212
|
const buffer = new Uint8Array(197);
|
|
@@ -28980,19 +29250,19 @@ function deserializeAttestationMessage(bytes) {
|
|
|
28980
29250
|
const version = bytes[offset++];
|
|
28981
29251
|
const chainId = view.getUint32(offset, false);
|
|
28982
29252
|
offset += 4;
|
|
28983
|
-
const intentHash = `0x${(0,
|
|
29253
|
+
const intentHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28984
29254
|
offset += 32;
|
|
28985
|
-
const recipient = `0x${(0,
|
|
29255
|
+
const recipient = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28986
29256
|
offset += 32;
|
|
28987
29257
|
const amount = bytesToBigint(bytes.slice(offset, offset + 16));
|
|
28988
29258
|
offset += 16;
|
|
28989
|
-
const assetId = `0x${(0,
|
|
29259
|
+
const assetId = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28990
29260
|
offset += 32;
|
|
28991
|
-
const txHash = `0x${(0,
|
|
29261
|
+
const txHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28992
29262
|
offset += 32;
|
|
28993
29263
|
const blockNumber = view.getBigUint64(offset, false);
|
|
28994
29264
|
offset += 8;
|
|
28995
|
-
const blockHash = `0x${(0,
|
|
29265
|
+
const blockHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
28996
29266
|
offset += 32;
|
|
28997
29267
|
const timestamp = Number(view.getBigUint64(offset, false));
|
|
28998
29268
|
return {
|
|
@@ -29009,7 +29279,7 @@ function deserializeAttestationMessage(bytes) {
|
|
|
29009
29279
|
};
|
|
29010
29280
|
}
|
|
29011
29281
|
function computeAttestationHash(message) {
|
|
29012
|
-
const domain = (0,
|
|
29282
|
+
const domain = (0, import_utils41.utf8ToBytes)(ORACLE_DOMAIN);
|
|
29013
29283
|
const messageBytes = serializeAttestationMessage(message);
|
|
29014
29284
|
const toHash = new Uint8Array(domain.length + messageBytes.length);
|
|
29015
29285
|
toHash.set(domain, 0);
|
|
@@ -29025,7 +29295,7 @@ function getChainNumericId(chain) {
|
|
|
29025
29295
|
}
|
|
29026
29296
|
function normalizeToBytes(hex, length, field) {
|
|
29027
29297
|
const stripped = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
29028
|
-
const bytes = (0,
|
|
29298
|
+
const bytes = (0, import_utils41.hexToBytes)(stripped);
|
|
29029
29299
|
if (bytes.length === length) {
|
|
29030
29300
|
return bytes;
|
|
29031
29301
|
}
|
|
@@ -29058,9 +29328,9 @@ function bytesToBigint(bytes) {
|
|
|
29058
29328
|
|
|
29059
29329
|
// src/oracle/verification.ts
|
|
29060
29330
|
function deriveOracleId(publicKey) {
|
|
29061
|
-
const keyBytes = typeof publicKey === "string" ? (0,
|
|
29331
|
+
const keyBytes = typeof publicKey === "string" ? (0, import_utils42.hexToBytes)(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey) : publicKey;
|
|
29062
29332
|
const hash2 = (0, import_sha25614.sha256)(keyBytes);
|
|
29063
|
-
return `0x${(0,
|
|
29333
|
+
return `0x${(0, import_utils42.bytesToHex)(hash2)}`;
|
|
29064
29334
|
}
|
|
29065
29335
|
function verifyAttestation(attestation, registry) {
|
|
29066
29336
|
const { message, signatures } = attestation;
|
|
@@ -29090,10 +29360,10 @@ function verifyAttestation(attestation, registry) {
|
|
|
29090
29360
|
continue;
|
|
29091
29361
|
}
|
|
29092
29362
|
try {
|
|
29093
|
-
const publicKeyBytes = (0,
|
|
29363
|
+
const publicKeyBytes = (0, import_utils42.hexToBytes)(
|
|
29094
29364
|
oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
|
|
29095
29365
|
);
|
|
29096
|
-
const signatureBytes = (0,
|
|
29366
|
+
const signatureBytes = (0, import_utils42.hexToBytes)(
|
|
29097
29367
|
sig.signature.startsWith("0x") ? sig.signature.slice(2) : sig.signature
|
|
29098
29368
|
);
|
|
29099
29369
|
const isValid = import_ed255199.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
|
|
@@ -29118,10 +29388,10 @@ function verifyAttestation(attestation, registry) {
|
|
|
29118
29388
|
}
|
|
29119
29389
|
function verifyOracleSignature(signature, messageHash, oracle) {
|
|
29120
29390
|
try {
|
|
29121
|
-
const publicKeyBytes = (0,
|
|
29391
|
+
const publicKeyBytes = (0, import_utils42.hexToBytes)(
|
|
29122
29392
|
oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
|
|
29123
29393
|
);
|
|
29124
|
-
const signatureBytes = (0,
|
|
29394
|
+
const signatureBytes = (0, import_utils42.hexToBytes)(
|
|
29125
29395
|
signature.signature.startsWith("0x") ? signature.signature.slice(2) : signature.signature
|
|
29126
29396
|
);
|
|
29127
29397
|
return import_ed255199.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
|
|
@@ -29135,7 +29405,7 @@ function signAttestationMessage(messageHash, privateKey) {
|
|
|
29135
29405
|
const oracleId = deriveOracleId(publicKey);
|
|
29136
29406
|
return {
|
|
29137
29407
|
oracleId,
|
|
29138
|
-
signature: `0x${(0,
|
|
29408
|
+
signature: `0x${(0, import_utils42.bytesToHex)(signature)}`
|
|
29139
29409
|
};
|
|
29140
29410
|
}
|
|
29141
29411
|
function createOracleRegistry(config = {}) {
|
|
@@ -29377,7 +29647,7 @@ var import_types87 = require("@sip-protocol/types");
|
|
|
29377
29647
|
|
|
29378
29648
|
// src/solver/mock-solver.ts
|
|
29379
29649
|
var import_types24 = require("@sip-protocol/types");
|
|
29380
|
-
var
|
|
29650
|
+
var import_utils43 = require("@noble/hashes/utils");
|
|
29381
29651
|
var MockSolver = class {
|
|
29382
29652
|
info;
|
|
29383
29653
|
capabilities;
|
|
@@ -29459,7 +29729,7 @@ var MockSolver = class {
|
|
|
29459
29729
|
const spreadAmount = baseOutput * BigInt(Math.floor(this.spreadPercent * 1e4)) / 10000n;
|
|
29460
29730
|
const outputAmount = baseOutput + spreadAmount;
|
|
29461
29731
|
const feeAmount = outputAmount * BigInt(Math.floor(this.feePercent * 1e4)) / 10000n;
|
|
29462
|
-
const quoteId = `quote-${(0,
|
|
29732
|
+
const quoteId = `quote-${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(8))}`;
|
|
29463
29733
|
const now = Math.floor(Date.now() / 1e3);
|
|
29464
29734
|
const quote = {
|
|
29465
29735
|
quoteId,
|
|
@@ -29470,7 +29740,7 @@ var MockSolver = class {
|
|
|
29470
29740
|
expiry: now + 60,
|
|
29471
29741
|
// Quote valid for 1 minute
|
|
29472
29742
|
fee: feeAmount,
|
|
29473
|
-
signature: `0x${(0,
|
|
29743
|
+
signature: `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(64))}`,
|
|
29474
29744
|
// Mock signature
|
|
29475
29745
|
validUntil: now + 60,
|
|
29476
29746
|
estimatedGas: 200000n
|
|
@@ -29507,7 +29777,7 @@ var MockSolver = class {
|
|
|
29507
29777
|
error: status.error
|
|
29508
29778
|
};
|
|
29509
29779
|
}
|
|
29510
|
-
const txHash = `0x${(0,
|
|
29780
|
+
const txHash = `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(32))}`;
|
|
29511
29781
|
status.status = "completed";
|
|
29512
29782
|
status.txHash = txHash;
|
|
29513
29783
|
return {
|
|
@@ -29517,10 +29787,10 @@ var MockSolver = class {
|
|
|
29517
29787
|
txHash: intent.privacyLevel === "transparent" ? txHash : void 0,
|
|
29518
29788
|
fulfillmentProof: {
|
|
29519
29789
|
type: "fulfillment",
|
|
29520
|
-
proof: `0x${(0,
|
|
29790
|
+
proof: `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(128))}`,
|
|
29521
29791
|
publicInputs: [
|
|
29522
|
-
`0x${(0,
|
|
29523
|
-
`0x${(0,
|
|
29792
|
+
`0x${(0, import_utils43.bytesToHex)(new TextEncoder().encode(intent.intentId))}`,
|
|
29793
|
+
`0x${(0, import_utils43.bytesToHex)(new TextEncoder().encode(quote.quoteId))}`
|
|
29524
29794
|
]
|
|
29525
29795
|
},
|
|
29526
29796
|
fulfilledAt: Math.floor(Date.now() / 1e3)
|
|
@@ -30079,6 +30349,7 @@ var SmartRouter = class {
|
|
|
30079
30349
|
log4.warn({ backend, error }, "Backend failed");
|
|
30080
30350
|
});
|
|
30081
30351
|
}
|
|
30352
|
+
registry;
|
|
30082
30353
|
cache;
|
|
30083
30354
|
tracker;
|
|
30084
30355
|
backendTimeoutMs;
|
|
@@ -31085,7 +31356,7 @@ function createZcashNativeBackend(config) {
|
|
|
31085
31356
|
var import_types27 = require("@sip-protocol/types");
|
|
31086
31357
|
init_stealth2();
|
|
31087
31358
|
init_errors();
|
|
31088
|
-
var
|
|
31359
|
+
var import_utils44 = require("@noble/hashes/utils");
|
|
31089
31360
|
var DEFAULT_GAS_FEES = {
|
|
31090
31361
|
ethereum: 21000n * 50n * 1000000000n,
|
|
31091
31362
|
// 21k gas * 50 gwei = 0.00105 ETH
|
|
@@ -31144,6 +31415,8 @@ var ZcashRPCError = class extends Error {
|
|
|
31144
31415
|
this.data = data;
|
|
31145
31416
|
this.name = "ZcashRPCError";
|
|
31146
31417
|
}
|
|
31418
|
+
code;
|
|
31419
|
+
data;
|
|
31147
31420
|
/**
|
|
31148
31421
|
* Check if error is due to insufficient funds
|
|
31149
31422
|
*/
|
|
@@ -32421,7 +32694,7 @@ var import_types89 = require("@sip-protocol/types");
|
|
|
32421
32694
|
// src/bitcoin/taproot.ts
|
|
32422
32695
|
var import_secp256k15 = require("@noble/curves/secp256k1");
|
|
32423
32696
|
var import_sha25615 = require("@noble/hashes/sha256");
|
|
32424
|
-
var
|
|
32697
|
+
var import_utils46 = require("@noble/hashes/utils");
|
|
32425
32698
|
init_errors();
|
|
32426
32699
|
init_validation();
|
|
32427
32700
|
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
@@ -32478,16 +32751,16 @@ function computeTweakedKey(internalKey, merkleRoot) {
|
|
|
32478
32751
|
}
|
|
32479
32752
|
const tweakData = merkleRoot ? new Uint8Array([...internalKey, ...merkleRoot]) : internalKey;
|
|
32480
32753
|
const tweak = taggedHash("TapTweak", tweakData);
|
|
32481
|
-
const tweakScalar = BigInt("0x" + (0,
|
|
32754
|
+
const tweakScalar = BigInt("0x" + (0, import_utils46.bytesToHex)(tweak)) % import_secp256k15.secp256k1.CURVE.n;
|
|
32482
32755
|
const internalPoint = import_secp256k15.secp256k1.ProjectivePoint.fromHex(
|
|
32483
|
-
"02" + (0,
|
|
32756
|
+
"02" + (0, import_utils46.bytesToHex)(internalKey)
|
|
32484
32757
|
);
|
|
32485
32758
|
const tweakPoint = import_secp256k15.secp256k1.ProjectivePoint.BASE.multiply(tweakScalar);
|
|
32486
32759
|
const tweakedPoint = internalPoint.add(tweakPoint);
|
|
32487
32760
|
const tweakedKeyBytes = tweakedPoint.toRawBytes(false);
|
|
32488
32761
|
const xOnly = tweakedKeyBytes.slice(1, 33);
|
|
32489
32762
|
const yCoord = tweakedKeyBytes.slice(33, 65);
|
|
32490
|
-
const yBigInt = BigInt("0x" + (0,
|
|
32763
|
+
const yBigInt = BigInt("0x" + (0, import_utils46.bytesToHex)(yCoord));
|
|
32491
32764
|
const parity = Number(yBigInt & 1n);
|
|
32492
32765
|
return {
|
|
32493
32766
|
tweakedKey: xOnly,
|
|
@@ -32517,9 +32790,9 @@ function createTaprootOutput(internalKey, scripts) {
|
|
|
32517
32790
|
}
|
|
32518
32791
|
const { tweakedKey, parity } = computeTweakedKey(internalKey, merkleRoot);
|
|
32519
32792
|
return {
|
|
32520
|
-
tweakedKey: `0x${(0,
|
|
32521
|
-
internalKey: `0x${(0,
|
|
32522
|
-
merkleRoot: merkleRoot ? `0x${(0,
|
|
32793
|
+
tweakedKey: `0x${(0, import_utils46.bytesToHex)(tweakedKey)}`,
|
|
32794
|
+
internalKey: `0x${(0, import_utils46.bytesToHex)(internalKey)}`,
|
|
32795
|
+
merkleRoot: merkleRoot ? `0x${(0, import_utils46.bytesToHex)(merkleRoot)}` : void 0,
|
|
32523
32796
|
parity
|
|
32524
32797
|
};
|
|
32525
32798
|
}
|
|
@@ -32652,10 +32925,10 @@ function createKeySpendOnlyOutput(privateKey, network = "mainnet") {
|
|
|
32652
32925
|
if (!isValidPrivateKey(privateKey)) {
|
|
32653
32926
|
throw new ValidationError("privateKey must be a valid 32-byte hex string", "privateKey");
|
|
32654
32927
|
}
|
|
32655
|
-
const privKeyBytes = (0,
|
|
32928
|
+
const privKeyBytes = (0, import_utils46.hexToBytes)(privateKey.slice(2));
|
|
32656
32929
|
const internalKey = getXOnlyPublicKey(privKeyBytes);
|
|
32657
32930
|
const output = createTaprootOutput(internalKey);
|
|
32658
|
-
const tweakedKeyBytes = (0,
|
|
32931
|
+
const tweakedKeyBytes = (0, import_utils46.hexToBytes)(output.tweakedKey.slice(2));
|
|
32659
32932
|
const address = taprootAddress(tweakedKeyBytes, network);
|
|
32660
32933
|
return {
|
|
32661
32934
|
output,
|
|
@@ -32681,11 +32954,11 @@ function schnorrSignHex(message, privateKey, auxRand) {
|
|
|
32681
32954
|
if (auxRand && !isValidHex(auxRand)) {
|
|
32682
32955
|
throw new ValidationError("auxRand must be a hex string", "auxRand");
|
|
32683
32956
|
}
|
|
32684
|
-
const messageBytes = (0,
|
|
32685
|
-
const privateKeyBytes = (0,
|
|
32686
|
-
const auxRandBytes = auxRand ? (0,
|
|
32957
|
+
const messageBytes = (0, import_utils46.hexToBytes)(message.slice(2));
|
|
32958
|
+
const privateKeyBytes = (0, import_utils46.hexToBytes)(privateKey.slice(2));
|
|
32959
|
+
const auxRandBytes = auxRand ? (0, import_utils46.hexToBytes)(auxRand.slice(2)) : void 0;
|
|
32687
32960
|
const signature = schnorrSign(messageBytes, privateKeyBytes, auxRandBytes);
|
|
32688
|
-
return `0x${(0,
|
|
32961
|
+
return `0x${(0, import_utils46.bytesToHex)(signature)}`;
|
|
32689
32962
|
}
|
|
32690
32963
|
function schnorrVerifyHex(signature, message, publicKey) {
|
|
32691
32964
|
if (!isValidHex(signature)) {
|
|
@@ -32697,23 +32970,23 @@ function schnorrVerifyHex(signature, message, publicKey) {
|
|
|
32697
32970
|
if (!isValidHex(publicKey)) {
|
|
32698
32971
|
throw new ValidationError("publicKey must be a hex string", "publicKey");
|
|
32699
32972
|
}
|
|
32700
|
-
const signatureBytes = (0,
|
|
32701
|
-
const messageBytes = (0,
|
|
32702
|
-
const publicKeyBytes = (0,
|
|
32973
|
+
const signatureBytes = (0, import_utils46.hexToBytes)(signature.slice(2));
|
|
32974
|
+
const messageBytes = (0, import_utils46.hexToBytes)(message.slice(2));
|
|
32975
|
+
const publicKeyBytes = (0, import_utils46.hexToBytes)(publicKey.slice(2));
|
|
32703
32976
|
return schnorrVerify(signatureBytes, messageBytes, publicKeyBytes);
|
|
32704
32977
|
}
|
|
32705
32978
|
|
|
32706
32979
|
// src/bitcoin/silent-payments.ts
|
|
32707
32980
|
var import_secp256k16 = require("@noble/curves/secp256k1");
|
|
32708
32981
|
var import_sha25616 = require("@noble/hashes/sha256");
|
|
32709
|
-
var
|
|
32982
|
+
var import_utils47 = require("@noble/hashes/utils");
|
|
32710
32983
|
init_errors();
|
|
32711
32984
|
init_validation();
|
|
32712
32985
|
|
|
32713
32986
|
// src/payment/payment.ts
|
|
32714
32987
|
var import_types32 = require("@sip-protocol/types");
|
|
32715
32988
|
var import_sha25617 = require("@noble/hashes/sha256");
|
|
32716
|
-
var
|
|
32989
|
+
var import_utils48 = require("@noble/hashes/utils");
|
|
32717
32990
|
var import_chacha3 = require("@noble/ciphers/chacha.js");
|
|
32718
32991
|
var import_hkdf3 = require("@noble/hashes/hkdf");
|
|
32719
32992
|
init_stealth2();
|
|
@@ -33213,8 +33486,8 @@ async function createShieldedPayment(params, options) {
|
|
|
33213
33486
|
let viewingKeyHash;
|
|
33214
33487
|
if (viewingKey) {
|
|
33215
33488
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
33216
|
-
const keyBytes = (0,
|
|
33217
|
-
viewingKeyHash = `0x${(0,
|
|
33489
|
+
const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
|
|
33490
|
+
viewingKeyHash = `0x${(0, import_utils48.bytesToHex)((0, import_sha25617.sha256)(keyBytes))}`;
|
|
33218
33491
|
}
|
|
33219
33492
|
const privacyConfig = getPrivacyConfig(
|
|
33220
33493
|
privacy,
|
|
@@ -33254,7 +33527,7 @@ async function createShieldedPayment(params, options) {
|
|
|
33254
33527
|
if (privacy !== import_types32.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
|
|
33255
33528
|
const hexToUint8 = (hex) => {
|
|
33256
33529
|
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
33257
|
-
return (0,
|
|
33530
|
+
return (0, import_utils48.hexToBytes)(cleanHex);
|
|
33258
33531
|
};
|
|
33259
33532
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
33260
33533
|
balance: amount,
|
|
@@ -33281,17 +33554,17 @@ async function createShieldedPayment(params, options) {
|
|
|
33281
33554
|
}
|
|
33282
33555
|
function encryptMemo(memo, viewingKey) {
|
|
33283
33556
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
33284
|
-
const keyBytes = (0,
|
|
33557
|
+
const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
|
|
33285
33558
|
const encKey = (0, import_hkdf3.hkdf)(import_sha25617.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
33286
33559
|
try {
|
|
33287
|
-
const nonce = (0,
|
|
33560
|
+
const nonce = (0, import_utils48.randomBytes)(24);
|
|
33288
33561
|
const cipher = (0, import_chacha3.xchacha20poly1305)(encKey, nonce);
|
|
33289
33562
|
const plaintext = new TextEncoder().encode(memo);
|
|
33290
33563
|
const ciphertext = cipher.encrypt(plaintext);
|
|
33291
33564
|
const result = new Uint8Array(nonce.length + ciphertext.length);
|
|
33292
33565
|
result.set(nonce);
|
|
33293
33566
|
result.set(ciphertext, nonce.length);
|
|
33294
|
-
return `0x${(0,
|
|
33567
|
+
return `0x${(0, import_utils48.bytesToHex)(result)}`;
|
|
33295
33568
|
} finally {
|
|
33296
33569
|
secureWipe(keyBytes);
|
|
33297
33570
|
secureWipe(encKey);
|
|
@@ -33299,11 +33572,11 @@ function encryptMemo(memo, viewingKey) {
|
|
|
33299
33572
|
}
|
|
33300
33573
|
function decryptMemo(encryptedMemo, viewingKey) {
|
|
33301
33574
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
33302
|
-
const keyBytes = (0,
|
|
33575
|
+
const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
|
|
33303
33576
|
const encKey = (0, import_hkdf3.hkdf)(import_sha25617.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
33304
33577
|
try {
|
|
33305
33578
|
const dataHex = encryptedMemo.startsWith("0x") ? encryptedMemo.slice(2) : encryptedMemo;
|
|
33306
|
-
const data = (0,
|
|
33579
|
+
const data = (0, import_utils48.hexToBytes)(dataHex);
|
|
33307
33580
|
const nonce = data.slice(0, 24);
|
|
33308
33581
|
const ciphertext = data.slice(24);
|
|
33309
33582
|
const cipher = (0, import_chacha3.xchacha20poly1305)(encKey, nonce);
|
|
@@ -33353,7 +33626,7 @@ function getPaymentSummary(payment) {
|
|
|
33353
33626
|
var import_types33 = require("@sip-protocol/types");
|
|
33354
33627
|
var import_secp256k17 = require("@noble/curves/secp256k1");
|
|
33355
33628
|
var import_sha25618 = require("@noble/hashes/sha256");
|
|
33356
|
-
var
|
|
33629
|
+
var import_utils49 = require("@noble/hashes/utils");
|
|
33357
33630
|
init_errors();
|
|
33358
33631
|
init_validation();
|
|
33359
33632
|
init_secure_memory();
|
|
@@ -33847,12 +34120,12 @@ var Treasury = class _Treasury {
|
|
|
33847
34120
|
}
|
|
33848
34121
|
};
|
|
33849
34122
|
function generateTreasuryId() {
|
|
33850
|
-
const bytes = (0,
|
|
33851
|
-
return `treasury_${(0,
|
|
34123
|
+
const bytes = (0, import_utils49.randomBytes)(16);
|
|
34124
|
+
return `treasury_${(0, import_utils49.bytesToHex)(bytes)}`;
|
|
33852
34125
|
}
|
|
33853
34126
|
function generateProposalId() {
|
|
33854
|
-
const bytes = (0,
|
|
33855
|
-
return `prop_${(0,
|
|
34127
|
+
const bytes = (0, import_utils49.randomBytes)(16);
|
|
34128
|
+
return `prop_${(0, import_utils49.bytesToHex)(bytes)}`;
|
|
33856
34129
|
}
|
|
33857
34130
|
function computeProposalHash(proposal) {
|
|
33858
34131
|
const data = JSON.stringify({
|
|
@@ -33868,7 +34141,7 @@ function computeProposalHash(proposal) {
|
|
|
33868
34141
|
}
|
|
33869
34142
|
function signMessage(messageHash, privateKey) {
|
|
33870
34143
|
const keyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
33871
|
-
const keyBytes = (0,
|
|
34144
|
+
const keyBytes = (0, import_utils49.hexToBytes)(keyHex);
|
|
33872
34145
|
try {
|
|
33873
34146
|
const signature = import_secp256k17.secp256k1.sign(messageHash, keyBytes);
|
|
33874
34147
|
return `0x${signature.toCompactHex()}`;
|
|
@@ -33880,8 +34153,8 @@ function verifySignature(messageHash, signature, publicKey) {
|
|
|
33880
34153
|
const sigHex = signature.startsWith("0x") ? signature.slice(2) : signature;
|
|
33881
34154
|
const pubKeyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
33882
34155
|
try {
|
|
33883
|
-
const sigBytes = (0,
|
|
33884
|
-
const pubKeyBytes = (0,
|
|
34156
|
+
const sigBytes = (0, import_utils49.hexToBytes)(sigHex);
|
|
34157
|
+
const pubKeyBytes = (0, import_utils49.hexToBytes)(pubKeyHex);
|
|
33885
34158
|
return import_secp256k17.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
|
|
33886
34159
|
} catch {
|
|
33887
34160
|
return false;
|
|
@@ -34040,7 +34313,7 @@ function validateBatchProposalParams(params, config) {
|
|
|
34040
34313
|
|
|
34041
34314
|
// src/compliance/compliance-manager.ts
|
|
34042
34315
|
var import_types34 = require("@sip-protocol/types");
|
|
34043
|
-
var
|
|
34316
|
+
var import_utils50 = require("@noble/hashes/utils");
|
|
34044
34317
|
init_errors();
|
|
34045
34318
|
var DEFAULTS2 = {
|
|
34046
34319
|
riskThreshold: 70,
|
|
@@ -34788,7 +35061,7 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
34788
35061
|
}
|
|
34789
35062
|
};
|
|
34790
35063
|
function generateId5(prefix) {
|
|
34791
|
-
return `${prefix}_${(0,
|
|
35064
|
+
return `${prefix}_${(0, import_utils50.bytesToHex)((0, import_utils50.randomBytes)(12))}`;
|
|
34792
35065
|
}
|
|
34793
35066
|
function validateRegisterAuditorParams(params) {
|
|
34794
35067
|
if (!params.organization?.trim()) {
|
|
@@ -34877,7 +35150,7 @@ function validateReportParams(params) {
|
|
|
34877
35150
|
|
|
34878
35151
|
// src/compliance/reports.ts
|
|
34879
35152
|
var import_sha25619 = require("@noble/hashes/sha256");
|
|
34880
|
-
var
|
|
35153
|
+
var import_utils51 = require("@noble/hashes/utils");
|
|
34881
35154
|
init_errors();
|
|
34882
35155
|
|
|
34883
35156
|
// src/compliance/pdf.ts
|
|
@@ -35179,12 +35452,12 @@ var ComplianceReporter = class {
|
|
|
35179
35452
|
normalizeViewingKey(viewingKey) {
|
|
35180
35453
|
if (typeof viewingKey === "string") {
|
|
35181
35454
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
35182
|
-
const keyBytes = (0,
|
|
35455
|
+
const keyBytes = (0, import_utils51.hexToBytes)(keyHex);
|
|
35183
35456
|
const hashBytes = (0, import_sha25619.sha256)(keyBytes);
|
|
35184
35457
|
return {
|
|
35185
35458
|
key: `0x${keyHex}`,
|
|
35186
35459
|
path: "m/0",
|
|
35187
|
-
hash: `0x${(0,
|
|
35460
|
+
hash: `0x${(0, import_utils51.bytesToHex)(hashBytes)}`
|
|
35188
35461
|
};
|
|
35189
35462
|
}
|
|
35190
35463
|
return viewingKey;
|
|
@@ -35566,7 +35839,7 @@ var ComplianceReporter = class {
|
|
|
35566
35839
|
|
|
35567
35840
|
// src/compliance/conditional.ts
|
|
35568
35841
|
var import_sha25620 = require("@noble/hashes/sha256");
|
|
35569
|
-
var
|
|
35842
|
+
var import_utils52 = require("@noble/hashes/utils");
|
|
35570
35843
|
var import_chacha4 = require("@noble/ciphers/chacha.js");
|
|
35571
35844
|
init_errors();
|
|
35572
35845
|
var ConditionalDisclosure = class {
|
|
@@ -35633,8 +35906,8 @@ var ConditionalDisclosure = class {
|
|
|
35633
35906
|
params.commitment,
|
|
35634
35907
|
revealAfterSeconds
|
|
35635
35908
|
);
|
|
35636
|
-
const nonce = (0,
|
|
35637
|
-
const viewingKeyBytes = (0,
|
|
35909
|
+
const nonce = (0, import_utils52.randomBytes)(24);
|
|
35910
|
+
const viewingKeyBytes = (0, import_utils52.hexToBytes)(params.viewingKey.slice(2));
|
|
35638
35911
|
const cipher = (0, import_chacha4.xchacha20poly1305)(encryptionKey, nonce);
|
|
35639
35912
|
const encryptedKey = cipher.encrypt(viewingKeyBytes);
|
|
35640
35913
|
const commitmentData = new Uint8Array([
|
|
@@ -35643,10 +35916,10 @@ var ConditionalDisclosure = class {
|
|
|
35643
35916
|
]);
|
|
35644
35917
|
const commitmentHash = (0, import_sha25620.sha256)(commitmentData);
|
|
35645
35918
|
return {
|
|
35646
|
-
encryptedKey: "0x" + (0,
|
|
35647
|
-
nonce: "0x" + (0,
|
|
35919
|
+
encryptedKey: "0x" + (0, import_utils52.bytesToHex)(encryptedKey),
|
|
35920
|
+
nonce: "0x" + (0, import_utils52.bytesToHex)(nonce),
|
|
35648
35921
|
revealAfter: revealAfterSeconds,
|
|
35649
|
-
verificationCommitment: "0x" + (0,
|
|
35922
|
+
verificationCommitment: "0x" + (0, import_utils52.bytesToHex)(commitmentHash),
|
|
35650
35923
|
encryptionCommitment: params.commitment,
|
|
35651
35924
|
type
|
|
35652
35925
|
};
|
|
@@ -35723,11 +35996,11 @@ var ConditionalDisclosure = class {
|
|
|
35723
35996
|
timeLock.encryptionCommitment,
|
|
35724
35997
|
timeLock.revealAfter
|
|
35725
35998
|
);
|
|
35726
|
-
const nonce = (0,
|
|
35727
|
-
const encryptedData = (0,
|
|
35999
|
+
const nonce = (0, import_utils52.hexToBytes)(timeLock.nonce.slice(2));
|
|
36000
|
+
const encryptedData = (0, import_utils52.hexToBytes)(timeLock.encryptedKey.slice(2));
|
|
35728
36001
|
const cipher = (0, import_chacha4.xchacha20poly1305)(encryptionKey, nonce);
|
|
35729
36002
|
const decryptedBytes = cipher.decrypt(encryptedData);
|
|
35730
|
-
const viewingKey = "0x" + (0,
|
|
36003
|
+
const viewingKey = "0x" + (0, import_utils52.bytesToHex)(decryptedBytes);
|
|
35731
36004
|
return {
|
|
35732
36005
|
unlocked: true,
|
|
35733
36006
|
viewingKey
|
|
@@ -35758,13 +36031,13 @@ var ConditionalDisclosure = class {
|
|
|
35758
36031
|
*/
|
|
35759
36032
|
verifyCommitment(timeLock, viewingKey) {
|
|
35760
36033
|
try {
|
|
35761
|
-
const viewingKeyBytes = (0,
|
|
36034
|
+
const viewingKeyBytes = (0, import_utils52.hexToBytes)(viewingKey.slice(2));
|
|
35762
36035
|
const commitmentData = new Uint8Array([
|
|
35763
36036
|
...viewingKeyBytes,
|
|
35764
36037
|
...this._numberToBytes(timeLock.revealAfter)
|
|
35765
36038
|
]);
|
|
35766
36039
|
const expectedCommitment = (0, import_sha25620.sha256)(commitmentData);
|
|
35767
|
-
const actualCommitment = (0,
|
|
36040
|
+
const actualCommitment = (0, import_utils52.hexToBytes)(timeLock.verificationCommitment.slice(2));
|
|
35768
36041
|
if (expectedCommitment.length !== actualCommitment.length) {
|
|
35769
36042
|
return false;
|
|
35770
36043
|
}
|
|
@@ -35783,7 +36056,7 @@ var ConditionalDisclosure = class {
|
|
|
35783
36056
|
* @private
|
|
35784
36057
|
*/
|
|
35785
36058
|
_deriveEncryptionKey(commitment, revealAfter) {
|
|
35786
|
-
const commitmentBytes = (0,
|
|
36059
|
+
const commitmentBytes = (0, import_utils52.hexToBytes)(commitment.slice(2));
|
|
35787
36060
|
const timeBytes = this._numberToBytes(revealAfter);
|
|
35788
36061
|
const combined = new Uint8Array([...commitmentBytes, ...timeBytes]);
|
|
35789
36062
|
const key = (0, import_sha25620.sha256)(combined);
|
|
@@ -35815,14 +36088,14 @@ var ConditionalDisclosure = class {
|
|
|
35815
36088
|
// src/compliance/conditional-threshold.ts
|
|
35816
36089
|
var import_secp256k18 = require("@noble/curves/secp256k1");
|
|
35817
36090
|
var import_sha25621 = require("@noble/hashes/sha256");
|
|
35818
|
-
var
|
|
36091
|
+
var import_utils53 = require("@noble/hashes/utils");
|
|
35819
36092
|
init_commitment();
|
|
35820
36093
|
init_errors();
|
|
35821
36094
|
var CURVE_ORDER2 = import_secp256k18.secp256k1.CURVE.n;
|
|
35822
36095
|
|
|
35823
36096
|
// src/compliance/threshold.ts
|
|
35824
36097
|
var import_sha25622 = require("@noble/hashes/sha256");
|
|
35825
|
-
var
|
|
36098
|
+
var import_utils54 = require("@noble/hashes/utils");
|
|
35826
36099
|
init_errors();
|
|
35827
36100
|
var FIELD_PRIME = 2n ** 256n - 189n;
|
|
35828
36101
|
var ThresholdViewingKey = class {
|
|
@@ -36006,7 +36279,7 @@ var ThresholdViewingKey = class {
|
|
|
36006
36279
|
* Convert viewing key to secret (bigint)
|
|
36007
36280
|
*/
|
|
36008
36281
|
static viewingKeyToSecret(viewingKey) {
|
|
36009
|
-
const bytes = (0,
|
|
36282
|
+
const bytes = (0, import_utils54.hexToBytes)(viewingKey.slice(2));
|
|
36010
36283
|
let secret = 0n;
|
|
36011
36284
|
for (let i = 0; i < bytes.length; i++) {
|
|
36012
36285
|
secret = secret << 8n | BigInt(bytes[i]);
|
|
@@ -36040,7 +36313,7 @@ var ThresholdViewingKey = class {
|
|
|
36040
36313
|
* Generate a random field element
|
|
36041
36314
|
*/
|
|
36042
36315
|
static randomFieldElement() {
|
|
36043
|
-
const bytes = (0,
|
|
36316
|
+
const bytes = (0, import_utils54.randomBytes)(32);
|
|
36044
36317
|
let value = 0n;
|
|
36045
36318
|
for (let i = 0; i < bytes.length; i++) {
|
|
36046
36319
|
value = value << 8n | BigInt(bytes[i]);
|
|
@@ -36065,8 +36338,8 @@ var ThresholdViewingKey = class {
|
|
|
36065
36338
|
*/
|
|
36066
36339
|
static createCommitment(secret, coefficients) {
|
|
36067
36340
|
const data = [secret, ...coefficients].map((c) => c.toString(16).padStart(64, "0")).join("");
|
|
36068
|
-
const hash2 = (0, import_sha25622.sha256)((0,
|
|
36069
|
-
return (0,
|
|
36341
|
+
const hash2 = (0, import_sha25622.sha256)((0, import_utils54.hexToBytes)(data));
|
|
36342
|
+
return (0, import_utils54.bytesToHex)(hash2);
|
|
36070
36343
|
}
|
|
36071
36344
|
/**
|
|
36072
36345
|
* Encode share as string: "x:y:len:commitment"
|
|
@@ -36190,9 +36463,9 @@ var ThresholdViewingKey = class {
|
|
|
36190
36463
|
|
|
36191
36464
|
// src/compliance/derivation.ts
|
|
36192
36465
|
var import_sha25623 = require("@noble/hashes/sha256");
|
|
36193
|
-
var
|
|
36466
|
+
var import_sha5124 = require("@noble/hashes/sha512");
|
|
36194
36467
|
var import_hmac5 = require("@noble/hashes/hmac");
|
|
36195
|
-
var
|
|
36468
|
+
var import_utils55 = require("@noble/hashes/utils");
|
|
36196
36469
|
init_errors();
|
|
36197
36470
|
init_secure_memory();
|
|
36198
36471
|
var AuditorType = /* @__PURE__ */ ((AuditorType2) => {
|
|
@@ -36291,7 +36564,7 @@ var AuditorKeyDerivation = class {
|
|
|
36291
36564
|
auditorType
|
|
36292
36565
|
// auditorType (non-hardened)
|
|
36293
36566
|
];
|
|
36294
|
-
const masterData = (0, import_hmac5.hmac)(
|
|
36567
|
+
const masterData = (0, import_hmac5.hmac)(import_sha5124.sha512, (0, import_utils55.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
|
|
36295
36568
|
let currentKey = new Uint8Array(masterData.slice(0, 32));
|
|
36296
36569
|
let chainCode = new Uint8Array(masterData.slice(32, 64));
|
|
36297
36570
|
try {
|
|
@@ -36304,9 +36577,9 @@ var AuditorKeyDerivation = class {
|
|
|
36304
36577
|
currentKey = new Uint8Array(derived.key);
|
|
36305
36578
|
chainCode = new Uint8Array(derived.chainCode);
|
|
36306
36579
|
}
|
|
36307
|
-
const keyHex = `0x${(0,
|
|
36580
|
+
const keyHex = `0x${(0, import_utils55.bytesToHex)(currentKey)}`;
|
|
36308
36581
|
const hashBytes = (0, import_sha25623.sha256)(currentKey);
|
|
36309
|
-
const hash2 = `0x${(0,
|
|
36582
|
+
const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
|
|
36310
36583
|
const viewingKey = {
|
|
36311
36584
|
key: keyHex,
|
|
36312
36585
|
path,
|
|
@@ -36373,7 +36646,7 @@ var AuditorKeyDerivation = class {
|
|
|
36373
36646
|
account | this.HARDENED
|
|
36374
36647
|
// account' (hardened)
|
|
36375
36648
|
];
|
|
36376
|
-
const masterData = (0, import_hmac5.hmac)(
|
|
36649
|
+
const masterData = (0, import_hmac5.hmac)(import_sha5124.sha512, (0, import_utils55.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
|
|
36377
36650
|
let commonKey = new Uint8Array(masterData.slice(0, 32));
|
|
36378
36651
|
let commonChainCode = new Uint8Array(masterData.slice(32, 64));
|
|
36379
36652
|
try {
|
|
@@ -36390,9 +36663,9 @@ var AuditorKeyDerivation = class {
|
|
|
36390
36663
|
for (const auditorType of uniqueTypes) {
|
|
36391
36664
|
const derived = this.deriveChildKey(commonKey, commonChainCode, auditorType);
|
|
36392
36665
|
try {
|
|
36393
|
-
const keyHex = `0x${(0,
|
|
36666
|
+
const keyHex = `0x${(0, import_utils55.bytesToHex)(derived.key)}`;
|
|
36394
36667
|
const hashBytes = (0, import_sha25623.sha256)(derived.key);
|
|
36395
|
-
const hash2 = `0x${(0,
|
|
36668
|
+
const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
|
|
36396
36669
|
const path = this.derivePath(auditorType, account);
|
|
36397
36670
|
const viewingKey = {
|
|
36398
36671
|
key: keyHex,
|
|
@@ -36457,7 +36730,7 @@ var AuditorKeyDerivation = class {
|
|
|
36457
36730
|
}
|
|
36458
36731
|
const indexView = new DataView(data.buffer, 33, 4);
|
|
36459
36732
|
indexView.setUint32(0, index, false);
|
|
36460
|
-
const hmacResult = (0, import_hmac5.hmac)(
|
|
36733
|
+
const hmacResult = (0, import_hmac5.hmac)(import_sha5124.sha512, chainCode, data);
|
|
36461
36734
|
const childKey = new Uint8Array(hmacResult.slice(0, 32));
|
|
36462
36735
|
const childChainCode = new Uint8Array(hmacResult.slice(32, 64));
|
|
36463
36736
|
return {
|
|
@@ -36515,8 +36788,8 @@ var AuditorKeyDerivation = class {
|
|
|
36515
36788
|
// src/compliance/range-sas.ts
|
|
36516
36789
|
var import_sha25624 = require("@noble/hashes/sha256");
|
|
36517
36790
|
var import_hmac6 = require("@noble/hashes/hmac");
|
|
36518
|
-
var
|
|
36519
|
-
var
|
|
36791
|
+
var import_sha5125 = require("@noble/hashes/sha512");
|
|
36792
|
+
var import_utils56 = require("@noble/hashes/utils");
|
|
36520
36793
|
init_errors();
|
|
36521
36794
|
init_secure_memory();
|
|
36522
36795
|
var AttestationSchema = /* @__PURE__ */ ((AttestationSchema2) => {
|
|
@@ -36752,16 +37025,16 @@ var AttestationGatedDisclosure = class {
|
|
|
36752
37025
|
*/
|
|
36753
37026
|
deriveKeyFromAttestation(attestation) {
|
|
36754
37027
|
const masterKeyHex = this.config.masterViewingKey.key.startsWith("0x") ? this.config.masterViewingKey.key.slice(2) : this.config.masterViewingKey.key;
|
|
36755
|
-
const masterKeyBytes = (0,
|
|
36756
|
-
const derivationData = (0,
|
|
37028
|
+
const masterKeyBytes = (0, import_utils56.hexToBytes)(masterKeyHex);
|
|
37029
|
+
const derivationData = (0, import_utils56.utf8ToBytes)(
|
|
36757
37030
|
`SIP-RANGE-SAS:${attestation.uid}:${attestation.subject}:${attestation.schema}:${attestation.signature}`
|
|
36758
37031
|
);
|
|
36759
|
-
const derived = (0, import_hmac6.hmac)(
|
|
37032
|
+
const derived = (0, import_hmac6.hmac)(import_sha5125.sha512, masterKeyBytes, derivationData);
|
|
36760
37033
|
const keyBytes = derived.slice(0, 32);
|
|
36761
37034
|
try {
|
|
36762
|
-
const key = `0x${(0,
|
|
37035
|
+
const key = `0x${(0, import_utils56.bytesToHex)(keyBytes)}`;
|
|
36763
37036
|
const hashBytes = (0, import_sha25624.sha256)(keyBytes);
|
|
36764
|
-
const hash2 = `0x${(0,
|
|
37037
|
+
const hash2 = `0x${(0, import_utils56.bytesToHex)(hashBytes)}`;
|
|
36765
37038
|
return {
|
|
36766
37039
|
key,
|
|
36767
37040
|
path: `${this.config.masterViewingKey.path}/sas/${attestation.uid.slice(0, 8)}`,
|
|
@@ -36853,13 +37126,13 @@ async function verifyAttestationSignature(attestation, options = {}) {
|
|
|
36853
37126
|
const signedMessage = constructAttestationMessage(attestation);
|
|
36854
37127
|
try {
|
|
36855
37128
|
const { ed25519: ed2551918 } = await import("@noble/curves/ed25519");
|
|
36856
|
-
const signatureBytes = (0,
|
|
37129
|
+
const signatureBytes = (0, import_utils56.hexToBytes)(
|
|
36857
37130
|
attestation.signature.startsWith("0x") ? attestation.signature.slice(2) : attestation.signature
|
|
36858
37131
|
);
|
|
36859
|
-
const publicKeyBytes = (0,
|
|
37132
|
+
const publicKeyBytes = (0, import_utils56.hexToBytes)(
|
|
36860
37133
|
issuerPublicKey.startsWith("0x") ? issuerPublicKey.slice(2) : issuerPublicKey
|
|
36861
37134
|
);
|
|
36862
|
-
const messageBytes = (0,
|
|
37135
|
+
const messageBytes = (0, import_utils56.utf8ToBytes)(signedMessage);
|
|
36863
37136
|
return ed2551918.verify(signatureBytes, messageBytes, publicKeyBytes);
|
|
36864
37137
|
} catch (error) {
|
|
36865
37138
|
console.warn(`[Range SAS] Signature verification error: ${error}`);
|
|
@@ -37016,11 +37289,11 @@ async function fetchWalletAttestations(walletAddress, options = {}) {
|
|
|
37016
37289
|
|
|
37017
37290
|
// src/compliance/fireblocks.ts
|
|
37018
37291
|
var import_sha25625 = require("@noble/hashes/sha256");
|
|
37019
|
-
var
|
|
37292
|
+
var import_utils57 = require("@noble/hashes/utils");
|
|
37020
37293
|
|
|
37021
37294
|
// src/auction/sealed-bid.ts
|
|
37022
37295
|
init_commitment();
|
|
37023
|
-
var
|
|
37296
|
+
var import_utils58 = require("@noble/hashes/utils");
|
|
37024
37297
|
init_errors();
|
|
37025
37298
|
var SealedBidAuction = class {
|
|
37026
37299
|
/**
|
|
@@ -37098,7 +37371,7 @@ var SealedBidAuction = class {
|
|
|
37098
37371
|
);
|
|
37099
37372
|
}
|
|
37100
37373
|
}
|
|
37101
|
-
const salt = params.salt ?? (0,
|
|
37374
|
+
const salt = params.salt ?? (0, import_utils58.randomBytes)(32);
|
|
37102
37375
|
const { commitment, blinding } = commit(params.amount, salt);
|
|
37103
37376
|
const sealedBid = {
|
|
37104
37377
|
auctionId: params.auctionId,
|
|
@@ -37242,7 +37515,7 @@ var SealedBidAuction = class {
|
|
|
37242
37515
|
* ```
|
|
37243
37516
|
*/
|
|
37244
37517
|
revealBid(bid, amount, salt) {
|
|
37245
|
-
const saltHex = `0x${(0,
|
|
37518
|
+
const saltHex = `0x${(0, import_utils58.bytesToHex)(salt)}`;
|
|
37246
37519
|
const isValid = this.verifyBid({
|
|
37247
37520
|
commitment: bid.commitment,
|
|
37248
37521
|
amount,
|
|
@@ -37729,7 +38002,7 @@ function createSealedBidAuction() {
|
|
|
37729
38002
|
// src/governance/private-vote.ts
|
|
37730
38003
|
var import_sha25626 = require("@noble/hashes/sha256");
|
|
37731
38004
|
var import_hkdf4 = require("@noble/hashes/hkdf");
|
|
37732
|
-
var
|
|
38005
|
+
var import_utils59 = require("@noble/hashes/utils");
|
|
37733
38006
|
var import_chacha5 = require("@noble/ciphers/chacha.js");
|
|
37734
38007
|
init_errors();
|
|
37735
38008
|
init_secure_memory();
|
|
@@ -37770,7 +38043,7 @@ var PrivateVoting = class {
|
|
|
37770
38043
|
const { proposalId, choice, weight, encryptionKey, voter = "anonymous" } = params;
|
|
37771
38044
|
const derivedKey = this.deriveEncryptionKey(encryptionKey, proposalId);
|
|
37772
38045
|
try {
|
|
37773
|
-
const nonce = (0,
|
|
38046
|
+
const nonce = (0, import_utils59.randomBytes)(NONCE_SIZE3);
|
|
37774
38047
|
const voteData = {
|
|
37775
38048
|
proposalId,
|
|
37776
38049
|
choice,
|
|
@@ -37778,14 +38051,14 @@ var PrivateVoting = class {
|
|
|
37778
38051
|
voter,
|
|
37779
38052
|
timestamp: Date.now()
|
|
37780
38053
|
};
|
|
37781
|
-
const plaintext = (0,
|
|
38054
|
+
const plaintext = (0, import_utils59.utf8ToBytes)(JSON.stringify(voteData));
|
|
37782
38055
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
|
|
37783
38056
|
const ciphertext = cipher.encrypt(plaintext);
|
|
37784
|
-
const keyHash = (0, import_sha25626.sha256)((0,
|
|
38057
|
+
const keyHash = (0, import_sha25626.sha256)((0, import_utils59.hexToBytes)(encryptionKey.slice(2)));
|
|
37785
38058
|
return {
|
|
37786
|
-
ciphertext: `0x${(0,
|
|
37787
|
-
nonce: `0x${(0,
|
|
37788
|
-
encryptionKeyHash: `0x${(0,
|
|
38059
|
+
ciphertext: `0x${(0, import_utils59.bytesToHex)(ciphertext)}`,
|
|
38060
|
+
nonce: `0x${(0, import_utils59.bytesToHex)(nonce)}`,
|
|
38061
|
+
encryptionKeyHash: `0x${(0, import_utils59.bytesToHex)(keyHash)}`,
|
|
37789
38062
|
proposalId,
|
|
37790
38063
|
voter,
|
|
37791
38064
|
timestamp: voteData.timestamp
|
|
@@ -37831,8 +38104,8 @@ var PrivateVoting = class {
|
|
|
37831
38104
|
}
|
|
37832
38105
|
const derivedKey = this.deriveEncryptionKey(decryptionKey, vote.proposalId);
|
|
37833
38106
|
try {
|
|
37834
|
-
const keyHash = (0, import_sha25626.sha256)((0,
|
|
37835
|
-
const expectedKeyHash = `0x${(0,
|
|
38107
|
+
const keyHash = (0, import_sha25626.sha256)((0, import_utils59.hexToBytes)(decryptionKey.slice(2)));
|
|
38108
|
+
const expectedKeyHash = `0x${(0, import_utils59.bytesToHex)(keyHash)}`;
|
|
37836
38109
|
if (vote.encryptionKeyHash !== expectedKeyHash) {
|
|
37837
38110
|
throw new CryptoError(
|
|
37838
38111
|
"Decryption key hash mismatch - this key cannot decrypt this vote",
|
|
@@ -37841,9 +38114,9 @@ var PrivateVoting = class {
|
|
|
37841
38114
|
);
|
|
37842
38115
|
}
|
|
37843
38116
|
const nonceHex = vote.nonce.startsWith("0x") ? vote.nonce.slice(2) : vote.nonce;
|
|
37844
|
-
const nonce = (0,
|
|
38117
|
+
const nonce = (0, import_utils59.hexToBytes)(nonceHex);
|
|
37845
38118
|
const ciphertextHex = vote.ciphertext.startsWith("0x") ? vote.ciphertext.slice(2) : vote.ciphertext;
|
|
37846
|
-
const ciphertext = (0,
|
|
38119
|
+
const ciphertext = (0, import_utils59.hexToBytes)(ciphertextHex);
|
|
37847
38120
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
|
|
37848
38121
|
let plaintext;
|
|
37849
38122
|
try {
|
|
@@ -37932,10 +38205,10 @@ var PrivateVoting = class {
|
|
|
37932
38205
|
*/
|
|
37933
38206
|
deriveEncryptionKey(key, proposalId) {
|
|
37934
38207
|
const keyHex = key.startsWith("0x") ? key.slice(2) : key;
|
|
37935
|
-
const keyBytes = (0,
|
|
38208
|
+
const keyBytes = (0, import_utils59.hexToBytes)(keyHex);
|
|
37936
38209
|
try {
|
|
37937
|
-
const salt = (0,
|
|
37938
|
-
const info = (0,
|
|
38210
|
+
const salt = (0, import_utils59.utf8ToBytes)(VOTE_ENCRYPTION_DOMAIN);
|
|
38211
|
+
const info = (0, import_utils59.utf8ToBytes)(proposalId);
|
|
37939
38212
|
return (0, import_hkdf4.hkdf)(import_sha25626.sha256, keyBytes, salt, info, 32);
|
|
37940
38213
|
} finally {
|
|
37941
38214
|
secureWipe(keyBytes);
|
|
@@ -38081,21 +38354,21 @@ var PrivateVoting = class {
|
|
|
38081
38354
|
const blindings = {};
|
|
38082
38355
|
for (const [choice, weights] of Object.entries(votesByChoice)) {
|
|
38083
38356
|
const totalWeight = weights.reduce((sum, w) => sum + w, 0n);
|
|
38084
|
-
const { commitment, blinding } = commit(totalWeight, (0,
|
|
38357
|
+
const { commitment, blinding } = commit(totalWeight, (0, import_utils59.hexToBytes)(generateBlinding().slice(2)));
|
|
38085
38358
|
tallies[choice] = commitment;
|
|
38086
38359
|
blindings[choice] = blinding;
|
|
38087
38360
|
}
|
|
38088
38361
|
const encryptedBlindings = {};
|
|
38089
38362
|
for (const [choice, blinding] of Object.entries(blindings)) {
|
|
38090
|
-
const nonce = (0,
|
|
38363
|
+
const nonce = (0, import_utils59.randomBytes)(NONCE_SIZE3);
|
|
38091
38364
|
const derivedKey = this.deriveEncryptionKey(decryptionKey, `${proposalId}-tally-${choice}`);
|
|
38092
38365
|
try {
|
|
38093
38366
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
|
|
38094
|
-
const blindingBytes = (0,
|
|
38367
|
+
const blindingBytes = (0, import_utils59.hexToBytes)(blinding.slice(2));
|
|
38095
38368
|
const ciphertext = cipher.encrypt(blindingBytes);
|
|
38096
38369
|
encryptedBlindings[choice] = {
|
|
38097
|
-
ciphertext: `0x${(0,
|
|
38098
|
-
nonce: `0x${(0,
|
|
38370
|
+
ciphertext: `0x${(0, import_utils59.bytesToHex)(ciphertext)}`,
|
|
38371
|
+
nonce: `0x${(0, import_utils59.bytesToHex)(nonce)}`
|
|
38099
38372
|
};
|
|
38100
38373
|
} finally {
|
|
38101
38374
|
secureWipe(derivedKey);
|
|
@@ -38188,9 +38461,9 @@ var PrivateVoting = class {
|
|
|
38188
38461
|
}
|
|
38189
38462
|
let reconstructedKey = null;
|
|
38190
38463
|
try {
|
|
38191
|
-
reconstructedKey = (0,
|
|
38464
|
+
reconstructedKey = (0, import_utils59.hexToBytes)(decryptionShares[0].share.slice(2));
|
|
38192
38465
|
for (let i = 1; i < decryptionShares.length; i++) {
|
|
38193
|
-
const shareBytes = (0,
|
|
38466
|
+
const shareBytes = (0, import_utils59.hexToBytes)(decryptionShares[i].share.slice(2));
|
|
38194
38467
|
if (shareBytes.length !== reconstructedKey.length) {
|
|
38195
38468
|
throw new ValidationError(
|
|
38196
38469
|
"all decryption shares must have the same length",
|
|
@@ -38203,7 +38476,7 @@ var PrivateVoting = class {
|
|
|
38203
38476
|
reconstructedKey[j] ^= shareBytes[j];
|
|
38204
38477
|
}
|
|
38205
38478
|
}
|
|
38206
|
-
const reconstructedKeyHex = `0x${(0,
|
|
38479
|
+
const reconstructedKeyHex = `0x${(0, import_utils59.bytesToHex)(reconstructedKey)}`;
|
|
38207
38480
|
const results = {};
|
|
38208
38481
|
for (const [choice, commitmentPoint] of Object.entries(tally.tallies)) {
|
|
38209
38482
|
const encBlinding = tally.encryptedBlindings[choice];
|
|
@@ -38220,11 +38493,11 @@ var PrivateVoting = class {
|
|
|
38220
38493
|
);
|
|
38221
38494
|
let blindingFactor;
|
|
38222
38495
|
try {
|
|
38223
|
-
const nonceBytes = (0,
|
|
38224
|
-
const ciphertextBytes = (0,
|
|
38496
|
+
const nonceBytes = (0, import_utils59.hexToBytes)(encBlinding.nonce.slice(2));
|
|
38497
|
+
const ciphertextBytes = (0, import_utils59.hexToBytes)(encBlinding.ciphertext.slice(2));
|
|
38225
38498
|
const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonceBytes);
|
|
38226
38499
|
const blindingBytes = cipher.decrypt(ciphertextBytes);
|
|
38227
|
-
blindingFactor = `0x${(0,
|
|
38500
|
+
blindingFactor = `0x${(0, import_utils59.bytesToHex)(blindingBytes)}`;
|
|
38228
38501
|
} catch (e) {
|
|
38229
38502
|
throw new CryptoError(
|
|
38230
38503
|
"failed to decrypt blinding factor",
|
|
@@ -38244,7 +38517,7 @@ var PrivateVoting = class {
|
|
|
38244
38517
|
try {
|
|
38245
38518
|
const { commitment: testCommit } = commit(
|
|
38246
38519
|
value,
|
|
38247
|
-
(0,
|
|
38520
|
+
(0, import_utils59.hexToBytes)(blindingFactor.slice(2))
|
|
38248
38521
|
);
|
|
38249
38522
|
if (testCommit === commitmentPoint) {
|
|
38250
38523
|
results[choice] = value;
|
|
@@ -38447,7 +38720,7 @@ function createPrivateVoting() {
|
|
|
38447
38720
|
var import_sha25627 = require("@noble/hashes/sha256");
|
|
38448
38721
|
var import_ed2551910 = require("@noble/curves/ed25519");
|
|
38449
38722
|
var import_secp256k19 = require("@noble/curves/secp256k1");
|
|
38450
|
-
var
|
|
38723
|
+
var import_utils60 = require("@noble/hashes/utils");
|
|
38451
38724
|
init_stealth2();
|
|
38452
38725
|
init_errors();
|
|
38453
38726
|
init_validation();
|
|
@@ -38537,22 +38810,22 @@ var PrivateNFT = class {
|
|
|
38537
38810
|
try {
|
|
38538
38811
|
const message = this.createProofMessage(ownership, challenge);
|
|
38539
38812
|
const messageHash = (0, import_sha25627.sha256)(new TextEncoder().encode(message));
|
|
38540
|
-
const privateKeyBytes = (0,
|
|
38813
|
+
const privateKeyBytes = (0, import_utils60.hexToBytes)(stealthPrivateKey.slice(2));
|
|
38541
38814
|
const signature = import_secp256k19.secp256k1.sign(messageHash, privateKeyBytes);
|
|
38542
38815
|
const zkProof = {
|
|
38543
38816
|
type: "ownership",
|
|
38544
|
-
proof: `0x${(0,
|
|
38817
|
+
proof: `0x${(0, import_utils60.bytesToHex)(signature.toCompactRawBytes())}`,
|
|
38545
38818
|
publicInputs: [
|
|
38546
|
-
`0x${(0,
|
|
38819
|
+
`0x${(0, import_utils60.bytesToHex)(messageHash)}`
|
|
38547
38820
|
]
|
|
38548
38821
|
};
|
|
38549
|
-
const stealthHashBytes = (0, import_sha25627.sha256)((0,
|
|
38822
|
+
const stealthHashBytes = (0, import_sha25627.sha256)((0, import_utils60.hexToBytes)(ownership.ownerStealth.address.slice(2)));
|
|
38550
38823
|
return {
|
|
38551
38824
|
nftContract: ownership.nftContract,
|
|
38552
38825
|
tokenId: ownership.tokenId,
|
|
38553
38826
|
challenge,
|
|
38554
38827
|
proof: zkProof,
|
|
38555
|
-
stealthHash: `0x${(0,
|
|
38828
|
+
stealthHash: `0x${(0, import_utils60.bytesToHex)(stealthHashBytes)}`,
|
|
38556
38829
|
timestamp: Date.now()
|
|
38557
38830
|
};
|
|
38558
38831
|
} catch (e) {
|
|
@@ -38594,9 +38867,9 @@ var PrivateNFT = class {
|
|
|
38594
38867
|
verifyOwnership(proof) {
|
|
38595
38868
|
try {
|
|
38596
38869
|
this.validateOwnershipProof(proof);
|
|
38597
|
-
const signatureBytes = (0,
|
|
38870
|
+
const signatureBytes = (0, import_utils60.hexToBytes)(proof.proof.proof.slice(2));
|
|
38598
38871
|
const signature = import_secp256k19.secp256k1.Signature.fromCompact(signatureBytes);
|
|
38599
|
-
const messageHash = (0,
|
|
38872
|
+
const messageHash = (0, import_utils60.hexToBytes)(proof.proof.publicInputs[0].slice(2));
|
|
38600
38873
|
if (signatureBytes.length !== 64) {
|
|
38601
38874
|
return {
|
|
38602
38875
|
valid: false,
|
|
@@ -38693,12 +38966,12 @@ var PrivateNFT = class {
|
|
|
38693
38966
|
chain: nft.chain,
|
|
38694
38967
|
timestamp: Date.now()
|
|
38695
38968
|
};
|
|
38696
|
-
const previousOwnerHashBytes = (0, import_sha25627.sha256)((0,
|
|
38969
|
+
const previousOwnerHashBytes = (0, import_sha25627.sha256)((0, import_utils60.hexToBytes)(nft.ownerStealth.address.slice(2)));
|
|
38697
38970
|
const transfer = {
|
|
38698
38971
|
nftContract: nft.nftContract,
|
|
38699
38972
|
tokenId: nft.tokenId,
|
|
38700
38973
|
newOwnerStealth,
|
|
38701
|
-
previousOwnerHash: `0x${(0,
|
|
38974
|
+
previousOwnerHash: `0x${(0, import_utils60.bytesToHex)(previousOwnerHashBytes)}`,
|
|
38702
38975
|
chain: nft.chain,
|
|
38703
38976
|
timestamp: Date.now()
|
|
38704
38977
|
};
|
|
@@ -38765,9 +39038,9 @@ var PrivateNFT = class {
|
|
|
38765
39038
|
);
|
|
38766
39039
|
}
|
|
38767
39040
|
const ownedNFTs = [];
|
|
38768
|
-
const viewingKeyHex = `0x${(0,
|
|
38769
|
-
const ed25519SpendingPubHex = `0x${(0,
|
|
38770
|
-
const secp256k1SpendingPubHex = `0x${(0,
|
|
39041
|
+
const viewingKeyHex = `0x${(0, import_utils60.bytesToHex)(viewingKey)}`;
|
|
39042
|
+
const ed25519SpendingPubHex = `0x${(0, import_utils60.bytesToHex)(import_ed2551910.ed25519.getPublicKey(scanKey))}`;
|
|
39043
|
+
const secp256k1SpendingPubHex = `0x${(0, import_utils60.bytesToHex)(import_secp256k19.secp256k1.getPublicKey(scanKey, true))}`;
|
|
38771
39044
|
for (const transfer of transfers) {
|
|
38772
39045
|
try {
|
|
38773
39046
|
if (!transfer || typeof transfer !== "object") {
|
|
@@ -40209,7 +40482,7 @@ function createMockSolanaAdapter(config = {}) {
|
|
|
40209
40482
|
var import_sha24 = require("@noble/hashes/sha2");
|
|
40210
40483
|
var import_ed2551911 = require("@noble/curves/ed25519");
|
|
40211
40484
|
init_stealth2();
|
|
40212
|
-
|
|
40485
|
+
init_utils();
|
|
40213
40486
|
|
|
40214
40487
|
// src/wallet/ethereum/adapter.ts
|
|
40215
40488
|
var import_types41 = require("@sip-protocol/types");
|
|
@@ -41314,7 +41587,7 @@ var import_types64 = require("@sip-protocol/types");
|
|
|
41314
41587
|
// src/wallet/near/adapter.ts
|
|
41315
41588
|
var import_ed2551913 = require("@noble/curves/ed25519");
|
|
41316
41589
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
41317
|
-
var
|
|
41590
|
+
var import_utils63 = require("@noble/hashes/utils");
|
|
41318
41591
|
var import_types66 = require("@sip-protocol/types");
|
|
41319
41592
|
|
|
41320
41593
|
// src/chains/near/stealth.ts
|
|
@@ -41521,16 +41794,16 @@ function validateNEARStealthAddress(stealthAddress) {
|
|
|
41521
41794
|
}
|
|
41522
41795
|
|
|
41523
41796
|
// src/wallet/near/adapter.ts
|
|
41524
|
-
var
|
|
41797
|
+
var ED25519_ORDER3 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
41525
41798
|
|
|
41526
41799
|
// src/wallet/near/wallet-selector.ts
|
|
41527
41800
|
var import_sha27 = require("@noble/hashes/sha2");
|
|
41528
|
-
var
|
|
41801
|
+
var import_utils65 = require("@noble/hashes/utils");
|
|
41529
41802
|
var import_ed2551915 = require("@noble/curves/ed25519");
|
|
41530
41803
|
|
|
41531
41804
|
// src/chains/near/implicit-account.ts
|
|
41532
41805
|
var import_ed2551914 = require("@noble/curves/ed25519");
|
|
41533
|
-
var
|
|
41806
|
+
var import_utils64 = require("@noble/hashes/utils");
|
|
41534
41807
|
init_errors();
|
|
41535
41808
|
init_validation();
|
|
41536
41809
|
|
|
@@ -41574,12 +41847,12 @@ function createAnnouncementMemo2(ephemeralPublicKey, viewTag) {
|
|
|
41574
41847
|
|
|
41575
41848
|
// src/wallet/near/my-near-wallet.ts
|
|
41576
41849
|
var import_sha28 = require("@noble/hashes/sha2");
|
|
41577
|
-
var
|
|
41850
|
+
var import_utils66 = require("@noble/hashes/utils");
|
|
41578
41851
|
var import_ed2551916 = require("@noble/curves/ed25519");
|
|
41579
41852
|
|
|
41580
41853
|
// src/wallet/near/meteor-wallet.ts
|
|
41581
41854
|
var import_sha29 = require("@noble/hashes/sha2");
|
|
41582
|
-
var
|
|
41855
|
+
var import_utils67 = require("@noble/hashes/utils");
|
|
41583
41856
|
var import_ed2551917 = require("@noble/curves/ed25519");
|
|
41584
41857
|
|
|
41585
41858
|
// src/wallet/hardware/types.ts
|
|
@@ -42192,7 +42465,7 @@ function createLedgerAdapter(config) {
|
|
|
42192
42465
|
// src/wallet/hardware/ledger-privacy.ts
|
|
42193
42466
|
var import_secp256k113 = require("@noble/curves/secp256k1");
|
|
42194
42467
|
var import_sha25628 = require("@noble/hashes/sha256");
|
|
42195
|
-
var
|
|
42468
|
+
var import_utils68 = require("@noble/hashes/utils");
|
|
42196
42469
|
var import_types70 = require("@sip-protocol/types");
|
|
42197
42470
|
|
|
42198
42471
|
// src/wallet/hardware/trezor.ts
|
|
@@ -42635,7 +42908,7 @@ function createTrezorAdapter(config) {
|
|
|
42635
42908
|
|
|
42636
42909
|
// src/wallet/hardware/mock.ts
|
|
42637
42910
|
var import_types74 = require("@sip-protocol/types");
|
|
42638
|
-
var
|
|
42911
|
+
var import_utils69 = require("@noble/hashes/utils");
|
|
42639
42912
|
var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
42640
42913
|
chain;
|
|
42641
42914
|
name = "mock-ledger";
|
|
@@ -42880,15 +43153,15 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
42880
43153
|
}
|
|
42881
43154
|
}
|
|
42882
43155
|
generateMockAddress(index) {
|
|
42883
|
-
const bytes = (0,
|
|
43156
|
+
const bytes = (0, import_utils69.randomBytes)(20);
|
|
42884
43157
|
bytes[0] = index;
|
|
42885
|
-
return `0x${(0,
|
|
43158
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
42886
43159
|
}
|
|
42887
43160
|
generateMockPublicKey(index) {
|
|
42888
|
-
const bytes = (0,
|
|
43161
|
+
const bytes = (0, import_utils69.randomBytes)(33);
|
|
42889
43162
|
bytes[0] = 2;
|
|
42890
43163
|
bytes[1] = index;
|
|
42891
|
-
return `0x${(0,
|
|
43164
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
42892
43165
|
}
|
|
42893
43166
|
generateMockSignature(data) {
|
|
42894
43167
|
const sig = new Uint8Array(65);
|
|
@@ -42897,7 +43170,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
42897
43170
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 11;
|
|
42898
43171
|
}
|
|
42899
43172
|
sig[64] = 27;
|
|
42900
|
-
return `0x${(0,
|
|
43173
|
+
return `0x${(0, import_utils69.bytesToHex)(sig)}`;
|
|
42901
43174
|
}
|
|
42902
43175
|
delay(ms) {
|
|
42903
43176
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -43086,15 +43359,15 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
43086
43359
|
}
|
|
43087
43360
|
}
|
|
43088
43361
|
generateMockAddress(index) {
|
|
43089
|
-
const bytes = (0,
|
|
43362
|
+
const bytes = (0, import_utils69.randomBytes)(20);
|
|
43090
43363
|
bytes[0] = index + 100;
|
|
43091
|
-
return `0x${(0,
|
|
43364
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
43092
43365
|
}
|
|
43093
43366
|
generateMockPublicKey(index) {
|
|
43094
|
-
const bytes = (0,
|
|
43367
|
+
const bytes = (0, import_utils69.randomBytes)(33);
|
|
43095
43368
|
bytes[0] = 3;
|
|
43096
43369
|
bytes[1] = index + 100;
|
|
43097
|
-
return `0x${(0,
|
|
43370
|
+
return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
|
|
43098
43371
|
}
|
|
43099
43372
|
generateMockSignature(data) {
|
|
43100
43373
|
const sig = new Uint8Array(65);
|
|
@@ -43103,7 +43376,7 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
43103
43376
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 17;
|
|
43104
43377
|
}
|
|
43105
43378
|
sig[64] = 28;
|
|
43106
|
-
return `0x${(0,
|
|
43379
|
+
return `0x${(0, import_utils69.bytesToHex)(sig)}`;
|
|
43107
43380
|
}
|
|
43108
43381
|
delay(ms) {
|
|
43109
43382
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -43123,7 +43396,7 @@ var import_types77 = require("@sip-protocol/types");
|
|
|
43123
43396
|
init_solana();
|
|
43124
43397
|
|
|
43125
43398
|
// src/solana/noir-verifier.ts
|
|
43126
|
-
var
|
|
43399
|
+
var import_web318 = require("@solana/web3.js");
|
|
43127
43400
|
|
|
43128
43401
|
// src/solana/noir-verifier-types.ts
|
|
43129
43402
|
init_endpoints();
|
|
@@ -43214,6 +43487,8 @@ var SolanaNoirError = class extends Error {
|
|
|
43214
43487
|
this.details = details;
|
|
43215
43488
|
this.name = "SolanaNoirError";
|
|
43216
43489
|
}
|
|
43490
|
+
code;
|
|
43491
|
+
details;
|
|
43217
43492
|
};
|
|
43218
43493
|
var MAX_PROOF_SIZE_BYTES = 4096;
|
|
43219
43494
|
var MAX_PUBLIC_INPUTS = 32;
|
|
@@ -43248,7 +43523,7 @@ var SolanaNoirVerifier = class {
|
|
|
43248
43523
|
commitment: config.commitment ?? "confirmed",
|
|
43249
43524
|
maxComputeUnits: config.maxComputeUnits ?? 4e5
|
|
43250
43525
|
};
|
|
43251
|
-
this.connection = new
|
|
43526
|
+
this.connection = new import_web318.Connection(this.config.rpcUrl, this.config.commitment);
|
|
43252
43527
|
}
|
|
43253
43528
|
/**
|
|
43254
43529
|
* Get the Solana connection
|
|
@@ -43500,16 +43775,16 @@ var SolanaNoirVerifier = class {
|
|
|
43500
43775
|
error: `Proof requires ${computeUnits} CU, max is ${this.config.maxComputeUnits}`
|
|
43501
43776
|
};
|
|
43502
43777
|
}
|
|
43503
|
-
const transaction = new
|
|
43778
|
+
const transaction = new import_web318.Transaction();
|
|
43504
43779
|
transaction.add(
|
|
43505
|
-
|
|
43780
|
+
import_web318.ComputeBudgetProgram.setComputeUnitLimit({ units: this.config.maxComputeUnits })
|
|
43506
43781
|
);
|
|
43507
43782
|
transaction.add(instruction);
|
|
43508
43783
|
const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash(
|
|
43509
43784
|
this.config.commitment
|
|
43510
43785
|
);
|
|
43511
43786
|
transaction.recentBlockhash = blockhash;
|
|
43512
|
-
transaction.feePayer = new
|
|
43787
|
+
transaction.feePayer = new import_web318.PublicKey(wallet.publicKey.toBase58());
|
|
43513
43788
|
const signedTransaction = await wallet.signTransaction(transaction);
|
|
43514
43789
|
const signature = await this.connection.sendRawTransaction(signedTransaction.serialize());
|
|
43515
43790
|
const confirmation = await this.connection.confirmTransaction(
|
|
@@ -43551,8 +43826,8 @@ var SolanaNoirVerifier = class {
|
|
|
43551
43826
|
*/
|
|
43552
43827
|
createSunspotVerifyInstruction(proof, programId) {
|
|
43553
43828
|
const serialized = this.serializeProofForSunspot(proof);
|
|
43554
|
-
return new
|
|
43555
|
-
programId: new
|
|
43829
|
+
return new import_web318.TransactionInstruction({
|
|
43830
|
+
programId: new import_web318.PublicKey(programId),
|
|
43556
43831
|
keys: [],
|
|
43557
43832
|
// Sunspot verifiers don't require any accounts
|
|
43558
43833
|
data: serialized
|
|
@@ -43726,8 +44001,8 @@ var SolanaNoirVerifier = class {
|
|
|
43726
44001
|
}
|
|
43727
44002
|
async hashBytes(bytes) {
|
|
43728
44003
|
const { sha256: sha25642 } = await import("@noble/hashes/sha256");
|
|
43729
|
-
const { bytesToHex:
|
|
43730
|
-
return
|
|
44004
|
+
const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
|
|
44005
|
+
return bytesToHex64(sha25642(bytes));
|
|
43731
44006
|
}
|
|
43732
44007
|
hexToBytes(hex) {
|
|
43733
44008
|
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
@@ -43764,8 +44039,8 @@ function createMainnetVerifier(config = {}) {
|
|
|
43764
44039
|
}
|
|
43765
44040
|
|
|
43766
44041
|
// src/solana/jito-relayer.ts
|
|
43767
|
-
var
|
|
43768
|
-
var
|
|
44042
|
+
var import_web319 = require("@solana/web3.js");
|
|
44043
|
+
var import_bs58 = __toESM(require("bs58"));
|
|
43769
44044
|
var JITO_BLOCK_ENGINES = {
|
|
43770
44045
|
mainnet: {
|
|
43771
44046
|
amsterdam: "https://amsterdam.mainnet.block-engine.jito.wtf/api/v1",
|
|
@@ -43814,8 +44089,10 @@ var JitoRelayerError = class extends Error {
|
|
|
43814
44089
|
this.details = details;
|
|
43815
44090
|
this.name = "JitoRelayerError";
|
|
43816
44091
|
}
|
|
44092
|
+
code;
|
|
44093
|
+
details;
|
|
43817
44094
|
};
|
|
43818
|
-
var JitoRelayer = class {
|
|
44095
|
+
var JitoRelayer = class _JitoRelayer {
|
|
43819
44096
|
connection;
|
|
43820
44097
|
blockEngineUrl;
|
|
43821
44098
|
defaultTipLamports;
|
|
@@ -43824,7 +44101,7 @@ var JitoRelayer = class {
|
|
|
43824
44101
|
submissionTimeout;
|
|
43825
44102
|
constructor(config = {}) {
|
|
43826
44103
|
this.blockEngineUrl = config.blockEngineUrl ?? JITO_BLOCK_ENGINES.mainnet.ny;
|
|
43827
|
-
this.connection = new
|
|
44104
|
+
this.connection = new import_web319.Connection(
|
|
43828
44105
|
config.rpcUrl ?? "https://api.mainnet-beta.solana.com",
|
|
43829
44106
|
"confirmed"
|
|
43830
44107
|
);
|
|
@@ -43833,6 +44110,11 @@ var JitoRelayer = class {
|
|
|
43833
44110
|
this.maxRetries = config.maxRetries ?? JITO_DEFAULTS.maxRetries;
|
|
43834
44111
|
this.submissionTimeout = config.submissionTimeout ?? JITO_DEFAULTS.submissionTimeout;
|
|
43835
44112
|
}
|
|
44113
|
+
// ─── Static Helpers ─────────────────────────────────────────────────────────
|
|
44114
|
+
/** Encode a 64-byte ed25519 signature as a base58 string (Solana canonical form). */
|
|
44115
|
+
static encodeSignature(sig) {
|
|
44116
|
+
return import_bs58.default.encode(sig);
|
|
44117
|
+
}
|
|
43836
44118
|
// ─── Public Methods ─────────────────────────────────────────────────────────
|
|
43837
44119
|
/**
|
|
43838
44120
|
* Submit a bundle of transactions to Jito
|
|
@@ -43884,11 +44166,11 @@ var JitoRelayer = class {
|
|
|
43884
44166
|
}
|
|
43885
44167
|
}
|
|
43886
44168
|
const signatures = bundleTransactions.map((tx) => {
|
|
43887
|
-
if (tx instanceof
|
|
43888
|
-
return
|
|
43889
|
-
} else {
|
|
43890
|
-
return tx.signature?.toString() ?? "";
|
|
44169
|
+
if (tx instanceof import_web319.VersionedTransaction) {
|
|
44170
|
+
return _JitoRelayer.encodeSignature(tx.signatures[0]);
|
|
43891
44171
|
}
|
|
44172
|
+
const sig = tx.signature;
|
|
44173
|
+
return sig ? _JitoRelayer.encodeSignature(sig) : "";
|
|
43892
44174
|
});
|
|
43893
44175
|
if (request.waitForConfirmation) {
|
|
43894
44176
|
const status = await this.waitForBundleConfirmation(bundleId, lastValidBlockHeight);
|
|
@@ -43920,13 +44202,30 @@ var JitoRelayer = class {
|
|
|
43920
44202
|
async relayTransaction(request) {
|
|
43921
44203
|
this.log("Relaying transaction");
|
|
43922
44204
|
try {
|
|
44205
|
+
if (request.tipPayer) {
|
|
44206
|
+
const bundle = await this.submitBundle({
|
|
44207
|
+
transactions: [request.transaction],
|
|
44208
|
+
tipLamports: request.tipLamports,
|
|
44209
|
+
tipPayer: request.tipPayer,
|
|
44210
|
+
waitForConfirmation: request.waitForConfirmation
|
|
44211
|
+
});
|
|
44212
|
+
return {
|
|
44213
|
+
signature: bundle.signatures[bundle.signatures.length - 1] ?? "",
|
|
44214
|
+
bundleId: bundle.bundleId,
|
|
44215
|
+
status: bundle.status === "landed" ? "confirmed" : bundle.status === "submitted" ? "submitted" : "failed",
|
|
44216
|
+
slot: bundle.slot,
|
|
44217
|
+
error: bundle.error,
|
|
44218
|
+
relayed: true
|
|
44219
|
+
};
|
|
44220
|
+
}
|
|
43923
44221
|
const serializedTx = Buffer.from(request.transaction.serialize()).toString("base64");
|
|
43924
44222
|
const bundleId = await this.sendBundle([serializedTx]);
|
|
43925
44223
|
let signature;
|
|
43926
|
-
if (request.transaction instanceof
|
|
43927
|
-
signature =
|
|
44224
|
+
if (request.transaction instanceof import_web319.VersionedTransaction) {
|
|
44225
|
+
signature = _JitoRelayer.encodeSignature(request.transaction.signatures[0]);
|
|
43928
44226
|
} else {
|
|
43929
|
-
|
|
44227
|
+
const sig = request.transaction.signature;
|
|
44228
|
+
signature = sig ? _JitoRelayer.encodeSignature(sig) : "";
|
|
43930
44229
|
}
|
|
43931
44230
|
if (request.waitForConfirmation) {
|
|
43932
44231
|
const { lastValidBlockHeight } = await this.connection.getLatestBlockhash();
|
|
@@ -43976,7 +44275,7 @@ var JitoRelayer = class {
|
|
|
43976
44275
|
*/
|
|
43977
44276
|
getRandomTipAccount() {
|
|
43978
44277
|
const index = Math.floor(Math.random() * JITO_TIP_ACCOUNTS.length);
|
|
43979
|
-
return new
|
|
44278
|
+
return new import_web319.PublicKey(JITO_TIP_ACCOUNTS[index]);
|
|
43980
44279
|
}
|
|
43981
44280
|
// ─── Private Methods ────────────────────────────────────────────────────────
|
|
43982
44281
|
/**
|
|
@@ -43984,7 +44283,7 @@ var JitoRelayer = class {
|
|
|
43984
44283
|
*/
|
|
43985
44284
|
createTipInstruction(payer, tipLamports) {
|
|
43986
44285
|
const tipAccount = this.getRandomTipAccount();
|
|
43987
|
-
return
|
|
44286
|
+
return import_web319.SystemProgram.transfer({
|
|
43988
44287
|
fromPubkey: payer,
|
|
43989
44288
|
toPubkey: tipAccount,
|
|
43990
44289
|
lamports: tipLamports
|
|
@@ -43994,7 +44293,7 @@ var JitoRelayer = class {
|
|
|
43994
44293
|
* Prepare transactions for bundle submission
|
|
43995
44294
|
*/
|
|
43996
44295
|
async prepareBundleTransactions(transactions, tipInstruction, tipPayer, blockhash) {
|
|
43997
|
-
const tipTx = new
|
|
44296
|
+
const tipTx = new import_web319.Transaction();
|
|
43998
44297
|
tipTx.add(tipInstruction);
|
|
43999
44298
|
tipTx.recentBlockhash = blockhash;
|
|
44000
44299
|
tipTx.feePayer = tipPayer.publicKey;
|
|
@@ -44149,15 +44448,15 @@ function createMainnetRelayer(rpcUrl) {
|
|
|
44149
44448
|
// src/chains/near/commitment.ts
|
|
44150
44449
|
var import_ed2551918 = require("@noble/curves/ed25519");
|
|
44151
44450
|
var import_sha210 = require("@noble/hashes/sha2");
|
|
44152
|
-
var
|
|
44451
|
+
var import_utils70 = require("@noble/hashes/utils");
|
|
44153
44452
|
init_errors();
|
|
44154
44453
|
init_validation();
|
|
44155
44454
|
var H_DOMAIN3 = "SIP-NEAR-PEDERSEN-GENERATOR-H-v1";
|
|
44156
44455
|
var G3 = import_ed2551918.ed25519.ExtendedPoint.BASE;
|
|
44157
|
-
var
|
|
44456
|
+
var ED25519_ORDER4 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
44158
44457
|
var ED25519_COFACTOR2 = 8n;
|
|
44159
44458
|
var MAX_NEAR_AMOUNT = 2n ** 128n - 1n;
|
|
44160
|
-
var MAX_COMMITMENT_VALUE =
|
|
44459
|
+
var MAX_COMMITMENT_VALUE = ED25519_ORDER4 - 1n;
|
|
44161
44460
|
var H3 = generateH3();
|
|
44162
44461
|
function generateH3() {
|
|
44163
44462
|
let counter = 0;
|
|
@@ -44170,7 +44469,7 @@ function generateH3() {
|
|
|
44170
44469
|
if (!point.equals(import_ed2551918.ed25519.ExtendedPoint.ZERO)) {
|
|
44171
44470
|
const gBytes = G3.toRawBytes();
|
|
44172
44471
|
const hBytes = point.toRawBytes();
|
|
44173
|
-
if ((0,
|
|
44472
|
+
if ((0, import_utils70.bytesToHex)(gBytes) !== (0, import_utils70.bytesToHex)(hBytes)) {
|
|
44174
44473
|
return point;
|
|
44175
44474
|
}
|
|
44176
44475
|
}
|
|
@@ -44214,20 +44513,20 @@ function commitNEAR(value, blinding) {
|
|
|
44214
44513
|
if (value < 0n) {
|
|
44215
44514
|
throw new ValidationError("must be non-negative", "value");
|
|
44216
44515
|
}
|
|
44217
|
-
if (value >=
|
|
44516
|
+
if (value >= ED25519_ORDER4) {
|
|
44218
44517
|
throw new ValidationError(
|
|
44219
44518
|
"must be less than curve order",
|
|
44220
44519
|
"value",
|
|
44221
|
-
{ curveOrder:
|
|
44520
|
+
{ curveOrder: ED25519_ORDER4.toString(16) }
|
|
44222
44521
|
);
|
|
44223
44522
|
}
|
|
44224
|
-
const r = blinding ?? (0,
|
|
44523
|
+
const r = blinding ?? (0, import_utils70.randomBytes)(32);
|
|
44225
44524
|
if (r.length !== 32) {
|
|
44226
44525
|
throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
|
|
44227
44526
|
}
|
|
44228
|
-
const rScalar = bytesToBigInt4(r) %
|
|
44527
|
+
const rScalar = bytesToBigInt4(r) % ED25519_ORDER4;
|
|
44229
44528
|
if (rScalar === 0n) {
|
|
44230
|
-
return commitNEAR(value, (0,
|
|
44529
|
+
return commitNEAR(value, (0, import_utils70.randomBytes)(32));
|
|
44231
44530
|
}
|
|
44232
44531
|
let C;
|
|
44233
44532
|
if (value === 0n) {
|
|
@@ -44239,8 +44538,8 @@ function commitNEAR(value, blinding) {
|
|
|
44239
44538
|
}
|
|
44240
44539
|
const rScalarBytes = bigIntToBytes4(rScalar, 32);
|
|
44241
44540
|
return {
|
|
44242
|
-
commitment: `0x${(0,
|
|
44243
|
-
blinding: `0x${(0,
|
|
44541
|
+
commitment: `0x${(0, import_utils70.bytesToHex)(C.toRawBytes())}`,
|
|
44542
|
+
blinding: `0x${(0, import_utils70.bytesToHex)(rScalarBytes)}`
|
|
44244
44543
|
};
|
|
44245
44544
|
}
|
|
44246
44545
|
function verifyOpeningNEAR(commitment, value, blinding) {
|
|
@@ -44248,7 +44547,7 @@ function verifyOpeningNEAR(commitment, value, blinding) {
|
|
|
44248
44547
|
const commitmentBytes = hexToBytes38(commitment.slice(2));
|
|
44249
44548
|
const C = import_ed2551918.ed25519.ExtendedPoint.fromHex(commitmentBytes);
|
|
44250
44549
|
const blindingBytes = hexToBytes38(blinding.slice(2));
|
|
44251
|
-
const rScalar = bytesToBigInt4(blindingBytes) %
|
|
44550
|
+
const rScalar = bytesToBigInt4(blindingBytes) % ED25519_ORDER4;
|
|
44252
44551
|
let expected;
|
|
44253
44552
|
if (value === 0n) {
|
|
44254
44553
|
expected = H3.multiply(rScalar);
|
|
@@ -44272,7 +44571,7 @@ function commitNEP141Token(amount, tokenContract, decimals, blinding) {
|
|
|
44272
44571
|
{ max: MAX_NEAR_AMOUNT.toString() }
|
|
44273
44572
|
);
|
|
44274
44573
|
}
|
|
44275
|
-
if (amount >=
|
|
44574
|
+
if (amount >= ED25519_ORDER4) {
|
|
44276
44575
|
throw new ValidationError(
|
|
44277
44576
|
"Amount exceeds maximum committable value (curve order)",
|
|
44278
44577
|
"amount",
|
|
@@ -44333,7 +44632,7 @@ function addCommitmentsNEAR(c1, c2) {
|
|
|
44333
44632
|
}
|
|
44334
44633
|
const sum = point1.add(point2);
|
|
44335
44634
|
return {
|
|
44336
|
-
commitment: `0x${(0,
|
|
44635
|
+
commitment: `0x${(0, import_utils70.bytesToHex)(sum.toRawBytes())}`
|
|
44337
44636
|
};
|
|
44338
44637
|
}
|
|
44339
44638
|
function subtractCommitmentsNEAR(c1, c2) {
|
|
@@ -44362,7 +44661,7 @@ function subtractCommitmentsNEAR(c1, c2) {
|
|
|
44362
44661
|
};
|
|
44363
44662
|
}
|
|
44364
44663
|
return {
|
|
44365
|
-
commitment: `0x${(0,
|
|
44664
|
+
commitment: `0x${(0, import_utils70.bytesToHex)(diff.toRawBytes())}`
|
|
44366
44665
|
};
|
|
44367
44666
|
}
|
|
44368
44667
|
function addBlindingsNEAR(b1, b2) {
|
|
@@ -44376,9 +44675,9 @@ function addBlindingsNEAR(b1, b2) {
|
|
|
44376
44675
|
const b2Bytes = hexToBytes38(b2.slice(2));
|
|
44377
44676
|
const b1Scalar = bytesToBigInt4(b1Bytes);
|
|
44378
44677
|
const b2Scalar = bytesToBigInt4(b2Bytes);
|
|
44379
|
-
const sum = (b1Scalar + b2Scalar) %
|
|
44678
|
+
const sum = (b1Scalar + b2Scalar) % ED25519_ORDER4;
|
|
44380
44679
|
const sumBytes = bigIntToBytes4(sum, 32);
|
|
44381
|
-
return `0x${(0,
|
|
44680
|
+
return `0x${(0, import_utils70.bytesToHex)(sumBytes)}`;
|
|
44382
44681
|
}
|
|
44383
44682
|
function subtractBlindingsNEAR(b1, b2) {
|
|
44384
44683
|
if (!isValidHex(b1)) {
|
|
@@ -44391,24 +44690,24 @@ function subtractBlindingsNEAR(b1, b2) {
|
|
|
44391
44690
|
const b2Bytes = hexToBytes38(b2.slice(2));
|
|
44392
44691
|
const b1Scalar = bytesToBigInt4(b1Bytes);
|
|
44393
44692
|
const b2Scalar = bytesToBigInt4(b2Bytes);
|
|
44394
|
-
const diff = (b1Scalar - b2Scalar +
|
|
44693
|
+
const diff = (b1Scalar - b2Scalar + ED25519_ORDER4) % ED25519_ORDER4;
|
|
44395
44694
|
const diffBytes = bigIntToBytes4(diff, 32);
|
|
44396
|
-
return `0x${(0,
|
|
44695
|
+
return `0x${(0, import_utils70.bytesToHex)(diffBytes)}`;
|
|
44397
44696
|
}
|
|
44398
44697
|
function getGeneratorsNEAR() {
|
|
44399
44698
|
return {
|
|
44400
|
-
G: `0x${(0,
|
|
44401
|
-
H: `0x${(0,
|
|
44699
|
+
G: `0x${(0, import_utils70.bytesToHex)(G3.toRawBytes())}`,
|
|
44700
|
+
H: `0x${(0, import_utils70.bytesToHex)(H3.toRawBytes())}`
|
|
44402
44701
|
};
|
|
44403
44702
|
}
|
|
44404
44703
|
function generateBlindingNEAR() {
|
|
44405
|
-
const bytes = (0,
|
|
44406
|
-
const scalar = bytesToBigInt4(bytes) %
|
|
44704
|
+
const bytes = (0, import_utils70.randomBytes)(32);
|
|
44705
|
+
const scalar = bytesToBigInt4(bytes) % ED25519_ORDER4;
|
|
44407
44706
|
if (scalar === 0n) {
|
|
44408
44707
|
return generateBlindingNEAR();
|
|
44409
44708
|
}
|
|
44410
44709
|
const scalarBytes = bigIntToBytes4(scalar, 32);
|
|
44411
|
-
return `0x${(0,
|
|
44710
|
+
return `0x${(0, import_utils70.bytesToHex)(scalarBytes)}`;
|
|
44412
44711
|
}
|
|
44413
44712
|
|
|
44414
44713
|
// src/chains/near/viewing-key.ts
|
|
@@ -44416,7 +44715,7 @@ var import_ed2551919 = require("@noble/curves/ed25519");
|
|
|
44416
44715
|
var import_sha25629 = require("@noble/hashes/sha256");
|
|
44417
44716
|
var import_hmac7 = require("@noble/hashes/hmac");
|
|
44418
44717
|
var import_hkdf5 = require("@noble/hashes/hkdf");
|
|
44419
|
-
var
|
|
44718
|
+
var import_utils71 = require("@noble/hashes/utils");
|
|
44420
44719
|
var import_chacha6 = require("@noble/ciphers/chacha.js");
|
|
44421
44720
|
init_errors();
|
|
44422
44721
|
init_validation();
|
|
@@ -44432,7 +44731,7 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
44432
44731
|
"spendingPrivateKey"
|
|
44433
44732
|
);
|
|
44434
44733
|
}
|
|
44435
|
-
const spendingBytes = (0,
|
|
44734
|
+
const spendingBytes = (0, import_utils71.hexToBytes)(spendingPrivateKey.slice(2));
|
|
44436
44735
|
if (spendingBytes.length !== 32) {
|
|
44437
44736
|
throw new ValidationError(
|
|
44438
44737
|
"spendingPrivateKey must be 32 bytes",
|
|
@@ -44443,15 +44742,15 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
44443
44742
|
try {
|
|
44444
44743
|
viewingPrivateBytes = (0, import_hmac7.hmac)(
|
|
44445
44744
|
import_sha25629.sha256,
|
|
44446
|
-
(0,
|
|
44745
|
+
(0, import_utils71.utf8ToBytes)(VIEWING_KEY_CONTEXT3),
|
|
44447
44746
|
spendingBytes
|
|
44448
44747
|
);
|
|
44449
44748
|
const viewingPublicBytes = import_ed2551919.ed25519.getPublicKey(viewingPrivateBytes);
|
|
44450
44749
|
const hashBytes = (0, import_sha25629.sha256)(viewingPublicBytes);
|
|
44451
44750
|
return {
|
|
44452
|
-
privateKey: `0x${(0,
|
|
44453
|
-
publicKey: `0x${(0,
|
|
44454
|
-
hash: `0x${(0,
|
|
44751
|
+
privateKey: `0x${(0, import_utils71.bytesToHex)(viewingPrivateBytes)}`,
|
|
44752
|
+
publicKey: `0x${(0, import_utils71.bytesToHex)(viewingPublicBytes)}`,
|
|
44753
|
+
hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
|
|
44455
44754
|
label,
|
|
44456
44755
|
createdAt: Date.now()
|
|
44457
44756
|
};
|
|
@@ -44461,14 +44760,14 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
44461
44760
|
}
|
|
44462
44761
|
}
|
|
44463
44762
|
function generateRandomNEARViewingKey(label) {
|
|
44464
|
-
const privateBytes = (0,
|
|
44763
|
+
const privateBytes = (0, import_utils71.randomBytes)(32);
|
|
44465
44764
|
try {
|
|
44466
44765
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
|
|
44467
44766
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44468
44767
|
return {
|
|
44469
|
-
privateKey: `0x${(0,
|
|
44470
|
-
publicKey: `0x${(0,
|
|
44471
|
-
hash: `0x${(0,
|
|
44768
|
+
privateKey: `0x${(0, import_utils71.bytesToHex)(privateBytes)}`,
|
|
44769
|
+
publicKey: `0x${(0, import_utils71.bytesToHex)(publicBytes)}`,
|
|
44770
|
+
hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
|
|
44472
44771
|
label,
|
|
44473
44772
|
createdAt: Date.now()
|
|
44474
44773
|
};
|
|
@@ -44483,7 +44782,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
|
|
|
44483
44782
|
"viewingPublicKey"
|
|
44484
44783
|
);
|
|
44485
44784
|
}
|
|
44486
|
-
const publicBytes = (0,
|
|
44785
|
+
const publicBytes = (0, import_utils71.hexToBytes)(viewingPublicKey.slice(2));
|
|
44487
44786
|
if (publicBytes.length !== 32) {
|
|
44488
44787
|
throw new ValidationError(
|
|
44489
44788
|
"viewingPublicKey must be 32 bytes",
|
|
@@ -44491,7 +44790,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
|
|
|
44491
44790
|
);
|
|
44492
44791
|
}
|
|
44493
44792
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44494
|
-
return `0x${(0,
|
|
44793
|
+
return `0x${(0, import_utils71.bytesToHex)(hashBytes)}`;
|
|
44495
44794
|
}
|
|
44496
44795
|
function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
44497
44796
|
if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
|
|
@@ -44500,7 +44799,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
44500
44799
|
"viewingPrivateKey"
|
|
44501
44800
|
);
|
|
44502
44801
|
}
|
|
44503
|
-
const privateBytes = (0,
|
|
44802
|
+
const privateBytes = (0, import_utils71.hexToBytes)(viewingPrivateKey.slice(2));
|
|
44504
44803
|
if (privateBytes.length !== 32) {
|
|
44505
44804
|
throw new ValidationError(
|
|
44506
44805
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -44510,7 +44809,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
44510
44809
|
try {
|
|
44511
44810
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
|
|
44512
44811
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44513
|
-
return `0x${(0,
|
|
44812
|
+
return `0x${(0, import_utils71.bytesToHex)(hashBytes)}`;
|
|
44514
44813
|
} finally {
|
|
44515
44814
|
secureWipe(privateBytes);
|
|
44516
44815
|
}
|
|
@@ -44557,9 +44856,9 @@ function importNEARViewingKey(exported) {
|
|
|
44557
44856
|
{ expected: computedHash, received: exported.hash }
|
|
44558
44857
|
);
|
|
44559
44858
|
}
|
|
44560
|
-
const privateBytes = (0,
|
|
44859
|
+
const privateBytes = (0, import_utils71.hexToBytes)(exported.privateKey.slice(2));
|
|
44561
44860
|
try {
|
|
44562
|
-
const derivedPublic = `0x${(0,
|
|
44861
|
+
const derivedPublic = `0x${(0, import_utils71.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
|
|
44563
44862
|
if (derivedPublic !== exported.publicKey) {
|
|
44564
44863
|
throw new ValidationError(
|
|
44565
44864
|
"Public key does not match private key",
|
|
@@ -44578,10 +44877,10 @@ function importNEARViewingKey(exported) {
|
|
|
44578
44877
|
};
|
|
44579
44878
|
}
|
|
44580
44879
|
function deriveEncryptionKey3(key, salt) {
|
|
44581
|
-
const keyBytes = (0,
|
|
44880
|
+
const keyBytes = (0, import_utils71.hexToBytes)(key.slice(2));
|
|
44582
44881
|
try {
|
|
44583
|
-
const hkdfSalt = salt ?? (0,
|
|
44584
|
-
return (0, import_hkdf5.hkdf)(import_sha25629.sha256, keyBytes, hkdfSalt, (0,
|
|
44882
|
+
const hkdfSalt = salt ?? (0, import_utils71.utf8ToBytes)(ENCRYPTION_DOMAIN3);
|
|
44883
|
+
return (0, import_hkdf5.hkdf)(import_sha25629.sha256, keyBytes, hkdfSalt, (0, import_utils71.utf8ToBytes)("encryption"), 32);
|
|
44585
44884
|
} finally {
|
|
44586
44885
|
secureWipe(keyBytes);
|
|
44587
44886
|
}
|
|
@@ -44589,13 +44888,13 @@ function deriveEncryptionKey3(key, salt) {
|
|
|
44589
44888
|
function encryptForNEARViewing(data, viewingKey) {
|
|
44590
44889
|
const encKey = deriveEncryptionKey3(viewingKey.privateKey);
|
|
44591
44890
|
try {
|
|
44592
|
-
const nonce = (0,
|
|
44593
|
-
const plaintext = (0,
|
|
44891
|
+
const nonce = (0, import_utils71.randomBytes)(NONCE_SIZE4);
|
|
44892
|
+
const plaintext = (0, import_utils71.utf8ToBytes)(JSON.stringify(data));
|
|
44594
44893
|
const cipher = (0, import_chacha6.xchacha20poly1305)(encKey, nonce);
|
|
44595
44894
|
const ciphertext = cipher.encrypt(plaintext);
|
|
44596
44895
|
return {
|
|
44597
|
-
ciphertext: `0x${(0,
|
|
44598
|
-
nonce: `0x${(0,
|
|
44896
|
+
ciphertext: `0x${(0, import_utils71.bytesToHex)(ciphertext)}`,
|
|
44897
|
+
nonce: `0x${(0, import_utils71.bytesToHex)(nonce)}`,
|
|
44599
44898
|
viewingKeyHash: viewingKey.hash
|
|
44600
44899
|
};
|
|
44601
44900
|
} finally {
|
|
@@ -44612,8 +44911,8 @@ function decryptWithNEARViewing(encrypted, viewingKey) {
|
|
|
44612
44911
|
}
|
|
44613
44912
|
const encKey = deriveEncryptionKey3(viewingKey.privateKey);
|
|
44614
44913
|
try {
|
|
44615
|
-
const ciphertext = (0,
|
|
44616
|
-
const nonce = (0,
|
|
44914
|
+
const ciphertext = (0, import_utils71.hexToBytes)(encrypted.ciphertext.slice(2));
|
|
44915
|
+
const nonce = (0, import_utils71.hexToBytes)(encrypted.nonce.slice(2));
|
|
44617
44916
|
if (nonce.length !== NONCE_SIZE4) {
|
|
44618
44917
|
throw new ValidationError(
|
|
44619
44918
|
`Invalid nonce length: ${nonce.length}. Expected: ${NONCE_SIZE4}`,
|
|
@@ -44663,15 +44962,15 @@ function deriveNEARChildViewingKey(parentKey, childPath, label) {
|
|
|
44663
44962
|
if (!childPath || typeof childPath !== "string") {
|
|
44664
44963
|
throw new ValidationError("childPath must be a non-empty string", "childPath");
|
|
44665
44964
|
}
|
|
44666
|
-
const parentBytes = (0,
|
|
44965
|
+
const parentBytes = (0, import_utils71.hexToBytes)(parentKey.privateKey.slice(2));
|
|
44667
44966
|
try {
|
|
44668
|
-
const childBytes = (0, import_hmac7.hmac)(import_sha25629.sha256, (0,
|
|
44967
|
+
const childBytes = (0, import_hmac7.hmac)(import_sha25629.sha256, (0, import_utils71.utf8ToBytes)(childPath), parentBytes);
|
|
44669
44968
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(childBytes);
|
|
44670
44969
|
const hashBytes = (0, import_sha25629.sha256)(publicBytes);
|
|
44671
44970
|
const result = {
|
|
44672
|
-
privateKey: `0x${(0,
|
|
44673
|
-
publicKey: `0x${(0,
|
|
44674
|
-
hash: `0x${(0,
|
|
44971
|
+
privateKey: `0x${(0, import_utils71.bytesToHex)(childBytes)}`,
|
|
44972
|
+
publicKey: `0x${(0, import_utils71.bytesToHex)(publicBytes)}`,
|
|
44973
|
+
hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
|
|
44675
44974
|
label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
|
|
44676
44975
|
createdAt: Date.now()
|
|
44677
44976
|
};
|
|
@@ -44688,7 +44987,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
|
|
|
44688
44987
|
"viewingPrivateKey"
|
|
44689
44988
|
);
|
|
44690
44989
|
}
|
|
44691
|
-
const privateBytes = (0,
|
|
44990
|
+
const privateBytes = (0, import_utils71.hexToBytes)(viewingPrivateKey.slice(2));
|
|
44692
44991
|
if (privateBytes.length !== 32) {
|
|
44693
44992
|
throw new ValidationError(
|
|
44694
44993
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -44697,7 +44996,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
|
|
|
44697
44996
|
}
|
|
44698
44997
|
try {
|
|
44699
44998
|
const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
|
|
44700
|
-
return `0x${(0,
|
|
44999
|
+
return `0x${(0, import_utils71.bytesToHex)(publicBytes)}`;
|
|
44701
45000
|
} finally {
|
|
44702
45001
|
secureWipe(privateBytes);
|
|
44703
45002
|
}
|
|
@@ -44732,9 +45031,9 @@ function validateNEARViewingKey(viewingKey) {
|
|
|
44732
45031
|
{ expected: computedHash, received: viewingKey.hash }
|
|
44733
45032
|
);
|
|
44734
45033
|
}
|
|
44735
|
-
const privateBytes = (0,
|
|
45034
|
+
const privateBytes = (0, import_utils71.hexToBytes)(viewingKey.privateKey.slice(2));
|
|
44736
45035
|
try {
|
|
44737
|
-
const derivedPublic = `0x${(0,
|
|
45036
|
+
const derivedPublic = `0x${(0, import_utils71.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
|
|
44738
45037
|
if (derivedPublic !== viewingKey.publicKey) {
|
|
44739
45038
|
throw new ValidationError(
|
|
44740
45039
|
"publicKey does not match privateKey",
|
|
@@ -44749,11 +45048,11 @@ function validateNEARViewingKey(viewingKey) {
|
|
|
44749
45048
|
|
|
44750
45049
|
// src/chains/near/resolver.ts
|
|
44751
45050
|
var import_ed2551920 = require("@noble/curves/ed25519");
|
|
44752
|
-
var
|
|
45051
|
+
var import_utils72 = require("@noble/hashes/utils");
|
|
44753
45052
|
init_errors();
|
|
44754
45053
|
init_validation();
|
|
44755
45054
|
function nearSpendingPublicFromPrivate(spendingPrivateKey) {
|
|
44756
|
-
return `0x${(0,
|
|
45055
|
+
return `0x${(0, import_utils72.bytesToHex)(import_ed2551920.ed25519.getPublicKey((0, import_utils72.hexToBytes)(spendingPrivateKey.slice(2))))}`;
|
|
44757
45056
|
}
|
|
44758
45057
|
function createNEARAnnouncementCache() {
|
|
44759
45058
|
const entries = [];
|
|
@@ -44794,6 +45093,8 @@ var NEARRpcClient = class {
|
|
|
44794
45093
|
this.rpcUrl = rpcUrl;
|
|
44795
45094
|
this.timeout = timeout;
|
|
44796
45095
|
}
|
|
45096
|
+
rpcUrl;
|
|
45097
|
+
timeout;
|
|
44797
45098
|
async call(method, params) {
|
|
44798
45099
|
const controller = new AbortController();
|
|
44799
45100
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
@@ -45004,7 +45305,7 @@ var NEARStealthScanner = class {
|
|
|
45004
45305
|
nearSpendingPublicFromPrivate(recipient.spendingPrivateKey)
|
|
45005
45306
|
);
|
|
45006
45307
|
if (isMatch) {
|
|
45007
|
-
const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : (0,
|
|
45308
|
+
const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : (0, import_utils72.bytesToHex)((0, import_utils72.hexToBytes)(stealthPublicKey.slice(2)));
|
|
45008
45309
|
let amount = metadata?.amount ?? 0n;
|
|
45009
45310
|
if (amount === 0n && isImplicitAccount(stealthAddress)) {
|
|
45010
45311
|
try {
|
|
@@ -45454,6 +45755,9 @@ var AllBackendsFailedError = class _AllBackendsFailedError extends Error {
|
|
|
45454
45755
|
this.params = params;
|
|
45455
45756
|
Object.setPrototypeOf(this, _AllBackendsFailedError.prototype);
|
|
45456
45757
|
}
|
|
45758
|
+
attemptedBackends;
|
|
45759
|
+
errors;
|
|
45760
|
+
params;
|
|
45457
45761
|
name = "AllBackendsFailedError";
|
|
45458
45762
|
/**
|
|
45459
45763
|
* Get formatted error summary
|
|
@@ -46109,6 +46413,10 @@ var RateLimitExceededError = class extends Error {
|
|
|
46109
46413
|
this.requestedTokens = requestedTokens;
|
|
46110
46414
|
this.retryAfterMs = retryAfterMs;
|
|
46111
46415
|
}
|
|
46416
|
+
backend;
|
|
46417
|
+
availableTokens;
|
|
46418
|
+
requestedTokens;
|
|
46419
|
+
retryAfterMs;
|
|
46112
46420
|
name = "RateLimitExceededError";
|
|
46113
46421
|
};
|
|
46114
46422
|
var QueueFullError = class extends Error {
|
|
@@ -46120,6 +46428,9 @@ var QueueFullError = class extends Error {
|
|
|
46120
46428
|
this.queueSize = queueSize;
|
|
46121
46429
|
this.maxQueueSize = maxQueueSize;
|
|
46122
46430
|
}
|
|
46431
|
+
backend;
|
|
46432
|
+
queueSize;
|
|
46433
|
+
maxQueueSize;
|
|
46123
46434
|
name = "QueueFullError";
|
|
46124
46435
|
};
|
|
46125
46436
|
var AcquireTimeoutError = class extends Error {
|
|
@@ -46128,6 +46439,8 @@ var AcquireTimeoutError = class extends Error {
|
|
|
46128
46439
|
this.backend = backend;
|
|
46129
46440
|
this.timeoutMs = timeoutMs;
|
|
46130
46441
|
}
|
|
46442
|
+
backend;
|
|
46443
|
+
timeoutMs;
|
|
46131
46444
|
name = "AcquireTimeoutError";
|
|
46132
46445
|
};
|
|
46133
46446
|
var RateLimiter = class {
|
|
@@ -47379,7 +47692,7 @@ function createPrivacyLogger(moduleName, config = {}) {
|
|
|
47379
47692
|
}
|
|
47380
47693
|
|
|
47381
47694
|
// src/privacy-backends/privacycash.ts
|
|
47382
|
-
var
|
|
47695
|
+
var import_utils73 = require("@noble/hashes/utils");
|
|
47383
47696
|
var privacyCashLogger = createPrivacyLogger("PrivacyCash");
|
|
47384
47697
|
var DEFAULT_ANONYMITY_SET = 50;
|
|
47385
47698
|
var BASE_COST_LAMPORTS = BigInt(1e7);
|
|
@@ -47409,7 +47722,7 @@ var PRIVACYCASH_CAPABILITIES = {
|
|
|
47409
47722
|
|
|
47410
47723
|
// src/privacy-backends/shadowwire.ts
|
|
47411
47724
|
var import_shadowwire = require("@radr/shadowwire");
|
|
47412
|
-
var
|
|
47725
|
+
var import_utils74 = require("@noble/hashes/utils");
|
|
47413
47726
|
var SHADOWWIRE_TOKEN_MINTS = {
|
|
47414
47727
|
SOL: "So11111111111111111111111111111111111111112",
|
|
47415
47728
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
@@ -47468,8 +47781,8 @@ var COST_PER_ENCRYPTED_INPUT_WEI = BigInt("1000000000000000");
|
|
|
47468
47781
|
|
|
47469
47782
|
// src/privacy-backends/magicblock.ts
|
|
47470
47783
|
var import_ephemeral_rollups_sdk = require("@magicblock-labs/ephemeral-rollups-sdk");
|
|
47471
|
-
var
|
|
47472
|
-
var
|
|
47784
|
+
var import_web320 = require("@solana/web3.js");
|
|
47785
|
+
var import_utils75 = require("@noble/hashes/utils");
|
|
47473
47786
|
var magicBlockLogger = createPrivacyLogger("MagicBlock");
|
|
47474
47787
|
|
|
47475
47788
|
// src/privacy-backends/cspl-types.ts
|
|
@@ -48159,7 +48472,7 @@ var CSPLClient = class {
|
|
|
48159
48472
|
|
|
48160
48473
|
// src/privacy-backends/private-swap.ts
|
|
48161
48474
|
var import_sha25630 = require("@noble/hashes/sha256");
|
|
48162
|
-
var
|
|
48475
|
+
var import_utils76 = require("@noble/hashes/utils");
|
|
48163
48476
|
|
|
48164
48477
|
// src/privacy-backends/cspl-token.ts
|
|
48165
48478
|
var CSPLTokenService = class {
|
|
@@ -50766,6 +51079,7 @@ var ProductionSafetyError = class extends Error {
|
|
|
50766
51079
|
this.errors = errors;
|
|
50767
51080
|
this.name = "ProductionSafetyError";
|
|
50768
51081
|
}
|
|
51082
|
+
errors;
|
|
50769
51083
|
};
|
|
50770
51084
|
function validateProductionConfig(config, options = {}) {
|
|
50771
51085
|
const isProduction = isProductionEnvironment();
|
|
@@ -50870,7 +51184,7 @@ init_proxy();
|
|
|
50870
51184
|
// src/sync/oblivious.ts
|
|
50871
51185
|
var import_sha211 = require("@noble/hashes/sha2");
|
|
50872
51186
|
var import_hmac8 = require("@noble/hashes/hmac");
|
|
50873
|
-
var
|
|
51187
|
+
var import_utils77 = require("@noble/hashes/utils");
|
|
50874
51188
|
init_secure_memory();
|
|
50875
51189
|
var DEFAULT_SYNC_CONFIG = {
|
|
50876
51190
|
maxBatchSize: 1e3,
|
|
@@ -50881,7 +51195,7 @@ var DEFAULT_SYNC_CONFIG = {
|
|
|
50881
51195
|
parallelSync: true
|
|
50882
51196
|
};
|
|
50883
51197
|
function generateSyncRandomness(epoch, durationSeconds = DEFAULT_SYNC_CONFIG.epochDurationSeconds) {
|
|
50884
|
-
const value = (0,
|
|
51198
|
+
const value = (0, import_utils77.randomBytes)(32);
|
|
50885
51199
|
const expiresAt = Date.now() + durationSeconds * 1e3;
|
|
50886
51200
|
return {
|
|
50887
51201
|
value,
|
|
@@ -50897,21 +51211,21 @@ function getCurrentEpoch(epochDurationSeconds = DEFAULT_SYNC_CONFIG.epochDuratio
|
|
|
50897
51211
|
}
|
|
50898
51212
|
var OBLIVIOUS_NULLIFIER_DOMAIN = "SIP-OBLIVIOUS-NULLIFIER-V1";
|
|
50899
51213
|
function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
50900
|
-
const commitmentBytes = (0,
|
|
51214
|
+
const commitmentBytes = (0, import_utils77.hexToBytes)(
|
|
50901
51215
|
noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
|
|
50902
51216
|
);
|
|
50903
|
-
const keyBytes = (0,
|
|
51217
|
+
const keyBytes = (0, import_utils77.hexToBytes)(
|
|
50904
51218
|
spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
|
|
50905
51219
|
);
|
|
50906
51220
|
try {
|
|
50907
|
-
const domain = (0,
|
|
51221
|
+
const domain = (0, import_utils77.utf8ToBytes)(OBLIVIOUS_NULLIFIER_DOMAIN);
|
|
50908
51222
|
const message = new Uint8Array(domain.length + commitmentBytes.length + syncRandomness.value.length);
|
|
50909
51223
|
message.set(domain, 0);
|
|
50910
51224
|
message.set(commitmentBytes, domain.length);
|
|
50911
51225
|
message.set(syncRandomness.value, domain.length + commitmentBytes.length);
|
|
50912
51226
|
const nullifierBytes = (0, import_hmac8.hmac)(import_sha211.sha256, keyBytes, message);
|
|
50913
51227
|
return {
|
|
50914
|
-
nullifier: `0x${(0,
|
|
51228
|
+
nullifier: `0x${(0, import_utils77.bytesToHex)(nullifierBytes)}`,
|
|
50915
51229
|
epoch: syncRandomness.epoch,
|
|
50916
51230
|
chainId: "default"
|
|
50917
51231
|
// Will be set by caller
|
|
@@ -50921,15 +51235,15 @@ function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
|
50921
51235
|
}
|
|
50922
51236
|
}
|
|
50923
51237
|
function deriveTraditionalNullifier(noteCommitment, spendingKey) {
|
|
50924
|
-
const commitmentBytes = (0,
|
|
51238
|
+
const commitmentBytes = (0, import_utils77.hexToBytes)(
|
|
50925
51239
|
noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
|
|
50926
51240
|
);
|
|
50927
|
-
const keyBytes = (0,
|
|
51241
|
+
const keyBytes = (0, import_utils77.hexToBytes)(
|
|
50928
51242
|
spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
|
|
50929
51243
|
);
|
|
50930
51244
|
try {
|
|
50931
51245
|
const nullifierBytes = (0, import_hmac8.hmac)(import_sha211.sha256, keyBytes, commitmentBytes);
|
|
50932
|
-
return `0x${(0,
|
|
51246
|
+
return `0x${(0, import_utils77.bytesToHex)(nullifierBytes)}`;
|
|
50933
51247
|
} finally {
|
|
50934
51248
|
secureWipe(keyBytes);
|
|
50935
51249
|
}
|
|
@@ -50974,7 +51288,7 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
|
|
|
50974
51288
|
for (let e = startEpoch; e <= endEpoch; e++) {
|
|
50975
51289
|
epochs.push(e);
|
|
50976
51290
|
}
|
|
50977
|
-
const keyBytes = (0,
|
|
51291
|
+
const keyBytes = (0, import_utils77.hexToBytes)(
|
|
50978
51292
|
masterViewingKey.startsWith("0x") ? masterViewingKey.slice(2) : masterViewingKey
|
|
50979
51293
|
);
|
|
50980
51294
|
const windowData = new Uint8Array(16);
|
|
@@ -50985,11 +51299,11 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
|
|
|
50985
51299
|
const keyHash = (0, import_sha211.sha256)(derivedKey);
|
|
50986
51300
|
secureWipe(keyBytes);
|
|
50987
51301
|
return {
|
|
50988
|
-
viewingKey: `0x${(0,
|
|
51302
|
+
viewingKey: `0x${(0, import_utils77.bytesToHex)(derivedKey)}`,
|
|
50989
51303
|
windowStart: startTime,
|
|
50990
51304
|
windowEnd: endTime,
|
|
50991
51305
|
epochs,
|
|
50992
|
-
hash: `0x${(0,
|
|
51306
|
+
hash: `0x${(0, import_utils77.bytesToHex)(keyHash)}`
|
|
50993
51307
|
};
|
|
50994
51308
|
}
|
|
50995
51309
|
function isNoteInWindow(_note, _windowedKey) {
|
|
@@ -51012,10 +51326,12 @@ var ObliviousSyncError = class extends Error {
|
|
|
51012
51326
|
this.context = context;
|
|
51013
51327
|
this.name = "ObliviousSyncError";
|
|
51014
51328
|
}
|
|
51329
|
+
code;
|
|
51330
|
+
context;
|
|
51015
51331
|
};
|
|
51016
51332
|
|
|
51017
51333
|
// src/sync/mock-provider.ts
|
|
51018
|
-
var
|
|
51334
|
+
var import_utils78 = require("@noble/hashes/utils");
|
|
51019
51335
|
var DEFAULT_MOCK_CONFIG = {
|
|
51020
51336
|
chains: ["ethereum", "solana", "near"],
|
|
51021
51337
|
latencyMs: 100,
|
|
@@ -51112,7 +51428,7 @@ var MockObliviousSyncProvider = class {
|
|
|
51112
51428
|
merkleProofs,
|
|
51113
51429
|
syncHeight: this.config.blockHeight,
|
|
51114
51430
|
timestamp: Date.now(),
|
|
51115
|
-
queryHash: `0x${(0,
|
|
51431
|
+
queryHash: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`
|
|
51116
51432
|
};
|
|
51117
51433
|
}
|
|
51118
51434
|
async getCurrentHeight(chainId) {
|
|
@@ -51193,23 +51509,23 @@ var MockObliviousSyncProvider = class {
|
|
|
51193
51509
|
generateMockNote(blockRange) {
|
|
51194
51510
|
const blockNumber = blockRange.startBlock + BigInt(Math.floor(Math.random() * Number(blockRange.endBlock - blockRange.startBlock)));
|
|
51195
51511
|
return {
|
|
51196
|
-
commitment: `0x${(0,
|
|
51197
|
-
encryptedData: `0x${(0,
|
|
51512
|
+
commitment: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`,
|
|
51513
|
+
encryptedData: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(128))}`,
|
|
51198
51514
|
blockNumber,
|
|
51199
|
-
txHash: `0x${(0,
|
|
51515
|
+
txHash: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`,
|
|
51200
51516
|
chainId: blockRange.chainId
|
|
51201
51517
|
};
|
|
51202
51518
|
}
|
|
51203
51519
|
generateMockMerkleProof(leaf) {
|
|
51204
51520
|
const siblings = [];
|
|
51205
51521
|
for (let i = 0; i < 20; i++) {
|
|
51206
|
-
siblings.push(`0x${(0,
|
|
51522
|
+
siblings.push(`0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`);
|
|
51207
51523
|
}
|
|
51208
51524
|
return {
|
|
51209
51525
|
leaf,
|
|
51210
51526
|
siblings,
|
|
51211
51527
|
index: BigInt(Math.floor(Math.random() * 1e6)),
|
|
51212
|
-
root: `0x${(0,
|
|
51528
|
+
root: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`
|
|
51213
51529
|
};
|
|
51214
51530
|
}
|
|
51215
51531
|
};
|
|
@@ -54470,6 +54786,8 @@ var ProofWorker = class _ProofWorker {
|
|
|
54470
54786
|
SIPError,
|
|
54471
54787
|
SIPNativeBackend,
|
|
54472
54788
|
SIP_MEMO_PREFIX,
|
|
54789
|
+
SIP_MEMO_PREFIX_ANY,
|
|
54790
|
+
SIP_MEMO_PREFIX_V2,
|
|
54473
54791
|
SIP_VERSION,
|
|
54474
54792
|
SOLANA_EXPLORER_URLS,
|
|
54475
54793
|
SOLANA_RPC_ENDPOINTS,
|
|
@@ -54529,6 +54847,7 @@ var ProofWorker = class _ProofWorker {
|
|
|
54529
54847
|
bpsToPercent,
|
|
54530
54848
|
browserBytesToHex,
|
|
54531
54849
|
browserHexToBytes,
|
|
54850
|
+
buildGaslessCashout,
|
|
54532
54851
|
cacheKeyGenerator,
|
|
54533
54852
|
calculateFeeForSwap,
|
|
54534
54853
|
calculatePrivacyScore,
|
|
@@ -54551,6 +54870,7 @@ var ProofWorker = class _ProofWorker {
|
|
|
54551
54870
|
computeAttestationHash,
|
|
54552
54871
|
computeNEARViewingKeyHash,
|
|
54553
54872
|
computeNEARViewingKeyHashFromPrivate,
|
|
54873
|
+
computeRelayerFee,
|
|
54554
54874
|
computeTweakedKey,
|
|
54555
54875
|
configureLogger,
|
|
54556
54876
|
convertFromSIP,
|
|
@@ -54655,6 +54975,7 @@ var ProofWorker = class _ProofWorker {
|
|
|
54655
54975
|
deriveSecp256k1StealthPrivateKeyV1,
|
|
54656
54976
|
deriveStealthPrivateKey,
|
|
54657
54977
|
deriveStealthPrivateKeyV1,
|
|
54978
|
+
deriveStealthSigner,
|
|
54658
54979
|
deriveSuiStealthPrivateKey,
|
|
54659
54980
|
deriveTraditionalNullifier,
|
|
54660
54981
|
deriveViewingKey,
|
|
@@ -54852,11 +55173,13 @@ var ProofWorker = class _ProofWorker {
|
|
|
54852
55173
|
serializePayment,
|
|
54853
55174
|
setLogLevel,
|
|
54854
55175
|
signAttestationMessage,
|
|
55176
|
+
signEd25519WithScalar,
|
|
54855
55177
|
silenceLogger,
|
|
54856
55178
|
solanaAddressToEd25519PublicKey,
|
|
54857
55179
|
solanaOptimizations,
|
|
54858
55180
|
solanaPublicKeyToHex,
|
|
54859
55181
|
stealthKeyToCosmosAddress,
|
|
55182
|
+
submitGaslessCashout,
|
|
54860
55183
|
subtractBlindings,
|
|
54861
55184
|
subtractBlindingsNEAR,
|
|
54862
55185
|
subtractCommitments,
|