@sip-protocol/sdk 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/{TransportWebUSB-YQMAGJAJ.mjs → TransportWebUSB-2KITI5HD.mjs} +24 -12
- package/dist/browser.d.mts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +1358 -847
- package/dist/browser.mjs +13 -3
- package/dist/{chunk-64AYA5F5.mjs → chunk-G3TBBG2K.mjs} +221 -146
- package/dist/{chunk-4GRJ5MAW.mjs → chunk-KXETSSKP.mjs} +4 -0
- package/dist/{chunk-YWGJ77A2.mjs → chunk-PT2DNA7E.mjs} +335 -310
- package/dist/{constants-LHAAUC2T.mjs → constants-DCJYTIU3.mjs} +5 -1
- package/dist/{dist-2OGQ7FED.mjs → dist-PYEXZNFD.mjs} +609 -221
- package/dist/{index-DeE1ZzA4.d.mts → index-B1d8pihL.d.mts} +117 -33
- package/dist/{index-DXh2IGkz.d.ts → index-UQhQJZbM.d.ts} +117 -33
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1348 -837
- package/dist/index.mjs +13 -3
- package/dist/{interface-Bf7w1PLW.d.mts → interface-CQi0-WfS.d.mts} +2 -2
- package/dist/{interface-Bf7w1PLW.d.ts → interface-CQi0-WfS.d.ts} +2 -2
- package/dist/{noir-kzbLVTei.d.mts → noir-CwPIyBLj.d.mts} +1 -1
- package/dist/{noir-kzbLVTei.d.ts → noir-CwPIyBLj.d.ts} +1 -1
- package/dist/proofs/halo2.d.mts +1 -1
- package/dist/proofs/halo2.d.ts +1 -1
- package/dist/proofs/kimchi.d.mts +1 -1
- package/dist/proofs/kimchi.d.ts +1 -1
- package/dist/proofs/noir.d.mts +1 -1
- package/dist/proofs/noir.d.ts +1 -1
- package/dist/{solana-U3MEGU7W.mjs → solana-ZWNIQTSU.mjs} +6 -6
- package/package.json +32 -32
- package/src/adapters/gelato-relay.ts +386 -0
- package/src/adapters/index.ts +28 -0
- package/src/adapters/oneinch.ts +126 -0
- package/src/chains/ethereum/constants.ts +33 -1
- package/src/chains/ethereum/index.ts +2 -1
- package/src/chains/ethereum/privacy-adapter.ts +44 -26
- package/src/chains/ethereum/stealth.ts +84 -30
- package/src/chains/ethereum/types.ts +4 -0
- package/src/chains/near/privacy-adapter.ts +8 -5
- package/src/chains/near/resolver.ts +22 -8
- package/src/chains/near/stealth.ts +9 -9
- package/src/chains/solana/constants.ts +13 -1
- package/src/chains/solana/ephemeral-keys.ts +3 -257
- package/src/chains/solana/index.ts +2 -3
- package/src/chains/solana/providers/helius-enhanced.ts +6 -6
- package/src/chains/solana/providers/webhook.ts +2 -2
- package/src/chains/solana/scan.ts +9 -8
- package/src/chains/solana/stealth-scanner.ts +3 -3
- package/src/chains/solana/types.ts +18 -4
- package/src/cosmos/ibc-stealth.ts +6 -6
- package/src/index.ts +6 -0
- package/src/move/aptos.ts +15 -9
- package/src/move/sui.ts +15 -9
- package/src/nft/private-nft.ts +10 -6
- package/src/privacy-backends/shadowwire.ts +13 -0
- package/src/stealth/ed25519.ts +173 -12
- package/src/stealth/index.ts +47 -4
- package/src/stealth/secp256k1.ts +144 -7
- package/src/stealth.ts +7 -0
- package/src/wallet/ethereum/privacy-adapter.ts +1 -1
- package/src/wallet/hardware/ledger-privacy.ts +2 -2
- package/src/wallet/near/adapter.ts +2 -2
- package/src/wallet/near/meteor-wallet.ts +2 -2
- package/src/wallet/near/my-near-wallet.ts +2 -2
- package/src/wallet/near/wallet-selector.ts +2 -2
- package/src/wallet/solana/privacy-adapter.ts +9 -9
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
validateEd25519StealthAddress,
|
|
35
35
|
validateEd25519StealthMetaAddress,
|
|
36
36
|
verifyOpening
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-G3TBBG2K.mjs";
|
|
38
38
|
import {
|
|
39
39
|
ProofGenerationError
|
|
40
40
|
} from "./chunk-HOR7PM3M.mjs";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
SOLANA_RPC_ENDPOINTS,
|
|
52
52
|
SUI_RPC_ENDPOINTS,
|
|
53
53
|
ZCASH_RPC_CONFIG
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-KXETSSKP.mjs";
|
|
55
55
|
import {
|
|
56
56
|
__export
|
|
57
57
|
} from "./chunk-XGB3TDIC.mjs";
|
|
@@ -756,12 +756,12 @@ async function createShieldedIntent(params, options) {
|
|
|
756
756
|
"Using placeholder signatures for proof generation - NOT cryptographically valid"
|
|
757
757
|
);
|
|
758
758
|
} else {
|
|
759
|
-
const { secp256k1:
|
|
760
|
-
const publicKey =
|
|
759
|
+
const { secp256k1: secp256k110 } = await import("@noble/curves/secp256k1");
|
|
760
|
+
const publicKey = secp256k110.getPublicKey(effectiveSenderSecret, true);
|
|
761
761
|
const senderAddressBytes = sha2563(publicKey);
|
|
762
|
-
const ownershipSig =
|
|
762
|
+
const ownershipSig = secp256k110.sign(senderAddressBytes, effectiveSenderSecret);
|
|
763
763
|
effectiveOwnershipSig = ownershipSig.toCompactRawBytes();
|
|
764
|
-
const authSig =
|
|
764
|
+
const authSig = secp256k110.sign(intentHashBytes, effectiveSenderSecret);
|
|
765
765
|
effectiveAuthSig = authSig.toCompactRawBytes();
|
|
766
766
|
}
|
|
767
767
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
@@ -1230,11 +1230,11 @@ function deriveAptosStealthPrivateKey(stealthAddress, spendingPrivateKey, viewin
|
|
|
1230
1230
|
aptosAddress
|
|
1231
1231
|
};
|
|
1232
1232
|
}
|
|
1233
|
-
function checkAptosStealthAddress(stealthAddress,
|
|
1233
|
+
function checkAptosStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey) {
|
|
1234
1234
|
return checkEd25519StealthAddress(
|
|
1235
1235
|
stealthAddress,
|
|
1236
|
-
|
|
1237
|
-
|
|
1236
|
+
viewingPrivateKey,
|
|
1237
|
+
spendingPublicKey
|
|
1238
1238
|
);
|
|
1239
1239
|
}
|
|
1240
1240
|
var AptosStealthService = class {
|
|
@@ -1270,13 +1270,16 @@ var AptosStealthService = class {
|
|
|
1270
1270
|
/**
|
|
1271
1271
|
* Check if a stealth address belongs to this recipient
|
|
1272
1272
|
*
|
|
1273
|
+
* Canonical EIP-5564 view-only check: requires only the recipient's viewing
|
|
1274
|
+
* private key plus their spending PUBLIC key (no spending private key needed).
|
|
1275
|
+
*
|
|
1273
1276
|
* @param stealthAddress - Stealth address to check
|
|
1274
|
-
* @param spendingPrivateKey - Recipient's spending private key
|
|
1275
1277
|
* @param viewingPrivateKey - Recipient's viewing private key
|
|
1278
|
+
* @param spendingPublicKey - Recipient's spending public key (meta-address spendingKey)
|
|
1276
1279
|
* @returns true if the address belongs to this recipient
|
|
1277
1280
|
*/
|
|
1278
|
-
checkStealthAddress(stealthAddress,
|
|
1279
|
-
return checkAptosStealthAddress(stealthAddress,
|
|
1281
|
+
checkStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey) {
|
|
1282
|
+
return checkAptosStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey);
|
|
1280
1283
|
}
|
|
1281
1284
|
/**
|
|
1282
1285
|
* Validate an Aptos address format
|
|
@@ -1366,11 +1369,11 @@ function deriveSuiStealthPrivateKey(stealthAddress, spendingPrivateKey, viewingP
|
|
|
1366
1369
|
suiAddress
|
|
1367
1370
|
};
|
|
1368
1371
|
}
|
|
1369
|
-
function checkSuiStealthAddress(stealthAddress,
|
|
1372
|
+
function checkSuiStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey) {
|
|
1370
1373
|
return checkEd25519StealthAddress(
|
|
1371
1374
|
stealthAddress,
|
|
1372
|
-
|
|
1373
|
-
|
|
1375
|
+
viewingPrivateKey,
|
|
1376
|
+
spendingPublicKey
|
|
1374
1377
|
);
|
|
1375
1378
|
}
|
|
1376
1379
|
var SuiStealthService = class {
|
|
@@ -1406,13 +1409,16 @@ var SuiStealthService = class {
|
|
|
1406
1409
|
/**
|
|
1407
1410
|
* Check if a stealth address belongs to this recipient
|
|
1408
1411
|
*
|
|
1412
|
+
* Canonical EIP-5564 view-only check: requires only the recipient's viewing
|
|
1413
|
+
* private key plus their spending PUBLIC key (no spending private key needed).
|
|
1414
|
+
*
|
|
1409
1415
|
* @param stealthAddress - Stealth address to check
|
|
1410
|
-
* @param spendingPrivateKey - Recipient's spending private key
|
|
1411
1416
|
* @param viewingPrivateKey - Recipient's viewing private key
|
|
1417
|
+
* @param spendingPublicKey - Recipient's spending public key (meta-address spendingKey)
|
|
1412
1418
|
* @returns true if the address belongs to this recipient
|
|
1413
1419
|
*/
|
|
1414
|
-
checkStealthAddress(stealthAddress,
|
|
1415
|
-
return checkSuiStealthAddress(stealthAddress,
|
|
1420
|
+
checkStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey) {
|
|
1421
|
+
return checkSuiStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey);
|
|
1416
1422
|
}
|
|
1417
1423
|
/**
|
|
1418
1424
|
* Validate a Sui address format
|
|
@@ -2198,6 +2204,10 @@ import {
|
|
|
2198
2204
|
} from "@solana/web3.js";
|
|
2199
2205
|
import { bytesToHex as bytesToHex6 } from "@noble/hashes/utils";
|
|
2200
2206
|
|
|
2207
|
+
// src/adapters/gelato-relay.ts
|
|
2208
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
2209
|
+
import { bytesToHex as bytesToHex7 } from "@noble/hashes/utils";
|
|
2210
|
+
|
|
2201
2211
|
// src/sip.ts
|
|
2202
2212
|
var SIP = class {
|
|
2203
2213
|
config;
|
|
@@ -2672,10 +2682,10 @@ var SIP = class {
|
|
|
2672
2682
|
"chain"
|
|
2673
2683
|
);
|
|
2674
2684
|
}
|
|
2675
|
-
const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await import("./solana-
|
|
2685
|
+
const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await import("./solana-ZWNIQTSU.mjs");
|
|
2676
2686
|
const { PublicKey: SolanaPublicKey } = await import("@solana/web3.js");
|
|
2677
2687
|
const { getAssociatedTokenAddress } = await import("@solana/spl-token");
|
|
2678
|
-
const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await import("./constants-
|
|
2688
|
+
const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await import("./constants-DCJYTIU3.mjs");
|
|
2679
2689
|
let mint;
|
|
2680
2690
|
if (params.token in SOLANA_TOKEN_MINTS3) {
|
|
2681
2691
|
mint = new SolanaPublicKey(SOLANA_TOKEN_MINTS3[params.token]);
|
|
@@ -2728,7 +2738,7 @@ function createProductionSIP(config) {
|
|
|
2728
2738
|
// src/cosmos/stealth.ts
|
|
2729
2739
|
import { sha256 as sha2564 } from "@noble/hashes/sha256";
|
|
2730
2740
|
import { ripemd160 } from "@noble/hashes/ripemd160";
|
|
2731
|
-
import { hexToBytes as hexToBytes5, bytesToHex as
|
|
2741
|
+
import { hexToBytes as hexToBytes5, bytesToHex as bytesToHex8 } from "@noble/hashes/utils";
|
|
2732
2742
|
import { bech32 } from "@scure/base";
|
|
2733
2743
|
var CHAIN_PREFIXES = {
|
|
2734
2744
|
cosmos: "cosmos",
|
|
@@ -2810,8 +2820,8 @@ var CosmosStealthService = class {
|
|
|
2810
2820
|
);
|
|
2811
2821
|
}
|
|
2812
2822
|
const metaAddress = {
|
|
2813
|
-
spendingKey: `0x${
|
|
2814
|
-
viewingKey: `0x${
|
|
2823
|
+
spendingKey: `0x${bytesToHex8(spendingPubKey)}`,
|
|
2824
|
+
viewingKey: `0x${bytesToHex8(viewingPubKey)}`,
|
|
2815
2825
|
chain: "ethereum"
|
|
2816
2826
|
// Use ethereum for secp256k1 generation
|
|
2817
2827
|
};
|
|
@@ -3024,13 +3034,13 @@ function isValidCosmosAddress(address, expectedChain) {
|
|
|
3024
3034
|
}
|
|
3025
3035
|
|
|
3026
3036
|
// src/cosmos/ibc-stealth.ts
|
|
3027
|
-
import { hexToBytes as hexToBytes6, bytesToHex as
|
|
3037
|
+
import { hexToBytes as hexToBytes6, bytesToHex as bytesToHex9 } from "@noble/hashes/utils";
|
|
3028
3038
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
3029
3039
|
import { sha256 as sha2565 } from "@noble/hashes/sha256";
|
|
3030
3040
|
|
|
3031
3041
|
// src/proofs/mock.ts
|
|
3032
3042
|
import { sha256 as sha2566 } from "@noble/hashes/sha256";
|
|
3033
|
-
import { bytesToHex as
|
|
3043
|
+
import { bytesToHex as bytesToHex10, randomBytes as randomBytes4 } from "@noble/hashes/utils";
|
|
3034
3044
|
var log3 = createLogger("proofs/mock");
|
|
3035
3045
|
var MOCK_PROOF_PREFIX = "0x4d4f434b";
|
|
3036
3046
|
var MockProofProvider = class {
|
|
@@ -3211,11 +3221,11 @@ var MockProofProvider = class {
|
|
|
3211
3221
|
combined.set(new TextEncoder().encode("MOCK"), 0);
|
|
3212
3222
|
combined.set(hash2, 4);
|
|
3213
3223
|
combined.set(random, 4 + hash2.length);
|
|
3214
|
-
return `${MOCK_PROOF_PREFIX}${
|
|
3224
|
+
return `${MOCK_PROOF_PREFIX}${bytesToHex10(combined.slice(4))}`;
|
|
3215
3225
|
}
|
|
3216
3226
|
hashToHex(data) {
|
|
3217
3227
|
const hash2 = sha2566(new TextEncoder().encode(data));
|
|
3218
|
-
return `0x${
|
|
3228
|
+
return `0x${bytesToHex10(hash2)}`;
|
|
3219
3229
|
}
|
|
3220
3230
|
};
|
|
3221
3231
|
|
|
@@ -3500,7 +3510,7 @@ function hexToBytes7(hex) {
|
|
|
3500
3510
|
}
|
|
3501
3511
|
return bytes;
|
|
3502
3512
|
}
|
|
3503
|
-
function
|
|
3513
|
+
function bytesToHex11(bytes) {
|
|
3504
3514
|
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
3505
3515
|
}
|
|
3506
3516
|
function isBrowser() {
|
|
@@ -3948,47 +3958,47 @@ var ComplianceProofProvider = class {
|
|
|
3948
3958
|
}
|
|
3949
3959
|
}
|
|
3950
3960
|
async hashViewingKey(viewingKey) {
|
|
3951
|
-
const { sha256:
|
|
3952
|
-
const { bytesToHex:
|
|
3961
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
3962
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
3953
3963
|
const keyString = typeof viewingKey === "string" ? viewingKey : JSON.stringify(viewingKey);
|
|
3954
3964
|
const encoder = new TextEncoder();
|
|
3955
3965
|
const keyBytes = encoder.encode(keyString);
|
|
3956
|
-
return
|
|
3966
|
+
return bytesToHex57(sha25635(keyBytes));
|
|
3957
3967
|
}
|
|
3958
3968
|
async computeDecryptionCommitment(viewingKey, encryptedData) {
|
|
3959
|
-
const { sha256:
|
|
3960
|
-
const { bytesToHex:
|
|
3969
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
3970
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
3961
3971
|
const keyHash = await this.hashViewingKey(viewingKey);
|
|
3962
3972
|
const keyBytes = this.hexToBytes(keyHash);
|
|
3963
3973
|
const preimage = new Uint8Array([...keyBytes, ...encryptedData.slice(0, 32)]);
|
|
3964
|
-
return
|
|
3974
|
+
return bytesToHex57(sha25635(preimage));
|
|
3965
3975
|
}
|
|
3966
3976
|
async computeAuditorHash(auditorPublicKey, transactionHash) {
|
|
3967
|
-
const { sha256:
|
|
3968
|
-
const { bytesToHex:
|
|
3977
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
3978
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
3969
3979
|
const auditorBytes = this.hexToBytes(auditorPublicKey.replace("0x", "").padStart(64, "0"));
|
|
3970
3980
|
const txBytes = this.hexToBytes(transactionHash.replace("0x", "").padStart(64, "0"));
|
|
3971
3981
|
const preimage = new Uint8Array([...auditorBytes, ...txBytes]);
|
|
3972
|
-
return
|
|
3982
|
+
return bytesToHex57(sha25635(preimage));
|
|
3973
3983
|
}
|
|
3974
3984
|
async computeAddressCommitment(address, blinding) {
|
|
3975
|
-
const { sha256:
|
|
3976
|
-
const { bytesToHex:
|
|
3985
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
3986
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
3977
3987
|
const addressBytes = this.hexToBytes(address.replace("0x", "").padStart(64, "0"));
|
|
3978
3988
|
const preimage = new Uint8Array([...addressBytes, ...blinding.slice(0, 32)]);
|
|
3979
|
-
return
|
|
3989
|
+
return bytesToHex57(sha25635(preimage));
|
|
3980
3990
|
}
|
|
3981
3991
|
async computeNonMembershipProof(senderAddress, recipientAddress, _sanctionsListRoot) {
|
|
3982
|
-
const { sha256:
|
|
3983
|
-
const { bytesToHex:
|
|
3992
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
3993
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
3984
3994
|
const senderBytes = this.hexToBytes(senderAddress.replace("0x", "").padStart(64, "0"));
|
|
3985
3995
|
const recipientBytes = this.hexToBytes(recipientAddress.replace("0x", "").padStart(64, "0"));
|
|
3986
3996
|
const preimage = new Uint8Array([...senderBytes, ...recipientBytes]);
|
|
3987
|
-
return
|
|
3997
|
+
return bytesToHex57(sha25635(preimage));
|
|
3988
3998
|
}
|
|
3989
3999
|
async computeBalanceCommitment(balance, blinding) {
|
|
3990
|
-
const { sha256:
|
|
3991
|
-
const { bytesToHex:
|
|
4000
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
4001
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
3992
4002
|
const balanceBytes = new Uint8Array(8);
|
|
3993
4003
|
let v = balance;
|
|
3994
4004
|
for (let i = 7; i >= 0; i--) {
|
|
@@ -3996,11 +4006,11 @@ var ComplianceProofProvider = class {
|
|
|
3996
4006
|
v = v >> 8n;
|
|
3997
4007
|
}
|
|
3998
4008
|
const preimage = new Uint8Array([...balanceBytes, ...blinding.slice(0, 32)]);
|
|
3999
|
-
return
|
|
4009
|
+
return bytesToHex57(sha25635(preimage));
|
|
4000
4010
|
}
|
|
4001
4011
|
async generateComplianceProofBytes(type, publicInputs) {
|
|
4002
|
-
const { sha256:
|
|
4003
|
-
const { bytesToHex:
|
|
4012
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
4013
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
4004
4014
|
const circuitId = COMPLIANCE_CIRCUIT_IDS[type];
|
|
4005
4015
|
const encoder = new TextEncoder();
|
|
4006
4016
|
const inputBytes = publicInputs.flatMap((pi) => Array.from(this.hexToBytes(pi.replace("0x", ""))));
|
|
@@ -4008,10 +4018,10 @@ var ComplianceProofProvider = class {
|
|
|
4008
4018
|
...encoder.encode(circuitId),
|
|
4009
4019
|
...inputBytes
|
|
4010
4020
|
]);
|
|
4011
|
-
const hash2 =
|
|
4021
|
+
const hash2 = sha25635(preimage);
|
|
4012
4022
|
let proofBytes = "";
|
|
4013
4023
|
for (let i = 0; i < 8; i++) {
|
|
4014
|
-
proofBytes +=
|
|
4024
|
+
proofBytes += bytesToHex57(sha25635(new Uint8Array([...hash2, i])));
|
|
4015
4025
|
}
|
|
4016
4026
|
return proofBytes;
|
|
4017
4027
|
}
|
|
@@ -4039,7 +4049,7 @@ var ComplianceProofProvider = class {
|
|
|
4039
4049
|
};
|
|
4040
4050
|
|
|
4041
4051
|
// src/proofs/aggregator.ts
|
|
4042
|
-
import { randomBytes as randomBytes5, bytesToHex as
|
|
4052
|
+
import { randomBytes as randomBytes5, bytesToHex as bytesToHex12 } from "@noble/hashes/utils";
|
|
4043
4053
|
import {
|
|
4044
4054
|
ProofAggregationStrategy as Strategy,
|
|
4045
4055
|
ComposedProofStatus
|
|
@@ -4061,7 +4071,7 @@ var DEFAULT_AGGREGATOR_CONFIG = {
|
|
|
4061
4071
|
};
|
|
4062
4072
|
function generateId(prefix) {
|
|
4063
4073
|
const bytes = randomBytes5(8);
|
|
4064
|
-
return `${prefix}-${
|
|
4074
|
+
return `${prefix}-${bytesToHex12(bytes)}`;
|
|
4065
4075
|
}
|
|
4066
4076
|
function computeProofHash(proofs) {
|
|
4067
4077
|
const data = proofs.map((p) => p.proof).join("");
|
|
@@ -4464,7 +4474,7 @@ var ProofAggregator = class {
|
|
|
4464
4474
|
const proofBytes = randomBytes5(256);
|
|
4465
4475
|
return {
|
|
4466
4476
|
id: generateId(`recursive-${depth}`),
|
|
4467
|
-
proof: `0x${
|
|
4477
|
+
proof: `0x${bytesToHex12(proofBytes)}`,
|
|
4468
4478
|
publicInputs: combinedInputs.slice(0, 10),
|
|
4469
4479
|
metadata: {
|
|
4470
4480
|
system: targetSystem,
|
|
@@ -4679,7 +4689,7 @@ function createProofAggregator(config) {
|
|
|
4679
4689
|
}
|
|
4680
4690
|
|
|
4681
4691
|
// src/proofs/verifier.ts
|
|
4682
|
-
import { randomBytes as randomBytes6, bytesToHex as
|
|
4692
|
+
import { randomBytes as randomBytes6, bytesToHex as bytesToHex13 } from "@noble/hashes/utils";
|
|
4683
4693
|
var DEFAULT_PIPELINE_CONFIG = {
|
|
4684
4694
|
enableParallel: true,
|
|
4685
4695
|
maxConcurrent: 4,
|
|
@@ -4693,7 +4703,7 @@ var DEFAULT_PIPELINE_CONFIG = {
|
|
|
4693
4703
|
generateVerificationProof: false
|
|
4694
4704
|
};
|
|
4695
4705
|
function generateId2(prefix) {
|
|
4696
|
-
return `${prefix}-${
|
|
4706
|
+
return `${prefix}-${bytesToHex13(randomBytes6(8))}`;
|
|
4697
4707
|
}
|
|
4698
4708
|
function computeLinkHash(sourceProof, targetProof) {
|
|
4699
4709
|
const combinedData = sourceProof.proof + targetProof.proof;
|
|
@@ -5673,7 +5683,7 @@ function createCrossSystemValidator(options) {
|
|
|
5673
5683
|
}
|
|
5674
5684
|
|
|
5675
5685
|
// src/proofs/orchestrator.ts
|
|
5676
|
-
import { randomBytes as randomBytes7, bytesToHex as
|
|
5686
|
+
import { randomBytes as randomBytes7, bytesToHex as bytesToHex14 } from "@noble/hashes/utils";
|
|
5677
5687
|
import {
|
|
5678
5688
|
ProofAggregationStrategy as Strategy2,
|
|
5679
5689
|
ComposedProofStatus as ComposedProofStatus2
|
|
@@ -5732,7 +5742,7 @@ var BUILTIN_TEMPLATES = [
|
|
|
5732
5742
|
}
|
|
5733
5743
|
];
|
|
5734
5744
|
function generateId3(prefix) {
|
|
5735
|
-
return `${prefix}-${
|
|
5745
|
+
return `${prefix}-${bytesToHex14(randomBytes7(8))}`;
|
|
5736
5746
|
}
|
|
5737
5747
|
function delay2(ms) {
|
|
5738
5748
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -6289,7 +6299,7 @@ var IncompatibleSystemsError = class extends ProofCompositionError {
|
|
|
6289
6299
|
|
|
6290
6300
|
// src/proofs/composer/base.ts
|
|
6291
6301
|
import { randomBytes as randomBytes8 } from "@noble/hashes/utils";
|
|
6292
|
-
import { bytesToHex as
|
|
6302
|
+
import { bytesToHex as bytesToHex15 } from "@noble/hashes/utils";
|
|
6293
6303
|
import {
|
|
6294
6304
|
ProofAggregationStrategy as Strategy3,
|
|
6295
6305
|
ComposedProofStatus as ComposedProofStatus4,
|
|
@@ -6298,7 +6308,7 @@ import {
|
|
|
6298
6308
|
} from "@sip-protocol/types";
|
|
6299
6309
|
function generateId4(prefix) {
|
|
6300
6310
|
const bytes = randomBytes8(8);
|
|
6301
|
-
return `${prefix}-${
|
|
6311
|
+
return `${prefix}-${bytesToHex15(bytes)}`;
|
|
6302
6312
|
}
|
|
6303
6313
|
function computeProofHash2(proofs) {
|
|
6304
6314
|
const data = proofs.map((p) => p.proof).join("");
|
|
@@ -6998,7 +7008,7 @@ var DEFAULT_CONVERSION_OPTIONS = {
|
|
|
6998
7008
|
var CONVERTER_VERSION = "1.0.0";
|
|
6999
7009
|
var SUPPORTED_NOIR_VERSIONS = ["0.30", "0.31", "0.32", "0.33", "0.34", "0.35", "1.0"];
|
|
7000
7010
|
var SUPPORTED_BB_VERSIONS = ["0.47", "0.48", "0.49", "0.50", "0.51", "0.52", "0.53"];
|
|
7001
|
-
function
|
|
7011
|
+
function bytesToHex16(bytes) {
|
|
7002
7012
|
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7003
7013
|
}
|
|
7004
7014
|
function hexToBytes8(hex) {
|
|
@@ -7044,7 +7054,7 @@ var NoirProofConverter = class {
|
|
|
7044
7054
|
nativeProof.proofData.length
|
|
7045
7055
|
);
|
|
7046
7056
|
}
|
|
7047
|
-
const proofHex =
|
|
7057
|
+
const proofHex = bytesToHex16(nativeProof.proofData);
|
|
7048
7058
|
const publicInputsHex = nativeProof.publicInputs.map((input) => {
|
|
7049
7059
|
if (input.startsWith("0x")) {
|
|
7050
7060
|
return input;
|
|
@@ -7052,7 +7062,7 @@ var NoirProofConverter = class {
|
|
|
7052
7062
|
const bigInt = BigInt(input);
|
|
7053
7063
|
return "0x" + bigInt.toString(16).padStart(64, "0");
|
|
7054
7064
|
});
|
|
7055
|
-
const verificationKey = opts.includeVerificationKey && nativeProof.verificationKey ? typeof nativeProof.verificationKey === "string" ? nativeProof.verificationKey :
|
|
7065
|
+
const verificationKey = opts.includeVerificationKey && nativeProof.verificationKey ? typeof nativeProof.verificationKey === "string" ? nativeProof.verificationKey : bytesToHex16(nativeProof.verificationKey) : void 0;
|
|
7056
7066
|
const metadata = {
|
|
7057
7067
|
system: "noir",
|
|
7058
7068
|
systemVersion: nativeProof.noirVersion || "unknown",
|
|
@@ -7285,7 +7295,7 @@ var CONVERTER_VERSION2 = "1.0.0";
|
|
|
7285
7295
|
var SUPPORTED_HALO2_VERSIONS = ["0.2", "0.3", "1.0"];
|
|
7286
7296
|
var MIN_K_VALUE = 4;
|
|
7287
7297
|
var MAX_K_VALUE = 28;
|
|
7288
|
-
function
|
|
7298
|
+
function bytesToHex17(bytes) {
|
|
7289
7299
|
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7290
7300
|
}
|
|
7291
7301
|
function hexToBytes9(hex) {
|
|
@@ -7327,7 +7337,7 @@ var Halo2ProofConverter = class {
|
|
|
7327
7337
|
nativeProof.proofData.length
|
|
7328
7338
|
);
|
|
7329
7339
|
}
|
|
7330
|
-
const proofHex =
|
|
7340
|
+
const proofHex = bytesToHex17(nativeProof.proofData);
|
|
7331
7341
|
const publicInputsHex = nativeProof.publicInputs.map((input) => {
|
|
7332
7342
|
if (input.startsWith("0x")) {
|
|
7333
7343
|
return input;
|
|
@@ -7335,7 +7345,7 @@ var Halo2ProofConverter = class {
|
|
|
7335
7345
|
const bigInt = BigInt(input);
|
|
7336
7346
|
return "0x" + bigInt.toString(16).padStart(64, "0");
|
|
7337
7347
|
});
|
|
7338
|
-
const verificationKey = opts.includeVerificationKey && nativeProof.verificationKey ? typeof nativeProof.verificationKey === "string" ? nativeProof.verificationKey :
|
|
7348
|
+
const verificationKey = opts.includeVerificationKey && nativeProof.verificationKey ? typeof nativeProof.verificationKey === "string" ? nativeProof.verificationKey : bytesToHex17(nativeProof.verificationKey) : void 0;
|
|
7339
7349
|
const circuitId = nativeProof.provingKeyCommitment ? `halo2-k${nativeProof.k || "unknown"}-${nativeProof.provingKeyCommitment.slice(0, 16)}` : `halo2-k${nativeProof.k || "unknown"}`;
|
|
7340
7350
|
const metadata = {
|
|
7341
7351
|
system: "halo2",
|
|
@@ -7572,7 +7582,7 @@ function createHalo2Converter() {
|
|
|
7572
7582
|
var CONVERTER_VERSION3 = "1.0.0";
|
|
7573
7583
|
var SUPPORTED_KIMCHI_VERSIONS = ["0.15", "0.16", "0.17", "0.18", "1.0", "1.1", "1.2"];
|
|
7574
7584
|
var PALLAS_MODULUS2 = BigInt("0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001");
|
|
7575
|
-
function
|
|
7585
|
+
function bytesToHex18(bytes) {
|
|
7576
7586
|
return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7577
7587
|
}
|
|
7578
7588
|
function hexToBytes10(hex) {
|
|
@@ -7622,7 +7632,7 @@ var KimchiProofConverter = class {
|
|
|
7622
7632
|
nativeProof.proofData.length
|
|
7623
7633
|
);
|
|
7624
7634
|
}
|
|
7625
|
-
const proofHex =
|
|
7635
|
+
const proofHex = bytesToHex18(nativeProof.proofData);
|
|
7626
7636
|
const publicInputsHex = nativeProof.publicInputs.map((input) => {
|
|
7627
7637
|
if (input.startsWith("0x")) {
|
|
7628
7638
|
return input;
|
|
@@ -7630,7 +7640,7 @@ var KimchiProofConverter = class {
|
|
|
7630
7640
|
const bigInt = BigInt(input);
|
|
7631
7641
|
return "0x" + bigInt.toString(16).padStart(64, "0");
|
|
7632
7642
|
});
|
|
7633
|
-
const verificationKey = opts.includeVerificationKey && nativeProof.verificationKey ? typeof nativeProof.verificationKey === "string" ? nativeProof.verificationKey :
|
|
7643
|
+
const verificationKey = opts.includeVerificationKey && nativeProof.verificationKey ? typeof nativeProof.verificationKey === "string" ? nativeProof.verificationKey : bytesToHex18(nativeProof.verificationKey) : void 0;
|
|
7634
7644
|
const circuitId = nativeProof.verifierIndexCommitment ? `kimchi-${nativeProof.verifierIndexCommitment.slice(0, 16)}` : "kimchi-unknown";
|
|
7635
7645
|
const metadata = {
|
|
7636
7646
|
system: "kimchi",
|
|
@@ -8013,7 +8023,7 @@ var DEFAULT_WARMING_CONFIG = {
|
|
|
8013
8023
|
|
|
8014
8024
|
// src/proofs/cache/key-generator.ts
|
|
8015
8025
|
import { sha256 as sha2567 } from "@noble/hashes/sha256";
|
|
8016
|
-
import { bytesToHex as
|
|
8026
|
+
import { bytesToHex as bytesToHex19 } from "@noble/hashes/utils";
|
|
8017
8027
|
var KEY_SEPARATOR = ":";
|
|
8018
8028
|
var KEY_PREFIX = "sip-proof";
|
|
8019
8029
|
var KEY_VERSION = "v1";
|
|
@@ -8035,7 +8045,7 @@ function canonicalize(value) {
|
|
|
8035
8045
|
return value.toString();
|
|
8036
8046
|
}
|
|
8037
8047
|
if (value instanceof Uint8Array) {
|
|
8038
|
-
return `bytes:${
|
|
8048
|
+
return `bytes:${bytesToHex19(value)}`;
|
|
8039
8049
|
}
|
|
8040
8050
|
if (Array.isArray(value)) {
|
|
8041
8051
|
return `[${value.map(canonicalize).join(",")}]`;
|
|
@@ -8098,7 +8108,7 @@ var CacheKeyGenerator = class {
|
|
|
8098
8108
|
hashInputs(inputs) {
|
|
8099
8109
|
const canonical = canonicalize(inputs);
|
|
8100
8110
|
const hash2 = sha2567(new TextEncoder().encode(canonical));
|
|
8101
|
-
return
|
|
8111
|
+
return bytesToHex19(hash2);
|
|
8102
8112
|
}
|
|
8103
8113
|
/**
|
|
8104
8114
|
* Generate a cache key from raw inputs
|
|
@@ -9547,11 +9557,11 @@ var CHAIN_NUMERIC_IDS = {
|
|
|
9547
9557
|
// src/oracle/verification.ts
|
|
9548
9558
|
import { ed25519 } from "@noble/curves/ed25519";
|
|
9549
9559
|
import { sha256 as sha2569 } from "@noble/hashes/sha256";
|
|
9550
|
-
import { bytesToHex as
|
|
9560
|
+
import { bytesToHex as bytesToHex21, hexToBytes as hexToBytes12 } from "@noble/hashes/utils";
|
|
9551
9561
|
|
|
9552
9562
|
// src/oracle/serialization.ts
|
|
9553
9563
|
import { sha256 as sha2568 } from "@noble/hashes/sha256";
|
|
9554
|
-
import { bytesToHex as
|
|
9564
|
+
import { bytesToHex as bytesToHex20, hexToBytes as hexToBytes11, utf8ToBytes as utf8ToBytes2 } from "@noble/hashes/utils";
|
|
9555
9565
|
function serializeAttestationMessage(message) {
|
|
9556
9566
|
const buffer = new Uint8Array(197);
|
|
9557
9567
|
const view = new DataView(buffer.buffer);
|
|
@@ -9594,19 +9604,19 @@ function deserializeAttestationMessage(bytes) {
|
|
|
9594
9604
|
const version = bytes[offset++];
|
|
9595
9605
|
const chainId = view.getUint32(offset, false);
|
|
9596
9606
|
offset += 4;
|
|
9597
|
-
const intentHash = `0x${
|
|
9607
|
+
const intentHash = `0x${bytesToHex20(bytes.slice(offset, offset + 32))}`;
|
|
9598
9608
|
offset += 32;
|
|
9599
|
-
const recipient = `0x${
|
|
9609
|
+
const recipient = `0x${bytesToHex20(bytes.slice(offset, offset + 32))}`;
|
|
9600
9610
|
offset += 32;
|
|
9601
9611
|
const amount = bytesToBigint(bytes.slice(offset, offset + 16));
|
|
9602
9612
|
offset += 16;
|
|
9603
|
-
const assetId = `0x${
|
|
9613
|
+
const assetId = `0x${bytesToHex20(bytes.slice(offset, offset + 32))}`;
|
|
9604
9614
|
offset += 32;
|
|
9605
|
-
const txHash = `0x${
|
|
9615
|
+
const txHash = `0x${bytesToHex20(bytes.slice(offset, offset + 32))}`;
|
|
9606
9616
|
offset += 32;
|
|
9607
9617
|
const blockNumber = view.getBigUint64(offset, false);
|
|
9608
9618
|
offset += 8;
|
|
9609
|
-
const blockHash = `0x${
|
|
9619
|
+
const blockHash = `0x${bytesToHex20(bytes.slice(offset, offset + 32))}`;
|
|
9610
9620
|
offset += 32;
|
|
9611
9621
|
const timestamp = Number(view.getBigUint64(offset, false));
|
|
9612
9622
|
return {
|
|
@@ -9674,7 +9684,7 @@ function bytesToBigint(bytes) {
|
|
|
9674
9684
|
function deriveOracleId(publicKey) {
|
|
9675
9685
|
const keyBytes = typeof publicKey === "string" ? hexToBytes12(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey) : publicKey;
|
|
9676
9686
|
const hash2 = sha2569(keyBytes);
|
|
9677
|
-
return `0x${
|
|
9687
|
+
return `0x${bytesToHex21(hash2)}`;
|
|
9678
9688
|
}
|
|
9679
9689
|
function verifyAttestation(attestation, registry) {
|
|
9680
9690
|
const { message, signatures } = attestation;
|
|
@@ -9749,7 +9759,7 @@ function signAttestationMessage(messageHash, privateKey) {
|
|
|
9749
9759
|
const oracleId = deriveOracleId(publicKey);
|
|
9750
9760
|
return {
|
|
9751
9761
|
oracleId,
|
|
9752
|
-
signature: `0x${
|
|
9762
|
+
signature: `0x${bytesToHex21(signature)}`
|
|
9753
9763
|
};
|
|
9754
9764
|
}
|
|
9755
9765
|
function createOracleRegistry(config = {}) {
|
|
@@ -9999,7 +10009,7 @@ import { ReportStatus as ReportStatus2 } from "@sip-protocol/types";
|
|
|
9999
10009
|
import {
|
|
10000
10010
|
IntentStatus as IntentStatus3
|
|
10001
10011
|
} from "@sip-protocol/types";
|
|
10002
|
-
import { bytesToHex as
|
|
10012
|
+
import { bytesToHex as bytesToHex22, randomBytes as randomBytes9 } from "@noble/hashes/utils";
|
|
10003
10013
|
var MockSolver = class {
|
|
10004
10014
|
info;
|
|
10005
10015
|
capabilities;
|
|
@@ -10081,7 +10091,7 @@ var MockSolver = class {
|
|
|
10081
10091
|
const spreadAmount = baseOutput * BigInt(Math.floor(this.spreadPercent * 1e4)) / 10000n;
|
|
10082
10092
|
const outputAmount = baseOutput + spreadAmount;
|
|
10083
10093
|
const feeAmount = outputAmount * BigInt(Math.floor(this.feePercent * 1e4)) / 10000n;
|
|
10084
|
-
const quoteId = `quote-${
|
|
10094
|
+
const quoteId = `quote-${bytesToHex22(randomBytes9(8))}`;
|
|
10085
10095
|
const now = Math.floor(Date.now() / 1e3);
|
|
10086
10096
|
const quote = {
|
|
10087
10097
|
quoteId,
|
|
@@ -10092,7 +10102,7 @@ var MockSolver = class {
|
|
|
10092
10102
|
expiry: now + 60,
|
|
10093
10103
|
// Quote valid for 1 minute
|
|
10094
10104
|
fee: feeAmount,
|
|
10095
|
-
signature: `0x${
|
|
10105
|
+
signature: `0x${bytesToHex22(randomBytes9(64))}`,
|
|
10096
10106
|
// Mock signature
|
|
10097
10107
|
validUntil: now + 60,
|
|
10098
10108
|
estimatedGas: 200000n
|
|
@@ -10129,7 +10139,7 @@ var MockSolver = class {
|
|
|
10129
10139
|
error: status.error
|
|
10130
10140
|
};
|
|
10131
10141
|
}
|
|
10132
|
-
const txHash = `0x${
|
|
10142
|
+
const txHash = `0x${bytesToHex22(randomBytes9(32))}`;
|
|
10133
10143
|
status.status = "completed";
|
|
10134
10144
|
status.txHash = txHash;
|
|
10135
10145
|
return {
|
|
@@ -10139,10 +10149,10 @@ var MockSolver = class {
|
|
|
10139
10149
|
txHash: intent.privacyLevel === "transparent" ? txHash : void 0,
|
|
10140
10150
|
fulfillmentProof: {
|
|
10141
10151
|
type: "fulfillment",
|
|
10142
|
-
proof: `0x${
|
|
10152
|
+
proof: `0x${bytesToHex22(randomBytes9(128))}`,
|
|
10143
10153
|
publicInputs: [
|
|
10144
|
-
`0x${
|
|
10145
|
-
`0x${
|
|
10154
|
+
`0x${bytesToHex22(new TextEncoder().encode(intent.intentId))}`,
|
|
10155
|
+
`0x${bytesToHex22(new TextEncoder().encode(quote.quoteId))}`
|
|
10146
10156
|
]
|
|
10147
10157
|
},
|
|
10148
10158
|
fulfilledAt: Math.floor(Date.now() / 1e3)
|
|
@@ -11710,7 +11720,7 @@ function createZcashNativeBackend(config) {
|
|
|
11710
11720
|
|
|
11711
11721
|
// src/settlement/backends/direct-chain.ts
|
|
11712
11722
|
import { PrivacyLevel as PrivacyLevel5 } from "@sip-protocol/types";
|
|
11713
|
-
import { randomBytes as randomBytes10, bytesToHex as
|
|
11723
|
+
import { randomBytes as randomBytes10, bytesToHex as bytesToHex23 } from "@noble/hashes/utils";
|
|
11714
11724
|
var DEFAULT_GAS_FEES = {
|
|
11715
11725
|
ethereum: 21000n * 50n * 1000000000n,
|
|
11716
11726
|
// 21k gas * 50 gwei = 0.00105 ETH
|
|
@@ -13043,7 +13053,7 @@ import { ZcashErrorCode as ZcashErrorCode3 } from "@sip-protocol/types";
|
|
|
13043
13053
|
// src/bitcoin/taproot.ts
|
|
13044
13054
|
import { secp256k1 as secp256k12, schnorr } from "@noble/curves/secp256k1";
|
|
13045
13055
|
import { sha256 as sha25610 } from "@noble/hashes/sha256";
|
|
13046
|
-
import { bytesToHex as
|
|
13056
|
+
import { bytesToHex as bytesToHex24, hexToBytes as hexToBytes13 } from "@noble/hashes/utils";
|
|
13047
13057
|
var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
13048
13058
|
var BECH32_GENERATOR = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
13049
13059
|
function taggedHash(tag, data) {
|
|
@@ -13098,16 +13108,16 @@ function computeTweakedKey(internalKey, merkleRoot) {
|
|
|
13098
13108
|
}
|
|
13099
13109
|
const tweakData = merkleRoot ? new Uint8Array([...internalKey, ...merkleRoot]) : internalKey;
|
|
13100
13110
|
const tweak = taggedHash("TapTweak", tweakData);
|
|
13101
|
-
const tweakScalar = BigInt("0x" +
|
|
13111
|
+
const tweakScalar = BigInt("0x" + bytesToHex24(tweak)) % secp256k12.CURVE.n;
|
|
13102
13112
|
const internalPoint = secp256k12.ProjectivePoint.fromHex(
|
|
13103
|
-
"02" +
|
|
13113
|
+
"02" + bytesToHex24(internalKey)
|
|
13104
13114
|
);
|
|
13105
13115
|
const tweakPoint = secp256k12.ProjectivePoint.BASE.multiply(tweakScalar);
|
|
13106
13116
|
const tweakedPoint = internalPoint.add(tweakPoint);
|
|
13107
13117
|
const tweakedKeyBytes = tweakedPoint.toRawBytes(false);
|
|
13108
13118
|
const xOnly = tweakedKeyBytes.slice(1, 33);
|
|
13109
13119
|
const yCoord = tweakedKeyBytes.slice(33, 65);
|
|
13110
|
-
const yBigInt = BigInt("0x" +
|
|
13120
|
+
const yBigInt = BigInt("0x" + bytesToHex24(yCoord));
|
|
13111
13121
|
const parity = Number(yBigInt & 1n);
|
|
13112
13122
|
return {
|
|
13113
13123
|
tweakedKey: xOnly,
|
|
@@ -13137,9 +13147,9 @@ function createTaprootOutput(internalKey, scripts) {
|
|
|
13137
13147
|
}
|
|
13138
13148
|
const { tweakedKey, parity } = computeTweakedKey(internalKey, merkleRoot);
|
|
13139
13149
|
return {
|
|
13140
|
-
tweakedKey: `0x${
|
|
13141
|
-
internalKey: `0x${
|
|
13142
|
-
merkleRoot: merkleRoot ? `0x${
|
|
13150
|
+
tweakedKey: `0x${bytesToHex24(tweakedKey)}`,
|
|
13151
|
+
internalKey: `0x${bytesToHex24(internalKey)}`,
|
|
13152
|
+
merkleRoot: merkleRoot ? `0x${bytesToHex24(merkleRoot)}` : void 0,
|
|
13143
13153
|
parity
|
|
13144
13154
|
};
|
|
13145
13155
|
}
|
|
@@ -13305,7 +13315,7 @@ function schnorrSignHex(message, privateKey, auxRand) {
|
|
|
13305
13315
|
const privateKeyBytes = hexToBytes13(privateKey.slice(2));
|
|
13306
13316
|
const auxRandBytes = auxRand ? hexToBytes13(auxRand.slice(2)) : void 0;
|
|
13307
13317
|
const signature = schnorrSign(messageBytes, privateKeyBytes, auxRandBytes);
|
|
13308
|
-
return `0x${
|
|
13318
|
+
return `0x${bytesToHex24(signature)}`;
|
|
13309
13319
|
}
|
|
13310
13320
|
function schnorrVerifyHex(signature, message, publicKey) {
|
|
13311
13321
|
if (!isValidHex(signature)) {
|
|
@@ -13326,7 +13336,7 @@ function schnorrVerifyHex(signature, message, publicKey) {
|
|
|
13326
13336
|
// src/bitcoin/silent-payments.ts
|
|
13327
13337
|
import { secp256k1 as secp256k13 } from "@noble/curves/secp256k1";
|
|
13328
13338
|
import { sha256 as sha25611 } from "@noble/hashes/sha256";
|
|
13329
|
-
import { bytesToHex as
|
|
13339
|
+
import { bytesToHex as bytesToHex25, hexToBytes as hexToBytes14 } from "@noble/hashes/utils";
|
|
13330
13340
|
|
|
13331
13341
|
// src/payment/payment.ts
|
|
13332
13342
|
import {
|
|
@@ -13335,7 +13345,7 @@ import {
|
|
|
13335
13345
|
PaymentStatus
|
|
13336
13346
|
} from "@sip-protocol/types";
|
|
13337
13347
|
import { sha256 as sha25612 } from "@noble/hashes/sha256";
|
|
13338
|
-
import { bytesToHex as
|
|
13348
|
+
import { bytesToHex as bytesToHex26, hexToBytes as hexToBytes15, randomBytes as randomBytes11 } from "@noble/hashes/utils";
|
|
13339
13349
|
import { xchacha20poly1305 as xchacha20poly13052 } from "@noble/ciphers/chacha.js";
|
|
13340
13350
|
import { hkdf as hkdf2 } from "@noble/hashes/hkdf";
|
|
13341
13351
|
|
|
@@ -13832,7 +13842,7 @@ async function createShieldedPayment(params, options) {
|
|
|
13832
13842
|
if (viewingKey) {
|
|
13833
13843
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
13834
13844
|
const keyBytes = hexToBytes15(keyHex);
|
|
13835
|
-
viewingKeyHash = `0x${
|
|
13845
|
+
viewingKeyHash = `0x${bytesToHex26(sha25612(keyBytes))}`;
|
|
13836
13846
|
}
|
|
13837
13847
|
const privacyConfig = getPrivacyConfig(
|
|
13838
13848
|
privacy,
|
|
@@ -13909,7 +13919,7 @@ function encryptMemo(memo, viewingKey) {
|
|
|
13909
13919
|
const result = new Uint8Array(nonce.length + ciphertext.length);
|
|
13910
13920
|
result.set(nonce);
|
|
13911
13921
|
result.set(ciphertext, nonce.length);
|
|
13912
|
-
return `0x${
|
|
13922
|
+
return `0x${bytesToHex26(result)}`;
|
|
13913
13923
|
} finally {
|
|
13914
13924
|
secureWipe(keyBytes);
|
|
13915
13925
|
secureWipe(encKey);
|
|
@@ -13974,7 +13984,7 @@ import {
|
|
|
13974
13984
|
} from "@sip-protocol/types";
|
|
13975
13985
|
import { secp256k1 as secp256k14 } from "@noble/curves/secp256k1";
|
|
13976
13986
|
import { sha256 as sha25613 } from "@noble/hashes/sha256";
|
|
13977
|
-
import { bytesToHex as
|
|
13987
|
+
import { bytesToHex as bytesToHex27, hexToBytes as hexToBytes16, randomBytes as randomBytes12 } from "@noble/hashes/utils";
|
|
13978
13988
|
var DEFAULT_PROPOSAL_TTL = 7 * 24 * 60 * 60;
|
|
13979
13989
|
var Treasury = class _Treasury {
|
|
13980
13990
|
config;
|
|
@@ -14466,11 +14476,11 @@ var Treasury = class _Treasury {
|
|
|
14466
14476
|
};
|
|
14467
14477
|
function generateTreasuryId() {
|
|
14468
14478
|
const bytes = randomBytes12(16);
|
|
14469
|
-
return `treasury_${
|
|
14479
|
+
return `treasury_${bytesToHex27(bytes)}`;
|
|
14470
14480
|
}
|
|
14471
14481
|
function generateProposalId() {
|
|
14472
14482
|
const bytes = randomBytes12(16);
|
|
14473
|
-
return `prop_${
|
|
14483
|
+
return `prop_${bytesToHex27(bytes)}`;
|
|
14474
14484
|
}
|
|
14475
14485
|
function computeProposalHash(proposal) {
|
|
14476
14486
|
const data = JSON.stringify({
|
|
@@ -14660,7 +14670,7 @@ function validateBatchProposalParams(params, config) {
|
|
|
14660
14670
|
import {
|
|
14661
14671
|
ReportStatus
|
|
14662
14672
|
} from "@sip-protocol/types";
|
|
14663
|
-
import { bytesToHex as
|
|
14673
|
+
import { bytesToHex as bytesToHex28, randomBytes as randomBytes13 } from "@noble/hashes/utils";
|
|
14664
14674
|
var DEFAULTS2 = {
|
|
14665
14675
|
riskThreshold: 70,
|
|
14666
14676
|
highValueThreshold: 10000000000n,
|
|
@@ -15407,7 +15417,7 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
15407
15417
|
}
|
|
15408
15418
|
};
|
|
15409
15419
|
function generateId5(prefix) {
|
|
15410
|
-
return `${prefix}_${
|
|
15420
|
+
return `${prefix}_${bytesToHex28(randomBytes13(12))}`;
|
|
15411
15421
|
}
|
|
15412
15422
|
function validateRegisterAuditorParams(params) {
|
|
15413
15423
|
if (!params.organization?.trim()) {
|
|
@@ -15496,7 +15506,7 @@ function validateReportParams(params) {
|
|
|
15496
15506
|
|
|
15497
15507
|
// src/compliance/reports.ts
|
|
15498
15508
|
import { sha256 as sha25614 } from "@noble/hashes/sha256";
|
|
15499
|
-
import { hexToBytes as hexToBytes17, bytesToHex as
|
|
15509
|
+
import { hexToBytes as hexToBytes17, bytesToHex as bytesToHex29 } from "@noble/hashes/utils";
|
|
15500
15510
|
|
|
15501
15511
|
// src/compliance/pdf.ts
|
|
15502
15512
|
function generatePdfReport(report, options = {}) {
|
|
@@ -15802,7 +15812,7 @@ var ComplianceReporter = class {
|
|
|
15802
15812
|
return {
|
|
15803
15813
|
key: `0x${keyHex}`,
|
|
15804
15814
|
path: "m/0",
|
|
15805
|
-
hash: `0x${
|
|
15815
|
+
hash: `0x${bytesToHex29(hashBytes)}`
|
|
15806
15816
|
};
|
|
15807
15817
|
}
|
|
15808
15818
|
return viewingKey;
|
|
@@ -16184,7 +16194,7 @@ var ComplianceReporter = class {
|
|
|
16184
16194
|
|
|
16185
16195
|
// src/compliance/conditional.ts
|
|
16186
16196
|
import { sha256 as sha25615 } from "@noble/hashes/sha256";
|
|
16187
|
-
import { bytesToHex as
|
|
16197
|
+
import { bytesToHex as bytesToHex30, hexToBytes as hexToBytes18, randomBytes as randomBytes14 } from "@noble/hashes/utils";
|
|
16188
16198
|
import { xchacha20poly1305 as xchacha20poly13053 } from "@noble/ciphers/chacha.js";
|
|
16189
16199
|
var ConditionalDisclosure = class {
|
|
16190
16200
|
/**
|
|
@@ -16260,10 +16270,10 @@ var ConditionalDisclosure = class {
|
|
|
16260
16270
|
]);
|
|
16261
16271
|
const commitmentHash = sha25615(commitmentData);
|
|
16262
16272
|
return {
|
|
16263
|
-
encryptedKey: "0x" +
|
|
16264
|
-
nonce: "0x" +
|
|
16273
|
+
encryptedKey: "0x" + bytesToHex30(encryptedKey),
|
|
16274
|
+
nonce: "0x" + bytesToHex30(nonce),
|
|
16265
16275
|
revealAfter: revealAfterSeconds,
|
|
16266
|
-
verificationCommitment: "0x" +
|
|
16276
|
+
verificationCommitment: "0x" + bytesToHex30(commitmentHash),
|
|
16267
16277
|
encryptionCommitment: params.commitment,
|
|
16268
16278
|
type
|
|
16269
16279
|
};
|
|
@@ -16344,7 +16354,7 @@ var ConditionalDisclosure = class {
|
|
|
16344
16354
|
const encryptedData = hexToBytes18(timeLock.encryptedKey.slice(2));
|
|
16345
16355
|
const cipher = xchacha20poly13053(encryptionKey, nonce);
|
|
16346
16356
|
const decryptedBytes = cipher.decrypt(encryptedData);
|
|
16347
|
-
const viewingKey = "0x" +
|
|
16357
|
+
const viewingKey = "0x" + bytesToHex30(decryptedBytes);
|
|
16348
16358
|
return {
|
|
16349
16359
|
unlocked: true,
|
|
16350
16360
|
viewingKey
|
|
@@ -16432,12 +16442,12 @@ var ConditionalDisclosure = class {
|
|
|
16432
16442
|
// src/compliance/conditional-threshold.ts
|
|
16433
16443
|
import { secp256k1 as secp256k15 } from "@noble/curves/secp256k1";
|
|
16434
16444
|
import { sha256 as sha25616 } from "@noble/hashes/sha256";
|
|
16435
|
-
import { bytesToHex as
|
|
16445
|
+
import { bytesToHex as bytesToHex31, hexToBytes as hexToBytes19 } from "@noble/hashes/utils";
|
|
16436
16446
|
var CURVE_ORDER = secp256k15.CURVE.n;
|
|
16437
16447
|
|
|
16438
16448
|
// src/compliance/threshold.ts
|
|
16439
16449
|
import { sha256 as sha25617 } from "@noble/hashes/sha256";
|
|
16440
|
-
import { bytesToHex as
|
|
16450
|
+
import { bytesToHex as bytesToHex32, hexToBytes as hexToBytes20, randomBytes as randomBytes15 } from "@noble/hashes/utils";
|
|
16441
16451
|
var FIELD_PRIME = 2n ** 256n - 189n;
|
|
16442
16452
|
var ThresholdViewingKey = class {
|
|
16443
16453
|
/**
|
|
@@ -16680,7 +16690,7 @@ var ThresholdViewingKey = class {
|
|
|
16680
16690
|
static createCommitment(secret, coefficients) {
|
|
16681
16691
|
const data = [secret, ...coefficients].map((c) => c.toString(16).padStart(64, "0")).join("");
|
|
16682
16692
|
const hash2 = sha25617(hexToBytes20(data));
|
|
16683
|
-
return
|
|
16693
|
+
return bytesToHex32(hash2);
|
|
16684
16694
|
}
|
|
16685
16695
|
/**
|
|
16686
16696
|
* Encode share as string: "x:y:len:commitment"
|
|
@@ -16806,7 +16816,7 @@ var ThresholdViewingKey = class {
|
|
|
16806
16816
|
import { sha256 as sha25618 } from "@noble/hashes/sha256";
|
|
16807
16817
|
import { sha512 as sha5122 } from "@noble/hashes/sha512";
|
|
16808
16818
|
import { hmac as hmac2 } from "@noble/hashes/hmac";
|
|
16809
|
-
import { bytesToHex as
|
|
16819
|
+
import { bytesToHex as bytesToHex33, utf8ToBytes as utf8ToBytes4 } from "@noble/hashes/utils";
|
|
16810
16820
|
var AuditorType = /* @__PURE__ */ ((AuditorType2) => {
|
|
16811
16821
|
AuditorType2[AuditorType2["PRIMARY"] = 0] = "PRIMARY";
|
|
16812
16822
|
AuditorType2[AuditorType2["REGULATORY"] = 1] = "REGULATORY";
|
|
@@ -16916,9 +16926,9 @@ var AuditorKeyDerivation = class {
|
|
|
16916
16926
|
currentKey = new Uint8Array(derived.key);
|
|
16917
16927
|
chainCode = new Uint8Array(derived.chainCode);
|
|
16918
16928
|
}
|
|
16919
|
-
const keyHex = `0x${
|
|
16929
|
+
const keyHex = `0x${bytesToHex33(currentKey)}`;
|
|
16920
16930
|
const hashBytes = sha25618(currentKey);
|
|
16921
|
-
const hash2 = `0x${
|
|
16931
|
+
const hash2 = `0x${bytesToHex33(hashBytes)}`;
|
|
16922
16932
|
const viewingKey = {
|
|
16923
16933
|
key: keyHex,
|
|
16924
16934
|
path,
|
|
@@ -17002,9 +17012,9 @@ var AuditorKeyDerivation = class {
|
|
|
17002
17012
|
for (const auditorType of uniqueTypes) {
|
|
17003
17013
|
const derived = this.deriveChildKey(commonKey, commonChainCode, auditorType);
|
|
17004
17014
|
try {
|
|
17005
|
-
const keyHex = `0x${
|
|
17015
|
+
const keyHex = `0x${bytesToHex33(derived.key)}`;
|
|
17006
17016
|
const hashBytes = sha25618(derived.key);
|
|
17007
|
-
const hash2 = `0x${
|
|
17017
|
+
const hash2 = `0x${bytesToHex33(hashBytes)}`;
|
|
17008
17018
|
const path = this.derivePath(auditorType, account);
|
|
17009
17019
|
const viewingKey = {
|
|
17010
17020
|
key: keyHex,
|
|
@@ -17128,7 +17138,7 @@ var AuditorKeyDerivation = class {
|
|
|
17128
17138
|
import { sha256 as sha25619 } from "@noble/hashes/sha256";
|
|
17129
17139
|
import { hmac as hmac3 } from "@noble/hashes/hmac";
|
|
17130
17140
|
import { sha512 as sha5123 } from "@noble/hashes/sha512";
|
|
17131
|
-
import { bytesToHex as
|
|
17141
|
+
import { bytesToHex as bytesToHex34, hexToBytes as hexToBytes22, utf8ToBytes as utf8ToBytes5 } from "@noble/hashes/utils";
|
|
17132
17142
|
var AttestationSchema = /* @__PURE__ */ ((AttestationSchema2) => {
|
|
17133
17143
|
AttestationSchema2["RANGE_KYC_V1"] = "range-kyc-v1";
|
|
17134
17144
|
AttestationSchema2["RANGE_ACCREDITED_INVESTOR"] = "range-accredited-investor";
|
|
@@ -17369,9 +17379,9 @@ var AttestationGatedDisclosure = class {
|
|
|
17369
17379
|
const derived = hmac3(sha5123, masterKeyBytes, derivationData);
|
|
17370
17380
|
const keyBytes = derived.slice(0, 32);
|
|
17371
17381
|
try {
|
|
17372
|
-
const key = `0x${
|
|
17382
|
+
const key = `0x${bytesToHex34(keyBytes)}`;
|
|
17373
17383
|
const hashBytes = sha25619(keyBytes);
|
|
17374
|
-
const hash2 = `0x${
|
|
17384
|
+
const hash2 = `0x${bytesToHex34(hashBytes)}`;
|
|
17375
17385
|
return {
|
|
17376
17386
|
key,
|
|
17377
17387
|
path: `${this.config.masterViewingKey.path}/sas/${attestation.uid.slice(0, 8)}`,
|
|
@@ -17462,7 +17472,7 @@ async function verifyAttestationSignature(attestation, options = {}) {
|
|
|
17462
17472
|
}
|
|
17463
17473
|
const signedMessage = constructAttestationMessage(attestation);
|
|
17464
17474
|
try {
|
|
17465
|
-
const { ed25519:
|
|
17475
|
+
const { ed25519: ed2551912 } = await import("@noble/curves/ed25519");
|
|
17466
17476
|
const signatureBytes = hexToBytes22(
|
|
17467
17477
|
attestation.signature.startsWith("0x") ? attestation.signature.slice(2) : attestation.signature
|
|
17468
17478
|
);
|
|
@@ -17470,7 +17480,7 @@ async function verifyAttestationSignature(attestation, options = {}) {
|
|
|
17470
17480
|
issuerPublicKey.startsWith("0x") ? issuerPublicKey.slice(2) : issuerPublicKey
|
|
17471
17481
|
);
|
|
17472
17482
|
const messageBytes = utf8ToBytes5(signedMessage);
|
|
17473
|
-
return
|
|
17483
|
+
return ed2551912.verify(signatureBytes, messageBytes, publicKeyBytes);
|
|
17474
17484
|
} catch (error) {
|
|
17475
17485
|
console.warn(`[Range SAS] Signature verification error: ${error}`);
|
|
17476
17486
|
return false;
|
|
@@ -17626,10 +17636,10 @@ async function fetchWalletAttestations(walletAddress, options = {}) {
|
|
|
17626
17636
|
|
|
17627
17637
|
// src/compliance/fireblocks.ts
|
|
17628
17638
|
import { sha256 as sha25620 } from "@noble/hashes/sha256";
|
|
17629
|
-
import { bytesToHex as
|
|
17639
|
+
import { bytesToHex as bytesToHex35, hexToBytes as hexToBytes23 } from "@noble/hashes/utils";
|
|
17630
17640
|
|
|
17631
17641
|
// src/auction/sealed-bid.ts
|
|
17632
|
-
import { randomBytes as randomBytes16, bytesToHex as
|
|
17642
|
+
import { randomBytes as randomBytes16, bytesToHex as bytesToHex36 } from "@noble/hashes/utils";
|
|
17633
17643
|
var SealedBidAuction = class {
|
|
17634
17644
|
/**
|
|
17635
17645
|
* Create a sealed bid for an auction
|
|
@@ -17850,7 +17860,7 @@ var SealedBidAuction = class {
|
|
|
17850
17860
|
* ```
|
|
17851
17861
|
*/
|
|
17852
17862
|
revealBid(bid, amount, salt) {
|
|
17853
|
-
const saltHex = `0x${
|
|
17863
|
+
const saltHex = `0x${bytesToHex36(salt)}`;
|
|
17854
17864
|
const isValid = this.verifyBid({
|
|
17855
17865
|
commitment: bid.commitment,
|
|
17856
17866
|
amount,
|
|
@@ -18337,7 +18347,7 @@ function createSealedBidAuction() {
|
|
|
18337
18347
|
// src/governance/private-vote.ts
|
|
18338
18348
|
import { sha256 as sha25621 } from "@noble/hashes/sha256";
|
|
18339
18349
|
import { hkdf as hkdf3 } from "@noble/hashes/hkdf";
|
|
18340
|
-
import { bytesToHex as
|
|
18350
|
+
import { bytesToHex as bytesToHex37, hexToBytes as hexToBytes24, randomBytes as randomBytes17, utf8ToBytes as utf8ToBytes6 } from "@noble/hashes/utils";
|
|
18341
18351
|
import { xchacha20poly1305 as xchacha20poly13054 } from "@noble/ciphers/chacha.js";
|
|
18342
18352
|
var VOTE_ENCRYPTION_DOMAIN = "SIP-PRIVATE-VOTE-ENCRYPTION-V1";
|
|
18343
18353
|
var NONCE_SIZE2 = 24;
|
|
@@ -18387,9 +18397,9 @@ var PrivateVoting = class {
|
|
|
18387
18397
|
const ciphertext = cipher.encrypt(plaintext);
|
|
18388
18398
|
const keyHash = sha25621(hexToBytes24(encryptionKey.slice(2)));
|
|
18389
18399
|
return {
|
|
18390
|
-
ciphertext: `0x${
|
|
18391
|
-
nonce: `0x${
|
|
18392
|
-
encryptionKeyHash: `0x${
|
|
18400
|
+
ciphertext: `0x${bytesToHex37(ciphertext)}`,
|
|
18401
|
+
nonce: `0x${bytesToHex37(nonce)}`,
|
|
18402
|
+
encryptionKeyHash: `0x${bytesToHex37(keyHash)}`,
|
|
18393
18403
|
proposalId,
|
|
18394
18404
|
voter,
|
|
18395
18405
|
timestamp: voteData.timestamp
|
|
@@ -18436,7 +18446,7 @@ var PrivateVoting = class {
|
|
|
18436
18446
|
const derivedKey = this.deriveEncryptionKey(decryptionKey, vote.proposalId);
|
|
18437
18447
|
try {
|
|
18438
18448
|
const keyHash = sha25621(hexToBytes24(decryptionKey.slice(2)));
|
|
18439
|
-
const expectedKeyHash = `0x${
|
|
18449
|
+
const expectedKeyHash = `0x${bytesToHex37(keyHash)}`;
|
|
18440
18450
|
if (vote.encryptionKeyHash !== expectedKeyHash) {
|
|
18441
18451
|
throw new CryptoError(
|
|
18442
18452
|
"Decryption key hash mismatch - this key cannot decrypt this vote",
|
|
@@ -18698,8 +18708,8 @@ var PrivateVoting = class {
|
|
|
18698
18708
|
const blindingBytes = hexToBytes24(blinding.slice(2));
|
|
18699
18709
|
const ciphertext = cipher.encrypt(blindingBytes);
|
|
18700
18710
|
encryptedBlindings[choice] = {
|
|
18701
|
-
ciphertext: `0x${
|
|
18702
|
-
nonce: `0x${
|
|
18711
|
+
ciphertext: `0x${bytesToHex37(ciphertext)}`,
|
|
18712
|
+
nonce: `0x${bytesToHex37(nonce)}`
|
|
18703
18713
|
};
|
|
18704
18714
|
} finally {
|
|
18705
18715
|
secureWipe(derivedKey);
|
|
@@ -18807,7 +18817,7 @@ var PrivateVoting = class {
|
|
|
18807
18817
|
reconstructedKey[j] ^= shareBytes[j];
|
|
18808
18818
|
}
|
|
18809
18819
|
}
|
|
18810
|
-
const reconstructedKeyHex = `0x${
|
|
18820
|
+
const reconstructedKeyHex = `0x${bytesToHex37(reconstructedKey)}`;
|
|
18811
18821
|
const results = {};
|
|
18812
18822
|
for (const [choice, commitmentPoint] of Object.entries(tally.tallies)) {
|
|
18813
18823
|
const encBlinding = tally.encryptedBlindings[choice];
|
|
@@ -18828,7 +18838,7 @@ var PrivateVoting = class {
|
|
|
18828
18838
|
const ciphertextBytes = hexToBytes24(encBlinding.ciphertext.slice(2));
|
|
18829
18839
|
const cipher = xchacha20poly13054(derivedKey, nonceBytes);
|
|
18830
18840
|
const blindingBytes = cipher.decrypt(ciphertextBytes);
|
|
18831
|
-
blindingFactor = `0x${
|
|
18841
|
+
blindingFactor = `0x${bytesToHex37(blindingBytes)}`;
|
|
18832
18842
|
} catch (e) {
|
|
18833
18843
|
throw new CryptoError(
|
|
18834
18844
|
"failed to decrypt blinding factor",
|
|
@@ -19049,8 +19059,9 @@ function createPrivateVoting() {
|
|
|
19049
19059
|
|
|
19050
19060
|
// src/nft/private-nft.ts
|
|
19051
19061
|
import { sha256 as sha25622 } from "@noble/hashes/sha256";
|
|
19062
|
+
import { ed25519 as ed255192 } from "@noble/curves/ed25519";
|
|
19052
19063
|
import { secp256k1 as secp256k16 } from "@noble/curves/secp256k1";
|
|
19053
|
-
import { bytesToHex as
|
|
19064
|
+
import { bytesToHex as bytesToHex38, hexToBytes as hexToBytes25 } from "@noble/hashes/utils";
|
|
19054
19065
|
var PrivateNFT = class {
|
|
19055
19066
|
/**
|
|
19056
19067
|
* Create a private ownership record for an NFT
|
|
@@ -19141,9 +19152,9 @@ var PrivateNFT = class {
|
|
|
19141
19152
|
const signature = secp256k16.sign(messageHash, privateKeyBytes);
|
|
19142
19153
|
const zkProof = {
|
|
19143
19154
|
type: "ownership",
|
|
19144
|
-
proof: `0x${
|
|
19155
|
+
proof: `0x${bytesToHex38(signature.toCompactRawBytes())}`,
|
|
19145
19156
|
publicInputs: [
|
|
19146
|
-
`0x${
|
|
19157
|
+
`0x${bytesToHex38(messageHash)}`
|
|
19147
19158
|
]
|
|
19148
19159
|
};
|
|
19149
19160
|
const stealthHashBytes = sha25622(hexToBytes25(ownership.ownerStealth.address.slice(2)));
|
|
@@ -19152,7 +19163,7 @@ var PrivateNFT = class {
|
|
|
19152
19163
|
tokenId: ownership.tokenId,
|
|
19153
19164
|
challenge,
|
|
19154
19165
|
proof: zkProof,
|
|
19155
|
-
stealthHash: `0x${
|
|
19166
|
+
stealthHash: `0x${bytesToHex38(stealthHashBytes)}`,
|
|
19156
19167
|
timestamp: Date.now()
|
|
19157
19168
|
};
|
|
19158
19169
|
} catch (e) {
|
|
@@ -19298,7 +19309,7 @@ var PrivateNFT = class {
|
|
|
19298
19309
|
nftContract: nft.nftContract,
|
|
19299
19310
|
tokenId: nft.tokenId,
|
|
19300
19311
|
newOwnerStealth,
|
|
19301
|
-
previousOwnerHash: `0x${
|
|
19312
|
+
previousOwnerHash: `0x${bytesToHex38(previousOwnerHashBytes)}`,
|
|
19302
19313
|
chain: nft.chain,
|
|
19303
19314
|
timestamp: Date.now()
|
|
19304
19315
|
};
|
|
@@ -19365,8 +19376,9 @@ var PrivateNFT = class {
|
|
|
19365
19376
|
);
|
|
19366
19377
|
}
|
|
19367
19378
|
const ownedNFTs = [];
|
|
19368
|
-
const
|
|
19369
|
-
const
|
|
19379
|
+
const viewingKeyHex = `0x${bytesToHex38(viewingKey)}`;
|
|
19380
|
+
const ed25519SpendingPubHex = `0x${bytesToHex38(ed255192.getPublicKey(scanKey))}`;
|
|
19381
|
+
const secp256k1SpendingPubHex = `0x${bytesToHex38(secp256k16.getPublicKey(scanKey, true))}`;
|
|
19370
19382
|
for (const transfer of transfers) {
|
|
19371
19383
|
try {
|
|
19372
19384
|
if (!transfer || typeof transfer !== "object") {
|
|
@@ -19379,14 +19391,14 @@ var PrivateNFT = class {
|
|
|
19379
19391
|
if (isEd25519Chain(transfer.chain)) {
|
|
19380
19392
|
isOwned = checkEd25519StealthAddress(
|
|
19381
19393
|
transfer.newOwnerStealth,
|
|
19382
|
-
|
|
19383
|
-
|
|
19394
|
+
viewingKeyHex,
|
|
19395
|
+
ed25519SpendingPubHex
|
|
19384
19396
|
);
|
|
19385
19397
|
} else {
|
|
19386
19398
|
isOwned = checkStealthAddress(
|
|
19387
19399
|
transfer.newOwnerStealth,
|
|
19388
|
-
|
|
19389
|
-
|
|
19400
|
+
viewingKeyHex,
|
|
19401
|
+
secp256k1SpendingPubHex
|
|
19390
19402
|
);
|
|
19391
19403
|
}
|
|
19392
19404
|
if (isOwned) {
|
|
@@ -20804,7 +20816,7 @@ function createMockSolanaAdapter(config = {}) {
|
|
|
20804
20816
|
|
|
20805
20817
|
// src/wallet/solana/privacy-adapter.ts
|
|
20806
20818
|
import { sha256 as sha25623 } from "@noble/hashes/sha2";
|
|
20807
|
-
import { ed25519 as
|
|
20819
|
+
import { ed25519 as ed255193 } from "@noble/curves/ed25519";
|
|
20808
20820
|
var ED25519_ORDER = BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed");
|
|
20809
20821
|
|
|
20810
20822
|
// src/wallet/ethereum/adapter.ts
|
|
@@ -21379,9 +21391,12 @@ function createEthereumAdapter(config) {
|
|
|
21379
21391
|
}
|
|
21380
21392
|
|
|
21381
21393
|
// src/wallet/ethereum/privacy-adapter.ts
|
|
21382
|
-
import { sha256 as
|
|
21394
|
+
import { sha256 as sha25625 } from "@noble/hashes/sha2";
|
|
21395
|
+
import { secp256k1 as secp256k18 } from "@noble/curves/secp256k1";
|
|
21396
|
+
import { keccak_256 as keccak_2562 } from "@noble/hashes/sha3";
|
|
21397
|
+
|
|
21398
|
+
// src/chains/ethereum/stealth.ts
|
|
21383
21399
|
import { secp256k1 as secp256k17 } from "@noble/curves/secp256k1";
|
|
21384
|
-
import { keccak_256 } from "@noble/hashes/sha3";
|
|
21385
21400
|
|
|
21386
21401
|
// src/chains/ethereum/constants.ts
|
|
21387
21402
|
function getEnvVar(name, defaultValue) {
|
|
@@ -21899,9 +21914,9 @@ import { WalletErrorCode as WalletErrorCode14 } from "@sip-protocol/types";
|
|
|
21899
21914
|
import { WalletErrorCode as WalletErrorCode15 } from "@sip-protocol/types";
|
|
21900
21915
|
|
|
21901
21916
|
// src/wallet/near/adapter.ts
|
|
21902
|
-
import { ed25519 as
|
|
21903
|
-
import { sha256 as
|
|
21904
|
-
import { bytesToHex as
|
|
21917
|
+
import { ed25519 as ed255194 } from "@noble/curves/ed25519";
|
|
21918
|
+
import { sha256 as sha25626 } from "@noble/hashes/sha2";
|
|
21919
|
+
import { bytesToHex as bytesToHex40, hexToBytes as hexToBytes27 } from "@noble/hashes/utils";
|
|
21905
21920
|
import { WalletErrorCode as WalletErrorCode16 } from "@sip-protocol/types";
|
|
21906
21921
|
|
|
21907
21922
|
// src/chains/near/constants.ts
|
|
@@ -22017,11 +22032,11 @@ function deriveNEARStealthPrivateKey(stealthAddress, spendingPrivateKey, viewing
|
|
|
22017
22032
|
viewingPrivateKey
|
|
22018
22033
|
);
|
|
22019
22034
|
}
|
|
22020
|
-
function checkNEARStealthAddress(stealthAddress,
|
|
22035
|
+
function checkNEARStealthAddress(stealthAddress, viewingPrivateKey, spendingPublicKey) {
|
|
22021
22036
|
return checkEd25519StealthAddress(
|
|
22022
22037
|
stealthAddress,
|
|
22023
|
-
|
|
22024
|
-
|
|
22038
|
+
viewingPrivateKey,
|
|
22039
|
+
spendingPublicKey
|
|
22025
22040
|
);
|
|
22026
22041
|
}
|
|
22027
22042
|
function ed25519PublicKeyToImplicitAccount(publicKey) {
|
|
@@ -22105,13 +22120,13 @@ function validateNEARStealthAddress(stealthAddress) {
|
|
|
22105
22120
|
var ED25519_ORDER2 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
22106
22121
|
|
|
22107
22122
|
// src/wallet/near/wallet-selector.ts
|
|
22108
|
-
import { sha256 as
|
|
22109
|
-
import { bytesToHex as
|
|
22110
|
-
import { ed25519 as
|
|
22123
|
+
import { sha256 as sha25627 } from "@noble/hashes/sha2";
|
|
22124
|
+
import { bytesToHex as bytesToHex42, hexToBytes as hexToBytes29 } from "@noble/hashes/utils";
|
|
22125
|
+
import { ed25519 as ed255196 } from "@noble/curves/ed25519";
|
|
22111
22126
|
|
|
22112
22127
|
// src/chains/near/implicit-account.ts
|
|
22113
|
-
import { ed25519 as
|
|
22114
|
-
import { bytesToHex as
|
|
22128
|
+
import { ed25519 as ed255195 } from "@noble/curves/ed25519";
|
|
22129
|
+
import { bytesToHex as bytesToHex41, hexToBytes as hexToBytes28 } from "@noble/hashes/utils";
|
|
22115
22130
|
|
|
22116
22131
|
// src/chains/near/types.ts
|
|
22117
22132
|
function parseAnnouncement(memo) {
|
|
@@ -22149,15 +22164,15 @@ function createAnnouncementMemo(ephemeralPublicKey, viewTag) {
|
|
|
22149
22164
|
}
|
|
22150
22165
|
|
|
22151
22166
|
// src/wallet/near/my-near-wallet.ts
|
|
22152
|
-
import { sha256 as sha25627 } from "@noble/hashes/sha2";
|
|
22153
|
-
import { bytesToHex as bytesToHex41 } from "@noble/hashes/utils";
|
|
22154
|
-
import { ed25519 as ed255196 } from "@noble/curves/ed25519";
|
|
22155
|
-
|
|
22156
|
-
// src/wallet/near/meteor-wallet.ts
|
|
22157
22167
|
import { sha256 as sha25628 } from "@noble/hashes/sha2";
|
|
22158
|
-
import { bytesToHex as
|
|
22168
|
+
import { bytesToHex as bytesToHex43 } from "@noble/hashes/utils";
|
|
22159
22169
|
import { ed25519 as ed255197 } from "@noble/curves/ed25519";
|
|
22160
22170
|
|
|
22171
|
+
// src/wallet/near/meteor-wallet.ts
|
|
22172
|
+
import { sha256 as sha25629 } from "@noble/hashes/sha2";
|
|
22173
|
+
import { bytesToHex as bytesToHex44 } from "@noble/hashes/utils";
|
|
22174
|
+
import { ed25519 as ed255198 } from "@noble/curves/ed25519";
|
|
22175
|
+
|
|
22161
22176
|
// src/wallet/hardware/types.ts
|
|
22162
22177
|
var DerivationPath = {
|
|
22163
22178
|
/** Ethereum: m/44'/60'/0'/0/index */
|
|
@@ -22437,7 +22452,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
|
22437
22452
|
*/
|
|
22438
22453
|
async loadTransport() {
|
|
22439
22454
|
try {
|
|
22440
|
-
const module = await import("./TransportWebUSB-
|
|
22455
|
+
const module = await import("./TransportWebUSB-2KITI5HD.mjs");
|
|
22441
22456
|
return module.default;
|
|
22442
22457
|
} catch {
|
|
22443
22458
|
throw new HardwareWalletError(
|
|
@@ -22627,7 +22642,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
|
22627
22642
|
* @see https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/
|
|
22628
22643
|
*/
|
|
22629
22644
|
buildRawEthereumTx(tx) {
|
|
22630
|
-
const
|
|
22645
|
+
const hexToBytes35 = (hex) => {
|
|
22631
22646
|
if (!hex || hex === "0x" || hex === "0x0" || hex === "0x00") {
|
|
22632
22647
|
return new Uint8Array(0);
|
|
22633
22648
|
}
|
|
@@ -22644,21 +22659,21 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
|
22644
22659
|
const isEIP1559 = tx.maxFeePerGas !== void 0 && tx.maxPriorityFeePerGas !== void 0;
|
|
22645
22660
|
if (isEIP1559) {
|
|
22646
22661
|
const txData = [
|
|
22647
|
-
|
|
22662
|
+
hexToBytes35(`0x${tx.chainId.toString(16)}`),
|
|
22648
22663
|
// chainId
|
|
22649
|
-
|
|
22664
|
+
hexToBytes35(tx.nonce),
|
|
22650
22665
|
// nonce
|
|
22651
|
-
|
|
22666
|
+
hexToBytes35(tx.maxPriorityFeePerGas),
|
|
22652
22667
|
// maxPriorityFeePerGas
|
|
22653
|
-
|
|
22668
|
+
hexToBytes35(tx.maxFeePerGas),
|
|
22654
22669
|
// maxFeePerGas
|
|
22655
|
-
|
|
22670
|
+
hexToBytes35(tx.gasLimit),
|
|
22656
22671
|
// gasLimit
|
|
22657
|
-
|
|
22672
|
+
hexToBytes35(tx.to),
|
|
22658
22673
|
// to
|
|
22659
|
-
|
|
22674
|
+
hexToBytes35(tx.value),
|
|
22660
22675
|
// value
|
|
22661
|
-
|
|
22676
|
+
hexToBytes35(tx.data),
|
|
22662
22677
|
// data
|
|
22663
22678
|
[]
|
|
22664
22679
|
// accessList (empty)
|
|
@@ -22677,19 +22692,19 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
|
22677
22692
|
);
|
|
22678
22693
|
}
|
|
22679
22694
|
const txData = [
|
|
22680
|
-
|
|
22695
|
+
hexToBytes35(tx.nonce),
|
|
22681
22696
|
// nonce
|
|
22682
|
-
|
|
22697
|
+
hexToBytes35(tx.gasPrice),
|
|
22683
22698
|
// gasPrice
|
|
22684
|
-
|
|
22699
|
+
hexToBytes35(tx.gasLimit),
|
|
22685
22700
|
// gasLimit
|
|
22686
|
-
|
|
22701
|
+
hexToBytes35(tx.to),
|
|
22687
22702
|
// to
|
|
22688
|
-
|
|
22703
|
+
hexToBytes35(tx.value),
|
|
22689
22704
|
// value
|
|
22690
|
-
|
|
22705
|
+
hexToBytes35(tx.data),
|
|
22691
22706
|
// data
|
|
22692
|
-
|
|
22707
|
+
hexToBytes35(`0x${tx.chainId.toString(16)}`),
|
|
22693
22708
|
// v (chainId for EIP-155)
|
|
22694
22709
|
new Uint8Array(0),
|
|
22695
22710
|
// r (empty for unsigned)
|
|
@@ -22766,9 +22781,9 @@ function createLedgerAdapter(config) {
|
|
|
22766
22781
|
}
|
|
22767
22782
|
|
|
22768
22783
|
// src/wallet/hardware/ledger-privacy.ts
|
|
22769
|
-
import { secp256k1 as
|
|
22770
|
-
import { sha256 as
|
|
22771
|
-
import { bytesToHex as
|
|
22784
|
+
import { secp256k1 as secp256k19 } from "@noble/curves/secp256k1";
|
|
22785
|
+
import { sha256 as sha25630 } from "@noble/hashes/sha256";
|
|
22786
|
+
import { bytesToHex as bytesToHex45, hexToBytes as hexToBytes30 } from "@noble/hashes/utils";
|
|
22772
22787
|
import { WalletErrorCode as WalletErrorCode18 } from "@sip-protocol/types";
|
|
22773
22788
|
|
|
22774
22789
|
// src/wallet/hardware/trezor.ts
|
|
@@ -23211,7 +23226,7 @@ function createTrezorAdapter(config) {
|
|
|
23211
23226
|
|
|
23212
23227
|
// src/wallet/hardware/mock.ts
|
|
23213
23228
|
import { WalletErrorCode as WalletErrorCode20 } from "@sip-protocol/types";
|
|
23214
|
-
import { bytesToHex as
|
|
23229
|
+
import { bytesToHex as bytesToHex46, randomBytes as randomBytes18 } from "@noble/hashes/utils";
|
|
23215
23230
|
var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
23216
23231
|
chain;
|
|
23217
23232
|
name = "mock-ledger";
|
|
@@ -23458,13 +23473,13 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
23458
23473
|
generateMockAddress(index) {
|
|
23459
23474
|
const bytes = randomBytes18(20);
|
|
23460
23475
|
bytes[0] = index;
|
|
23461
|
-
return `0x${
|
|
23476
|
+
return `0x${bytesToHex46(bytes)}`;
|
|
23462
23477
|
}
|
|
23463
23478
|
generateMockPublicKey(index) {
|
|
23464
23479
|
const bytes = randomBytes18(33);
|
|
23465
23480
|
bytes[0] = 2;
|
|
23466
23481
|
bytes[1] = index;
|
|
23467
|
-
return `0x${
|
|
23482
|
+
return `0x${bytesToHex46(bytes)}`;
|
|
23468
23483
|
}
|
|
23469
23484
|
generateMockSignature(data) {
|
|
23470
23485
|
const sig = new Uint8Array(65);
|
|
@@ -23473,7 +23488,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
23473
23488
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 11;
|
|
23474
23489
|
}
|
|
23475
23490
|
sig[64] = 27;
|
|
23476
|
-
return `0x${
|
|
23491
|
+
return `0x${bytesToHex46(sig)}`;
|
|
23477
23492
|
}
|
|
23478
23493
|
delay(ms) {
|
|
23479
23494
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -23664,13 +23679,13 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
23664
23679
|
generateMockAddress(index) {
|
|
23665
23680
|
const bytes = randomBytes18(20);
|
|
23666
23681
|
bytes[0] = index + 100;
|
|
23667
|
-
return `0x${
|
|
23682
|
+
return `0x${bytesToHex46(bytes)}`;
|
|
23668
23683
|
}
|
|
23669
23684
|
generateMockPublicKey(index) {
|
|
23670
23685
|
const bytes = randomBytes18(33);
|
|
23671
23686
|
bytes[0] = 3;
|
|
23672
23687
|
bytes[1] = index + 100;
|
|
23673
|
-
return `0x${
|
|
23688
|
+
return `0x${bytesToHex46(bytes)}`;
|
|
23674
23689
|
}
|
|
23675
23690
|
generateMockSignature(data) {
|
|
23676
23691
|
const sig = new Uint8Array(65);
|
|
@@ -23679,7 +23694,7 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
23679
23694
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 17;
|
|
23680
23695
|
}
|
|
23681
23696
|
sig[64] = 28;
|
|
23682
|
-
return `0x${
|
|
23697
|
+
return `0x${bytesToHex46(sig)}`;
|
|
23683
23698
|
}
|
|
23684
23699
|
delay(ms) {
|
|
23685
23700
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -24303,9 +24318,9 @@ var SolanaNoirVerifier = class {
|
|
|
24303
24318
|
return vkeyBytes;
|
|
24304
24319
|
}
|
|
24305
24320
|
async hashBytes(bytes) {
|
|
24306
|
-
const { sha256:
|
|
24307
|
-
const { bytesToHex:
|
|
24308
|
-
return
|
|
24321
|
+
const { sha256: sha25635 } = await import("@noble/hashes/sha256");
|
|
24322
|
+
const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
|
|
24323
|
+
return bytesToHex57(sha25635(bytes));
|
|
24309
24324
|
}
|
|
24310
24325
|
hexToBytes(hex) {
|
|
24311
24326
|
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
@@ -24349,7 +24364,7 @@ import {
|
|
|
24349
24364
|
Transaction as Transaction2,
|
|
24350
24365
|
SystemProgram
|
|
24351
24366
|
} from "@solana/web3.js";
|
|
24352
|
-
import { bytesToHex as
|
|
24367
|
+
import { bytesToHex as bytesToHex47 } from "@noble/hashes/utils";
|
|
24353
24368
|
var JITO_BLOCK_ENGINES = {
|
|
24354
24369
|
mainnet: {
|
|
24355
24370
|
amsterdam: "https://amsterdam.mainnet.block-engine.jito.wtf/api/v1",
|
|
@@ -24469,7 +24484,7 @@ var JitoRelayer = class {
|
|
|
24469
24484
|
}
|
|
24470
24485
|
const signatures = bundleTransactions.map((tx) => {
|
|
24471
24486
|
if (tx instanceof VersionedTransaction2) {
|
|
24472
|
-
return
|
|
24487
|
+
return bytesToHex47(tx.signatures[0]);
|
|
24473
24488
|
} else {
|
|
24474
24489
|
return tx.signature?.toString() ?? "";
|
|
24475
24490
|
}
|
|
@@ -24508,7 +24523,7 @@ var JitoRelayer = class {
|
|
|
24508
24523
|
const bundleId = await this.sendBundle([serializedTx]);
|
|
24509
24524
|
let signature;
|
|
24510
24525
|
if (request.transaction instanceof VersionedTransaction2) {
|
|
24511
|
-
signature =
|
|
24526
|
+
signature = bytesToHex47(request.transaction.signatures[0]);
|
|
24512
24527
|
} else {
|
|
24513
24528
|
signature = request.transaction.signature?.toString() ?? "";
|
|
24514
24529
|
}
|
|
@@ -24731,11 +24746,11 @@ function createMainnetRelayer(rpcUrl) {
|
|
|
24731
24746
|
}
|
|
24732
24747
|
|
|
24733
24748
|
// src/chains/near/commitment.ts
|
|
24734
|
-
import { ed25519 as
|
|
24735
|
-
import { sha256 as
|
|
24736
|
-
import { bytesToHex as
|
|
24749
|
+
import { ed25519 as ed255199 } from "@noble/curves/ed25519";
|
|
24750
|
+
import { sha256 as sha25631 } from "@noble/hashes/sha2";
|
|
24751
|
+
import { bytesToHex as bytesToHex48, randomBytes as randomBytes19 } from "@noble/hashes/utils";
|
|
24737
24752
|
var H_DOMAIN = "SIP-NEAR-PEDERSEN-GENERATOR-H-v1";
|
|
24738
|
-
var G =
|
|
24753
|
+
var G = ed255199.ExtendedPoint.BASE;
|
|
24739
24754
|
var ED25519_ORDER3 = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
24740
24755
|
var ED25519_COFACTOR = 8n;
|
|
24741
24756
|
var MAX_NEAR_AMOUNT = 2n ** 128n - 1n;
|
|
@@ -24745,14 +24760,14 @@ function generateH() {
|
|
|
24745
24760
|
let counter = 0;
|
|
24746
24761
|
while (counter < 256) {
|
|
24747
24762
|
const input = new TextEncoder().encode(`${H_DOMAIN}:${counter}`);
|
|
24748
|
-
const hashBytes =
|
|
24763
|
+
const hashBytes = sha25631(input);
|
|
24749
24764
|
try {
|
|
24750
|
-
const rawPoint =
|
|
24765
|
+
const rawPoint = ed255199.ExtendedPoint.fromHex(hashBytes);
|
|
24751
24766
|
const point = rawPoint.multiply(ED25519_COFACTOR);
|
|
24752
|
-
if (!point.equals(
|
|
24767
|
+
if (!point.equals(ed255199.ExtendedPoint.ZERO)) {
|
|
24753
24768
|
const gBytes = G.toRawBytes();
|
|
24754
24769
|
const hBytes = point.toRawBytes();
|
|
24755
|
-
if (
|
|
24770
|
+
if (bytesToHex48(gBytes) !== bytesToHex48(hBytes)) {
|
|
24756
24771
|
return point;
|
|
24757
24772
|
}
|
|
24758
24773
|
}
|
|
@@ -24782,7 +24797,7 @@ function bigIntToBytes(n, length) {
|
|
|
24782
24797
|
}
|
|
24783
24798
|
return result;
|
|
24784
24799
|
}
|
|
24785
|
-
function
|
|
24800
|
+
function hexToBytes31(hex) {
|
|
24786
24801
|
const result = new Uint8Array(hex.length / 2);
|
|
24787
24802
|
for (let i = 0; i < hex.length; i += 2) {
|
|
24788
24803
|
result[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
|
@@ -24821,15 +24836,15 @@ function commitNEAR(value, blinding) {
|
|
|
24821
24836
|
}
|
|
24822
24837
|
const rScalarBytes = bigIntToBytes(rScalar, 32);
|
|
24823
24838
|
return {
|
|
24824
|
-
commitment: `0x${
|
|
24825
|
-
blinding: `0x${
|
|
24839
|
+
commitment: `0x${bytesToHex48(C.toRawBytes())}`,
|
|
24840
|
+
blinding: `0x${bytesToHex48(rScalarBytes)}`
|
|
24826
24841
|
};
|
|
24827
24842
|
}
|
|
24828
24843
|
function verifyOpeningNEAR(commitment, value, blinding) {
|
|
24829
24844
|
try {
|
|
24830
|
-
const commitmentBytes =
|
|
24831
|
-
const C =
|
|
24832
|
-
const blindingBytes =
|
|
24845
|
+
const commitmentBytes = hexToBytes31(commitment.slice(2));
|
|
24846
|
+
const C = ed255199.ExtendedPoint.fromHex(commitmentBytes);
|
|
24847
|
+
const blindingBytes = hexToBytes31(blinding.slice(2));
|
|
24833
24848
|
const rScalar = bytesToBigInt(blindingBytes) % ED25519_ORDER3;
|
|
24834
24849
|
let expected;
|
|
24835
24850
|
if (value === 0n) {
|
|
@@ -24904,18 +24919,18 @@ function addCommitmentsNEAR(c1, c2) {
|
|
|
24904
24919
|
let point1;
|
|
24905
24920
|
let point2;
|
|
24906
24921
|
try {
|
|
24907
|
-
point1 =
|
|
24922
|
+
point1 = ed255199.ExtendedPoint.fromHex(hexToBytes31(c1.slice(2)));
|
|
24908
24923
|
} catch {
|
|
24909
24924
|
throw new ValidationError("must be a valid ed25519 point", "c1");
|
|
24910
24925
|
}
|
|
24911
24926
|
try {
|
|
24912
|
-
point2 =
|
|
24927
|
+
point2 = ed255199.ExtendedPoint.fromHex(hexToBytes31(c2.slice(2)));
|
|
24913
24928
|
} catch {
|
|
24914
24929
|
throw new ValidationError("must be a valid ed25519 point", "c2");
|
|
24915
24930
|
}
|
|
24916
24931
|
const sum = point1.add(point2);
|
|
24917
24932
|
return {
|
|
24918
|
-
commitment: `0x${
|
|
24933
|
+
commitment: `0x${bytesToHex48(sum.toRawBytes())}`
|
|
24919
24934
|
};
|
|
24920
24935
|
}
|
|
24921
24936
|
function subtractCommitmentsNEAR(c1, c2) {
|
|
@@ -24928,23 +24943,23 @@ function subtractCommitmentsNEAR(c1, c2) {
|
|
|
24928
24943
|
let point1;
|
|
24929
24944
|
let point2;
|
|
24930
24945
|
try {
|
|
24931
|
-
point1 =
|
|
24946
|
+
point1 = ed255199.ExtendedPoint.fromHex(hexToBytes31(c1.slice(2)));
|
|
24932
24947
|
} catch {
|
|
24933
24948
|
throw new ValidationError("must be a valid ed25519 point", "c1");
|
|
24934
24949
|
}
|
|
24935
24950
|
try {
|
|
24936
|
-
point2 =
|
|
24951
|
+
point2 = ed255199.ExtendedPoint.fromHex(hexToBytes31(c2.slice(2)));
|
|
24937
24952
|
} catch {
|
|
24938
24953
|
throw new ValidationError("must be a valid ed25519 point", "c2");
|
|
24939
24954
|
}
|
|
24940
24955
|
const diff = point1.subtract(point2);
|
|
24941
|
-
if (diff.equals(
|
|
24956
|
+
if (diff.equals(ed255199.ExtendedPoint.ZERO)) {
|
|
24942
24957
|
return {
|
|
24943
24958
|
commitment: "0x" + "00".repeat(32)
|
|
24944
24959
|
};
|
|
24945
24960
|
}
|
|
24946
24961
|
return {
|
|
24947
|
-
commitment: `0x${
|
|
24962
|
+
commitment: `0x${bytesToHex48(diff.toRawBytes())}`
|
|
24948
24963
|
};
|
|
24949
24964
|
}
|
|
24950
24965
|
function addBlindingsNEAR(b1, b2) {
|
|
@@ -24954,13 +24969,13 @@ function addBlindingsNEAR(b1, b2) {
|
|
|
24954
24969
|
if (!isValidHex(b2)) {
|
|
24955
24970
|
throw new ValidationError("must be a valid hex string", "b2");
|
|
24956
24971
|
}
|
|
24957
|
-
const b1Bytes =
|
|
24958
|
-
const b2Bytes =
|
|
24972
|
+
const b1Bytes = hexToBytes31(b1.slice(2));
|
|
24973
|
+
const b2Bytes = hexToBytes31(b2.slice(2));
|
|
24959
24974
|
const b1Scalar = bytesToBigInt(b1Bytes);
|
|
24960
24975
|
const b2Scalar = bytesToBigInt(b2Bytes);
|
|
24961
24976
|
const sum = (b1Scalar + b2Scalar) % ED25519_ORDER3;
|
|
24962
24977
|
const sumBytes = bigIntToBytes(sum, 32);
|
|
24963
|
-
return `0x${
|
|
24978
|
+
return `0x${bytesToHex48(sumBytes)}`;
|
|
24964
24979
|
}
|
|
24965
24980
|
function subtractBlindingsNEAR(b1, b2) {
|
|
24966
24981
|
if (!isValidHex(b1)) {
|
|
@@ -24969,18 +24984,18 @@ function subtractBlindingsNEAR(b1, b2) {
|
|
|
24969
24984
|
if (!isValidHex(b2)) {
|
|
24970
24985
|
throw new ValidationError("must be a valid hex string", "b2");
|
|
24971
24986
|
}
|
|
24972
|
-
const b1Bytes =
|
|
24973
|
-
const b2Bytes =
|
|
24987
|
+
const b1Bytes = hexToBytes31(b1.slice(2));
|
|
24988
|
+
const b2Bytes = hexToBytes31(b2.slice(2));
|
|
24974
24989
|
const b1Scalar = bytesToBigInt(b1Bytes);
|
|
24975
24990
|
const b2Scalar = bytesToBigInt(b2Bytes);
|
|
24976
24991
|
const diff = (b1Scalar - b2Scalar + ED25519_ORDER3) % ED25519_ORDER3;
|
|
24977
24992
|
const diffBytes = bigIntToBytes(diff, 32);
|
|
24978
|
-
return `0x${
|
|
24993
|
+
return `0x${bytesToHex48(diffBytes)}`;
|
|
24979
24994
|
}
|
|
24980
24995
|
function getGeneratorsNEAR() {
|
|
24981
24996
|
return {
|
|
24982
|
-
G: `0x${
|
|
24983
|
-
H: `0x${
|
|
24997
|
+
G: `0x${bytesToHex48(G.toRawBytes())}`,
|
|
24998
|
+
H: `0x${bytesToHex48(H.toRawBytes())}`
|
|
24984
24999
|
};
|
|
24985
25000
|
}
|
|
24986
25001
|
function generateBlindingNEAR() {
|
|
@@ -24990,15 +25005,15 @@ function generateBlindingNEAR() {
|
|
|
24990
25005
|
return generateBlindingNEAR();
|
|
24991
25006
|
}
|
|
24992
25007
|
const scalarBytes = bigIntToBytes(scalar, 32);
|
|
24993
|
-
return `0x${
|
|
25008
|
+
return `0x${bytesToHex48(scalarBytes)}`;
|
|
24994
25009
|
}
|
|
24995
25010
|
|
|
24996
25011
|
// src/chains/near/viewing-key.ts
|
|
24997
|
-
import { ed25519 as
|
|
24998
|
-
import { sha256 as
|
|
25012
|
+
import { ed25519 as ed2551910 } from "@noble/curves/ed25519";
|
|
25013
|
+
import { sha256 as sha25632 } from "@noble/hashes/sha256";
|
|
24999
25014
|
import { hmac as hmac4 } from "@noble/hashes/hmac";
|
|
25000
25015
|
import { hkdf as hkdf4 } from "@noble/hashes/hkdf";
|
|
25001
|
-
import { bytesToHex as
|
|
25016
|
+
import { bytesToHex as bytesToHex49, hexToBytes as hexToBytes32, randomBytes as randomBytes20, utf8ToBytes as utf8ToBytes7 } from "@noble/hashes/utils";
|
|
25002
25017
|
import { xchacha20poly1305 as xchacha20poly13055 } from "@noble/ciphers/chacha.js";
|
|
25003
25018
|
var VIEWING_KEY_CONTEXT = "SIP-NEAR-viewing-key-v1";
|
|
25004
25019
|
var ENCRYPTION_DOMAIN2 = "SIP-NEAR-VIEWING-KEY-ENCRYPTION-V1";
|
|
@@ -25011,7 +25026,7 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
25011
25026
|
"spendingPrivateKey"
|
|
25012
25027
|
);
|
|
25013
25028
|
}
|
|
25014
|
-
const spendingBytes =
|
|
25029
|
+
const spendingBytes = hexToBytes32(spendingPrivateKey.slice(2));
|
|
25015
25030
|
if (spendingBytes.length !== 32) {
|
|
25016
25031
|
throw new ValidationError(
|
|
25017
25032
|
"spendingPrivateKey must be 32 bytes",
|
|
@@ -25021,16 +25036,16 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
25021
25036
|
let viewingPrivateBytes = null;
|
|
25022
25037
|
try {
|
|
25023
25038
|
viewingPrivateBytes = hmac4(
|
|
25024
|
-
|
|
25039
|
+
sha25632,
|
|
25025
25040
|
utf8ToBytes7(VIEWING_KEY_CONTEXT),
|
|
25026
25041
|
spendingBytes
|
|
25027
25042
|
);
|
|
25028
|
-
const viewingPublicBytes =
|
|
25029
|
-
const hashBytes =
|
|
25043
|
+
const viewingPublicBytes = ed2551910.getPublicKey(viewingPrivateBytes);
|
|
25044
|
+
const hashBytes = sha25632(viewingPublicBytes);
|
|
25030
25045
|
return {
|
|
25031
|
-
privateKey: `0x${
|
|
25032
|
-
publicKey: `0x${
|
|
25033
|
-
hash: `0x${
|
|
25046
|
+
privateKey: `0x${bytesToHex49(viewingPrivateBytes)}`,
|
|
25047
|
+
publicKey: `0x${bytesToHex49(viewingPublicBytes)}`,
|
|
25048
|
+
hash: `0x${bytesToHex49(hashBytes)}`,
|
|
25034
25049
|
label,
|
|
25035
25050
|
createdAt: Date.now()
|
|
25036
25051
|
};
|
|
@@ -25042,12 +25057,12 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
|
|
|
25042
25057
|
function generateRandomNEARViewingKey(label) {
|
|
25043
25058
|
const privateBytes = randomBytes20(32);
|
|
25044
25059
|
try {
|
|
25045
|
-
const publicBytes =
|
|
25046
|
-
const hashBytes =
|
|
25060
|
+
const publicBytes = ed2551910.getPublicKey(privateBytes);
|
|
25061
|
+
const hashBytes = sha25632(publicBytes);
|
|
25047
25062
|
return {
|
|
25048
|
-
privateKey: `0x${
|
|
25049
|
-
publicKey: `0x${
|
|
25050
|
-
hash: `0x${
|
|
25063
|
+
privateKey: `0x${bytesToHex49(privateBytes)}`,
|
|
25064
|
+
publicKey: `0x${bytesToHex49(publicBytes)}`,
|
|
25065
|
+
hash: `0x${bytesToHex49(hashBytes)}`,
|
|
25051
25066
|
label,
|
|
25052
25067
|
createdAt: Date.now()
|
|
25053
25068
|
};
|
|
@@ -25062,15 +25077,15 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
|
|
|
25062
25077
|
"viewingPublicKey"
|
|
25063
25078
|
);
|
|
25064
25079
|
}
|
|
25065
|
-
const publicBytes =
|
|
25080
|
+
const publicBytes = hexToBytes32(viewingPublicKey.slice(2));
|
|
25066
25081
|
if (publicBytes.length !== 32) {
|
|
25067
25082
|
throw new ValidationError(
|
|
25068
25083
|
"viewingPublicKey must be 32 bytes",
|
|
25069
25084
|
"viewingPublicKey"
|
|
25070
25085
|
);
|
|
25071
25086
|
}
|
|
25072
|
-
const hashBytes =
|
|
25073
|
-
return `0x${
|
|
25087
|
+
const hashBytes = sha25632(publicBytes);
|
|
25088
|
+
return `0x${bytesToHex49(hashBytes)}`;
|
|
25074
25089
|
}
|
|
25075
25090
|
function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
25076
25091
|
if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
|
|
@@ -25079,7 +25094,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
25079
25094
|
"viewingPrivateKey"
|
|
25080
25095
|
);
|
|
25081
25096
|
}
|
|
25082
|
-
const privateBytes =
|
|
25097
|
+
const privateBytes = hexToBytes32(viewingPrivateKey.slice(2));
|
|
25083
25098
|
if (privateBytes.length !== 32) {
|
|
25084
25099
|
throw new ValidationError(
|
|
25085
25100
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -25087,9 +25102,9 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
|
|
|
25087
25102
|
);
|
|
25088
25103
|
}
|
|
25089
25104
|
try {
|
|
25090
|
-
const publicBytes =
|
|
25091
|
-
const hashBytes =
|
|
25092
|
-
return `0x${
|
|
25105
|
+
const publicBytes = ed2551910.getPublicKey(privateBytes);
|
|
25106
|
+
const hashBytes = sha25632(publicBytes);
|
|
25107
|
+
return `0x${bytesToHex49(hashBytes)}`;
|
|
25093
25108
|
} finally {
|
|
25094
25109
|
secureWipe(privateBytes);
|
|
25095
25110
|
}
|
|
@@ -25136,9 +25151,9 @@ function importNEARViewingKey(exported) {
|
|
|
25136
25151
|
{ expected: computedHash, received: exported.hash }
|
|
25137
25152
|
);
|
|
25138
25153
|
}
|
|
25139
|
-
const privateBytes =
|
|
25154
|
+
const privateBytes = hexToBytes32(exported.privateKey.slice(2));
|
|
25140
25155
|
try {
|
|
25141
|
-
const derivedPublic = `0x${
|
|
25156
|
+
const derivedPublic = `0x${bytesToHex49(ed2551910.getPublicKey(privateBytes))}`;
|
|
25142
25157
|
if (derivedPublic !== exported.publicKey) {
|
|
25143
25158
|
throw new ValidationError(
|
|
25144
25159
|
"Public key does not match private key",
|
|
@@ -25157,10 +25172,10 @@ function importNEARViewingKey(exported) {
|
|
|
25157
25172
|
};
|
|
25158
25173
|
}
|
|
25159
25174
|
function deriveEncryptionKey2(key, salt) {
|
|
25160
|
-
const keyBytes =
|
|
25175
|
+
const keyBytes = hexToBytes32(key.slice(2));
|
|
25161
25176
|
try {
|
|
25162
25177
|
const hkdfSalt = salt ?? utf8ToBytes7(ENCRYPTION_DOMAIN2);
|
|
25163
|
-
return hkdf4(
|
|
25178
|
+
return hkdf4(sha25632, keyBytes, hkdfSalt, utf8ToBytes7("encryption"), 32);
|
|
25164
25179
|
} finally {
|
|
25165
25180
|
secureWipe(keyBytes);
|
|
25166
25181
|
}
|
|
@@ -25173,8 +25188,8 @@ function encryptForNEARViewing(data, viewingKey) {
|
|
|
25173
25188
|
const cipher = xchacha20poly13055(encKey, nonce);
|
|
25174
25189
|
const ciphertext = cipher.encrypt(plaintext);
|
|
25175
25190
|
return {
|
|
25176
|
-
ciphertext: `0x${
|
|
25177
|
-
nonce: `0x${
|
|
25191
|
+
ciphertext: `0x${bytesToHex49(ciphertext)}`,
|
|
25192
|
+
nonce: `0x${bytesToHex49(nonce)}`,
|
|
25178
25193
|
viewingKeyHash: viewingKey.hash
|
|
25179
25194
|
};
|
|
25180
25195
|
} finally {
|
|
@@ -25191,8 +25206,8 @@ function decryptWithNEARViewing(encrypted, viewingKey) {
|
|
|
25191
25206
|
}
|
|
25192
25207
|
const encKey = deriveEncryptionKey2(viewingKey.privateKey);
|
|
25193
25208
|
try {
|
|
25194
|
-
const ciphertext =
|
|
25195
|
-
const nonce =
|
|
25209
|
+
const ciphertext = hexToBytes32(encrypted.ciphertext.slice(2));
|
|
25210
|
+
const nonce = hexToBytes32(encrypted.nonce.slice(2));
|
|
25196
25211
|
if (nonce.length !== NONCE_SIZE3) {
|
|
25197
25212
|
throw new ValidationError(
|
|
25198
25213
|
`Invalid nonce length: ${nonce.length}. Expected: ${NONCE_SIZE3}`,
|
|
@@ -25242,15 +25257,15 @@ function deriveNEARChildViewingKey(parentKey, childPath, label) {
|
|
|
25242
25257
|
if (!childPath || typeof childPath !== "string") {
|
|
25243
25258
|
throw new ValidationError("childPath must be a non-empty string", "childPath");
|
|
25244
25259
|
}
|
|
25245
|
-
const parentBytes =
|
|
25260
|
+
const parentBytes = hexToBytes32(parentKey.privateKey.slice(2));
|
|
25246
25261
|
try {
|
|
25247
|
-
const childBytes = hmac4(
|
|
25248
|
-
const publicBytes =
|
|
25249
|
-
const hashBytes =
|
|
25262
|
+
const childBytes = hmac4(sha25632, utf8ToBytes7(childPath), parentBytes);
|
|
25263
|
+
const publicBytes = ed2551910.getPublicKey(childBytes);
|
|
25264
|
+
const hashBytes = sha25632(publicBytes);
|
|
25250
25265
|
const result = {
|
|
25251
|
-
privateKey: `0x${
|
|
25252
|
-
publicKey: `0x${
|
|
25253
|
-
hash: `0x${
|
|
25266
|
+
privateKey: `0x${bytesToHex49(childBytes)}`,
|
|
25267
|
+
publicKey: `0x${bytesToHex49(publicBytes)}`,
|
|
25268
|
+
hash: `0x${bytesToHex49(hashBytes)}`,
|
|
25254
25269
|
label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
|
|
25255
25270
|
createdAt: Date.now()
|
|
25256
25271
|
};
|
|
@@ -25267,7 +25282,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
|
|
|
25267
25282
|
"viewingPrivateKey"
|
|
25268
25283
|
);
|
|
25269
25284
|
}
|
|
25270
|
-
const privateBytes =
|
|
25285
|
+
const privateBytes = hexToBytes32(viewingPrivateKey.slice(2));
|
|
25271
25286
|
if (privateBytes.length !== 32) {
|
|
25272
25287
|
throw new ValidationError(
|
|
25273
25288
|
"viewingPrivateKey must be 32 bytes",
|
|
@@ -25275,8 +25290,8 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
|
|
|
25275
25290
|
);
|
|
25276
25291
|
}
|
|
25277
25292
|
try {
|
|
25278
|
-
const publicBytes =
|
|
25279
|
-
return `0x${
|
|
25293
|
+
const publicBytes = ed2551910.getPublicKey(privateBytes);
|
|
25294
|
+
return `0x${bytesToHex49(publicBytes)}`;
|
|
25280
25295
|
} finally {
|
|
25281
25296
|
secureWipe(privateBytes);
|
|
25282
25297
|
}
|
|
@@ -25311,9 +25326,9 @@ function validateNEARViewingKey(viewingKey) {
|
|
|
25311
25326
|
{ expected: computedHash, received: viewingKey.hash }
|
|
25312
25327
|
);
|
|
25313
25328
|
}
|
|
25314
|
-
const privateBytes =
|
|
25329
|
+
const privateBytes = hexToBytes32(viewingKey.privateKey.slice(2));
|
|
25315
25330
|
try {
|
|
25316
|
-
const derivedPublic = `0x${
|
|
25331
|
+
const derivedPublic = `0x${bytesToHex49(ed2551910.getPublicKey(privateBytes))}`;
|
|
25317
25332
|
if (derivedPublic !== viewingKey.publicKey) {
|
|
25318
25333
|
throw new ValidationError(
|
|
25319
25334
|
"publicKey does not match privateKey",
|
|
@@ -25327,7 +25342,11 @@ function validateNEARViewingKey(viewingKey) {
|
|
|
25327
25342
|
}
|
|
25328
25343
|
|
|
25329
25344
|
// src/chains/near/resolver.ts
|
|
25330
|
-
import {
|
|
25345
|
+
import { ed25519 as ed2551911 } from "@noble/curves/ed25519";
|
|
25346
|
+
import { bytesToHex as bytesToHex50, hexToBytes as hexToBytes33 } from "@noble/hashes/utils";
|
|
25347
|
+
function nearSpendingPublicFromPrivate(spendingPrivateKey) {
|
|
25348
|
+
return `0x${bytesToHex50(ed2551911.getPublicKey(hexToBytes33(spendingPrivateKey.slice(2))))}`;
|
|
25349
|
+
}
|
|
25331
25350
|
function createNEARAnnouncementCache() {
|
|
25332
25351
|
const entries = [];
|
|
25333
25352
|
return {
|
|
@@ -25573,11 +25592,11 @@ var NEARStealthScanner = class {
|
|
|
25573
25592
|
try {
|
|
25574
25593
|
const isMatch = checkNEARStealthAddress(
|
|
25575
25594
|
stealthAddressToCheck,
|
|
25576
|
-
recipient.
|
|
25577
|
-
recipient.
|
|
25595
|
+
recipient.viewingPrivateKey,
|
|
25596
|
+
nearSpendingPublicFromPrivate(recipient.spendingPrivateKey)
|
|
25578
25597
|
);
|
|
25579
25598
|
if (isMatch) {
|
|
25580
|
-
const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress :
|
|
25599
|
+
const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : bytesToHex50(hexToBytes33(stealthPublicKey.slice(2)));
|
|
25581
25600
|
let amount = metadata?.amount ?? 0n;
|
|
25582
25601
|
if (amount === 0n && isImplicitAccount(stealthAddress)) {
|
|
25583
25602
|
try {
|
|
@@ -25659,8 +25678,8 @@ var NEARStealthScanner = class {
|
|
|
25659
25678
|
try {
|
|
25660
25679
|
return checkNEARStealthAddress(
|
|
25661
25680
|
stealthAddressToCheck,
|
|
25662
|
-
|
|
25663
|
-
|
|
25681
|
+
viewingPrivateKey,
|
|
25682
|
+
nearSpendingPublicFromPrivate(spendingPrivateKey)
|
|
25664
25683
|
);
|
|
25665
25684
|
} catch {
|
|
25666
25685
|
return false;
|
|
@@ -25700,8 +25719,8 @@ var NEARStealthScanner = class {
|
|
|
25700
25719
|
try {
|
|
25701
25720
|
const isMatch = checkNEARStealthAddress(
|
|
25702
25721
|
stealthAddressToCheck,
|
|
25703
|
-
recipient.
|
|
25704
|
-
recipient.
|
|
25722
|
+
recipient.viewingPrivateKey,
|
|
25723
|
+
nearSpendingPublicFromPrivate(recipient.spendingPrivateKey)
|
|
25705
25724
|
);
|
|
25706
25725
|
if (isMatch) {
|
|
25707
25726
|
matches.set(announcement.stealthAddress, recipient.label);
|
|
@@ -27937,7 +27956,7 @@ function createPrivacyLogger(moduleName, config = {}) {
|
|
|
27937
27956
|
}
|
|
27938
27957
|
|
|
27939
27958
|
// src/privacy-backends/privacycash.ts
|
|
27940
|
-
import { randomBytes as randomBytes21, bytesToHex as
|
|
27959
|
+
import { randomBytes as randomBytes21, bytesToHex as bytesToHex51 } from "@noble/hashes/utils";
|
|
27941
27960
|
var privacyCashLogger = createPrivacyLogger("PrivacyCash");
|
|
27942
27961
|
var DEFAULT_ANONYMITY_SET = 50;
|
|
27943
27962
|
var BASE_COST_LAMPORTS = BigInt(1e7);
|
|
@@ -27973,7 +27992,7 @@ import {
|
|
|
27973
27992
|
InvalidAmountError,
|
|
27974
27993
|
InvalidAddressError
|
|
27975
27994
|
} from "@radr/shadowwire";
|
|
27976
|
-
import { bytesToHex as
|
|
27995
|
+
import { bytesToHex as bytesToHex52 } from "@noble/hashes/utils";
|
|
27977
27996
|
var SHADOWWIRE_TOKEN_MINTS = {
|
|
27978
27997
|
SOL: "So11111111111111111111111111111111111111112",
|
|
27979
27998
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
@@ -28003,8 +28022,14 @@ var SHADOWWIRE_TOKEN_MINTS = {
|
|
|
28003
28022
|
// Placeholder - USD1 stablecoin
|
|
28004
28023
|
AOL: "AOLexampleaddress11111111111111111111111111",
|
|
28005
28024
|
// Placeholder
|
|
28006
|
-
IQLABS: "IQLABSexampleaddress111111111111111111111"
|
|
28025
|
+
IQLABS: "IQLABSexampleaddress111111111111111111111",
|
|
28007
28026
|
// Placeholder - IQ Labs token
|
|
28027
|
+
// Added in @radr/shadowwire@1.1.15 — real mints verified against the package's TOKEN_MINTS
|
|
28028
|
+
SANA: "5dpN5wMH8j8au29Rp91qn4WfNq6t6xJfcjQNcFeDJ8Ct",
|
|
28029
|
+
POKI: "6vK6cL9C66Bsqw7SC2hcCdkgm1UKBDUE6DCYJ4kubonk",
|
|
28030
|
+
RAIN: "3iC63FgnB7EhcPaiSaC51UkVweeBDkqu17SaRyy2pump",
|
|
28031
|
+
HOSICO: "Dx2bQe2UPv4k3BmcW8G2KhaL5oKsxduM5XxLSV3Sbonk",
|
|
28032
|
+
SKR: "SKRbvo6Gf7GondiT3BbTfuRDPqLWei4j2Qy2NPGZhW3"
|
|
28008
28033
|
};
|
|
28009
28034
|
var MINT_TO_SYMBOL = Object.fromEntries(
|
|
28010
28035
|
Object.entries(SHADOWWIRE_TOKEN_MINTS).map(([symbol, mint]) => [mint, symbol])
|
|
@@ -28037,7 +28062,7 @@ import {
|
|
|
28037
28062
|
PublicKey as PublicKey4,
|
|
28038
28063
|
Transaction as Transaction3
|
|
28039
28064
|
} from "@solana/web3.js";
|
|
28040
|
-
import { bytesToHex as
|
|
28065
|
+
import { bytesToHex as bytesToHex53 } from "@noble/hashes/utils";
|
|
28041
28066
|
var magicBlockLogger = createPrivacyLogger("MagicBlock");
|
|
28042
28067
|
|
|
28043
28068
|
// src/privacy-backends/cspl-types.ts
|
|
@@ -28725,8 +28750,8 @@ var CSPLClient = class {
|
|
|
28725
28750
|
};
|
|
28726
28751
|
|
|
28727
28752
|
// src/privacy-backends/private-swap.ts
|
|
28728
|
-
import { sha256 as
|
|
28729
|
-
import { bytesToHex as
|
|
28753
|
+
import { sha256 as sha25633 } from "@noble/hashes/sha256";
|
|
28754
|
+
import { bytesToHex as bytesToHex54 } from "@noble/hashes/utils";
|
|
28730
28755
|
|
|
28731
28756
|
// src/privacy-backends/cspl-token.ts
|
|
28732
28757
|
var CSPLTokenService = class {
|
|
@@ -31429,9 +31454,9 @@ function createProductionConfig(defaults) {
|
|
|
31429
31454
|
}
|
|
31430
31455
|
|
|
31431
31456
|
// src/sync/oblivious.ts
|
|
31432
|
-
import { sha256 as
|
|
31457
|
+
import { sha256 as sha25634 } from "@noble/hashes/sha2";
|
|
31433
31458
|
import { hmac as hmac5 } from "@noble/hashes/hmac";
|
|
31434
|
-
import { bytesToHex as
|
|
31459
|
+
import { bytesToHex as bytesToHex55, hexToBytes as hexToBytes34, randomBytes as randomBytes22, utf8ToBytes as utf8ToBytes8 } from "@noble/hashes/utils";
|
|
31435
31460
|
var DEFAULT_SYNC_CONFIG = {
|
|
31436
31461
|
maxBatchSize: 1e3,
|
|
31437
31462
|
timeoutMs: 3e4,
|
|
@@ -31457,10 +31482,10 @@ function getCurrentEpoch(epochDurationSeconds = DEFAULT_SYNC_CONFIG.epochDuratio
|
|
|
31457
31482
|
}
|
|
31458
31483
|
var OBLIVIOUS_NULLIFIER_DOMAIN = "SIP-OBLIVIOUS-NULLIFIER-V1";
|
|
31459
31484
|
function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
31460
|
-
const commitmentBytes =
|
|
31485
|
+
const commitmentBytes = hexToBytes34(
|
|
31461
31486
|
noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
|
|
31462
31487
|
);
|
|
31463
|
-
const keyBytes =
|
|
31488
|
+
const keyBytes = hexToBytes34(
|
|
31464
31489
|
spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
|
|
31465
31490
|
);
|
|
31466
31491
|
try {
|
|
@@ -31469,9 +31494,9 @@ function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
|
31469
31494
|
message.set(domain, 0);
|
|
31470
31495
|
message.set(commitmentBytes, domain.length);
|
|
31471
31496
|
message.set(syncRandomness.value, domain.length + commitmentBytes.length);
|
|
31472
|
-
const nullifierBytes = hmac5(
|
|
31497
|
+
const nullifierBytes = hmac5(sha25634, keyBytes, message);
|
|
31473
31498
|
return {
|
|
31474
|
-
nullifier: `0x${
|
|
31499
|
+
nullifier: `0x${bytesToHex55(nullifierBytes)}`,
|
|
31475
31500
|
epoch: syncRandomness.epoch,
|
|
31476
31501
|
chainId: "default"
|
|
31477
31502
|
// Will be set by caller
|
|
@@ -31481,15 +31506,15 @@ function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
|
|
|
31481
31506
|
}
|
|
31482
31507
|
}
|
|
31483
31508
|
function deriveTraditionalNullifier(noteCommitment, spendingKey) {
|
|
31484
|
-
const commitmentBytes =
|
|
31509
|
+
const commitmentBytes = hexToBytes34(
|
|
31485
31510
|
noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
|
|
31486
31511
|
);
|
|
31487
|
-
const keyBytes =
|
|
31512
|
+
const keyBytes = hexToBytes34(
|
|
31488
31513
|
spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
|
|
31489
31514
|
);
|
|
31490
31515
|
try {
|
|
31491
|
-
const nullifierBytes = hmac5(
|
|
31492
|
-
return `0x${
|
|
31516
|
+
const nullifierBytes = hmac5(sha25634, keyBytes, commitmentBytes);
|
|
31517
|
+
return `0x${bytesToHex55(nullifierBytes)}`;
|
|
31493
31518
|
} finally {
|
|
31494
31519
|
secureWipe(keyBytes);
|
|
31495
31520
|
}
|
|
@@ -31534,22 +31559,22 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
|
|
|
31534
31559
|
for (let e = startEpoch; e <= endEpoch; e++) {
|
|
31535
31560
|
epochs.push(e);
|
|
31536
31561
|
}
|
|
31537
|
-
const keyBytes =
|
|
31562
|
+
const keyBytes = hexToBytes34(
|
|
31538
31563
|
masterViewingKey.startsWith("0x") ? masterViewingKey.slice(2) : masterViewingKey
|
|
31539
31564
|
);
|
|
31540
31565
|
const windowData = new Uint8Array(16);
|
|
31541
31566
|
const view = new DataView(windowData.buffer);
|
|
31542
31567
|
view.setBigUint64(0, BigInt(startTime), false);
|
|
31543
31568
|
view.setBigUint64(8, BigInt(endTime), false);
|
|
31544
|
-
const derivedKey = hmac5(
|
|
31545
|
-
const keyHash =
|
|
31569
|
+
const derivedKey = hmac5(sha25634, keyBytes, windowData);
|
|
31570
|
+
const keyHash = sha25634(derivedKey);
|
|
31546
31571
|
secureWipe(keyBytes);
|
|
31547
31572
|
return {
|
|
31548
|
-
viewingKey: `0x${
|
|
31573
|
+
viewingKey: `0x${bytesToHex55(derivedKey)}`,
|
|
31549
31574
|
windowStart: startTime,
|
|
31550
31575
|
windowEnd: endTime,
|
|
31551
31576
|
epochs,
|
|
31552
|
-
hash: `0x${
|
|
31577
|
+
hash: `0x${bytesToHex55(keyHash)}`
|
|
31553
31578
|
};
|
|
31554
31579
|
}
|
|
31555
31580
|
function isNoteInWindow(_note, _windowedKey) {
|
|
@@ -31575,7 +31600,7 @@ var ObliviousSyncError = class extends Error {
|
|
|
31575
31600
|
};
|
|
31576
31601
|
|
|
31577
31602
|
// src/sync/mock-provider.ts
|
|
31578
|
-
import { bytesToHex as
|
|
31603
|
+
import { bytesToHex as bytesToHex56, randomBytes as randomBytes23 } from "@noble/hashes/utils";
|
|
31579
31604
|
var DEFAULT_MOCK_CONFIG = {
|
|
31580
31605
|
chains: ["ethereum", "solana", "near"],
|
|
31581
31606
|
latencyMs: 100,
|
|
@@ -31672,7 +31697,7 @@ var MockObliviousSyncProvider = class {
|
|
|
31672
31697
|
merkleProofs,
|
|
31673
31698
|
syncHeight: this.config.blockHeight,
|
|
31674
31699
|
timestamp: Date.now(),
|
|
31675
|
-
queryHash: `0x${
|
|
31700
|
+
queryHash: `0x${bytesToHex56(randomBytes23(32))}`
|
|
31676
31701
|
};
|
|
31677
31702
|
}
|
|
31678
31703
|
async getCurrentHeight(chainId) {
|
|
@@ -31753,23 +31778,23 @@ var MockObliviousSyncProvider = class {
|
|
|
31753
31778
|
generateMockNote(blockRange) {
|
|
31754
31779
|
const blockNumber = blockRange.startBlock + BigInt(Math.floor(Math.random() * Number(blockRange.endBlock - blockRange.startBlock)));
|
|
31755
31780
|
return {
|
|
31756
|
-
commitment: `0x${
|
|
31757
|
-
encryptedData: `0x${
|
|
31781
|
+
commitment: `0x${bytesToHex56(randomBytes23(32))}`,
|
|
31782
|
+
encryptedData: `0x${bytesToHex56(randomBytes23(128))}`,
|
|
31758
31783
|
blockNumber,
|
|
31759
|
-
txHash: `0x${
|
|
31784
|
+
txHash: `0x${bytesToHex56(randomBytes23(32))}`,
|
|
31760
31785
|
chainId: blockRange.chainId
|
|
31761
31786
|
};
|
|
31762
31787
|
}
|
|
31763
31788
|
generateMockMerkleProof(leaf) {
|
|
31764
31789
|
const siblings = [];
|
|
31765
31790
|
for (let i = 0; i < 20; i++) {
|
|
31766
|
-
siblings.push(`0x${
|
|
31791
|
+
siblings.push(`0x${bytesToHex56(randomBytes23(32))}`);
|
|
31767
31792
|
}
|
|
31768
31793
|
return {
|
|
31769
31794
|
leaf,
|
|
31770
31795
|
siblings,
|
|
31771
31796
|
index: BigInt(Math.floor(Math.random() * 1e6)),
|
|
31772
|
-
root: `0x${
|
|
31797
|
+
root: `0x${bytesToHex56(randomBytes23(32))}`
|
|
31773
31798
|
};
|
|
31774
31799
|
}
|
|
31775
31800
|
};
|
|
@@ -33418,7 +33443,7 @@ export {
|
|
|
33418
33443
|
supportsWASMBulkMemory,
|
|
33419
33444
|
checkMobileWASMCompatibility,
|
|
33420
33445
|
hexToBytes7 as hexToBytes,
|
|
33421
|
-
|
|
33446
|
+
bytesToHex11 as bytesToHex,
|
|
33422
33447
|
isBrowser,
|
|
33423
33448
|
supportsWebWorkers,
|
|
33424
33449
|
supportsSharedArrayBuffer,
|