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