@sip-protocol/sdk 0.6.17 → 0.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +23 -24
- package/dist/browser.mjs +20 -20
- package/dist/{chunk-O33JCQFJ.mjs → chunk-NM5PTCQ5.mjs} +34 -35
- package/dist/index.js +4 -5
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/intent.ts +7 -5
- package/src/proofs/browser.ts +24 -20
package/dist/browser.js
CHANGED
|
@@ -5434,9 +5434,9 @@ async function createShieldedIntent(params, options) {
|
|
|
5434
5434
|
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
5435
5435
|
return (0, import_utils6.hexToBytes)(cleanHex);
|
|
5436
5436
|
};
|
|
5437
|
-
const effectiveOwnershipSig = ownershipSignature ??
|
|
5438
|
-
const effectiveSenderSecret = senderSecret ??
|
|
5439
|
-
const effectiveAuthSig = authorizationSignature ??
|
|
5437
|
+
const effectiveOwnershipSig = ownershipSignature ?? (0, import_utils6.randomBytes)(64);
|
|
5438
|
+
const effectiveSenderSecret = senderSecret ?? (0, import_utils6.randomBytes)(32);
|
|
5439
|
+
const effectiveAuthSig = authorizationSignature ?? (0, import_utils6.randomBytes)(64);
|
|
5440
5440
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
5441
5441
|
balance: input.amount,
|
|
5442
5442
|
minimumRequired: input.amount,
|
|
@@ -5453,8 +5453,7 @@ async function createShieldedIntent(params, options) {
|
|
|
5453
5453
|
senderBlinding: hexToUint8(senderCommitment.blindingFactor),
|
|
5454
5454
|
senderSecret: effectiveSenderSecret,
|
|
5455
5455
|
authorizationSignature: effectiveAuthSig,
|
|
5456
|
-
nonce:
|
|
5457
|
-
// Could use randomBytes here
|
|
5456
|
+
nonce: (0, import_utils6.randomBytes)(32),
|
|
5458
5457
|
timestamp: now,
|
|
5459
5458
|
expiry: now + ttl
|
|
5460
5459
|
});
|
|
@@ -21605,7 +21604,7 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
21605
21604
|
minimum_required: `0x${params.minimumRequired.toString(16)}`,
|
|
21606
21605
|
asset_id: `0x${this.assetIdToField(params.assetId)}`,
|
|
21607
21606
|
balance: `0x${params.balance.toString(16)}`,
|
|
21608
|
-
blinding: blindingField
|
|
21607
|
+
blinding: `0x${blindingField}`
|
|
21609
21608
|
};
|
|
21610
21609
|
onProgress?.({
|
|
21611
21610
|
stage: "witness",
|
|
@@ -21705,20 +21704,20 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
21705
21704
|
pubKeyY = coords.y;
|
|
21706
21705
|
}
|
|
21707
21706
|
const witnessInputs = {
|
|
21708
|
-
intent_hash: intentHashField
|
|
21709
|
-
sender_commitment_x: commitmentX
|
|
21710
|
-
sender_commitment_y: commitmentY
|
|
21711
|
-
nullifier
|
|
21707
|
+
intent_hash: `0x${intentHashField}`,
|
|
21708
|
+
sender_commitment_x: `0x${commitmentX}`,
|
|
21709
|
+
sender_commitment_y: `0x${commitmentY}`,
|
|
21710
|
+
nullifier: `0x${nullifier}`,
|
|
21712
21711
|
timestamp: params.timestamp.toString(),
|
|
21713
21712
|
expiry: params.expiry.toString(),
|
|
21714
|
-
sender_address: senderAddressField
|
|
21715
|
-
sender_blinding: senderBlindingField
|
|
21716
|
-
sender_secret: senderSecretField
|
|
21713
|
+
sender_address: `0x${senderAddressField}`,
|
|
21714
|
+
sender_blinding: `0x${senderBlindingField}`,
|
|
21715
|
+
sender_secret: `0x${senderSecretField}`,
|
|
21717
21716
|
pub_key_x: pubKeyX,
|
|
21718
21717
|
pub_key_y: pubKeyY,
|
|
21719
21718
|
signature,
|
|
21720
21719
|
message_hash: messageHash,
|
|
21721
|
-
nonce: nonceField
|
|
21720
|
+
nonce: `0x${nonceField}`
|
|
21722
21721
|
};
|
|
21723
21722
|
onProgress?.({
|
|
21724
21723
|
stage: "witness",
|
|
@@ -21800,20 +21799,20 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
21800
21799
|
const oraclePubKeyX = this.config.oraclePublicKey?.x ?? new Array(32).fill(0);
|
|
21801
21800
|
const oraclePubKeyY = this.config.oraclePublicKey?.y ?? new Array(32).fill(0);
|
|
21802
21801
|
const witnessInputs = {
|
|
21803
|
-
intent_hash: intentHashField
|
|
21804
|
-
output_commitment_x: commitmentX
|
|
21805
|
-
output_commitment_y: commitmentY
|
|
21806
|
-
recipient_stealth: recipientStealthField
|
|
21802
|
+
intent_hash: `0x${intentHashField}`,
|
|
21803
|
+
output_commitment_x: `0x${commitmentX}`,
|
|
21804
|
+
output_commitment_y: `0x${commitmentY}`,
|
|
21805
|
+
recipient_stealth: `0x${recipientStealthField}`,
|
|
21807
21806
|
min_output_amount: params.minOutputAmount.toString(),
|
|
21808
|
-
solver_id: solverId
|
|
21807
|
+
solver_id: `0x${solverId}`,
|
|
21809
21808
|
fulfillment_time: params.fulfillmentTime.toString(),
|
|
21810
21809
|
expiry: params.expiry.toString(),
|
|
21811
21810
|
output_amount: params.outputAmount.toString(),
|
|
21812
|
-
output_blinding: outputBlindingField
|
|
21813
|
-
solver_secret: solverSecretField
|
|
21814
|
-
attestation_recipient: attestationRecipientField
|
|
21811
|
+
output_blinding: `0x${outputBlindingField}`,
|
|
21812
|
+
solver_secret: `0x${solverSecretField}`,
|
|
21813
|
+
attestation_recipient: `0x${attestationRecipientField}`,
|
|
21815
21814
|
attestation_amount: attestation.amount.toString(),
|
|
21816
|
-
attestation_tx_hash: attestationTxHashField
|
|
21815
|
+
attestation_tx_hash: `0x${attestationTxHashField}`,
|
|
21817
21816
|
attestation_block: attestation.blockNumber.toString(),
|
|
21818
21817
|
oracle_signature: oracleSignature,
|
|
21819
21818
|
oracle_message_hash: oracleMessageHash,
|
|
@@ -21993,7 +21992,7 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
21993
21992
|
for (let i = 0; i < len; i++) {
|
|
21994
21993
|
result = result * 256n + BigInt(arr[i]);
|
|
21995
21994
|
}
|
|
21996
|
-
return
|
|
21995
|
+
return result.toString(16).padStart(64, "0");
|
|
21997
21996
|
}
|
|
21998
21997
|
bigintToBytes(value, length) {
|
|
21999
21998
|
const bytes = new Uint8Array(length);
|
package/dist/browser.mjs
CHANGED
|
@@ -263,7 +263,7 @@ import {
|
|
|
263
263
|
walletRegistry,
|
|
264
264
|
withSecureBuffer,
|
|
265
265
|
withSecureBufferSync
|
|
266
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-NM5PTCQ5.mjs";
|
|
267
267
|
import {
|
|
268
268
|
fulfillment_proof_default,
|
|
269
269
|
funding_proof_default,
|
|
@@ -618,7 +618,7 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
618
618
|
minimum_required: `0x${params.minimumRequired.toString(16)}`,
|
|
619
619
|
asset_id: `0x${this.assetIdToField(params.assetId)}`,
|
|
620
620
|
balance: `0x${params.balance.toString(16)}`,
|
|
621
|
-
blinding: blindingField
|
|
621
|
+
blinding: `0x${blindingField}`
|
|
622
622
|
};
|
|
623
623
|
onProgress?.({
|
|
624
624
|
stage: "witness",
|
|
@@ -718,20 +718,20 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
718
718
|
pubKeyY = coords.y;
|
|
719
719
|
}
|
|
720
720
|
const witnessInputs = {
|
|
721
|
-
intent_hash: intentHashField
|
|
722
|
-
sender_commitment_x: commitmentX
|
|
723
|
-
sender_commitment_y: commitmentY
|
|
724
|
-
nullifier
|
|
721
|
+
intent_hash: `0x${intentHashField}`,
|
|
722
|
+
sender_commitment_x: `0x${commitmentX}`,
|
|
723
|
+
sender_commitment_y: `0x${commitmentY}`,
|
|
724
|
+
nullifier: `0x${nullifier}`,
|
|
725
725
|
timestamp: params.timestamp.toString(),
|
|
726
726
|
expiry: params.expiry.toString(),
|
|
727
|
-
sender_address: senderAddressField
|
|
728
|
-
sender_blinding: senderBlindingField
|
|
729
|
-
sender_secret: senderSecretField
|
|
727
|
+
sender_address: `0x${senderAddressField}`,
|
|
728
|
+
sender_blinding: `0x${senderBlindingField}`,
|
|
729
|
+
sender_secret: `0x${senderSecretField}`,
|
|
730
730
|
pub_key_x: pubKeyX,
|
|
731
731
|
pub_key_y: pubKeyY,
|
|
732
732
|
signature,
|
|
733
733
|
message_hash: messageHash,
|
|
734
|
-
nonce: nonceField
|
|
734
|
+
nonce: `0x${nonceField}`
|
|
735
735
|
};
|
|
736
736
|
onProgress?.({
|
|
737
737
|
stage: "witness",
|
|
@@ -813,20 +813,20 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
813
813
|
const oraclePubKeyX = this.config.oraclePublicKey?.x ?? new Array(32).fill(0);
|
|
814
814
|
const oraclePubKeyY = this.config.oraclePublicKey?.y ?? new Array(32).fill(0);
|
|
815
815
|
const witnessInputs = {
|
|
816
|
-
intent_hash: intentHashField
|
|
817
|
-
output_commitment_x: commitmentX
|
|
818
|
-
output_commitment_y: commitmentY
|
|
819
|
-
recipient_stealth: recipientStealthField
|
|
816
|
+
intent_hash: `0x${intentHashField}`,
|
|
817
|
+
output_commitment_x: `0x${commitmentX}`,
|
|
818
|
+
output_commitment_y: `0x${commitmentY}`,
|
|
819
|
+
recipient_stealth: `0x${recipientStealthField}`,
|
|
820
820
|
min_output_amount: params.minOutputAmount.toString(),
|
|
821
|
-
solver_id: solverId
|
|
821
|
+
solver_id: `0x${solverId}`,
|
|
822
822
|
fulfillment_time: params.fulfillmentTime.toString(),
|
|
823
823
|
expiry: params.expiry.toString(),
|
|
824
824
|
output_amount: params.outputAmount.toString(),
|
|
825
|
-
output_blinding: outputBlindingField
|
|
826
|
-
solver_secret: solverSecretField
|
|
827
|
-
attestation_recipient: attestationRecipientField
|
|
825
|
+
output_blinding: `0x${outputBlindingField}`,
|
|
826
|
+
solver_secret: `0x${solverSecretField}`,
|
|
827
|
+
attestation_recipient: `0x${attestationRecipientField}`,
|
|
828
828
|
attestation_amount: attestation.amount.toString(),
|
|
829
|
-
attestation_tx_hash: attestationTxHashField
|
|
829
|
+
attestation_tx_hash: `0x${attestationTxHashField}`,
|
|
830
830
|
attestation_block: attestation.blockNumber.toString(),
|
|
831
831
|
oracle_signature: oracleSignature,
|
|
832
832
|
oracle_message_hash: oracleMessageHash,
|
|
@@ -1006,7 +1006,7 @@ var BrowserNoirProvider = class _BrowserNoirProvider {
|
|
|
1006
1006
|
for (let i = 0; i < len; i++) {
|
|
1007
1007
|
result = result * 256n + BigInt(arr[i]);
|
|
1008
1008
|
}
|
|
1009
|
-
return
|
|
1009
|
+
return result.toString(16).padStart(64, "0");
|
|
1010
1010
|
}
|
|
1011
1011
|
bigintToBytes(value, length) {
|
|
1012
1012
|
const bytes = new Uint8Array(length);
|
|
@@ -1303,7 +1303,7 @@ function generateRandomBytes(length) {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
|
|
1305
1305
|
// src/intent.ts
|
|
1306
|
-
import { hexToBytes as hexToBytes4, bytesToHex as bytesToHex5 } from "@noble/hashes/utils";
|
|
1306
|
+
import { hexToBytes as hexToBytes4, bytesToHex as bytesToHex5, randomBytes as randomBytes6 } from "@noble/hashes/utils";
|
|
1307
1307
|
import { sha256 as sha2565 } from "@noble/hashes/sha256";
|
|
1308
1308
|
|
|
1309
1309
|
// src/privacy.ts
|
|
@@ -1777,9 +1777,9 @@ async function createShieldedIntent(params, options) {
|
|
|
1777
1777
|
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
1778
1778
|
return hexToBytes4(cleanHex);
|
|
1779
1779
|
};
|
|
1780
|
-
const effectiveOwnershipSig = ownershipSignature ??
|
|
1781
|
-
const effectiveSenderSecret = senderSecret ??
|
|
1782
|
-
const effectiveAuthSig = authorizationSignature ??
|
|
1780
|
+
const effectiveOwnershipSig = ownershipSignature ?? randomBytes6(64);
|
|
1781
|
+
const effectiveSenderSecret = senderSecret ?? randomBytes6(32);
|
|
1782
|
+
const effectiveAuthSig = authorizationSignature ?? randomBytes6(64);
|
|
1783
1783
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
1784
1784
|
balance: input.amount,
|
|
1785
1785
|
minimumRequired: input.amount,
|
|
@@ -1796,8 +1796,7 @@ async function createShieldedIntent(params, options) {
|
|
|
1796
1796
|
senderBlinding: hexToUint8(senderCommitment.blindingFactor),
|
|
1797
1797
|
senderSecret: effectiveSenderSecret,
|
|
1798
1798
|
authorizationSignature: effectiveAuthSig,
|
|
1799
|
-
nonce:
|
|
1800
|
-
// Could use randomBytes here
|
|
1799
|
+
nonce: randomBytes6(32),
|
|
1801
1800
|
timestamp: now,
|
|
1802
1801
|
expiry: now + ttl
|
|
1803
1802
|
});
|
|
@@ -3598,7 +3597,7 @@ import { sha256 as sha2567 } from "@noble/hashes/sha256";
|
|
|
3598
3597
|
|
|
3599
3598
|
// src/proofs/mock.ts
|
|
3600
3599
|
import { sha256 as sha2568 } from "@noble/hashes/sha256";
|
|
3601
|
-
import { bytesToHex as bytesToHex10, randomBytes as
|
|
3600
|
+
import { bytesToHex as bytesToHex10, randomBytes as randomBytes7 } from "@noble/hashes/utils";
|
|
3602
3601
|
var MOCK_PROOF_PREFIX = "0x4d4f434b";
|
|
3603
3602
|
var WARNING_MESSAGE = `
|
|
3604
3603
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
@@ -3764,7 +3763,7 @@ var MockProofProvider = class {
|
|
|
3764
3763
|
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
3765
3764
|
);
|
|
3766
3765
|
const hash2 = sha2568(new TextEncoder().encode(input));
|
|
3767
|
-
const random =
|
|
3766
|
+
const random = randomBytes7(16);
|
|
3768
3767
|
const combined = new Uint8Array(4 + hash2.length + random.length);
|
|
3769
3768
|
combined.set(new TextEncoder().encode("MOCK"), 0);
|
|
3770
3769
|
combined.set(hash2, 4);
|
|
@@ -4393,7 +4392,7 @@ import { ReportStatus as ReportStatus2 } from "@sip-protocol/types";
|
|
|
4393
4392
|
import {
|
|
4394
4393
|
IntentStatus as IntentStatus3
|
|
4395
4394
|
} from "@sip-protocol/types";
|
|
4396
|
-
import { bytesToHex as bytesToHex14, randomBytes as
|
|
4395
|
+
import { bytesToHex as bytesToHex14, randomBytes as randomBytes8 } from "@noble/hashes/utils";
|
|
4397
4396
|
var MockSolver = class {
|
|
4398
4397
|
info;
|
|
4399
4398
|
capabilities;
|
|
@@ -4475,7 +4474,7 @@ var MockSolver = class {
|
|
|
4475
4474
|
const spreadAmount = baseOutput * BigInt(Math.floor(this.spreadPercent * 1e4)) / 10000n;
|
|
4476
4475
|
const outputAmount = baseOutput + spreadAmount;
|
|
4477
4476
|
const feeAmount = outputAmount * BigInt(Math.floor(this.feePercent * 1e4)) / 10000n;
|
|
4478
|
-
const quoteId = `quote-${bytesToHex14(
|
|
4477
|
+
const quoteId = `quote-${bytesToHex14(randomBytes8(8))}`;
|
|
4479
4478
|
const now = Math.floor(Date.now() / 1e3);
|
|
4480
4479
|
const quote = {
|
|
4481
4480
|
quoteId,
|
|
@@ -4486,7 +4485,7 @@ var MockSolver = class {
|
|
|
4486
4485
|
expiry: now + 60,
|
|
4487
4486
|
// Quote valid for 1 minute
|
|
4488
4487
|
fee: feeAmount,
|
|
4489
|
-
signature: `0x${bytesToHex14(
|
|
4488
|
+
signature: `0x${bytesToHex14(randomBytes8(64))}`,
|
|
4490
4489
|
// Mock signature
|
|
4491
4490
|
validUntil: now + 60,
|
|
4492
4491
|
estimatedGas: 200000n
|
|
@@ -4523,7 +4522,7 @@ var MockSolver = class {
|
|
|
4523
4522
|
error: status.error
|
|
4524
4523
|
};
|
|
4525
4524
|
}
|
|
4526
|
-
const txHash = `0x${bytesToHex14(
|
|
4525
|
+
const txHash = `0x${bytesToHex14(randomBytes8(32))}`;
|
|
4527
4526
|
status.status = "completed";
|
|
4528
4527
|
status.txHash = txHash;
|
|
4529
4528
|
return {
|
|
@@ -4533,7 +4532,7 @@ var MockSolver = class {
|
|
|
4533
4532
|
txHash: intent.privacyLevel === "transparent" ? txHash : void 0,
|
|
4534
4533
|
fulfillmentProof: {
|
|
4535
4534
|
type: "fulfillment",
|
|
4536
|
-
proof: `0x${bytesToHex14(
|
|
4535
|
+
proof: `0x${bytesToHex14(randomBytes8(128))}`,
|
|
4537
4536
|
publicInputs: [
|
|
4538
4537
|
`0x${bytesToHex14(new TextEncoder().encode(intent.intentId))}`,
|
|
4539
4538
|
`0x${bytesToHex14(new TextEncoder().encode(quote.quoteId))}`
|
|
@@ -5688,7 +5687,7 @@ function createZcashNativeBackend(config) {
|
|
|
5688
5687
|
|
|
5689
5688
|
// src/settlement/backends/direct-chain.ts
|
|
5690
5689
|
import { PrivacyLevel as PrivacyLevel5 } from "@sip-protocol/types";
|
|
5691
|
-
import { randomBytes as
|
|
5690
|
+
import { randomBytes as randomBytes9, bytesToHex as bytesToHex15 } from "@noble/hashes/utils";
|
|
5692
5691
|
var DEFAULT_GAS_FEES = {
|
|
5693
5692
|
ethereum: 21000n * 50n * 1000000000n,
|
|
5694
5693
|
// 21k gas * 50 gwei = 0.00105 ETH
|
|
@@ -7309,7 +7308,7 @@ import {
|
|
|
7309
7308
|
PaymentStatus
|
|
7310
7309
|
} from "@sip-protocol/types";
|
|
7311
7310
|
import { sha256 as sha25613 } from "@noble/hashes/sha256";
|
|
7312
|
-
import { bytesToHex as bytesToHex18, hexToBytes as hexToBytes14, randomBytes as
|
|
7311
|
+
import { bytesToHex as bytesToHex18, hexToBytes as hexToBytes14, randomBytes as randomBytes10 } from "@noble/hashes/utils";
|
|
7313
7312
|
import { xchacha20poly1305 as xchacha20poly13052 } from "@noble/ciphers/chacha.js";
|
|
7314
7313
|
import { hkdf as hkdf2 } from "@noble/hashes/hkdf";
|
|
7315
7314
|
|
|
@@ -7876,7 +7875,7 @@ function encryptMemo(memo, viewingKey) {
|
|
|
7876
7875
|
const keyBytes = hexToBytes14(keyHex);
|
|
7877
7876
|
const encKey = hkdf2(sha25613, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
7878
7877
|
try {
|
|
7879
|
-
const nonce =
|
|
7878
|
+
const nonce = randomBytes10(24);
|
|
7880
7879
|
const cipher = xchacha20poly13052(encKey, nonce);
|
|
7881
7880
|
const plaintext = new TextEncoder().encode(memo);
|
|
7882
7881
|
const ciphertext = cipher.encrypt(plaintext);
|
|
@@ -7948,7 +7947,7 @@ import {
|
|
|
7948
7947
|
} from "@sip-protocol/types";
|
|
7949
7948
|
import { secp256k1 as secp256k16 } from "@noble/curves/secp256k1";
|
|
7950
7949
|
import { sha256 as sha25614 } from "@noble/hashes/sha256";
|
|
7951
|
-
import { bytesToHex as bytesToHex19, hexToBytes as hexToBytes15, randomBytes as
|
|
7950
|
+
import { bytesToHex as bytesToHex19, hexToBytes as hexToBytes15, randomBytes as randomBytes11 } from "@noble/hashes/utils";
|
|
7952
7951
|
var DEFAULT_PROPOSAL_TTL = 7 * 24 * 60 * 60;
|
|
7953
7952
|
var Treasury = class _Treasury {
|
|
7954
7953
|
config;
|
|
@@ -8439,11 +8438,11 @@ var Treasury = class _Treasury {
|
|
|
8439
8438
|
}
|
|
8440
8439
|
};
|
|
8441
8440
|
function generateTreasuryId() {
|
|
8442
|
-
const bytes =
|
|
8441
|
+
const bytes = randomBytes11(16);
|
|
8443
8442
|
return `treasury_${bytesToHex19(bytes)}`;
|
|
8444
8443
|
}
|
|
8445
8444
|
function generateProposalId() {
|
|
8446
|
-
const bytes =
|
|
8445
|
+
const bytes = randomBytes11(16);
|
|
8447
8446
|
return `prop_${bytesToHex19(bytes)}`;
|
|
8448
8447
|
}
|
|
8449
8448
|
function computeProposalHash(proposal) {
|
|
@@ -8634,7 +8633,7 @@ function validateBatchProposalParams(params, config) {
|
|
|
8634
8633
|
import {
|
|
8635
8634
|
ReportStatus
|
|
8636
8635
|
} from "@sip-protocol/types";
|
|
8637
|
-
import { bytesToHex as bytesToHex20, randomBytes as
|
|
8636
|
+
import { bytesToHex as bytesToHex20, randomBytes as randomBytes12 } from "@noble/hashes/utils";
|
|
8638
8637
|
var DEFAULTS2 = {
|
|
8639
8638
|
riskThreshold: 70,
|
|
8640
8639
|
highValueThreshold: 10000000000n,
|
|
@@ -9381,7 +9380,7 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
9381
9380
|
}
|
|
9382
9381
|
};
|
|
9383
9382
|
function generateId(prefix) {
|
|
9384
|
-
return `${prefix}_${bytesToHex20(
|
|
9383
|
+
return `${prefix}_${bytesToHex20(randomBytes12(12))}`;
|
|
9385
9384
|
}
|
|
9386
9385
|
function validateRegisterAuditorParams(params) {
|
|
9387
9386
|
if (!params.organization?.trim()) {
|
|
@@ -10158,7 +10157,7 @@ var ComplianceReporter = class {
|
|
|
10158
10157
|
|
|
10159
10158
|
// src/compliance/conditional.ts
|
|
10160
10159
|
import { sha256 as sha25616 } from "@noble/hashes/sha256";
|
|
10161
|
-
import { bytesToHex as bytesToHex22, hexToBytes as hexToBytes17, randomBytes as
|
|
10160
|
+
import { bytesToHex as bytesToHex22, hexToBytes as hexToBytes17, randomBytes as randomBytes13 } from "@noble/hashes/utils";
|
|
10162
10161
|
import { xchacha20poly1305 as xchacha20poly13053 } from "@noble/ciphers/chacha.js";
|
|
10163
10162
|
var ConditionalDisclosure = class {
|
|
10164
10163
|
/**
|
|
@@ -10224,7 +10223,7 @@ var ConditionalDisclosure = class {
|
|
|
10224
10223
|
params.commitment,
|
|
10225
10224
|
revealAfterSeconds
|
|
10226
10225
|
);
|
|
10227
|
-
const nonce =
|
|
10226
|
+
const nonce = randomBytes13(24);
|
|
10228
10227
|
const viewingKeyBytes = hexToBytes17(params.viewingKey.slice(2));
|
|
10229
10228
|
const cipher = xchacha20poly13053(encryptionKey, nonce);
|
|
10230
10229
|
const encryptedKey = cipher.encrypt(viewingKeyBytes);
|
|
@@ -10411,7 +10410,7 @@ var CURVE_ORDER2 = secp256k17.CURVE.n;
|
|
|
10411
10410
|
|
|
10412
10411
|
// src/compliance/threshold.ts
|
|
10413
10412
|
import { sha256 as sha25618 } from "@noble/hashes/sha256";
|
|
10414
|
-
import { bytesToHex as bytesToHex24, hexToBytes as hexToBytes19, randomBytes as
|
|
10413
|
+
import { bytesToHex as bytesToHex24, hexToBytes as hexToBytes19, randomBytes as randomBytes14 } from "@noble/hashes/utils";
|
|
10415
10414
|
var FIELD_PRIME = 2n ** 256n - 189n;
|
|
10416
10415
|
var ThresholdViewingKey = class {
|
|
10417
10416
|
/**
|
|
@@ -10628,7 +10627,7 @@ var ThresholdViewingKey = class {
|
|
|
10628
10627
|
* Generate a random field element
|
|
10629
10628
|
*/
|
|
10630
10629
|
static randomFieldElement() {
|
|
10631
|
-
const bytes =
|
|
10630
|
+
const bytes = randomBytes14(32);
|
|
10632
10631
|
let value = 0n;
|
|
10633
10632
|
for (let i = 0; i < bytes.length; i++) {
|
|
10634
10633
|
value = value << 8n | BigInt(bytes[i]);
|
|
@@ -11099,7 +11098,7 @@ var AuditorKeyDerivation = class {
|
|
|
11099
11098
|
};
|
|
11100
11099
|
|
|
11101
11100
|
// src/auction/sealed-bid.ts
|
|
11102
|
-
import { randomBytes as
|
|
11101
|
+
import { randomBytes as randomBytes15, bytesToHex as bytesToHex26 } from "@noble/hashes/utils";
|
|
11103
11102
|
var SealedBidAuction = class {
|
|
11104
11103
|
/**
|
|
11105
11104
|
* Create a sealed bid for an auction
|
|
@@ -11176,7 +11175,7 @@ var SealedBidAuction = class {
|
|
|
11176
11175
|
);
|
|
11177
11176
|
}
|
|
11178
11177
|
}
|
|
11179
|
-
const salt = params.salt ??
|
|
11178
|
+
const salt = params.salt ?? randomBytes15(32);
|
|
11180
11179
|
const { commitment, blinding } = commit(params.amount, salt);
|
|
11181
11180
|
const sealedBid = {
|
|
11182
11181
|
auctionId: params.auctionId,
|
|
@@ -11807,7 +11806,7 @@ function createSealedBidAuction() {
|
|
|
11807
11806
|
// src/governance/private-vote.ts
|
|
11808
11807
|
import { sha256 as sha25620 } from "@noble/hashes/sha256";
|
|
11809
11808
|
import { hkdf as hkdf3 } from "@noble/hashes/hkdf";
|
|
11810
|
-
import { bytesToHex as bytesToHex27, hexToBytes as hexToBytes21, randomBytes as
|
|
11809
|
+
import { bytesToHex as bytesToHex27, hexToBytes as hexToBytes21, randomBytes as randomBytes16, utf8ToBytes as utf8ToBytes5 } from "@noble/hashes/utils";
|
|
11811
11810
|
import { xchacha20poly1305 as xchacha20poly13054 } from "@noble/ciphers/chacha.js";
|
|
11812
11811
|
var VOTE_ENCRYPTION_DOMAIN = "SIP-PRIVATE-VOTE-ENCRYPTION-V1";
|
|
11813
11812
|
var NONCE_SIZE2 = 24;
|
|
@@ -11844,7 +11843,7 @@ var PrivateVoting = class {
|
|
|
11844
11843
|
const { proposalId, choice, weight, encryptionKey, voter = "anonymous" } = params;
|
|
11845
11844
|
const derivedKey = this.deriveEncryptionKey(encryptionKey, proposalId);
|
|
11846
11845
|
try {
|
|
11847
|
-
const nonce =
|
|
11846
|
+
const nonce = randomBytes16(NONCE_SIZE2);
|
|
11848
11847
|
const voteData = {
|
|
11849
11848
|
proposalId,
|
|
11850
11849
|
choice,
|
|
@@ -12161,7 +12160,7 @@ var PrivateVoting = class {
|
|
|
12161
12160
|
}
|
|
12162
12161
|
const encryptedBlindings = {};
|
|
12163
12162
|
for (const [choice, blinding] of Object.entries(blindings)) {
|
|
12164
|
-
const nonce =
|
|
12163
|
+
const nonce = randomBytes16(NONCE_SIZE2);
|
|
12165
12164
|
const derivedKey = this.deriveEncryptionKey(decryptionKey, `${proposalId}-tally-${choice}`);
|
|
12166
12165
|
try {
|
|
12167
12166
|
const cipher = xchacha20poly13054(derivedKey, nonce);
|
|
@@ -16280,7 +16279,7 @@ function createTrezorAdapter(config) {
|
|
|
16280
16279
|
|
|
16281
16280
|
// src/wallet/hardware/mock.ts
|
|
16282
16281
|
import { WalletErrorCode as WalletErrorCode17 } from "@sip-protocol/types";
|
|
16283
|
-
import { bytesToHex as bytesToHex29, randomBytes as
|
|
16282
|
+
import { bytesToHex as bytesToHex29, randomBytes as randomBytes17 } from "@noble/hashes/utils";
|
|
16284
16283
|
var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
16285
16284
|
chain;
|
|
16286
16285
|
name = "mock-ledger";
|
|
@@ -16525,12 +16524,12 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
16525
16524
|
}
|
|
16526
16525
|
}
|
|
16527
16526
|
generateMockAddress(index) {
|
|
16528
|
-
const bytes =
|
|
16527
|
+
const bytes = randomBytes17(20);
|
|
16529
16528
|
bytes[0] = index;
|
|
16530
16529
|
return `0x${bytesToHex29(bytes)}`;
|
|
16531
16530
|
}
|
|
16532
16531
|
generateMockPublicKey(index) {
|
|
16533
|
-
const bytes =
|
|
16532
|
+
const bytes = randomBytes17(33);
|
|
16534
16533
|
bytes[0] = 2;
|
|
16535
16534
|
bytes[1] = index;
|
|
16536
16535
|
return `0x${bytesToHex29(bytes)}`;
|
|
@@ -16731,12 +16730,12 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
16731
16730
|
}
|
|
16732
16731
|
}
|
|
16733
16732
|
generateMockAddress(index) {
|
|
16734
|
-
const bytes =
|
|
16733
|
+
const bytes = randomBytes17(20);
|
|
16735
16734
|
bytes[0] = index + 100;
|
|
16736
16735
|
return `0x${bytesToHex29(bytes)}`;
|
|
16737
16736
|
}
|
|
16738
16737
|
generateMockPublicKey(index) {
|
|
16739
|
-
const bytes =
|
|
16738
|
+
const bytes = randomBytes17(33);
|
|
16740
16739
|
bytes[0] = 3;
|
|
16741
16740
|
bytes[1] = index + 100;
|
|
16742
16741
|
return `0x${bytesToHex29(bytes)}`;
|
package/dist/index.js
CHANGED
|
@@ -5421,9 +5421,9 @@ async function createShieldedIntent(params, options) {
|
|
|
5421
5421
|
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
5422
5422
|
return (0, import_utils6.hexToBytes)(cleanHex);
|
|
5423
5423
|
};
|
|
5424
|
-
const effectiveOwnershipSig = ownershipSignature ??
|
|
5425
|
-
const effectiveSenderSecret = senderSecret ??
|
|
5426
|
-
const effectiveAuthSig = authorizationSignature ??
|
|
5424
|
+
const effectiveOwnershipSig = ownershipSignature ?? (0, import_utils6.randomBytes)(64);
|
|
5425
|
+
const effectiveSenderSecret = senderSecret ?? (0, import_utils6.randomBytes)(32);
|
|
5426
|
+
const effectiveAuthSig = authorizationSignature ?? (0, import_utils6.randomBytes)(64);
|
|
5427
5427
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
5428
5428
|
balance: input.amount,
|
|
5429
5429
|
minimumRequired: input.amount,
|
|
@@ -5440,8 +5440,7 @@ async function createShieldedIntent(params, options) {
|
|
|
5440
5440
|
senderBlinding: hexToUint8(senderCommitment.blindingFactor),
|
|
5441
5441
|
senderSecret: effectiveSenderSecret,
|
|
5442
5442
|
authorizationSignature: effectiveAuthSig,
|
|
5443
|
-
nonce:
|
|
5444
|
-
// Could use randomBytes here
|
|
5443
|
+
nonce: (0, import_utils6.randomBytes)(32),
|
|
5445
5444
|
timestamp: now,
|
|
5446
5445
|
expiry: now + ttl
|
|
5447
5446
|
});
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sip-protocol/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
4
|
"description": "Core SDK for Shielded Intents Protocol - Privacy layer for cross-chain transactions",
|
|
5
5
|
"author": "SIP Protocol <hello@sip-protocol.org>",
|
|
6
6
|
"homepage": "https://sip-protocol.org",
|
package/src/intent.ts
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
generateIntentId,
|
|
32
32
|
hash,
|
|
33
33
|
} from './crypto'
|
|
34
|
-
import { hexToBytes, bytesToHex } from '@noble/hashes/utils'
|
|
34
|
+
import { hexToBytes, bytesToHex, randomBytes } from '@noble/hashes/utils'
|
|
35
35
|
import { sha256 } from '@noble/hashes/sha256'
|
|
36
36
|
import { getPrivacyConfig, generateViewingKey } from './privacy'
|
|
37
37
|
import type { ProofProvider } from './proofs'
|
|
@@ -556,9 +556,11 @@ export async function createShieldedIntent(
|
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
// Use provided signatures or placeholders (if allowed)
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const
|
|
559
|
+
// IMPORTANT: senderSecret must be random even for placeholders, as secp256k1
|
|
560
|
+
// rejects all-zero private keys. randomBytes generates cryptographically secure random values.
|
|
561
|
+
const effectiveOwnershipSig = ownershipSignature ?? randomBytes(64)
|
|
562
|
+
const effectiveSenderSecret = senderSecret ?? randomBytes(32)
|
|
563
|
+
const effectiveAuthSig = authorizationSignature ?? randomBytes(64)
|
|
562
564
|
|
|
563
565
|
// Generate funding proof
|
|
564
566
|
// Note: The funding proof proves balance >= minimumRequired
|
|
@@ -583,7 +585,7 @@ export async function createShieldedIntent(
|
|
|
583
585
|
senderBlinding: hexToUint8(senderCommitment.blindingFactor as HexString),
|
|
584
586
|
senderSecret: effectiveSenderSecret,
|
|
585
587
|
authorizationSignature: effectiveAuthSig,
|
|
586
|
-
nonce:
|
|
588
|
+
nonce: randomBytes(32),
|
|
587
589
|
timestamp: now,
|
|
588
590
|
expiry: now + ttl,
|
|
589
591
|
})
|
package/src/proofs/browser.ts
CHANGED
|
@@ -573,11 +573,12 @@ export class BrowserNoirProvider implements ProofProvider {
|
|
|
573
573
|
|
|
574
574
|
// Circuit signature: (minimum_required: pub Field, asset_id: pub Field, balance: Field, blinding: Field) -> [u8; 32]
|
|
575
575
|
// Using Field type for unlimited precision (handles NEAR's 24 decimals, etc.)
|
|
576
|
+
// Noir expects field values as hex strings with 0x prefix
|
|
576
577
|
const witnessInputs = {
|
|
577
578
|
minimum_required: `0x${params.minimumRequired.toString(16)}`,
|
|
578
579
|
asset_id: `0x${this.assetIdToField(params.assetId)}`,
|
|
579
580
|
balance: `0x${params.balance.toString(16)}`,
|
|
580
|
-
blinding: blindingField
|
|
581
|
+
blinding: `0x${blindingField}`,
|
|
581
582
|
}
|
|
582
583
|
|
|
583
584
|
onProgress?.({
|
|
@@ -707,21 +708,22 @@ export class BrowserNoirProvider implements ProofProvider {
|
|
|
707
708
|
pubKeyY = coords.y
|
|
708
709
|
}
|
|
709
710
|
|
|
711
|
+
// Noir expects field values as hex strings with 0x prefix
|
|
710
712
|
const witnessInputs = {
|
|
711
|
-
intent_hash: intentHashField
|
|
712
|
-
sender_commitment_x: commitmentX
|
|
713
|
-
sender_commitment_y: commitmentY
|
|
714
|
-
nullifier: nullifier
|
|
713
|
+
intent_hash: `0x${intentHashField}`,
|
|
714
|
+
sender_commitment_x: `0x${commitmentX}`,
|
|
715
|
+
sender_commitment_y: `0x${commitmentY}`,
|
|
716
|
+
nullifier: `0x${nullifier}`,
|
|
715
717
|
timestamp: params.timestamp.toString(),
|
|
716
718
|
expiry: params.expiry.toString(),
|
|
717
|
-
sender_address: senderAddressField
|
|
718
|
-
sender_blinding: senderBlindingField
|
|
719
|
-
sender_secret: senderSecretField
|
|
719
|
+
sender_address: `0x${senderAddressField}`,
|
|
720
|
+
sender_blinding: `0x${senderBlindingField}`,
|
|
721
|
+
sender_secret: `0x${senderSecretField}`,
|
|
720
722
|
pub_key_x: pubKeyX,
|
|
721
723
|
pub_key_y: pubKeyY,
|
|
722
724
|
signature: signature,
|
|
723
725
|
message_hash: messageHash,
|
|
724
|
-
nonce: nonceField
|
|
726
|
+
nonce: `0x${nonceField}`,
|
|
725
727
|
}
|
|
726
728
|
|
|
727
729
|
onProgress?.({
|
|
@@ -823,21 +825,22 @@ export class BrowserNoirProvider implements ProofProvider {
|
|
|
823
825
|
const oraclePubKeyX = this.config.oraclePublicKey?.x ?? new Array(32).fill(0)
|
|
824
826
|
const oraclePubKeyY = this.config.oraclePublicKey?.y ?? new Array(32).fill(0)
|
|
825
827
|
|
|
828
|
+
// Noir expects field values as hex strings with 0x prefix
|
|
826
829
|
const witnessInputs = {
|
|
827
|
-
intent_hash: intentHashField
|
|
828
|
-
output_commitment_x: commitmentX
|
|
829
|
-
output_commitment_y: commitmentY
|
|
830
|
-
recipient_stealth: recipientStealthField
|
|
830
|
+
intent_hash: `0x${intentHashField}`,
|
|
831
|
+
output_commitment_x: `0x${commitmentX}`,
|
|
832
|
+
output_commitment_y: `0x${commitmentY}`,
|
|
833
|
+
recipient_stealth: `0x${recipientStealthField}`,
|
|
831
834
|
min_output_amount: params.minOutputAmount.toString(),
|
|
832
|
-
solver_id: solverId
|
|
835
|
+
solver_id: `0x${solverId}`,
|
|
833
836
|
fulfillment_time: params.fulfillmentTime.toString(),
|
|
834
837
|
expiry: params.expiry.toString(),
|
|
835
838
|
output_amount: params.outputAmount.toString(),
|
|
836
|
-
output_blinding: outputBlindingField
|
|
837
|
-
solver_secret: solverSecretField
|
|
838
|
-
attestation_recipient: attestationRecipientField
|
|
839
|
+
output_blinding: `0x${outputBlindingField}`,
|
|
840
|
+
solver_secret: `0x${solverSecretField}`,
|
|
841
|
+
attestation_recipient: `0x${attestationRecipientField}`,
|
|
839
842
|
attestation_amount: attestation.amount.toString(),
|
|
840
|
-
attestation_tx_hash: attestationTxHashField
|
|
843
|
+
attestation_tx_hash: `0x${attestationTxHashField}`,
|
|
841
844
|
attestation_block: attestation.blockNumber.toString(),
|
|
842
845
|
oracle_signature: oracleSignature,
|
|
843
846
|
oracle_message_hash: oracleMessageHash,
|
|
@@ -1057,8 +1060,9 @@ export class BrowserNoirProvider implements ProofProvider {
|
|
|
1057
1060
|
for (let i = 0; i < len; i++) {
|
|
1058
1061
|
result = result * 256n + BigInt(arr[i])
|
|
1059
1062
|
}
|
|
1060
|
-
// Return hex format
|
|
1061
|
-
|
|
1063
|
+
// Return hex format WITHOUT prefix (consistent with hexToField)
|
|
1064
|
+
// Prefix is added when building witnessInputs for Noir
|
|
1065
|
+
return result.toString(16).padStart(64, '0')
|
|
1062
1066
|
}
|
|
1063
1067
|
|
|
1064
1068
|
private bigintToBytes(value: bigint, length: number): Uint8Array {
|