@sip-protocol/sdk 0.3.0 → 0.3.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/browser.d.mts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +246 -4
- package/dist/browser.mjs +241 -5
- package/dist/chunk-YZCK337Y.mjs +12155 -0
- package/dist/index-DAgedMrt.d.ts +6927 -0
- package/dist/index-DW7AQwcU.d.mts +6927 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/proofs/worker.ts +240 -4
- package/src/zcash/bridge.ts +20 -2
- package/src/zcash/swap-service.ts +20 -2
package/dist/browser.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { bj as ATTESTATION_VERSION, bv as AttestationRequest, bw as AttestationResult, bT as BackendCapabilities, cT as BaseWalletAdapter, cr as BridgeProvider, B as BrowserNoirProvider, t as BrowserNoirProviderConfig, bm as CHAIN_NUMERIC_IDS, aM as CommitmentPoint, cS as ComplianceManager, $ as CreateIntentOptions, cP as CreatePaymentOptions, C as CryptoError, bk as DEFAULT_THRESHOLD, bl as DEFAULT_TOTAL_ORACLES, dq as DerivationPath, dT as EIP1193ConnectInfo, dS as EIP1193Event, dQ as EIP1193Provider, dU as EIP1193ProviderRpcError, dR as EIP1193RequestArguments, dV as EIP712Domain, dW as EIP712TypeDefinition, dY as EIP712TypedData, dX as EIP712Types, w as EncryptionNotImplementedError, E as ErrorCode, e2 as EthereumAdapterConfig, dm as EthereumChainId, e3 as EthereumChainIdType, e0 as EthereumChainMetadata, d$ as EthereumTokenMetadata, d_ as EthereumTransactionReceipt, dZ as EthereumTransactionRequest, da as EthereumWalletAdapter, e1 as EthereumWalletName, ci as ExportedViewingKey, c0 as FindBestRouteParams, eh as HardwareAccount, e8 as HardwareConnectionStatus, ea as HardwareDeviceInfo, dn as HardwareErrorCode, ej as HardwareErrorCodeType, ef as HardwareEthereumTx, ee as HardwareSignRequest, eg as HardwareSignature, ei as HardwareTransport, eb as HardwareWalletConfig, dp as HardwareWalletError, e5 as HardwareWalletType, L as IntentBuilder, I as IntentError, ec as LedgerConfig, e6 as LedgerModel, dw as LedgerWalletAdapter, p as MobileBrowser, q as MobileDeviceInfo, M as MobilePlatform, r as MobileWASMCompatibility, dc as MockEthereumAdapter, e4 as MockEthereumAdapterConfig, ek as MockHardwareConfig, dA as MockLedgerAdapter, b3 as MockProofProvider, d2 as MockSolanaAdapter, dP as MockSolanaAdapterConfig, bF as MockSolver, bH as MockSolverConfig, dB as MockTrezorAdapter, cU as MockWalletAdapter, bz as NEARIntentsAdapter, bE as NEARIntentsAdapterConfig, c1 as NEARIntentsBackend, N as NetworkError, bi as ORACLE_DOMAIN, by as OneClickClient, bq as OracleAttestationMessage, bn as OracleId, bp as OracleInfo, bt as OracleRegistry, bu as OracleRegistryConfig, br as OracleSignature, bo as OracleStatus, ct as PaymentBuilder, aL as PedersenCommitment, bC as PreparedSwap, cs as PriceFeed, ar as PrivacyConfig, K as ProductionQuote, u as ProofError, v as ProofNotImplementedError, P as ProofProgressCallback, b$ as QuoteComparison, cg as ReceivedNote, bX as Route, b_ as RouteWithQuote, F as SIP, J as SIPConfig, S as SIPError, cD as STABLECOIN_ADDRESSES, cE as STABLECOIN_DECIMALS, cC as STABLECOIN_INFO, D as SerializedError, bU as SettlementBackend, bV as SettlementBackendFactory, bL as SettlementBackendName, bW as SettlementBackendRegistry, bN as SettlementQuote, bM as SettlementQuoteParams, bJ as SettlementRegistry, bK as SettlementRegistryError, bQ as SettlementSwapParams, bR as SettlementSwapResult, bO as SettlementSwapRoute, bP as SettlementSwapRouteStep, ch as ShieldedBalance, ce as ShieldedSendParams, cf as ShieldedSendResult, bs as SignedOracleAttestation, bY as SmartRouter, dK as SolanaAdapterConfig, dJ as SolanaCluster, dL as SolanaConnection, dE as SolanaPublicKey, dM as SolanaSendOptions, dO as SolanaSignature, dF as SolanaTransaction, dN as SolanaUnsignedTransaction, dG as SolanaVersionedTransaction, d0 as SolanaWalletAdapter, dI as SolanaWalletName, dH as SolanaWalletProvider, cQ as StablecoinInfo, ak as StealthCurve, bB as SwapRequest, bD as SwapResult, bI as SwapStatus, bS as SwapStatusResponse, as as TransactionData, e9 as TransportType, cR as Treasury, ed as TrezorConfig, e7 as TrezorModel, dy as TrezorWalletAdapter, V as ValidationError, bx as VerificationResult, W as WalletAdapter, cV as WalletError, c3 as ZcashNativeBackend, c5 as ZcashNativeBackendConfig, cn as ZcashQuote, cm as ZcashQuoteParams, c6 as ZcashRPCClient, c7 as ZcashRPCError, c9 as ZcashShieldedService, cd as ZcashShieldedServiceConfig, co as ZcashSwapParams, cp as ZcashSwapResult, cb as ZcashSwapService, cj as ZcashSwapServiceConfig, ck as ZcashSwapSourceChain, cl as ZcashSwapSourceToken, cq as ZcashSwapStatus, aH as addBlindings, aF as addCommitments, b9 as addOracle, Q as attachProofs, d9 as base58ToHex, b as browserBytesToHex, h as browserHexToBytes, ac as checkEd25519StealthAddress, f as checkMobileWASMCompatibility, a3 as checkStealthAddress, aC as commit, aE as commitZero, bg as computeAttestationHash, at as createCommitment, db as createEthereumAdapter, dx as createLedgerAdapter, dd as createMockEthereumAdapter, de as createMockEthereumProvider, dC as createMockLedgerAdapter, d3 as createMockSolanaAdapter, d5 as createMockSolanaConnection, d4 as createMockSolanaProvider, bG as createMockSolver, dD as createMockTrezorAdapter, bA as createNEARIntentsAdapter, c2 as createNEARIntentsBackend, b8 as createOracleRegistry, H as createProductionSIP, G as createSIP, O as createShieldedIntent, cu as createShieldedPayment, bZ as createSmartRouter, d1 as createSolanaAdapter, dz as createTrezorAdapter, c_ as createWalletFactory, c8 as createZcashClient, c4 as createZcashNativeBackend, ca as createZcashShieldedService, cc as createZcashSwapService, a5 as decodeStealthMetaAddress, cv as decryptMemo, ap as decryptWithViewing, ab as deriveEd25519StealthPrivateKey, b7 as deriveOracleId, a2 as deriveStealthPrivateKey, an as deriveViewingKey, bf as deserializeAttestationMessage, Z as deserializeIntent, cA as deserializePayment, dg as detectEthereumWallets, c as detectMobileBrowser, d as detectMobilePlatform, d7 as detectSolanaWallets, ag as ed25519PublicKeyToNearAddress, ad as ed25519PublicKeyToSolanaAddress, a4 as encodeStealthMetaAddress, ao as encryptForViewing, cX as featureNotSupportedError, cO as formatStablecoinAmount, di as fromHex, cN as fromStablecoinUnits, aK as generateBlinding, aa as generateEd25519StealthAddress, a9 as generateEd25519StealthMetaAddress, av as generateIntentId, ax as generateRandomBytes, a1 as generateStealthAddress, a0 as generateStealthMetaAddress, am as generateViewingKey, bc as getActiveOracles, dv as getAvailableTransports, g as getBrowserInfo, j as getBrowserVersion, bh as getChainNumericId, cL as getChainsForStablecoin, a8 as getCurveForChain, dl as getDefaultRpcEndpoint, dr as getDerivationPath, A as getErrorMessage, df as getEthereumProvider, aJ as getGenerators, _ as getIntentSummary, e as getMobileDeviceInfo, k as getOSVersion, cB as getPaymentSummary, cy as getPaymentTimeRemaining, al as getPrivacyConfig, aq as getPrivacyDescription, d6 as getSolanaProvider, cF as getStablecoin, cI as getStablecoinInfo, cG as getStablecoinsForChain, cJ as getSupportedStablecoins, X as getTimeRemaining, bd as hasEnoughOracles, y as hasErrorCode, R as hasRequiredProofs, aw as hash, dj as hexToNumber, i as isBrowser, a7 as isEd25519Chain, U as isExpired, aS as isNonNegativeAmount, cx as isPaymentExpired, c$ as isPrivateWalletAdapter, x as isSIPError, cH as isStablecoin, cK as isStablecoinOnChain, l as isTablet, aR as isValidAmount, aN as isValidChainId, aV as isValidCompressedPublicKey, aW as isValidEd25519PublicKey, aP as isValidHex, aQ as isValidHexLength, aj as isValidNearAccountId, ai as isValidNearImplicitAddress, aO as isValidPrivacyLevel, aX as isValidPrivateKey, aY as isValidScalar, aT as isValidSlippage, af as isValidSolanaAddress, aU as isValidStealthMetaAddress, ah as nearAddressToEd25519PublicKey, dk as normalizeAddress, cW as notConnectedError, a6 as publicKeyToEthAddress, cZ as registerWallet, ba as removeOracle, ay as secureWipe, az as secureWipeAll, be as serializeAttestationMessage, Y as serializeIntent, cz as serializePayment, b6 as signAttestationMessage, ae as solanaAddressToEd25519PublicKey, d8 as solanaPublicKeyToHex, aI as subtractBlindings, aG as subtractCommitments, a as supportsSharedArrayBuffer, m as supportsTouch, o as supportsWASMBulkMemory, n as supportsWASMSimd, du as supportsWebBluetooth, dt as supportsWebHID, ds as supportsWebUSB, s as supportsWebWorkers, dh as toHex, cM as toStablecoinUnits, T as trackIntent, cw as trackPayment, bb as updateOracleStatus, a_ as validateAsset, aZ as validateCreateIntentParams, a$ as validateIntentInput, b0 as validateIntentOutput, b2 as validateScalar, b1 as validateViewingKey, b4 as verifyAttestation, au as verifyCommitment, aD as verifyOpening, b5 as verifyOracleSignature, cY as walletRegistry, aA as withSecureBuffer, aB as withSecureBufferSync, z as wrapError } from './index-
|
|
1
|
+
export { bj as ATTESTATION_VERSION, bv as AttestationRequest, bw as AttestationResult, bT as BackendCapabilities, cT as BaseWalletAdapter, cr as BridgeProvider, B as BrowserNoirProvider, t as BrowserNoirProviderConfig, bm as CHAIN_NUMERIC_IDS, aM as CommitmentPoint, cS as ComplianceManager, $ as CreateIntentOptions, cP as CreatePaymentOptions, C as CryptoError, bk as DEFAULT_THRESHOLD, bl as DEFAULT_TOTAL_ORACLES, dq as DerivationPath, dT as EIP1193ConnectInfo, dS as EIP1193Event, dQ as EIP1193Provider, dU as EIP1193ProviderRpcError, dR as EIP1193RequestArguments, dV as EIP712Domain, dW as EIP712TypeDefinition, dY as EIP712TypedData, dX as EIP712Types, w as EncryptionNotImplementedError, E as ErrorCode, e2 as EthereumAdapterConfig, dm as EthereumChainId, e3 as EthereumChainIdType, e0 as EthereumChainMetadata, d$ as EthereumTokenMetadata, d_ as EthereumTransactionReceipt, dZ as EthereumTransactionRequest, da as EthereumWalletAdapter, e1 as EthereumWalletName, ci as ExportedViewingKey, c0 as FindBestRouteParams, eh as HardwareAccount, e8 as HardwareConnectionStatus, ea as HardwareDeviceInfo, dn as HardwareErrorCode, ej as HardwareErrorCodeType, ef as HardwareEthereumTx, ee as HardwareSignRequest, eg as HardwareSignature, ei as HardwareTransport, eb as HardwareWalletConfig, dp as HardwareWalletError, e5 as HardwareWalletType, L as IntentBuilder, I as IntentError, ec as LedgerConfig, e6 as LedgerModel, dw as LedgerWalletAdapter, p as MobileBrowser, q as MobileDeviceInfo, M as MobilePlatform, r as MobileWASMCompatibility, dc as MockEthereumAdapter, e4 as MockEthereumAdapterConfig, ek as MockHardwareConfig, dA as MockLedgerAdapter, b3 as MockProofProvider, d2 as MockSolanaAdapter, dP as MockSolanaAdapterConfig, bF as MockSolver, bH as MockSolverConfig, dB as MockTrezorAdapter, cU as MockWalletAdapter, bz as NEARIntentsAdapter, bE as NEARIntentsAdapterConfig, c1 as NEARIntentsBackend, N as NetworkError, bi as ORACLE_DOMAIN, by as OneClickClient, bq as OracleAttestationMessage, bn as OracleId, bp as OracleInfo, bt as OracleRegistry, bu as OracleRegistryConfig, br as OracleSignature, bo as OracleStatus, ct as PaymentBuilder, aL as PedersenCommitment, bC as PreparedSwap, cs as PriceFeed, ar as PrivacyConfig, K as ProductionQuote, u as ProofError, v as ProofNotImplementedError, P as ProofProgressCallback, b$ as QuoteComparison, cg as ReceivedNote, bX as Route, b_ as RouteWithQuote, F as SIP, J as SIPConfig, S as SIPError, cD as STABLECOIN_ADDRESSES, cE as STABLECOIN_DECIMALS, cC as STABLECOIN_INFO, D as SerializedError, bU as SettlementBackend, bV as SettlementBackendFactory, bL as SettlementBackendName, bW as SettlementBackendRegistry, bN as SettlementQuote, bM as SettlementQuoteParams, bJ as SettlementRegistry, bK as SettlementRegistryError, bQ as SettlementSwapParams, bR as SettlementSwapResult, bO as SettlementSwapRoute, bP as SettlementSwapRouteStep, ch as ShieldedBalance, ce as ShieldedSendParams, cf as ShieldedSendResult, bs as SignedOracleAttestation, bY as SmartRouter, dK as SolanaAdapterConfig, dJ as SolanaCluster, dL as SolanaConnection, dE as SolanaPublicKey, dM as SolanaSendOptions, dO as SolanaSignature, dF as SolanaTransaction, dN as SolanaUnsignedTransaction, dG as SolanaVersionedTransaction, d0 as SolanaWalletAdapter, dI as SolanaWalletName, dH as SolanaWalletProvider, cQ as StablecoinInfo, ak as StealthCurve, bB as SwapRequest, bD as SwapResult, bI as SwapStatus, bS as SwapStatusResponse, as as TransactionData, e9 as TransportType, cR as Treasury, ed as TrezorConfig, e7 as TrezorModel, dy as TrezorWalletAdapter, V as ValidationError, bx as VerificationResult, W as WalletAdapter, cV as WalletError, c3 as ZcashNativeBackend, c5 as ZcashNativeBackendConfig, cn as ZcashQuote, cm as ZcashQuoteParams, c6 as ZcashRPCClient, c7 as ZcashRPCError, c9 as ZcashShieldedService, cd as ZcashShieldedServiceConfig, co as ZcashSwapParams, cp as ZcashSwapResult, cb as ZcashSwapService, cj as ZcashSwapServiceConfig, ck as ZcashSwapSourceChain, cl as ZcashSwapSourceToken, cq as ZcashSwapStatus, aH as addBlindings, aF as addCommitments, b9 as addOracle, Q as attachProofs, d9 as base58ToHex, b as browserBytesToHex, h as browserHexToBytes, ac as checkEd25519StealthAddress, f as checkMobileWASMCompatibility, a3 as checkStealthAddress, aC as commit, aE as commitZero, bg as computeAttestationHash, at as createCommitment, db as createEthereumAdapter, dx as createLedgerAdapter, dd as createMockEthereumAdapter, de as createMockEthereumProvider, dC as createMockLedgerAdapter, d3 as createMockSolanaAdapter, d5 as createMockSolanaConnection, d4 as createMockSolanaProvider, bG as createMockSolver, dD as createMockTrezorAdapter, bA as createNEARIntentsAdapter, c2 as createNEARIntentsBackend, b8 as createOracleRegistry, H as createProductionSIP, G as createSIP, O as createShieldedIntent, cu as createShieldedPayment, bZ as createSmartRouter, d1 as createSolanaAdapter, dz as createTrezorAdapter, c_ as createWalletFactory, c8 as createZcashClient, c4 as createZcashNativeBackend, ca as createZcashShieldedService, cc as createZcashSwapService, a5 as decodeStealthMetaAddress, cv as decryptMemo, ap as decryptWithViewing, ab as deriveEd25519StealthPrivateKey, b7 as deriveOracleId, a2 as deriveStealthPrivateKey, an as deriveViewingKey, bf as deserializeAttestationMessage, Z as deserializeIntent, cA as deserializePayment, dg as detectEthereumWallets, c as detectMobileBrowser, d as detectMobilePlatform, d7 as detectSolanaWallets, ag as ed25519PublicKeyToNearAddress, ad as ed25519PublicKeyToSolanaAddress, a4 as encodeStealthMetaAddress, ao as encryptForViewing, cX as featureNotSupportedError, cO as formatStablecoinAmount, di as fromHex, cN as fromStablecoinUnits, aK as generateBlinding, aa as generateEd25519StealthAddress, a9 as generateEd25519StealthMetaAddress, av as generateIntentId, ax as generateRandomBytes, a1 as generateStealthAddress, a0 as generateStealthMetaAddress, am as generateViewingKey, bc as getActiveOracles, dv as getAvailableTransports, g as getBrowserInfo, j as getBrowserVersion, bh as getChainNumericId, cL as getChainsForStablecoin, a8 as getCurveForChain, dl as getDefaultRpcEndpoint, dr as getDerivationPath, A as getErrorMessage, df as getEthereumProvider, aJ as getGenerators, _ as getIntentSummary, e as getMobileDeviceInfo, k as getOSVersion, cB as getPaymentSummary, cy as getPaymentTimeRemaining, al as getPrivacyConfig, aq as getPrivacyDescription, d6 as getSolanaProvider, cF as getStablecoin, cI as getStablecoinInfo, cG as getStablecoinsForChain, cJ as getSupportedStablecoins, X as getTimeRemaining, bd as hasEnoughOracles, y as hasErrorCode, R as hasRequiredProofs, aw as hash, dj as hexToNumber, i as isBrowser, a7 as isEd25519Chain, U as isExpired, aS as isNonNegativeAmount, cx as isPaymentExpired, c$ as isPrivateWalletAdapter, x as isSIPError, cH as isStablecoin, cK as isStablecoinOnChain, l as isTablet, aR as isValidAmount, aN as isValidChainId, aV as isValidCompressedPublicKey, aW as isValidEd25519PublicKey, aP as isValidHex, aQ as isValidHexLength, aj as isValidNearAccountId, ai as isValidNearImplicitAddress, aO as isValidPrivacyLevel, aX as isValidPrivateKey, aY as isValidScalar, aT as isValidSlippage, af as isValidSolanaAddress, aU as isValidStealthMetaAddress, ah as nearAddressToEd25519PublicKey, dk as normalizeAddress, cW as notConnectedError, a6 as publicKeyToEthAddress, cZ as registerWallet, ba as removeOracle, ay as secureWipe, az as secureWipeAll, be as serializeAttestationMessage, Y as serializeIntent, cz as serializePayment, b6 as signAttestationMessage, ae as solanaAddressToEd25519PublicKey, d8 as solanaPublicKeyToHex, aI as subtractBlindings, aG as subtractCommitments, a as supportsSharedArrayBuffer, m as supportsTouch, o as supportsWASMBulkMemory, n as supportsWASMSimd, du as supportsWebBluetooth, dt as supportsWebHID, ds as supportsWebUSB, s as supportsWebWorkers, dh as toHex, cM as toStablecoinUnits, T as trackIntent, cw as trackPayment, bb as updateOracleStatus, a_ as validateAsset, aZ as validateCreateIntentParams, a$ as validateIntentInput, b0 as validateIntentOutput, b2 as validateScalar, b1 as validateViewingKey, b4 as verifyAttestation, au as verifyCommitment, aD as verifyOpening, b5 as verifyOracleSignature, cY as walletRegistry, aA as withSecureBuffer, aB as withSecureBufferSync, z as wrapError } from './index-DW7AQwcU.mjs';
|
|
2
2
|
import { F as FundingProofParams, V as ValidityProofParams, a as FulfillmentProofParams, P as ProofResult } from './noir-BTyLXLlZ.mjs';
|
|
3
3
|
export { N as NoirProviderConfig, O as OracleAttestation, d as ProofFramework, b as ProofGenerationError, c as ProofProvider } from './noir-BTyLXLlZ.mjs';
|
|
4
4
|
export { Asset, AuditLogEntry, AuditScope, AuditorRegistration, AuditorViewingKey, BatchPaymentRecipient, BatchPaymentRequest, ChainId, Commitment, ComplianceConfig, ComplianceReport, ComplianceRole, CreateBatchProposalParams, CreateComplianceConfigParams, CreateIntentParams, CreatePaymentParams, CreatePaymentProposalParams, CreateTreasuryParams, DefuseAssetId, DisclosedTransaction, DisclosureRequest, FulfillmentCommitment, FulfillmentProof, FulfillmentRequest, FulfillmentResult, FulfillmentStatus, GenerateReportParams, Hash, HexString, WalletAdapter as IWalletAdapter, IntentStatus, NATIVE_TOKENS, OneClickConfig, OneClickDepositMode, OneClickErrorCode, OneClickQuoteRequest, OneClickQuoteResponse, OneClickStatusResponse, OneClickSwapStatus, OneClickSwapType, PaymentPurpose, PaymentReceipt, PaymentStatus, PaymentStatusType, PrivacyLevel, PrivateWalletAdapter, ProposalSignature, ProposalStatus, ProposalStatusType, ProposalType, Quote, RegisterAuditorParams, ReportData, ReportFormat, ReportStatus, ReportStatusType, ReportType, SIPSolver, SIP_VERSION, ShieldedIntent, ShieldedPayment, Signature, SignedTransaction, Solver, SolverCapabilities, SolverEvent, SolverEventListener, SolverQuote, SolverVisibleIntent, StablecoinSymbol, StealthAddress, StealthAddressRecovery, StealthMetaAddress, SwapRoute, SwapRouteStep, TrackedIntent, TrackedPayment, TransactionReceipt, TreasuryBalance, TreasuryConfig, TreasuryMember, TreasuryProposal, TreasuryRole, TreasuryTransaction, UnsignedTransaction, ViewingKey, WalletAccountChangedEvent, WalletAdapterFactory, WalletChainChangedEvent, WalletConnectEvent, WalletConnectionState, WalletDisconnectEvent, WalletErrorCode, WalletErrorEvent, WalletEvent, WalletEventHandler, WalletEventType, WalletInfo, WalletRegistryEntry, WalletShieldedSendParams, WalletShieldedSendResult, ZKProof, ZcashAccountAddress, ZcashAccountBalance, ZcashAddressInfo, ZcashAddressType, ZcashBlock, ZcashBlockHeader, ZcashBlockchainInfo, ZcashConfig, ZcashErrorCode, ZcashNetwork, ZcashNetworkInfo, ZcashNewAccount, ZcashOperation, ZcashOperationError, ZcashOperationStatus, ZcashOperationTxResult, ZcashPool, ZcashPoolBalance, ZcashPrivacyPolicy, ZcashReceiverType, ZcashSendRecipient, ZcashShieldedSendParams, ZcashUnspentNote, isPrivate, supportsViewingKey } from '@sip-protocol/types';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { bj as ATTESTATION_VERSION, bv as AttestationRequest, bw as AttestationResult, bT as BackendCapabilities, cT as BaseWalletAdapter, cr as BridgeProvider, B as BrowserNoirProvider, t as BrowserNoirProviderConfig, bm as CHAIN_NUMERIC_IDS, aM as CommitmentPoint, cS as ComplianceManager, $ as CreateIntentOptions, cP as CreatePaymentOptions, C as CryptoError, bk as DEFAULT_THRESHOLD, bl as DEFAULT_TOTAL_ORACLES, dq as DerivationPath, dT as EIP1193ConnectInfo, dS as EIP1193Event, dQ as EIP1193Provider, dU as EIP1193ProviderRpcError, dR as EIP1193RequestArguments, dV as EIP712Domain, dW as EIP712TypeDefinition, dY as EIP712TypedData, dX as EIP712Types, w as EncryptionNotImplementedError, E as ErrorCode, e2 as EthereumAdapterConfig, dm as EthereumChainId, e3 as EthereumChainIdType, e0 as EthereumChainMetadata, d$ as EthereumTokenMetadata, d_ as EthereumTransactionReceipt, dZ as EthereumTransactionRequest, da as EthereumWalletAdapter, e1 as EthereumWalletName, ci as ExportedViewingKey, c0 as FindBestRouteParams, eh as HardwareAccount, e8 as HardwareConnectionStatus, ea as HardwareDeviceInfo, dn as HardwareErrorCode, ej as HardwareErrorCodeType, ef as HardwareEthereumTx, ee as HardwareSignRequest, eg as HardwareSignature, ei as HardwareTransport, eb as HardwareWalletConfig, dp as HardwareWalletError, e5 as HardwareWalletType, L as IntentBuilder, I as IntentError, ec as LedgerConfig, e6 as LedgerModel, dw as LedgerWalletAdapter, p as MobileBrowser, q as MobileDeviceInfo, M as MobilePlatform, r as MobileWASMCompatibility, dc as MockEthereumAdapter, e4 as MockEthereumAdapterConfig, ek as MockHardwareConfig, dA as MockLedgerAdapter, b3 as MockProofProvider, d2 as MockSolanaAdapter, dP as MockSolanaAdapterConfig, bF as MockSolver, bH as MockSolverConfig, dB as MockTrezorAdapter, cU as MockWalletAdapter, bz as NEARIntentsAdapter, bE as NEARIntentsAdapterConfig, c1 as NEARIntentsBackend, N as NetworkError, bi as ORACLE_DOMAIN, by as OneClickClient, bq as OracleAttestationMessage, bn as OracleId, bp as OracleInfo, bt as OracleRegistry, bu as OracleRegistryConfig, br as OracleSignature, bo as OracleStatus, ct as PaymentBuilder, aL as PedersenCommitment, bC as PreparedSwap, cs as PriceFeed, ar as PrivacyConfig, K as ProductionQuote, u as ProofError, v as ProofNotImplementedError, P as ProofProgressCallback, b$ as QuoteComparison, cg as ReceivedNote, bX as Route, b_ as RouteWithQuote, F as SIP, J as SIPConfig, S as SIPError, cD as STABLECOIN_ADDRESSES, cE as STABLECOIN_DECIMALS, cC as STABLECOIN_INFO, D as SerializedError, bU as SettlementBackend, bV as SettlementBackendFactory, bL as SettlementBackendName, bW as SettlementBackendRegistry, bN as SettlementQuote, bM as SettlementQuoteParams, bJ as SettlementRegistry, bK as SettlementRegistryError, bQ as SettlementSwapParams, bR as SettlementSwapResult, bO as SettlementSwapRoute, bP as SettlementSwapRouteStep, ch as ShieldedBalance, ce as ShieldedSendParams, cf as ShieldedSendResult, bs as SignedOracleAttestation, bY as SmartRouter, dK as SolanaAdapterConfig, dJ as SolanaCluster, dL as SolanaConnection, dE as SolanaPublicKey, dM as SolanaSendOptions, dO as SolanaSignature, dF as SolanaTransaction, dN as SolanaUnsignedTransaction, dG as SolanaVersionedTransaction, d0 as SolanaWalletAdapter, dI as SolanaWalletName, dH as SolanaWalletProvider, cQ as StablecoinInfo, ak as StealthCurve, bB as SwapRequest, bD as SwapResult, bI as SwapStatus, bS as SwapStatusResponse, as as TransactionData, e9 as TransportType, cR as Treasury, ed as TrezorConfig, e7 as TrezorModel, dy as TrezorWalletAdapter, V as ValidationError, bx as VerificationResult, W as WalletAdapter, cV as WalletError, c3 as ZcashNativeBackend, c5 as ZcashNativeBackendConfig, cn as ZcashQuote, cm as ZcashQuoteParams, c6 as ZcashRPCClient, c7 as ZcashRPCError, c9 as ZcashShieldedService, cd as ZcashShieldedServiceConfig, co as ZcashSwapParams, cp as ZcashSwapResult, cb as ZcashSwapService, cj as ZcashSwapServiceConfig, ck as ZcashSwapSourceChain, cl as ZcashSwapSourceToken, cq as ZcashSwapStatus, aH as addBlindings, aF as addCommitments, b9 as addOracle, Q as attachProofs, d9 as base58ToHex, b as browserBytesToHex, h as browserHexToBytes, ac as checkEd25519StealthAddress, f as checkMobileWASMCompatibility, a3 as checkStealthAddress, aC as commit, aE as commitZero, bg as computeAttestationHash, at as createCommitment, db as createEthereumAdapter, dx as createLedgerAdapter, dd as createMockEthereumAdapter, de as createMockEthereumProvider, dC as createMockLedgerAdapter, d3 as createMockSolanaAdapter, d5 as createMockSolanaConnection, d4 as createMockSolanaProvider, bG as createMockSolver, dD as createMockTrezorAdapter, bA as createNEARIntentsAdapter, c2 as createNEARIntentsBackend, b8 as createOracleRegistry, H as createProductionSIP, G as createSIP, O as createShieldedIntent, cu as createShieldedPayment, bZ as createSmartRouter, d1 as createSolanaAdapter, dz as createTrezorAdapter, c_ as createWalletFactory, c8 as createZcashClient, c4 as createZcashNativeBackend, ca as createZcashShieldedService, cc as createZcashSwapService, a5 as decodeStealthMetaAddress, cv as decryptMemo, ap as decryptWithViewing, ab as deriveEd25519StealthPrivateKey, b7 as deriveOracleId, a2 as deriveStealthPrivateKey, an as deriveViewingKey, bf as deserializeAttestationMessage, Z as deserializeIntent, cA as deserializePayment, dg as detectEthereumWallets, c as detectMobileBrowser, d as detectMobilePlatform, d7 as detectSolanaWallets, ag as ed25519PublicKeyToNearAddress, ad as ed25519PublicKeyToSolanaAddress, a4 as encodeStealthMetaAddress, ao as encryptForViewing, cX as featureNotSupportedError, cO as formatStablecoinAmount, di as fromHex, cN as fromStablecoinUnits, aK as generateBlinding, aa as generateEd25519StealthAddress, a9 as generateEd25519StealthMetaAddress, av as generateIntentId, ax as generateRandomBytes, a1 as generateStealthAddress, a0 as generateStealthMetaAddress, am as generateViewingKey, bc as getActiveOracles, dv as getAvailableTransports, g as getBrowserInfo, j as getBrowserVersion, bh as getChainNumericId, cL as getChainsForStablecoin, a8 as getCurveForChain, dl as getDefaultRpcEndpoint, dr as getDerivationPath, A as getErrorMessage, df as getEthereumProvider, aJ as getGenerators, _ as getIntentSummary, e as getMobileDeviceInfo, k as getOSVersion, cB as getPaymentSummary, cy as getPaymentTimeRemaining, al as getPrivacyConfig, aq as getPrivacyDescription, d6 as getSolanaProvider, cF as getStablecoin, cI as getStablecoinInfo, cG as getStablecoinsForChain, cJ as getSupportedStablecoins, X as getTimeRemaining, bd as hasEnoughOracles, y as hasErrorCode, R as hasRequiredProofs, aw as hash, dj as hexToNumber, i as isBrowser, a7 as isEd25519Chain, U as isExpired, aS as isNonNegativeAmount, cx as isPaymentExpired, c$ as isPrivateWalletAdapter, x as isSIPError, cH as isStablecoin, cK as isStablecoinOnChain, l as isTablet, aR as isValidAmount, aN as isValidChainId, aV as isValidCompressedPublicKey, aW as isValidEd25519PublicKey, aP as isValidHex, aQ as isValidHexLength, aj as isValidNearAccountId, ai as isValidNearImplicitAddress, aO as isValidPrivacyLevel, aX as isValidPrivateKey, aY as isValidScalar, aT as isValidSlippage, af as isValidSolanaAddress, aU as isValidStealthMetaAddress, ah as nearAddressToEd25519PublicKey, dk as normalizeAddress, cW as notConnectedError, a6 as publicKeyToEthAddress, cZ as registerWallet, ba as removeOracle, ay as secureWipe, az as secureWipeAll, be as serializeAttestationMessage, Y as serializeIntent, cz as serializePayment, b6 as signAttestationMessage, ae as solanaAddressToEd25519PublicKey, d8 as solanaPublicKeyToHex, aI as subtractBlindings, aG as subtractCommitments, a as supportsSharedArrayBuffer, m as supportsTouch, o as supportsWASMBulkMemory, n as supportsWASMSimd, du as supportsWebBluetooth, dt as supportsWebHID, ds as supportsWebUSB, s as supportsWebWorkers, dh as toHex, cM as toStablecoinUnits, T as trackIntent, cw as trackPayment, bb as updateOracleStatus, a_ as validateAsset, aZ as validateCreateIntentParams, a$ as validateIntentInput, b0 as validateIntentOutput, b2 as validateScalar, b1 as validateViewingKey, b4 as verifyAttestation, au as verifyCommitment, aD as verifyOpening, b5 as verifyOracleSignature, cY as walletRegistry, aA as withSecureBuffer, aB as withSecureBufferSync, z as wrapError } from './index-
|
|
1
|
+
export { bj as ATTESTATION_VERSION, bv as AttestationRequest, bw as AttestationResult, bT as BackendCapabilities, cT as BaseWalletAdapter, cr as BridgeProvider, B as BrowserNoirProvider, t as BrowserNoirProviderConfig, bm as CHAIN_NUMERIC_IDS, aM as CommitmentPoint, cS as ComplianceManager, $ as CreateIntentOptions, cP as CreatePaymentOptions, C as CryptoError, bk as DEFAULT_THRESHOLD, bl as DEFAULT_TOTAL_ORACLES, dq as DerivationPath, dT as EIP1193ConnectInfo, dS as EIP1193Event, dQ as EIP1193Provider, dU as EIP1193ProviderRpcError, dR as EIP1193RequestArguments, dV as EIP712Domain, dW as EIP712TypeDefinition, dY as EIP712TypedData, dX as EIP712Types, w as EncryptionNotImplementedError, E as ErrorCode, e2 as EthereumAdapterConfig, dm as EthereumChainId, e3 as EthereumChainIdType, e0 as EthereumChainMetadata, d$ as EthereumTokenMetadata, d_ as EthereumTransactionReceipt, dZ as EthereumTransactionRequest, da as EthereumWalletAdapter, e1 as EthereumWalletName, ci as ExportedViewingKey, c0 as FindBestRouteParams, eh as HardwareAccount, e8 as HardwareConnectionStatus, ea as HardwareDeviceInfo, dn as HardwareErrorCode, ej as HardwareErrorCodeType, ef as HardwareEthereumTx, ee as HardwareSignRequest, eg as HardwareSignature, ei as HardwareTransport, eb as HardwareWalletConfig, dp as HardwareWalletError, e5 as HardwareWalletType, L as IntentBuilder, I as IntentError, ec as LedgerConfig, e6 as LedgerModel, dw as LedgerWalletAdapter, p as MobileBrowser, q as MobileDeviceInfo, M as MobilePlatform, r as MobileWASMCompatibility, dc as MockEthereumAdapter, e4 as MockEthereumAdapterConfig, ek as MockHardwareConfig, dA as MockLedgerAdapter, b3 as MockProofProvider, d2 as MockSolanaAdapter, dP as MockSolanaAdapterConfig, bF as MockSolver, bH as MockSolverConfig, dB as MockTrezorAdapter, cU as MockWalletAdapter, bz as NEARIntentsAdapter, bE as NEARIntentsAdapterConfig, c1 as NEARIntentsBackend, N as NetworkError, bi as ORACLE_DOMAIN, by as OneClickClient, bq as OracleAttestationMessage, bn as OracleId, bp as OracleInfo, bt as OracleRegistry, bu as OracleRegistryConfig, br as OracleSignature, bo as OracleStatus, ct as PaymentBuilder, aL as PedersenCommitment, bC as PreparedSwap, cs as PriceFeed, ar as PrivacyConfig, K as ProductionQuote, u as ProofError, v as ProofNotImplementedError, P as ProofProgressCallback, b$ as QuoteComparison, cg as ReceivedNote, bX as Route, b_ as RouteWithQuote, F as SIP, J as SIPConfig, S as SIPError, cD as STABLECOIN_ADDRESSES, cE as STABLECOIN_DECIMALS, cC as STABLECOIN_INFO, D as SerializedError, bU as SettlementBackend, bV as SettlementBackendFactory, bL as SettlementBackendName, bW as SettlementBackendRegistry, bN as SettlementQuote, bM as SettlementQuoteParams, bJ as SettlementRegistry, bK as SettlementRegistryError, bQ as SettlementSwapParams, bR as SettlementSwapResult, bO as SettlementSwapRoute, bP as SettlementSwapRouteStep, ch as ShieldedBalance, ce as ShieldedSendParams, cf as ShieldedSendResult, bs as SignedOracleAttestation, bY as SmartRouter, dK as SolanaAdapterConfig, dJ as SolanaCluster, dL as SolanaConnection, dE as SolanaPublicKey, dM as SolanaSendOptions, dO as SolanaSignature, dF as SolanaTransaction, dN as SolanaUnsignedTransaction, dG as SolanaVersionedTransaction, d0 as SolanaWalletAdapter, dI as SolanaWalletName, dH as SolanaWalletProvider, cQ as StablecoinInfo, ak as StealthCurve, bB as SwapRequest, bD as SwapResult, bI as SwapStatus, bS as SwapStatusResponse, as as TransactionData, e9 as TransportType, cR as Treasury, ed as TrezorConfig, e7 as TrezorModel, dy as TrezorWalletAdapter, V as ValidationError, bx as VerificationResult, W as WalletAdapter, cV as WalletError, c3 as ZcashNativeBackend, c5 as ZcashNativeBackendConfig, cn as ZcashQuote, cm as ZcashQuoteParams, c6 as ZcashRPCClient, c7 as ZcashRPCError, c9 as ZcashShieldedService, cd as ZcashShieldedServiceConfig, co as ZcashSwapParams, cp as ZcashSwapResult, cb as ZcashSwapService, cj as ZcashSwapServiceConfig, ck as ZcashSwapSourceChain, cl as ZcashSwapSourceToken, cq as ZcashSwapStatus, aH as addBlindings, aF as addCommitments, b9 as addOracle, Q as attachProofs, d9 as base58ToHex, b as browserBytesToHex, h as browserHexToBytes, ac as checkEd25519StealthAddress, f as checkMobileWASMCompatibility, a3 as checkStealthAddress, aC as commit, aE as commitZero, bg as computeAttestationHash, at as createCommitment, db as createEthereumAdapter, dx as createLedgerAdapter, dd as createMockEthereumAdapter, de as createMockEthereumProvider, dC as createMockLedgerAdapter, d3 as createMockSolanaAdapter, d5 as createMockSolanaConnection, d4 as createMockSolanaProvider, bG as createMockSolver, dD as createMockTrezorAdapter, bA as createNEARIntentsAdapter, c2 as createNEARIntentsBackend, b8 as createOracleRegistry, H as createProductionSIP, G as createSIP, O as createShieldedIntent, cu as createShieldedPayment, bZ as createSmartRouter, d1 as createSolanaAdapter, dz as createTrezorAdapter, c_ as createWalletFactory, c8 as createZcashClient, c4 as createZcashNativeBackend, ca as createZcashShieldedService, cc as createZcashSwapService, a5 as decodeStealthMetaAddress, cv as decryptMemo, ap as decryptWithViewing, ab as deriveEd25519StealthPrivateKey, b7 as deriveOracleId, a2 as deriveStealthPrivateKey, an as deriveViewingKey, bf as deserializeAttestationMessage, Z as deserializeIntent, cA as deserializePayment, dg as detectEthereumWallets, c as detectMobileBrowser, d as detectMobilePlatform, d7 as detectSolanaWallets, ag as ed25519PublicKeyToNearAddress, ad as ed25519PublicKeyToSolanaAddress, a4 as encodeStealthMetaAddress, ao as encryptForViewing, cX as featureNotSupportedError, cO as formatStablecoinAmount, di as fromHex, cN as fromStablecoinUnits, aK as generateBlinding, aa as generateEd25519StealthAddress, a9 as generateEd25519StealthMetaAddress, av as generateIntentId, ax as generateRandomBytes, a1 as generateStealthAddress, a0 as generateStealthMetaAddress, am as generateViewingKey, bc as getActiveOracles, dv as getAvailableTransports, g as getBrowserInfo, j as getBrowserVersion, bh as getChainNumericId, cL as getChainsForStablecoin, a8 as getCurveForChain, dl as getDefaultRpcEndpoint, dr as getDerivationPath, A as getErrorMessage, df as getEthereumProvider, aJ as getGenerators, _ as getIntentSummary, e as getMobileDeviceInfo, k as getOSVersion, cB as getPaymentSummary, cy as getPaymentTimeRemaining, al as getPrivacyConfig, aq as getPrivacyDescription, d6 as getSolanaProvider, cF as getStablecoin, cI as getStablecoinInfo, cG as getStablecoinsForChain, cJ as getSupportedStablecoins, X as getTimeRemaining, bd as hasEnoughOracles, y as hasErrorCode, R as hasRequiredProofs, aw as hash, dj as hexToNumber, i as isBrowser, a7 as isEd25519Chain, U as isExpired, aS as isNonNegativeAmount, cx as isPaymentExpired, c$ as isPrivateWalletAdapter, x as isSIPError, cH as isStablecoin, cK as isStablecoinOnChain, l as isTablet, aR as isValidAmount, aN as isValidChainId, aV as isValidCompressedPublicKey, aW as isValidEd25519PublicKey, aP as isValidHex, aQ as isValidHexLength, aj as isValidNearAccountId, ai as isValidNearImplicitAddress, aO as isValidPrivacyLevel, aX as isValidPrivateKey, aY as isValidScalar, aT as isValidSlippage, af as isValidSolanaAddress, aU as isValidStealthMetaAddress, ah as nearAddressToEd25519PublicKey, dk as normalizeAddress, cW as notConnectedError, a6 as publicKeyToEthAddress, cZ as registerWallet, ba as removeOracle, ay as secureWipe, az as secureWipeAll, be as serializeAttestationMessage, Y as serializeIntent, cz as serializePayment, b6 as signAttestationMessage, ae as solanaAddressToEd25519PublicKey, d8 as solanaPublicKeyToHex, aI as subtractBlindings, aG as subtractCommitments, a as supportsSharedArrayBuffer, m as supportsTouch, o as supportsWASMBulkMemory, n as supportsWASMSimd, du as supportsWebBluetooth, dt as supportsWebHID, ds as supportsWebUSB, s as supportsWebWorkers, dh as toHex, cM as toStablecoinUnits, T as trackIntent, cw as trackPayment, bb as updateOracleStatus, a_ as validateAsset, aZ as validateCreateIntentParams, a$ as validateIntentInput, b0 as validateIntentOutput, b2 as validateScalar, b1 as validateViewingKey, b4 as verifyAttestation, au as verifyCommitment, aD as verifyOpening, b5 as verifyOracleSignature, cY as walletRegistry, aA as withSecureBuffer, aB as withSecureBufferSync, z as wrapError } from './index-DAgedMrt.js';
|
|
2
2
|
import { F as FundingProofParams, V as ValidityProofParams, a as FulfillmentProofParams, P as ProofResult } from './noir-BTyLXLlZ.js';
|
|
3
3
|
export { N as NoirProviderConfig, O as OracleAttestation, d as ProofFramework, b as ProofGenerationError, c as ProofProvider } from './noir-BTyLXLlZ.js';
|
|
4
4
|
export { Asset, AuditLogEntry, AuditScope, AuditorRegistration, AuditorViewingKey, BatchPaymentRecipient, BatchPaymentRequest, ChainId, Commitment, ComplianceConfig, ComplianceReport, ComplianceRole, CreateBatchProposalParams, CreateComplianceConfigParams, CreateIntentParams, CreatePaymentParams, CreatePaymentProposalParams, CreateTreasuryParams, DefuseAssetId, DisclosedTransaction, DisclosureRequest, FulfillmentCommitment, FulfillmentProof, FulfillmentRequest, FulfillmentResult, FulfillmentStatus, GenerateReportParams, Hash, HexString, WalletAdapter as IWalletAdapter, IntentStatus, NATIVE_TOKENS, OneClickConfig, OneClickDepositMode, OneClickErrorCode, OneClickQuoteRequest, OneClickQuoteResponse, OneClickStatusResponse, OneClickSwapStatus, OneClickSwapType, PaymentPurpose, PaymentReceipt, PaymentStatus, PaymentStatusType, PrivacyLevel, PrivateWalletAdapter, ProposalSignature, ProposalStatus, ProposalStatusType, ProposalType, Quote, RegisterAuditorParams, ReportData, ReportFormat, ReportStatus, ReportStatusType, ReportType, SIPSolver, SIP_VERSION, ShieldedIntent, ShieldedPayment, Signature, SignedTransaction, Solver, SolverCapabilities, SolverEvent, SolverEventListener, SolverQuote, SolverVisibleIntent, StablecoinSymbol, StealthAddress, StealthAddressRecovery, StealthMetaAddress, SwapRoute, SwapRouteStep, TrackedIntent, TrackedPayment, TransactionReceipt, TreasuryBalance, TreasuryConfig, TreasuryMember, TreasuryProposal, TreasuryRole, TreasuryTransaction, UnsignedTransaction, ViewingKey, WalletAccountChangedEvent, WalletAdapterFactory, WalletChainChangedEvent, WalletConnectEvent, WalletConnectionState, WalletDisconnectEvent, WalletErrorCode, WalletErrorEvent, WalletEvent, WalletEventHandler, WalletEventType, WalletInfo, WalletRegistryEntry, WalletShieldedSendParams, WalletShieldedSendResult, ZKProof, ZcashAccountAddress, ZcashAccountBalance, ZcashAddressInfo, ZcashAddressType, ZcashBlock, ZcashBlockHeader, ZcashBlockchainInfo, ZcashConfig, ZcashErrorCode, ZcashNetwork, ZcashNetworkInfo, ZcashNewAccount, ZcashOperation, ZcashOperationError, ZcashOperationStatus, ZcashOperationTxResult, ZcashPool, ZcashPoolBalance, ZcashPrivacyPolicy, ZcashReceiverType, ZcashSendRecipient, ZcashShieldedSendParams, ZcashUnspentNote, isPrivate, supportsViewingKey } from '@sip-protocol/types';
|
package/dist/browser.js
CHANGED
|
@@ -6248,6 +6248,12 @@ var ZcashSwapService = class {
|
|
|
6248
6248
|
quotes = /* @__PURE__ */ new Map();
|
|
6249
6249
|
swaps = /* @__PURE__ */ new Map();
|
|
6250
6250
|
constructor(config) {
|
|
6251
|
+
if (config.mode === "production" && !config.bridgeProvider) {
|
|
6252
|
+
throw new IntentError(
|
|
6253
|
+
"Bridge provider required for production mode",
|
|
6254
|
+
"SIP_5004" /* INTENT_INVALID_STATE */
|
|
6255
|
+
);
|
|
6256
|
+
}
|
|
6251
6257
|
this.config = {
|
|
6252
6258
|
mode: config.mode,
|
|
6253
6259
|
defaultSlippage: config.defaultSlippage ?? 100,
|
|
@@ -14115,6 +14121,211 @@ function createWorkerBlobURL() {
|
|
|
14115
14121
|
}
|
|
14116
14122
|
}
|
|
14117
14123
|
|
|
14124
|
+
// Generate validity proof
|
|
14125
|
+
async function generateValidityProof(id, params) {
|
|
14126
|
+
if (!isReady) {
|
|
14127
|
+
sendError(id, new Error('Worker not initialized'));
|
|
14128
|
+
return;
|
|
14129
|
+
}
|
|
14130
|
+
|
|
14131
|
+
try {
|
|
14132
|
+
sendProgress(id, 'witness', 20, 'Preparing validity witness...');
|
|
14133
|
+
|
|
14134
|
+
// Import noble crypto for hashing
|
|
14135
|
+
const { sha256 } = await import('@noble/hashes/sha256');
|
|
14136
|
+
|
|
14137
|
+
// Convert inputs to field elements
|
|
14138
|
+
const intentHashField = hexToField(params.intentHash);
|
|
14139
|
+
const senderAddressField = hexToField(params.senderAddress);
|
|
14140
|
+
const senderBlindingField = bytesToField(params.senderBlinding);
|
|
14141
|
+
const senderSecretField = bytesToField(params.senderSecret);
|
|
14142
|
+
const nonceField = bytesToField(params.nonce);
|
|
14143
|
+
|
|
14144
|
+
// Compute sender commitment
|
|
14145
|
+
const addressBytes = hexToBytes(senderAddressField);
|
|
14146
|
+
const blindingBytes = hexToBytes(senderBlindingField.padStart(64, '0'));
|
|
14147
|
+
const commitmentPreimage = new Uint8Array([...addressBytes, ...blindingBytes]);
|
|
14148
|
+
const commitmentHash = sha256(commitmentPreimage);
|
|
14149
|
+
const commitmentX = bytesToHex(commitmentHash.slice(0, 16)).padStart(64, '0');
|
|
14150
|
+
const commitmentY = bytesToHex(commitmentHash.slice(16, 32)).padStart(64, '0');
|
|
14151
|
+
|
|
14152
|
+
// Compute nullifier
|
|
14153
|
+
const secretBytes = hexToBytes(senderSecretField.padStart(64, '0'));
|
|
14154
|
+
const intentBytes = hexToBytes(intentHashField);
|
|
14155
|
+
const nonceBytes = hexToBytes(nonceField.padStart(64, '0'));
|
|
14156
|
+
const nullifierPreimage = new Uint8Array([...secretBytes, ...intentBytes, ...nonceBytes]);
|
|
14157
|
+
const nullifierHash = sha256(nullifierPreimage);
|
|
14158
|
+
const nullifier = bytesToHex(nullifierHash);
|
|
14159
|
+
|
|
14160
|
+
const signature = Array.from(params.authorizationSignature);
|
|
14161
|
+
const messageHash = fieldToBytes32(intentHashField);
|
|
14162
|
+
|
|
14163
|
+
// Get public key coordinates
|
|
14164
|
+
let pubKeyX, pubKeyY;
|
|
14165
|
+
if (params.senderPublicKey) {
|
|
14166
|
+
pubKeyX = Array.from(params.senderPublicKey.x);
|
|
14167
|
+
pubKeyY = Array.from(params.senderPublicKey.y);
|
|
14168
|
+
} else {
|
|
14169
|
+
// Derive from secret
|
|
14170
|
+
const { secp256k1 } = await import('@noble/curves/secp256k1');
|
|
14171
|
+
const uncompressedPubKey = secp256k1.getPublicKey(params.senderSecret, false);
|
|
14172
|
+
pubKeyX = Array.from(uncompressedPubKey.slice(1, 33));
|
|
14173
|
+
pubKeyY = Array.from(uncompressedPubKey.slice(33, 65));
|
|
14174
|
+
}
|
|
14175
|
+
|
|
14176
|
+
const witnessInputs = {
|
|
14177
|
+
intent_hash: intentHashField,
|
|
14178
|
+
sender_commitment_x: commitmentX,
|
|
14179
|
+
sender_commitment_y: commitmentY,
|
|
14180
|
+
nullifier: nullifier,
|
|
14181
|
+
timestamp: params.timestamp.toString(),
|
|
14182
|
+
expiry: params.expiry.toString(),
|
|
14183
|
+
sender_address: senderAddressField,
|
|
14184
|
+
sender_blinding: senderBlindingField,
|
|
14185
|
+
sender_secret: senderSecretField,
|
|
14186
|
+
pub_key_x: pubKeyX,
|
|
14187
|
+
pub_key_y: pubKeyY,
|
|
14188
|
+
signature: signature,
|
|
14189
|
+
message_hash: messageHash,
|
|
14190
|
+
nonce: nonceField,
|
|
14191
|
+
};
|
|
14192
|
+
|
|
14193
|
+
sendProgress(id, 'witness', 40, 'Executing validity circuit...');
|
|
14194
|
+
const { witness } = await validityNoir.execute(witnessInputs);
|
|
14195
|
+
|
|
14196
|
+
sendProgress(id, 'proving', 60, 'Generating validity proof...');
|
|
14197
|
+
const proofData = await validityBackend.generateProof(witness);
|
|
14198
|
+
|
|
14199
|
+
sendProgress(id, 'complete', 100, 'Validity proof generated');
|
|
14200
|
+
|
|
14201
|
+
const publicInputs = [
|
|
14202
|
+
'0x' + intentHashField,
|
|
14203
|
+
'0x' + commitmentX,
|
|
14204
|
+
'0x' + commitmentY,
|
|
14205
|
+
'0x' + nullifier,
|
|
14206
|
+
'0x' + params.timestamp.toString(16).padStart(16, '0'),
|
|
14207
|
+
'0x' + params.expiry.toString(16).padStart(16, '0'),
|
|
14208
|
+
];
|
|
14209
|
+
|
|
14210
|
+
const proof = {
|
|
14211
|
+
type: 'validity',
|
|
14212
|
+
proof: '0x' + bytesToHex(proofData.proof),
|
|
14213
|
+
publicInputs,
|
|
14214
|
+
};
|
|
14215
|
+
|
|
14216
|
+
sendSuccess(id, { proof, publicInputs });
|
|
14217
|
+
} catch (error) {
|
|
14218
|
+
sendError(id, error);
|
|
14219
|
+
}
|
|
14220
|
+
}
|
|
14221
|
+
|
|
14222
|
+
// Generate fulfillment proof
|
|
14223
|
+
async function generateFulfillmentProof(id, params) {
|
|
14224
|
+
if (!isReady) {
|
|
14225
|
+
sendError(id, new Error('Worker not initialized'));
|
|
14226
|
+
return;
|
|
14227
|
+
}
|
|
14228
|
+
|
|
14229
|
+
try {
|
|
14230
|
+
sendProgress(id, 'witness', 20, 'Preparing fulfillment witness...');
|
|
14231
|
+
|
|
14232
|
+
// Import noble crypto for hashing
|
|
14233
|
+
const { sha256 } = await import('@noble/hashes/sha256');
|
|
14234
|
+
|
|
14235
|
+
const intentHashField = hexToField(params.intentHash);
|
|
14236
|
+
const recipientStealthField = hexToField(params.recipientStealth);
|
|
14237
|
+
|
|
14238
|
+
// Compute output commitment
|
|
14239
|
+
const amountBytes = bigintToBytes(params.outputAmount, 8);
|
|
14240
|
+
const blindingBytes = params.outputBlinding.slice(0, 32);
|
|
14241
|
+
const outputPreimage = new Uint8Array([...amountBytes, ...blindingBytes]);
|
|
14242
|
+
const outputHash = sha256(outputPreimage);
|
|
14243
|
+
const commitmentX = bytesToHex(outputHash.slice(0, 16)).padStart(64, '0');
|
|
14244
|
+
const commitmentY = bytesToHex(outputHash.slice(16, 32)).padStart(64, '0');
|
|
14245
|
+
|
|
14246
|
+
const solverSecretField = bytesToField(params.solverSecret);
|
|
14247
|
+
|
|
14248
|
+
// Compute solver ID
|
|
14249
|
+
const solverSecretBytes = hexToBytes(solverSecretField.padStart(64, '0'));
|
|
14250
|
+
const solverIdHash = sha256(solverSecretBytes);
|
|
14251
|
+
const solverId = bytesToHex(solverIdHash);
|
|
14252
|
+
|
|
14253
|
+
const outputBlindingField = bytesToField(params.outputBlinding);
|
|
14254
|
+
|
|
14255
|
+
const attestation = params.oracleAttestation;
|
|
14256
|
+
const attestationRecipientField = hexToField(attestation.recipient);
|
|
14257
|
+
const attestationTxHashField = hexToField(attestation.txHash);
|
|
14258
|
+
const oracleSignature = Array.from(attestation.signature);
|
|
14259
|
+
|
|
14260
|
+
// Compute oracle message hash
|
|
14261
|
+
const recipientBytes = hexToBytes(attestationRecipientField);
|
|
14262
|
+
const attestationAmountBytes = bigintToBytes(attestation.amount, 8);
|
|
14263
|
+
const txHashBytes = hexToBytes(attestationTxHashField);
|
|
14264
|
+
const blockBytes = bigintToBytes(attestation.blockNumber, 8);
|
|
14265
|
+
const oraclePreimage = new Uint8Array([
|
|
14266
|
+
...recipientBytes,
|
|
14267
|
+
...attestationAmountBytes,
|
|
14268
|
+
...txHashBytes,
|
|
14269
|
+
...blockBytes,
|
|
14270
|
+
]);
|
|
14271
|
+
const oracleMessageHash = Array.from(sha256(oraclePreimage));
|
|
14272
|
+
|
|
14273
|
+
const oraclePubKeyX = config.oraclePublicKey?.x ?? new Array(32).fill(0);
|
|
14274
|
+
const oraclePubKeyY = config.oraclePublicKey?.y ?? new Array(32).fill(0);
|
|
14275
|
+
|
|
14276
|
+
const witnessInputs = {
|
|
14277
|
+
intent_hash: intentHashField,
|
|
14278
|
+
output_commitment_x: commitmentX,
|
|
14279
|
+
output_commitment_y: commitmentY,
|
|
14280
|
+
recipient_stealth: recipientStealthField,
|
|
14281
|
+
min_output_amount: params.minOutputAmount.toString(),
|
|
14282
|
+
solver_id: solverId,
|
|
14283
|
+
fulfillment_time: params.fulfillmentTime.toString(),
|
|
14284
|
+
expiry: params.expiry.toString(),
|
|
14285
|
+
output_amount: params.outputAmount.toString(),
|
|
14286
|
+
output_blinding: outputBlindingField,
|
|
14287
|
+
solver_secret: solverSecretField,
|
|
14288
|
+
attestation_recipient: attestationRecipientField,
|
|
14289
|
+
attestation_amount: attestation.amount.toString(),
|
|
14290
|
+
attestation_tx_hash: attestationTxHashField,
|
|
14291
|
+
attestation_block: attestation.blockNumber.toString(),
|
|
14292
|
+
oracle_signature: oracleSignature,
|
|
14293
|
+
oracle_message_hash: oracleMessageHash,
|
|
14294
|
+
oracle_pub_key_x: oraclePubKeyX,
|
|
14295
|
+
oracle_pub_key_y: oraclePubKeyY,
|
|
14296
|
+
};
|
|
14297
|
+
|
|
14298
|
+
sendProgress(id, 'witness', 40, 'Executing fulfillment circuit...');
|
|
14299
|
+
const { witness } = await fulfillmentNoir.execute(witnessInputs);
|
|
14300
|
+
|
|
14301
|
+
sendProgress(id, 'proving', 60, 'Generating fulfillment proof...');
|
|
14302
|
+
const proofData = await fulfillmentBackend.generateProof(witness);
|
|
14303
|
+
|
|
14304
|
+
sendProgress(id, 'complete', 100, 'Fulfillment proof generated');
|
|
14305
|
+
|
|
14306
|
+
const publicInputs = [
|
|
14307
|
+
'0x' + intentHashField,
|
|
14308
|
+
'0x' + commitmentX,
|
|
14309
|
+
'0x' + commitmentY,
|
|
14310
|
+
'0x' + recipientStealthField,
|
|
14311
|
+
'0x' + params.minOutputAmount.toString(16).padStart(16, '0'),
|
|
14312
|
+
'0x' + solverId,
|
|
14313
|
+
'0x' + params.fulfillmentTime.toString(16).padStart(16, '0'),
|
|
14314
|
+
'0x' + params.expiry.toString(16).padStart(16, '0'),
|
|
14315
|
+
];
|
|
14316
|
+
|
|
14317
|
+
const proof = {
|
|
14318
|
+
type: 'fulfillment',
|
|
14319
|
+
proof: '0x' + bytesToHex(proofData.proof),
|
|
14320
|
+
publicInputs,
|
|
14321
|
+
};
|
|
14322
|
+
|
|
14323
|
+
sendSuccess(id, { proof, publicInputs });
|
|
14324
|
+
} catch (error) {
|
|
14325
|
+
sendError(id, error);
|
|
14326
|
+
}
|
|
14327
|
+
}
|
|
14328
|
+
|
|
14118
14329
|
// Helper functions
|
|
14119
14330
|
function bytesToField(bytes) {
|
|
14120
14331
|
let result = 0n;
|
|
@@ -14142,6 +14353,39 @@ function createWorkerBlobURL() {
|
|
|
14142
14353
|
return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
14143
14354
|
}
|
|
14144
14355
|
|
|
14356
|
+
function hexToBytes(hex) {
|
|
14357
|
+
const h = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
14358
|
+
const bytes = new Uint8Array(h.length / 2);
|
|
14359
|
+
for (let i = 0; i < h.length; i += 2) {
|
|
14360
|
+
bytes[i / 2] = parseInt(h.slice(i, i + 2), 16);
|
|
14361
|
+
}
|
|
14362
|
+
return bytes;
|
|
14363
|
+
}
|
|
14364
|
+
|
|
14365
|
+
function hexToField(hex) {
|
|
14366
|
+
const h = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
14367
|
+
return h.padStart(64, '0');
|
|
14368
|
+
}
|
|
14369
|
+
|
|
14370
|
+
function fieldToBytes32(field) {
|
|
14371
|
+
const hex = field.padStart(64, '0');
|
|
14372
|
+
const bytes = [];
|
|
14373
|
+
for (let i = 0; i < 32; i++) {
|
|
14374
|
+
bytes.push(parseInt(hex.slice(i * 2, i * 2 + 2), 16));
|
|
14375
|
+
}
|
|
14376
|
+
return bytes;
|
|
14377
|
+
}
|
|
14378
|
+
|
|
14379
|
+
function bigintToBytes(value, length) {
|
|
14380
|
+
const bytes = new Uint8Array(length);
|
|
14381
|
+
let v = value;
|
|
14382
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
14383
|
+
bytes[i] = Number(v & 0xffn);
|
|
14384
|
+
v = v >> 8n;
|
|
14385
|
+
}
|
|
14386
|
+
return bytes;
|
|
14387
|
+
}
|
|
14388
|
+
|
|
14145
14389
|
// Message handler
|
|
14146
14390
|
self.onmessage = async function(event) {
|
|
14147
14391
|
const { id, type, params, config: initConfig } = event.data;
|
|
@@ -14154,12 +14398,10 @@ function createWorkerBlobURL() {
|
|
|
14154
14398
|
await generateFundingProof(id, params);
|
|
14155
14399
|
break;
|
|
14156
14400
|
case 'generateValidityProof':
|
|
14157
|
-
|
|
14158
|
-
sendError(id, new Error('Validity proof not yet implemented in worker'));
|
|
14401
|
+
await generateValidityProof(id, params);
|
|
14159
14402
|
break;
|
|
14160
14403
|
case 'generateFulfillmentProof':
|
|
14161
|
-
|
|
14162
|
-
sendError(id, new Error('Fulfillment proof not yet implemented in worker'));
|
|
14404
|
+
await generateFulfillmentProof(id, params);
|
|
14163
14405
|
break;
|
|
14164
14406
|
case 'destroy':
|
|
14165
14407
|
// Cleanup
|
package/dist/browser.mjs
CHANGED
|
@@ -218,7 +218,7 @@ import {
|
|
|
218
218
|
walletRegistry,
|
|
219
219
|
withSecureBuffer,
|
|
220
220
|
withSecureBufferSync
|
|
221
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-YZCK337Y.mjs";
|
|
222
222
|
import {
|
|
223
223
|
fulfillment_proof_default,
|
|
224
224
|
funding_proof_default,
|
|
@@ -1129,6 +1129,211 @@ function createWorkerBlobURL() {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
1132
|
+
// Generate validity proof
|
|
1133
|
+
async function generateValidityProof(id, params) {
|
|
1134
|
+
if (!isReady) {
|
|
1135
|
+
sendError(id, new Error('Worker not initialized'));
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
try {
|
|
1140
|
+
sendProgress(id, 'witness', 20, 'Preparing validity witness...');
|
|
1141
|
+
|
|
1142
|
+
// Import noble crypto for hashing
|
|
1143
|
+
const { sha256 } = await import('@noble/hashes/sha256');
|
|
1144
|
+
|
|
1145
|
+
// Convert inputs to field elements
|
|
1146
|
+
const intentHashField = hexToField(params.intentHash);
|
|
1147
|
+
const senderAddressField = hexToField(params.senderAddress);
|
|
1148
|
+
const senderBlindingField = bytesToField(params.senderBlinding);
|
|
1149
|
+
const senderSecretField = bytesToField(params.senderSecret);
|
|
1150
|
+
const nonceField = bytesToField(params.nonce);
|
|
1151
|
+
|
|
1152
|
+
// Compute sender commitment
|
|
1153
|
+
const addressBytes = hexToBytes(senderAddressField);
|
|
1154
|
+
const blindingBytes = hexToBytes(senderBlindingField.padStart(64, '0'));
|
|
1155
|
+
const commitmentPreimage = new Uint8Array([...addressBytes, ...blindingBytes]);
|
|
1156
|
+
const commitmentHash = sha256(commitmentPreimage);
|
|
1157
|
+
const commitmentX = bytesToHex(commitmentHash.slice(0, 16)).padStart(64, '0');
|
|
1158
|
+
const commitmentY = bytesToHex(commitmentHash.slice(16, 32)).padStart(64, '0');
|
|
1159
|
+
|
|
1160
|
+
// Compute nullifier
|
|
1161
|
+
const secretBytes = hexToBytes(senderSecretField.padStart(64, '0'));
|
|
1162
|
+
const intentBytes = hexToBytes(intentHashField);
|
|
1163
|
+
const nonceBytes = hexToBytes(nonceField.padStart(64, '0'));
|
|
1164
|
+
const nullifierPreimage = new Uint8Array([...secretBytes, ...intentBytes, ...nonceBytes]);
|
|
1165
|
+
const nullifierHash = sha256(nullifierPreimage);
|
|
1166
|
+
const nullifier = bytesToHex(nullifierHash);
|
|
1167
|
+
|
|
1168
|
+
const signature = Array.from(params.authorizationSignature);
|
|
1169
|
+
const messageHash = fieldToBytes32(intentHashField);
|
|
1170
|
+
|
|
1171
|
+
// Get public key coordinates
|
|
1172
|
+
let pubKeyX, pubKeyY;
|
|
1173
|
+
if (params.senderPublicKey) {
|
|
1174
|
+
pubKeyX = Array.from(params.senderPublicKey.x);
|
|
1175
|
+
pubKeyY = Array.from(params.senderPublicKey.y);
|
|
1176
|
+
} else {
|
|
1177
|
+
// Derive from secret
|
|
1178
|
+
const { secp256k1 } = await import('@noble/curves/secp256k1');
|
|
1179
|
+
const uncompressedPubKey = secp256k1.getPublicKey(params.senderSecret, false);
|
|
1180
|
+
pubKeyX = Array.from(uncompressedPubKey.slice(1, 33));
|
|
1181
|
+
pubKeyY = Array.from(uncompressedPubKey.slice(33, 65));
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
const witnessInputs = {
|
|
1185
|
+
intent_hash: intentHashField,
|
|
1186
|
+
sender_commitment_x: commitmentX,
|
|
1187
|
+
sender_commitment_y: commitmentY,
|
|
1188
|
+
nullifier: nullifier,
|
|
1189
|
+
timestamp: params.timestamp.toString(),
|
|
1190
|
+
expiry: params.expiry.toString(),
|
|
1191
|
+
sender_address: senderAddressField,
|
|
1192
|
+
sender_blinding: senderBlindingField,
|
|
1193
|
+
sender_secret: senderSecretField,
|
|
1194
|
+
pub_key_x: pubKeyX,
|
|
1195
|
+
pub_key_y: pubKeyY,
|
|
1196
|
+
signature: signature,
|
|
1197
|
+
message_hash: messageHash,
|
|
1198
|
+
nonce: nonceField,
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
sendProgress(id, 'witness', 40, 'Executing validity circuit...');
|
|
1202
|
+
const { witness } = await validityNoir.execute(witnessInputs);
|
|
1203
|
+
|
|
1204
|
+
sendProgress(id, 'proving', 60, 'Generating validity proof...');
|
|
1205
|
+
const proofData = await validityBackend.generateProof(witness);
|
|
1206
|
+
|
|
1207
|
+
sendProgress(id, 'complete', 100, 'Validity proof generated');
|
|
1208
|
+
|
|
1209
|
+
const publicInputs = [
|
|
1210
|
+
'0x' + intentHashField,
|
|
1211
|
+
'0x' + commitmentX,
|
|
1212
|
+
'0x' + commitmentY,
|
|
1213
|
+
'0x' + nullifier,
|
|
1214
|
+
'0x' + params.timestamp.toString(16).padStart(16, '0'),
|
|
1215
|
+
'0x' + params.expiry.toString(16).padStart(16, '0'),
|
|
1216
|
+
];
|
|
1217
|
+
|
|
1218
|
+
const proof = {
|
|
1219
|
+
type: 'validity',
|
|
1220
|
+
proof: '0x' + bytesToHex(proofData.proof),
|
|
1221
|
+
publicInputs,
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
sendSuccess(id, { proof, publicInputs });
|
|
1225
|
+
} catch (error) {
|
|
1226
|
+
sendError(id, error);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// Generate fulfillment proof
|
|
1231
|
+
async function generateFulfillmentProof(id, params) {
|
|
1232
|
+
if (!isReady) {
|
|
1233
|
+
sendError(id, new Error('Worker not initialized'));
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
try {
|
|
1238
|
+
sendProgress(id, 'witness', 20, 'Preparing fulfillment witness...');
|
|
1239
|
+
|
|
1240
|
+
// Import noble crypto for hashing
|
|
1241
|
+
const { sha256 } = await import('@noble/hashes/sha256');
|
|
1242
|
+
|
|
1243
|
+
const intentHashField = hexToField(params.intentHash);
|
|
1244
|
+
const recipientStealthField = hexToField(params.recipientStealth);
|
|
1245
|
+
|
|
1246
|
+
// Compute output commitment
|
|
1247
|
+
const amountBytes = bigintToBytes(params.outputAmount, 8);
|
|
1248
|
+
const blindingBytes = params.outputBlinding.slice(0, 32);
|
|
1249
|
+
const outputPreimage = new Uint8Array([...amountBytes, ...blindingBytes]);
|
|
1250
|
+
const outputHash = sha256(outputPreimage);
|
|
1251
|
+
const commitmentX = bytesToHex(outputHash.slice(0, 16)).padStart(64, '0');
|
|
1252
|
+
const commitmentY = bytesToHex(outputHash.slice(16, 32)).padStart(64, '0');
|
|
1253
|
+
|
|
1254
|
+
const solverSecretField = bytesToField(params.solverSecret);
|
|
1255
|
+
|
|
1256
|
+
// Compute solver ID
|
|
1257
|
+
const solverSecretBytes = hexToBytes(solverSecretField.padStart(64, '0'));
|
|
1258
|
+
const solverIdHash = sha256(solverSecretBytes);
|
|
1259
|
+
const solverId = bytesToHex(solverIdHash);
|
|
1260
|
+
|
|
1261
|
+
const outputBlindingField = bytesToField(params.outputBlinding);
|
|
1262
|
+
|
|
1263
|
+
const attestation = params.oracleAttestation;
|
|
1264
|
+
const attestationRecipientField = hexToField(attestation.recipient);
|
|
1265
|
+
const attestationTxHashField = hexToField(attestation.txHash);
|
|
1266
|
+
const oracleSignature = Array.from(attestation.signature);
|
|
1267
|
+
|
|
1268
|
+
// Compute oracle message hash
|
|
1269
|
+
const recipientBytes = hexToBytes(attestationRecipientField);
|
|
1270
|
+
const attestationAmountBytes = bigintToBytes(attestation.amount, 8);
|
|
1271
|
+
const txHashBytes = hexToBytes(attestationTxHashField);
|
|
1272
|
+
const blockBytes = bigintToBytes(attestation.blockNumber, 8);
|
|
1273
|
+
const oraclePreimage = new Uint8Array([
|
|
1274
|
+
...recipientBytes,
|
|
1275
|
+
...attestationAmountBytes,
|
|
1276
|
+
...txHashBytes,
|
|
1277
|
+
...blockBytes,
|
|
1278
|
+
]);
|
|
1279
|
+
const oracleMessageHash = Array.from(sha256(oraclePreimage));
|
|
1280
|
+
|
|
1281
|
+
const oraclePubKeyX = config.oraclePublicKey?.x ?? new Array(32).fill(0);
|
|
1282
|
+
const oraclePubKeyY = config.oraclePublicKey?.y ?? new Array(32).fill(0);
|
|
1283
|
+
|
|
1284
|
+
const witnessInputs = {
|
|
1285
|
+
intent_hash: intentHashField,
|
|
1286
|
+
output_commitment_x: commitmentX,
|
|
1287
|
+
output_commitment_y: commitmentY,
|
|
1288
|
+
recipient_stealth: recipientStealthField,
|
|
1289
|
+
min_output_amount: params.minOutputAmount.toString(),
|
|
1290
|
+
solver_id: solverId,
|
|
1291
|
+
fulfillment_time: params.fulfillmentTime.toString(),
|
|
1292
|
+
expiry: params.expiry.toString(),
|
|
1293
|
+
output_amount: params.outputAmount.toString(),
|
|
1294
|
+
output_blinding: outputBlindingField,
|
|
1295
|
+
solver_secret: solverSecretField,
|
|
1296
|
+
attestation_recipient: attestationRecipientField,
|
|
1297
|
+
attestation_amount: attestation.amount.toString(),
|
|
1298
|
+
attestation_tx_hash: attestationTxHashField,
|
|
1299
|
+
attestation_block: attestation.blockNumber.toString(),
|
|
1300
|
+
oracle_signature: oracleSignature,
|
|
1301
|
+
oracle_message_hash: oracleMessageHash,
|
|
1302
|
+
oracle_pub_key_x: oraclePubKeyX,
|
|
1303
|
+
oracle_pub_key_y: oraclePubKeyY,
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
sendProgress(id, 'witness', 40, 'Executing fulfillment circuit...');
|
|
1307
|
+
const { witness } = await fulfillmentNoir.execute(witnessInputs);
|
|
1308
|
+
|
|
1309
|
+
sendProgress(id, 'proving', 60, 'Generating fulfillment proof...');
|
|
1310
|
+
const proofData = await fulfillmentBackend.generateProof(witness);
|
|
1311
|
+
|
|
1312
|
+
sendProgress(id, 'complete', 100, 'Fulfillment proof generated');
|
|
1313
|
+
|
|
1314
|
+
const publicInputs = [
|
|
1315
|
+
'0x' + intentHashField,
|
|
1316
|
+
'0x' + commitmentX,
|
|
1317
|
+
'0x' + commitmentY,
|
|
1318
|
+
'0x' + recipientStealthField,
|
|
1319
|
+
'0x' + params.minOutputAmount.toString(16).padStart(16, '0'),
|
|
1320
|
+
'0x' + solverId,
|
|
1321
|
+
'0x' + params.fulfillmentTime.toString(16).padStart(16, '0'),
|
|
1322
|
+
'0x' + params.expiry.toString(16).padStart(16, '0'),
|
|
1323
|
+
];
|
|
1324
|
+
|
|
1325
|
+
const proof = {
|
|
1326
|
+
type: 'fulfillment',
|
|
1327
|
+
proof: '0x' + bytesToHex(proofData.proof),
|
|
1328
|
+
publicInputs,
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
sendSuccess(id, { proof, publicInputs });
|
|
1332
|
+
} catch (error) {
|
|
1333
|
+
sendError(id, error);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1132
1337
|
// Helper functions
|
|
1133
1338
|
function bytesToField(bytes) {
|
|
1134
1339
|
let result = 0n;
|
|
@@ -1156,6 +1361,39 @@ function createWorkerBlobURL() {
|
|
|
1156
1361
|
return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
1157
1362
|
}
|
|
1158
1363
|
|
|
1364
|
+
function hexToBytes(hex) {
|
|
1365
|
+
const h = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
1366
|
+
const bytes = new Uint8Array(h.length / 2);
|
|
1367
|
+
for (let i = 0; i < h.length; i += 2) {
|
|
1368
|
+
bytes[i / 2] = parseInt(h.slice(i, i + 2), 16);
|
|
1369
|
+
}
|
|
1370
|
+
return bytes;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
function hexToField(hex) {
|
|
1374
|
+
const h = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
1375
|
+
return h.padStart(64, '0');
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
function fieldToBytes32(field) {
|
|
1379
|
+
const hex = field.padStart(64, '0');
|
|
1380
|
+
const bytes = [];
|
|
1381
|
+
for (let i = 0; i < 32; i++) {
|
|
1382
|
+
bytes.push(parseInt(hex.slice(i * 2, i * 2 + 2), 16));
|
|
1383
|
+
}
|
|
1384
|
+
return bytes;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
function bigintToBytes(value, length) {
|
|
1388
|
+
const bytes = new Uint8Array(length);
|
|
1389
|
+
let v = value;
|
|
1390
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
1391
|
+
bytes[i] = Number(v & 0xffn);
|
|
1392
|
+
v = v >> 8n;
|
|
1393
|
+
}
|
|
1394
|
+
return bytes;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1159
1397
|
// Message handler
|
|
1160
1398
|
self.onmessage = async function(event) {
|
|
1161
1399
|
const { id, type, params, config: initConfig } = event.data;
|
|
@@ -1168,12 +1406,10 @@ function createWorkerBlobURL() {
|
|
|
1168
1406
|
await generateFundingProof(id, params);
|
|
1169
1407
|
break;
|
|
1170
1408
|
case 'generateValidityProof':
|
|
1171
|
-
|
|
1172
|
-
sendError(id, new Error('Validity proof not yet implemented in worker'));
|
|
1409
|
+
await generateValidityProof(id, params);
|
|
1173
1410
|
break;
|
|
1174
1411
|
case 'generateFulfillmentProof':
|
|
1175
|
-
|
|
1176
|
-
sendError(id, new Error('Fulfillment proof not yet implemented in worker'));
|
|
1412
|
+
await generateFulfillmentProof(id, params);
|
|
1177
1413
|
break;
|
|
1178
1414
|
case 'destroy':
|
|
1179
1415
|
// Cleanup
|