@sip-protocol/sdk 0.2.0 → 0.2.1

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/index.js CHANGED
@@ -32,7 +32,6 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ATTESTATION_VERSION: () => ATTESTATION_VERSION,
34
34
  BaseWalletAdapter: () => BaseWalletAdapter,
35
- BrowserNoirProvider: () => BrowserNoirProvider,
36
35
  CHAIN_NUMERIC_IDS: () => CHAIN_NUMERIC_IDS,
37
36
  ComplianceManager: () => ComplianceManager,
38
37
  CryptoError: () => CryptoError,
@@ -5097,609 +5096,6 @@ function getBrowserInfo() {
5097
5096
  };
5098
5097
  }
5099
5098
 
5100
- // src/proofs/browser.ts
5101
- var import_noir_js2 = require("@noir-lang/noir_js");
5102
- var import_bb2 = require("@aztec/bb.js");
5103
- var import_secp256k14 = require("@noble/curves/secp256k1");
5104
- var BrowserNoirProvider = class _BrowserNoirProvider {
5105
- framework = "noir";
5106
- _isReady = false;
5107
- config;
5108
- // Circuit instances
5109
- fundingNoir = null;
5110
- fundingBackend = null;
5111
- validityNoir = null;
5112
- validityBackend = null;
5113
- fulfillmentNoir = null;
5114
- fulfillmentBackend = null;
5115
- // Worker instance (optional)
5116
- worker = null;
5117
- workerPending = /* @__PURE__ */ new Map();
5118
- constructor(config = {}) {
5119
- this.config = {
5120
- useWorker: config.useWorker ?? true,
5121
- verbose: config.verbose ?? false,
5122
- oraclePublicKey: config.oraclePublicKey ?? void 0,
5123
- timeout: config.timeout ?? 6e4
5124
- };
5125
- if (!isBrowser()) {
5126
- console.warn(
5127
- "[BrowserNoirProvider] Not running in browser environment. Consider using NoirProofProvider for Node.js."
5128
- );
5129
- }
5130
- }
5131
- get isReady() {
5132
- return this._isReady;
5133
- }
5134
- /**
5135
- * Get browser environment info
5136
- */
5137
- static getBrowserInfo() {
5138
- return getBrowserInfo();
5139
- }
5140
- /**
5141
- * Check if browser supports all required features
5142
- */
5143
- static checkBrowserSupport() {
5144
- const missing = [];
5145
- if (!isBrowser()) {
5146
- missing.push("browser environment");
5147
- }
5148
- if (typeof WebAssembly === "undefined") {
5149
- missing.push("WebAssembly");
5150
- }
5151
- if (!supportsSharedArrayBuffer()) {
5152
- missing.push("SharedArrayBuffer (requires COOP/COEP headers)");
5153
- }
5154
- return {
5155
- supported: missing.length === 0,
5156
- missing
5157
- };
5158
- }
5159
- /**
5160
- * Derive secp256k1 public key coordinates from a private key
5161
- */
5162
- static derivePublicKey(privateKey) {
5163
- const uncompressedPubKey = import_secp256k14.secp256k1.getPublicKey(privateKey, false);
5164
- const x = Array.from(uncompressedPubKey.slice(1, 33));
5165
- const y = Array.from(uncompressedPubKey.slice(33, 65));
5166
- return { x, y };
5167
- }
5168
- /**
5169
- * Initialize the browser provider
5170
- *
5171
- * Loads WASM and circuit artifacts. This should be called before any
5172
- * proof generation. Consider showing a loading indicator during init.
5173
- *
5174
- * @param onProgress - Optional progress callback
5175
- */
5176
- async initialize(onProgress) {
5177
- if (this._isReady) {
5178
- return;
5179
- }
5180
- const { supported, missing } = _BrowserNoirProvider.checkBrowserSupport();
5181
- if (!supported) {
5182
- throw new ProofError(
5183
- `Browser missing required features: ${missing.join(", ")}`,
5184
- "SIP_4004" /* PROOF_PROVIDER_NOT_READY */
5185
- );
5186
- }
5187
- try {
5188
- onProgress?.({
5189
- stage: "initializing",
5190
- percent: 0,
5191
- message: "Loading WASM runtime..."
5192
- });
5193
- if (this.config.verbose) {
5194
- console.log("[BrowserNoirProvider] Initializing...");
5195
- console.log("[BrowserNoirProvider] Browser info:", getBrowserInfo());
5196
- }
5197
- const fundingCircuit = funding_proof_default;
5198
- const validityCircuit = validity_proof_default;
5199
- const fulfillmentCircuit = fulfillment_proof_default;
5200
- onProgress?.({
5201
- stage: "initializing",
5202
- percent: 20,
5203
- message: "Creating proof backends..."
5204
- });
5205
- this.fundingBackend = new import_bb2.UltraHonkBackend(fundingCircuit.bytecode);
5206
- this.validityBackend = new import_bb2.UltraHonkBackend(validityCircuit.bytecode);
5207
- this.fulfillmentBackend = new import_bb2.UltraHonkBackend(fulfillmentCircuit.bytecode);
5208
- onProgress?.({
5209
- stage: "initializing",
5210
- percent: 60,
5211
- message: "Initializing Noir circuits..."
5212
- });
5213
- this.fundingNoir = new import_noir_js2.Noir(fundingCircuit);
5214
- this.validityNoir = new import_noir_js2.Noir(validityCircuit);
5215
- this.fulfillmentNoir = new import_noir_js2.Noir(fulfillmentCircuit);
5216
- onProgress?.({
5217
- stage: "initializing",
5218
- percent: 90,
5219
- message: "Setting up worker..."
5220
- });
5221
- if (this.config.useWorker && supportsWebWorkers()) {
5222
- await this.initializeWorker();
5223
- }
5224
- this._isReady = true;
5225
- onProgress?.({
5226
- stage: "complete",
5227
- percent: 100,
5228
- message: "Ready for proof generation"
5229
- });
5230
- if (this.config.verbose) {
5231
- console.log("[BrowserNoirProvider] Initialization complete");
5232
- }
5233
- } catch (error) {
5234
- throw new ProofError(
5235
- `Failed to initialize BrowserNoirProvider: ${error instanceof Error ? error.message : String(error)}`,
5236
- "SIP_4003" /* PROOF_NOT_IMPLEMENTED */,
5237
- { context: { error } }
5238
- );
5239
- }
5240
- }
5241
- /**
5242
- * Initialize Web Worker for off-main-thread proof generation
5243
- */
5244
- async initializeWorker() {
5245
- if (this.config.verbose) {
5246
- console.log("[BrowserNoirProvider] Worker support: using async main-thread");
5247
- }
5248
- }
5249
- /**
5250
- * Generate a Funding Proof
5251
- *
5252
- * Proves: balance >= minimumRequired without revealing balance
5253
- *
5254
- * @param params - Funding proof parameters
5255
- * @param onProgress - Optional progress callback
5256
- */
5257
- async generateFundingProof(params, onProgress) {
5258
- this.ensureReady();
5259
- if (!this.fundingNoir || !this.fundingBackend) {
5260
- throw new ProofGenerationError("funding", "Funding circuit not initialized");
5261
- }
5262
- try {
5263
- onProgress?.({
5264
- stage: "witness",
5265
- percent: 10,
5266
- message: "Preparing witness inputs..."
5267
- });
5268
- const { commitmentHash, blindingField } = await this.computeCommitmentHash(
5269
- params.balance,
5270
- params.blindingFactor,
5271
- params.assetId
5272
- );
5273
- const witnessInputs = {
5274
- commitment_hash: commitmentHash,
5275
- minimum_required: params.minimumRequired.toString(),
5276
- asset_id: this.assetIdToField(params.assetId),
5277
- balance: params.balance.toString(),
5278
- blinding: blindingField
5279
- };
5280
- onProgress?.({
5281
- stage: "witness",
5282
- percent: 30,
5283
- message: "Generating witness..."
5284
- });
5285
- const { witness } = await this.fundingNoir.execute(witnessInputs);
5286
- onProgress?.({
5287
- stage: "proving",
5288
- percent: 50,
5289
- message: "Generating proof (this may take a moment)..."
5290
- });
5291
- const proofData = await this.fundingBackend.generateProof(witness);
5292
- onProgress?.({
5293
- stage: "complete",
5294
- percent: 100,
5295
- message: "Proof generated successfully"
5296
- });
5297
- const publicInputs = [
5298
- `0x${commitmentHash}`,
5299
- `0x${params.minimumRequired.toString(16).padStart(16, "0")}`,
5300
- `0x${this.assetIdToField(params.assetId)}`
5301
- ];
5302
- const proof = {
5303
- type: "funding",
5304
- proof: `0x${bytesToHex7(proofData.proof)}`,
5305
- publicInputs
5306
- };
5307
- return { proof, publicInputs };
5308
- } catch (error) {
5309
- const message = error instanceof Error ? error.message : String(error);
5310
- throw new ProofGenerationError(
5311
- "funding",
5312
- `Failed to generate funding proof: ${message}`,
5313
- error instanceof Error ? error : void 0
5314
- );
5315
- }
5316
- }
5317
- /**
5318
- * Generate a Validity Proof
5319
- *
5320
- * Proves: Intent is authorized by sender without revealing identity
5321
- */
5322
- async generateValidityProof(params, onProgress) {
5323
- this.ensureReady();
5324
- if (!this.validityNoir || !this.validityBackend) {
5325
- throw new ProofGenerationError("validity", "Validity circuit not initialized");
5326
- }
5327
- try {
5328
- onProgress?.({
5329
- stage: "witness",
5330
- percent: 10,
5331
- message: "Preparing validity witness..."
5332
- });
5333
- const intentHashField = this.hexToField(params.intentHash);
5334
- const senderAddressField = this.hexToField(params.senderAddress);
5335
- const senderBlindingField = this.bytesToField(params.senderBlinding);
5336
- const senderSecretField = this.bytesToField(params.senderSecret);
5337
- const nonceField = this.bytesToField(params.nonce);
5338
- const { commitmentX, commitmentY } = await this.computeSenderCommitment(
5339
- senderAddressField,
5340
- senderBlindingField
5341
- );
5342
- const nullifier = await this.computeNullifier(senderSecretField, intentHashField, nonceField);
5343
- const signature = Array.from(params.authorizationSignature);
5344
- const messageHash = this.fieldToBytes32(intentHashField);
5345
- let pubKeyX;
5346
- let pubKeyY;
5347
- if (params.senderPublicKey) {
5348
- pubKeyX = Array.from(params.senderPublicKey.x);
5349
- pubKeyY = Array.from(params.senderPublicKey.y);
5350
- } else {
5351
- const coords = this.getPublicKeyCoordinates(params.senderSecret);
5352
- pubKeyX = coords.x;
5353
- pubKeyY = coords.y;
5354
- }
5355
- const witnessInputs = {
5356
- intent_hash: intentHashField,
5357
- sender_commitment_x: commitmentX,
5358
- sender_commitment_y: commitmentY,
5359
- nullifier,
5360
- timestamp: params.timestamp.toString(),
5361
- expiry: params.expiry.toString(),
5362
- sender_address: senderAddressField,
5363
- sender_blinding: senderBlindingField,
5364
- sender_secret: senderSecretField,
5365
- pub_key_x: pubKeyX,
5366
- pub_key_y: pubKeyY,
5367
- signature,
5368
- message_hash: messageHash,
5369
- nonce: nonceField
5370
- };
5371
- onProgress?.({
5372
- stage: "witness",
5373
- percent: 30,
5374
- message: "Generating witness..."
5375
- });
5376
- const { witness } = await this.validityNoir.execute(witnessInputs);
5377
- onProgress?.({
5378
- stage: "proving",
5379
- percent: 50,
5380
- message: "Generating validity proof..."
5381
- });
5382
- const proofData = await this.validityBackend.generateProof(witness);
5383
- onProgress?.({
5384
- stage: "complete",
5385
- percent: 100,
5386
- message: "Validity proof generated"
5387
- });
5388
- const publicInputs = [
5389
- `0x${intentHashField}`,
5390
- `0x${commitmentX}`,
5391
- `0x${commitmentY}`,
5392
- `0x${nullifier}`,
5393
- `0x${params.timestamp.toString(16).padStart(16, "0")}`,
5394
- `0x${params.expiry.toString(16).padStart(16, "0")}`
5395
- ];
5396
- const proof = {
5397
- type: "validity",
5398
- proof: `0x${bytesToHex7(proofData.proof)}`,
5399
- publicInputs
5400
- };
5401
- return { proof, publicInputs };
5402
- } catch (error) {
5403
- const message = error instanceof Error ? error.message : String(error);
5404
- throw new ProofGenerationError(
5405
- "validity",
5406
- `Failed to generate validity proof: ${message}`,
5407
- error instanceof Error ? error : void 0
5408
- );
5409
- }
5410
- }
5411
- /**
5412
- * Generate a Fulfillment Proof
5413
- *
5414
- * Proves: Solver correctly executed the intent
5415
- */
5416
- async generateFulfillmentProof(params, onProgress) {
5417
- this.ensureReady();
5418
- if (!this.fulfillmentNoir || !this.fulfillmentBackend) {
5419
- throw new ProofGenerationError("fulfillment", "Fulfillment circuit not initialized");
5420
- }
5421
- try {
5422
- onProgress?.({
5423
- stage: "witness",
5424
- percent: 10,
5425
- message: "Preparing fulfillment witness..."
5426
- });
5427
- const intentHashField = this.hexToField(params.intentHash);
5428
- const recipientStealthField = this.hexToField(params.recipientStealth);
5429
- const { commitmentX, commitmentY } = await this.computeOutputCommitment(
5430
- params.outputAmount,
5431
- params.outputBlinding
5432
- );
5433
- const solverSecretField = this.bytesToField(params.solverSecret);
5434
- const solverId = await this.computeSolverId(solverSecretField);
5435
- const outputBlindingField = this.bytesToField(params.outputBlinding);
5436
- const attestation = params.oracleAttestation;
5437
- const attestationRecipientField = this.hexToField(attestation.recipient);
5438
- const attestationTxHashField = this.hexToField(attestation.txHash);
5439
- const oracleSignature = Array.from(attestation.signature);
5440
- const oracleMessageHash = await this.computeOracleMessageHash(
5441
- attestation.recipient,
5442
- attestation.amount,
5443
- attestation.txHash,
5444
- attestation.blockNumber
5445
- );
5446
- const oraclePubKeyX = this.config.oraclePublicKey?.x ?? new Array(32).fill(0);
5447
- const oraclePubKeyY = this.config.oraclePublicKey?.y ?? new Array(32).fill(0);
5448
- const witnessInputs = {
5449
- intent_hash: intentHashField,
5450
- output_commitment_x: commitmentX,
5451
- output_commitment_y: commitmentY,
5452
- recipient_stealth: recipientStealthField,
5453
- min_output_amount: params.minOutputAmount.toString(),
5454
- solver_id: solverId,
5455
- fulfillment_time: params.fulfillmentTime.toString(),
5456
- expiry: params.expiry.toString(),
5457
- output_amount: params.outputAmount.toString(),
5458
- output_blinding: outputBlindingField,
5459
- solver_secret: solverSecretField,
5460
- attestation_recipient: attestationRecipientField,
5461
- attestation_amount: attestation.amount.toString(),
5462
- attestation_tx_hash: attestationTxHashField,
5463
- attestation_block: attestation.blockNumber.toString(),
5464
- oracle_signature: oracleSignature,
5465
- oracle_message_hash: oracleMessageHash,
5466
- oracle_pub_key_x: oraclePubKeyX,
5467
- oracle_pub_key_y: oraclePubKeyY
5468
- };
5469
- onProgress?.({
5470
- stage: "witness",
5471
- percent: 30,
5472
- message: "Generating witness..."
5473
- });
5474
- const { witness } = await this.fulfillmentNoir.execute(witnessInputs);
5475
- onProgress?.({
5476
- stage: "proving",
5477
- percent: 50,
5478
- message: "Generating fulfillment proof..."
5479
- });
5480
- const proofData = await this.fulfillmentBackend.generateProof(witness);
5481
- onProgress?.({
5482
- stage: "complete",
5483
- percent: 100,
5484
- message: "Fulfillment proof generated"
5485
- });
5486
- const publicInputs = [
5487
- `0x${intentHashField}`,
5488
- `0x${commitmentX}`,
5489
- `0x${commitmentY}`,
5490
- `0x${recipientStealthField}`,
5491
- `0x${params.minOutputAmount.toString(16).padStart(16, "0")}`,
5492
- `0x${solverId}`,
5493
- `0x${params.fulfillmentTime.toString(16).padStart(16, "0")}`,
5494
- `0x${params.expiry.toString(16).padStart(16, "0")}`
5495
- ];
5496
- const proof = {
5497
- type: "fulfillment",
5498
- proof: `0x${bytesToHex7(proofData.proof)}`,
5499
- publicInputs
5500
- };
5501
- return { proof, publicInputs };
5502
- } catch (error) {
5503
- const message = error instanceof Error ? error.message : String(error);
5504
- throw new ProofGenerationError(
5505
- "fulfillment",
5506
- `Failed to generate fulfillment proof: ${message}`,
5507
- error instanceof Error ? error : void 0
5508
- );
5509
- }
5510
- }
5511
- /**
5512
- * Verify a proof
5513
- */
5514
- async verifyProof(proof) {
5515
- this.ensureReady();
5516
- let backend = null;
5517
- switch (proof.type) {
5518
- case "funding":
5519
- backend = this.fundingBackend;
5520
- break;
5521
- case "validity":
5522
- backend = this.validityBackend;
5523
- break;
5524
- case "fulfillment":
5525
- backend = this.fulfillmentBackend;
5526
- break;
5527
- default:
5528
- throw new ProofError(`Unknown proof type: ${proof.type}`, "SIP_4003" /* PROOF_NOT_IMPLEMENTED */);
5529
- }
5530
- if (!backend) {
5531
- throw new ProofError(
5532
- `${proof.type} backend not initialized`,
5533
- "SIP_4004" /* PROOF_PROVIDER_NOT_READY */
5534
- );
5535
- }
5536
- try {
5537
- const proofHex = proof.proof.startsWith("0x") ? proof.proof.slice(2) : proof.proof;
5538
- const proofBytes = hexToBytes5(proofHex);
5539
- const isValid = await backend.verifyProof({
5540
- proof: proofBytes,
5541
- publicInputs: proof.publicInputs.map(
5542
- (input) => input.startsWith("0x") ? input.slice(2) : input
5543
- )
5544
- });
5545
- return isValid;
5546
- } catch (error) {
5547
- if (this.config.verbose) {
5548
- console.error("[BrowserNoirProvider] Verification error:", error);
5549
- }
5550
- return false;
5551
- }
5552
- }
5553
- /**
5554
- * Destroy the provider and free resources
5555
- */
5556
- async destroy() {
5557
- if (this.fundingBackend) {
5558
- await this.fundingBackend.destroy();
5559
- this.fundingBackend = null;
5560
- }
5561
- if (this.validityBackend) {
5562
- await this.validityBackend.destroy();
5563
- this.validityBackend = null;
5564
- }
5565
- if (this.fulfillmentBackend) {
5566
- await this.fulfillmentBackend.destroy();
5567
- this.fulfillmentBackend = null;
5568
- }
5569
- if (this.worker) {
5570
- this.worker.terminate();
5571
- this.worker = null;
5572
- }
5573
- this.fundingNoir = null;
5574
- this.validityNoir = null;
5575
- this.fulfillmentNoir = null;
5576
- this._isReady = false;
5577
- }
5578
- // ─── Private Utility Methods ────────────────────────────────────────────────
5579
- ensureReady() {
5580
- if (!this._isReady) {
5581
- throw new ProofError(
5582
- "BrowserNoirProvider not initialized. Call initialize() first.",
5583
- "SIP_4004" /* PROOF_PROVIDER_NOT_READY */
5584
- );
5585
- }
5586
- }
5587
- async computeCommitmentHash(balance, blindingFactor, assetId) {
5588
- const blindingField = this.bytesToField(blindingFactor);
5589
- const { sha256: sha25611 } = await import("@noble/hashes/sha256");
5590
- const { bytesToHex: nobleToHex } = await import("@noble/hashes/utils");
5591
- const preimage = new Uint8Array([
5592
- ...this.bigintToBytes(balance, 8),
5593
- ...blindingFactor.slice(0, 32),
5594
- ...hexToBytes5(this.assetIdToField(assetId))
5595
- ]);
5596
- const hash2 = sha25611(preimage);
5597
- const commitmentHash = nobleToHex(hash2);
5598
- return { commitmentHash, blindingField };
5599
- }
5600
- assetIdToField(assetId) {
5601
- if (assetId.startsWith("0x")) {
5602
- return assetId.slice(2).padStart(64, "0");
5603
- }
5604
- const encoder = new TextEncoder();
5605
- const bytes = encoder.encode(assetId);
5606
- let result = 0n;
5607
- for (let i = 0; i < bytes.length && i < 31; i++) {
5608
- result = result * 256n + BigInt(bytes[i]);
5609
- }
5610
- return result.toString(16).padStart(64, "0");
5611
- }
5612
- bytesToField(bytes) {
5613
- let result = 0n;
5614
- const len = Math.min(bytes.length, 31);
5615
- for (let i = 0; i < len; i++) {
5616
- result = result * 256n + BigInt(bytes[i]);
5617
- }
5618
- return result.toString();
5619
- }
5620
- bigintToBytes(value, length) {
5621
- const bytes = new Uint8Array(length);
5622
- let v = value;
5623
- for (let i = length - 1; i >= 0; i--) {
5624
- bytes[i] = Number(v & 0xffn);
5625
- v = v >> 8n;
5626
- }
5627
- return bytes;
5628
- }
5629
- hexToField(hex) {
5630
- const h = hex.startsWith("0x") ? hex.slice(2) : hex;
5631
- return h.padStart(64, "0");
5632
- }
5633
- fieldToBytes32(field) {
5634
- const hex = field.padStart(64, "0");
5635
- const bytes = [];
5636
- for (let i = 0; i < 32; i++) {
5637
- bytes.push(parseInt(hex.slice(i * 2, i * 2 + 2), 16));
5638
- }
5639
- return bytes;
5640
- }
5641
- async computeSenderCommitment(senderAddressField, senderBlindingField) {
5642
- const { sha256: sha25611 } = await import("@noble/hashes/sha256");
5643
- const { bytesToHex: nobleToHex } = await import("@noble/hashes/utils");
5644
- const addressBytes = hexToBytes5(senderAddressField);
5645
- const blindingBytes = hexToBytes5(senderBlindingField.padStart(64, "0"));
5646
- const preimage = new Uint8Array([...addressBytes, ...blindingBytes]);
5647
- const hash2 = sha25611(preimage);
5648
- const commitmentX = nobleToHex(hash2.slice(0, 16)).padStart(64, "0");
5649
- const commitmentY = nobleToHex(hash2.slice(16, 32)).padStart(64, "0");
5650
- return { commitmentX, commitmentY };
5651
- }
5652
- async computeNullifier(senderSecretField, intentHashField, nonceField) {
5653
- const { sha256: sha25611 } = await import("@noble/hashes/sha256");
5654
- const { bytesToHex: nobleToHex } = await import("@noble/hashes/utils");
5655
- const secretBytes = hexToBytes5(senderSecretField.padStart(64, "0"));
5656
- const intentBytes = hexToBytes5(intentHashField);
5657
- const nonceBytes = hexToBytes5(nonceField.padStart(64, "0"));
5658
- const preimage = new Uint8Array([...secretBytes, ...intentBytes, ...nonceBytes]);
5659
- const hash2 = sha25611(preimage);
5660
- return nobleToHex(hash2);
5661
- }
5662
- async computeOutputCommitment(outputAmount, outputBlinding) {
5663
- const { sha256: sha25611 } = await import("@noble/hashes/sha256");
5664
- const { bytesToHex: nobleToHex } = await import("@noble/hashes/utils");
5665
- const amountBytes = this.bigintToBytes(outputAmount, 8);
5666
- const blindingBytes = outputBlinding.slice(0, 32);
5667
- const preimage = new Uint8Array([...amountBytes, ...blindingBytes]);
5668
- const hash2 = sha25611(preimage);
5669
- const commitmentX = nobleToHex(hash2.slice(0, 16)).padStart(64, "0");
5670
- const commitmentY = nobleToHex(hash2.slice(16, 32)).padStart(64, "0");
5671
- return { commitmentX, commitmentY };
5672
- }
5673
- async computeSolverId(solverSecretField) {
5674
- const { sha256: sha25611 } = await import("@noble/hashes/sha256");
5675
- const { bytesToHex: nobleToHex } = await import("@noble/hashes/utils");
5676
- const secretBytes = hexToBytes5(solverSecretField.padStart(64, "0"));
5677
- const hash2 = sha25611(secretBytes);
5678
- return nobleToHex(hash2);
5679
- }
5680
- async computeOracleMessageHash(recipient, amount, txHash, blockNumber) {
5681
- const { sha256: sha25611 } = await import("@noble/hashes/sha256");
5682
- const recipientBytes = hexToBytes5(this.hexToField(recipient));
5683
- const amountBytes = this.bigintToBytes(amount, 8);
5684
- const txHashBytes = hexToBytes5(this.hexToField(txHash));
5685
- const blockBytes = this.bigintToBytes(blockNumber, 8);
5686
- const preimage = new Uint8Array([
5687
- ...recipientBytes,
5688
- ...amountBytes,
5689
- ...txHashBytes,
5690
- ...blockBytes
5691
- ]);
5692
- const hash2 = sha25611(preimage);
5693
- return Array.from(hash2);
5694
- }
5695
- getPublicKeyCoordinates(privateKey) {
5696
- const uncompressedPubKey = import_secp256k14.secp256k1.getPublicKey(privateKey, false);
5697
- const x = Array.from(uncompressedPubKey.slice(1, 33));
5698
- const y = Array.from(uncompressedPubKey.slice(33, 65));
5699
- return { x, y };
5700
- }
5701
- };
5702
-
5703
5099
  // src/oracle/types.ts
5704
5100
  var ORACLE_DOMAIN = "SIP-ORACLE-ATTESTATION-V1";
5705
5101
  var ATTESTATION_VERSION = 1;
@@ -7653,7 +7049,7 @@ function getPaymentSummary(payment) {
7653
7049
 
7654
7050
  // src/treasury/treasury.ts
7655
7051
  var import_types12 = require("@sip-protocol/types");
7656
- var import_secp256k15 = require("@noble/curves/secp256k1");
7052
+ var import_secp256k14 = require("@noble/curves/secp256k1");
7657
7053
  var import_sha25610 = require("@noble/hashes/sha256");
7658
7054
  var import_utils12 = require("@noble/hashes/utils");
7659
7055
  var DEFAULT_PROPOSAL_TTL = 7 * 24 * 60 * 60;
@@ -8169,7 +7565,7 @@ function signMessage(messageHash, privateKey) {
8169
7565
  const keyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
8170
7566
  const keyBytes = (0, import_utils12.hexToBytes)(keyHex);
8171
7567
  try {
8172
- const signature = import_secp256k15.secp256k1.sign(messageHash, keyBytes);
7568
+ const signature = import_secp256k14.secp256k1.sign(messageHash, keyBytes);
8173
7569
  return `0x${signature.toCompactHex()}`;
8174
7570
  } finally {
8175
7571
  secureWipe(keyBytes);
@@ -8181,7 +7577,7 @@ function verifySignature(messageHash, signature, publicKey) {
8181
7577
  try {
8182
7578
  const sigBytes = (0, import_utils12.hexToBytes)(sigHex);
8183
7579
  const pubKeyBytes = (0, import_utils12.hexToBytes)(pubKeyHex);
8184
- return import_secp256k15.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
7580
+ return import_secp256k14.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
8185
7581
  } catch {
8186
7582
  return false;
8187
7583
  }
@@ -12710,7 +12106,6 @@ var import_types32 = require("@sip-protocol/types");
12710
12106
  0 && (module.exports = {
12711
12107
  ATTESTATION_VERSION,
12712
12108
  BaseWalletAdapter,
12713
- BrowserNoirProvider,
12714
12109
  CHAIN_NUMERIC_IDS,
12715
12110
  ComplianceManager,
12716
12111
  CryptoError,
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  ATTESTATION_VERSION,
3
3
  BaseWalletAdapter,
4
- BrowserNoirProvider,
5
4
  CHAIN_NUMERIC_IDS,
6
5
  ComplianceManager,
7
6
  CryptoError,
@@ -213,11 +212,10 @@ import {
213
212
  withSecureBuffer,
214
213
  withSecureBufferSync,
215
214
  wrapError
216
- } from "./chunk-O4Y2ZUDL.mjs";
215
+ } from "./chunk-4VJHI66K.mjs";
217
216
  export {
218
217
  ATTESTATION_VERSION,
219
218
  BaseWalletAdapter,
220
- BrowserNoirProvider,
221
219
  CHAIN_NUMERIC_IDS,
222
220
  ComplianceManager,
223
221
  CryptoError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sip-protocol/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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",
@@ -27,9 +27,6 @@
27
27
  "require": "./dist/browser.js"
28
28
  }
29
29
  },
30
- "browser": {
31
- "./dist/index.mjs": "./dist/browser.mjs"
32
- },
33
30
  "files": [
34
31
  "dist",
35
32
  "src"
package/src/browser.ts CHANGED
@@ -19,9 +19,11 @@
19
19
  // Re-export everything from main entry
20
20
  export * from './index'
21
21
 
22
- // Browser-specific exports (already in main, but explicit here)
22
+ // Browser-specific exports (import directly from browser module to get WASM support)
23
+ export { BrowserNoirProvider } from './proofs/browser'
24
+
25
+ // Re-export utilities that are already in main (for convenience)
23
26
  export {
24
- BrowserNoirProvider,
25
27
  isBrowser,
26
28
  supportsWebWorkers,
27
29
  supportsSharedArrayBuffer,