@sip-protocol/sdk 0.1.6 → 0.1.8
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.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +57 -2
- package/dist/index.mjs +56 -2
- package/package.json +1 -1
- package/src/adapters/near-intents.ts +33 -4
- package/src/index.ts +1 -0
- package/src/stealth.ts +66 -0
package/dist/index.d.mts
CHANGED
|
@@ -1610,6 +1610,19 @@ declare function encodeStealthMetaAddress(metaAddress: StealthMetaAddress): stri
|
|
|
1610
1610
|
* @throws {ValidationError} If format is invalid or keys are malformed
|
|
1611
1611
|
*/
|
|
1612
1612
|
declare function decodeStealthMetaAddress(encoded: string): StealthMetaAddress;
|
|
1613
|
+
/**
|
|
1614
|
+
* Convert a secp256k1 public key to an Ethereum address
|
|
1615
|
+
*
|
|
1616
|
+
* Algorithm (EIP-5564 style):
|
|
1617
|
+
* 1. Decompress the public key to uncompressed form (65 bytes)
|
|
1618
|
+
* 2. Remove the 0x04 prefix (take last 64 bytes)
|
|
1619
|
+
* 3. keccak256 hash of the 64 bytes
|
|
1620
|
+
* 4. Take the last 20 bytes as the address
|
|
1621
|
+
*
|
|
1622
|
+
* @param publicKey - Compressed (33 bytes) or uncompressed (65 bytes) public key
|
|
1623
|
+
* @returns Ethereum address (20 bytes, checksummed)
|
|
1624
|
+
*/
|
|
1625
|
+
declare function publicKeyToEthAddress(publicKey: HexString): HexString;
|
|
1613
1626
|
|
|
1614
1627
|
/**
|
|
1615
1628
|
* Privacy level handling for SIP Protocol
|
|
@@ -5319,4 +5332,4 @@ declare function createMockLedgerAdapter(config: Omit<MockHardwareConfig, 'devic
|
|
|
5319
5332
|
*/
|
|
5320
5333
|
declare function createMockTrezorAdapter(config: Omit<MockHardwareConfig, 'deviceType'>): MockTrezorAdapter;
|
|
5321
5334
|
|
|
5322
|
-
export { BaseWalletAdapter, type CommitmentPoint, ComplianceManager, type CreateIntentOptions, type CreatePaymentOptions, CryptoError, DerivationPath, type EIP1193ConnectInfo, type EIP1193Event, type EIP1193Provider, type EIP1193ProviderRpcError, type EIP1193RequestArguments, type EIP712Domain, type EIP712TypeDefinition, type EIP712TypedData, type EIP712Types, EncryptionNotImplementedError, ErrorCode, type EthereumAdapterConfig, EthereumChainId, type EthereumChainIdType, type EthereumChainMetadata, type EthereumTokenMetadata, type EthereumTransactionReceipt, type EthereumTransactionRequest, EthereumWalletAdapter, type EthereumWalletName, type ExportedViewingKey, type FulfillmentProofParams, type FundingProofParams, type HardwareAccount, type HardwareConnectionStatus, type HardwareDeviceInfo, HardwareErrorCode, type HardwareErrorCodeType, type HardwareEthereumTx, type HardwareSignRequest, type HardwareSignature, type HardwareTransport, type HardwareWalletConfig, HardwareWalletError, type HardwareWalletType, IntentBuilder, IntentError, type LedgerConfig, type LedgerModel, LedgerWalletAdapter, MockEthereumAdapter, type MockEthereumAdapterConfig, type MockHardwareConfig, MockLedgerAdapter, MockProofProvider, MockSolanaAdapter, type MockSolanaAdapterConfig, MockSolver, type MockSolverConfig, MockTrezorAdapter, MockWalletAdapter, NEARIntentsAdapter, type NEARIntentsAdapterConfig, NetworkError, NoirProofProvider, type NoirProviderConfig, OneClickClient, type OracleAttestation, PaymentBuilder, type PedersenCommitment, type PreparedSwap, type PrivacyConfig, type ProductionQuote, ProofError, type ProofFramework, ProofGenerationError, ProofNotImplementedError, type ProofProvider, type ProofResult, type ReceivedNote, SIP, type SIPConfig, SIPError, STABLECOIN_ADDRESSES, STABLECOIN_DECIMALS, STABLECOIN_INFO, type SerializedError, type ShieldedBalance, type ShieldedSendParams, type ShieldedSendResult, type SolanaAdapterConfig, type SolanaCluster, type SolanaConnection, type SolanaPublicKey, type SolanaSendOptions, type SolanaSignature, type SolanaTransaction, type SolanaUnsignedTransaction, type SolanaVersionedTransaction, SolanaWalletAdapter, type SolanaWalletName, type SolanaWalletProvider, type StablecoinInfo, type SwapRequest, type SwapResult, type TransactionData, type TransportType, Treasury, type TrezorConfig, type TrezorModel, TrezorWalletAdapter, ValidationError, type ValidityProofParams, type WalletAdapter, WalletError, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, type ZcashShieldedServiceConfig, addBlindings, addCommitments, attachProofs, base58ToHex, checkStealthAddress, commit, commitZero, createCommitment, createEthereumAdapter, createLedgerAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockLedgerAdapter, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createMockTrezorAdapter, createNEARIntentsAdapter, createProductionSIP, createSIP, createShieldedIntent, createShieldedPayment, createSolanaAdapter, createTrezorAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, decodeStealthMetaAddress, decryptMemo, decryptWithViewing, deriveStealthPrivateKey, deriveViewingKey, deserializeIntent, deserializePayment, detectEthereumWallets, detectSolanaWallets, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, formatStablecoinAmount, fromHex, fromStablecoinUnits, generateBlinding, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getAvailableTransports, getChainsForStablecoin, getDefaultRpcEndpoint, getDerivationPath, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPaymentSummary, getPaymentTimeRemaining, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getStablecoin, getStablecoinInfo, getStablecoinsForChain, getSupportedStablecoins, getTimeRemaining, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isExpired, isNonNegativeAmount, isPaymentExpired, isPrivateWalletAdapter, isSIPError, isStablecoin, isStablecoinOnChain, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidHex, isValidHexLength, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidStealthMetaAddress, normalizeAddress, notConnectedError, registerWallet, secureWipe, secureWipeAll, serializeIntent, serializePayment, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, supportsWebBluetooth, supportsWebHID, supportsWebUSB, toHex, toStablecoinUnits, trackIntent, trackPayment, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyCommitment, verifyOpening, walletRegistry, withSecureBuffer, withSecureBufferSync, wrapError };
|
|
5335
|
+
export { BaseWalletAdapter, type CommitmentPoint, ComplianceManager, type CreateIntentOptions, type CreatePaymentOptions, CryptoError, DerivationPath, type EIP1193ConnectInfo, type EIP1193Event, type EIP1193Provider, type EIP1193ProviderRpcError, type EIP1193RequestArguments, type EIP712Domain, type EIP712TypeDefinition, type EIP712TypedData, type EIP712Types, EncryptionNotImplementedError, ErrorCode, type EthereumAdapterConfig, EthereumChainId, type EthereumChainIdType, type EthereumChainMetadata, type EthereumTokenMetadata, type EthereumTransactionReceipt, type EthereumTransactionRequest, EthereumWalletAdapter, type EthereumWalletName, type ExportedViewingKey, type FulfillmentProofParams, type FundingProofParams, type HardwareAccount, type HardwareConnectionStatus, type HardwareDeviceInfo, HardwareErrorCode, type HardwareErrorCodeType, type HardwareEthereumTx, type HardwareSignRequest, type HardwareSignature, type HardwareTransport, type HardwareWalletConfig, HardwareWalletError, type HardwareWalletType, IntentBuilder, IntentError, type LedgerConfig, type LedgerModel, LedgerWalletAdapter, MockEthereumAdapter, type MockEthereumAdapterConfig, type MockHardwareConfig, MockLedgerAdapter, MockProofProvider, MockSolanaAdapter, type MockSolanaAdapterConfig, MockSolver, type MockSolverConfig, MockTrezorAdapter, MockWalletAdapter, NEARIntentsAdapter, type NEARIntentsAdapterConfig, NetworkError, NoirProofProvider, type NoirProviderConfig, OneClickClient, type OracleAttestation, PaymentBuilder, type PedersenCommitment, type PreparedSwap, type PrivacyConfig, type ProductionQuote, ProofError, type ProofFramework, ProofGenerationError, ProofNotImplementedError, type ProofProvider, type ProofResult, type ReceivedNote, SIP, type SIPConfig, SIPError, STABLECOIN_ADDRESSES, STABLECOIN_DECIMALS, STABLECOIN_INFO, type SerializedError, type ShieldedBalance, type ShieldedSendParams, type ShieldedSendResult, type SolanaAdapterConfig, type SolanaCluster, type SolanaConnection, type SolanaPublicKey, type SolanaSendOptions, type SolanaSignature, type SolanaTransaction, type SolanaUnsignedTransaction, type SolanaVersionedTransaction, SolanaWalletAdapter, type SolanaWalletName, type SolanaWalletProvider, type StablecoinInfo, type SwapRequest, type SwapResult, type TransactionData, type TransportType, Treasury, type TrezorConfig, type TrezorModel, TrezorWalletAdapter, ValidationError, type ValidityProofParams, type WalletAdapter, WalletError, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, type ZcashShieldedServiceConfig, addBlindings, addCommitments, attachProofs, base58ToHex, checkStealthAddress, commit, commitZero, createCommitment, createEthereumAdapter, createLedgerAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockLedgerAdapter, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createMockTrezorAdapter, createNEARIntentsAdapter, createProductionSIP, createSIP, createShieldedIntent, createShieldedPayment, createSolanaAdapter, createTrezorAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, decodeStealthMetaAddress, decryptMemo, decryptWithViewing, deriveStealthPrivateKey, deriveViewingKey, deserializeIntent, deserializePayment, detectEthereumWallets, detectSolanaWallets, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, formatStablecoinAmount, fromHex, fromStablecoinUnits, generateBlinding, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getAvailableTransports, getChainsForStablecoin, getDefaultRpcEndpoint, getDerivationPath, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPaymentSummary, getPaymentTimeRemaining, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getStablecoin, getStablecoinInfo, getStablecoinsForChain, getSupportedStablecoins, getTimeRemaining, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isExpired, isNonNegativeAmount, isPaymentExpired, isPrivateWalletAdapter, isSIPError, isStablecoin, isStablecoinOnChain, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidHex, isValidHexLength, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidStealthMetaAddress, normalizeAddress, notConnectedError, publicKeyToEthAddress, registerWallet, secureWipe, secureWipeAll, serializeIntent, serializePayment, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, supportsWebBluetooth, supportsWebHID, supportsWebUSB, toHex, toStablecoinUnits, trackIntent, trackPayment, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyCommitment, verifyOpening, walletRegistry, withSecureBuffer, withSecureBufferSync, wrapError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1610,6 +1610,19 @@ declare function encodeStealthMetaAddress(metaAddress: StealthMetaAddress): stri
|
|
|
1610
1610
|
* @throws {ValidationError} If format is invalid or keys are malformed
|
|
1611
1611
|
*/
|
|
1612
1612
|
declare function decodeStealthMetaAddress(encoded: string): StealthMetaAddress;
|
|
1613
|
+
/**
|
|
1614
|
+
* Convert a secp256k1 public key to an Ethereum address
|
|
1615
|
+
*
|
|
1616
|
+
* Algorithm (EIP-5564 style):
|
|
1617
|
+
* 1. Decompress the public key to uncompressed form (65 bytes)
|
|
1618
|
+
* 2. Remove the 0x04 prefix (take last 64 bytes)
|
|
1619
|
+
* 3. keccak256 hash of the 64 bytes
|
|
1620
|
+
* 4. Take the last 20 bytes as the address
|
|
1621
|
+
*
|
|
1622
|
+
* @param publicKey - Compressed (33 bytes) or uncompressed (65 bytes) public key
|
|
1623
|
+
* @returns Ethereum address (20 bytes, checksummed)
|
|
1624
|
+
*/
|
|
1625
|
+
declare function publicKeyToEthAddress(publicKey: HexString): HexString;
|
|
1613
1626
|
|
|
1614
1627
|
/**
|
|
1615
1628
|
* Privacy level handling for SIP Protocol
|
|
@@ -5319,4 +5332,4 @@ declare function createMockLedgerAdapter(config: Omit<MockHardwareConfig, 'devic
|
|
|
5319
5332
|
*/
|
|
5320
5333
|
declare function createMockTrezorAdapter(config: Omit<MockHardwareConfig, 'deviceType'>): MockTrezorAdapter;
|
|
5321
5334
|
|
|
5322
|
-
export { BaseWalletAdapter, type CommitmentPoint, ComplianceManager, type CreateIntentOptions, type CreatePaymentOptions, CryptoError, DerivationPath, type EIP1193ConnectInfo, type EIP1193Event, type EIP1193Provider, type EIP1193ProviderRpcError, type EIP1193RequestArguments, type EIP712Domain, type EIP712TypeDefinition, type EIP712TypedData, type EIP712Types, EncryptionNotImplementedError, ErrorCode, type EthereumAdapterConfig, EthereumChainId, type EthereumChainIdType, type EthereumChainMetadata, type EthereumTokenMetadata, type EthereumTransactionReceipt, type EthereumTransactionRequest, EthereumWalletAdapter, type EthereumWalletName, type ExportedViewingKey, type FulfillmentProofParams, type FundingProofParams, type HardwareAccount, type HardwareConnectionStatus, type HardwareDeviceInfo, HardwareErrorCode, type HardwareErrorCodeType, type HardwareEthereumTx, type HardwareSignRequest, type HardwareSignature, type HardwareTransport, type HardwareWalletConfig, HardwareWalletError, type HardwareWalletType, IntentBuilder, IntentError, type LedgerConfig, type LedgerModel, LedgerWalletAdapter, MockEthereumAdapter, type MockEthereumAdapterConfig, type MockHardwareConfig, MockLedgerAdapter, MockProofProvider, MockSolanaAdapter, type MockSolanaAdapterConfig, MockSolver, type MockSolverConfig, MockTrezorAdapter, MockWalletAdapter, NEARIntentsAdapter, type NEARIntentsAdapterConfig, NetworkError, NoirProofProvider, type NoirProviderConfig, OneClickClient, type OracleAttestation, PaymentBuilder, type PedersenCommitment, type PreparedSwap, type PrivacyConfig, type ProductionQuote, ProofError, type ProofFramework, ProofGenerationError, ProofNotImplementedError, type ProofProvider, type ProofResult, type ReceivedNote, SIP, type SIPConfig, SIPError, STABLECOIN_ADDRESSES, STABLECOIN_DECIMALS, STABLECOIN_INFO, type SerializedError, type ShieldedBalance, type ShieldedSendParams, type ShieldedSendResult, type SolanaAdapterConfig, type SolanaCluster, type SolanaConnection, type SolanaPublicKey, type SolanaSendOptions, type SolanaSignature, type SolanaTransaction, type SolanaUnsignedTransaction, type SolanaVersionedTransaction, SolanaWalletAdapter, type SolanaWalletName, type SolanaWalletProvider, type StablecoinInfo, type SwapRequest, type SwapResult, type TransactionData, type TransportType, Treasury, type TrezorConfig, type TrezorModel, TrezorWalletAdapter, ValidationError, type ValidityProofParams, type WalletAdapter, WalletError, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, type ZcashShieldedServiceConfig, addBlindings, addCommitments, attachProofs, base58ToHex, checkStealthAddress, commit, commitZero, createCommitment, createEthereumAdapter, createLedgerAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockLedgerAdapter, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createMockTrezorAdapter, createNEARIntentsAdapter, createProductionSIP, createSIP, createShieldedIntent, createShieldedPayment, createSolanaAdapter, createTrezorAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, decodeStealthMetaAddress, decryptMemo, decryptWithViewing, deriveStealthPrivateKey, deriveViewingKey, deserializeIntent, deserializePayment, detectEthereumWallets, detectSolanaWallets, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, formatStablecoinAmount, fromHex, fromStablecoinUnits, generateBlinding, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getAvailableTransports, getChainsForStablecoin, getDefaultRpcEndpoint, getDerivationPath, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPaymentSummary, getPaymentTimeRemaining, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getStablecoin, getStablecoinInfo, getStablecoinsForChain, getSupportedStablecoins, getTimeRemaining, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isExpired, isNonNegativeAmount, isPaymentExpired, isPrivateWalletAdapter, isSIPError, isStablecoin, isStablecoinOnChain, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidHex, isValidHexLength, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidStealthMetaAddress, normalizeAddress, notConnectedError, registerWallet, secureWipe, secureWipeAll, serializeIntent, serializePayment, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, supportsWebBluetooth, supportsWebHID, supportsWebUSB, toHex, toStablecoinUnits, trackIntent, trackPayment, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyCommitment, verifyOpening, walletRegistry, withSecureBuffer, withSecureBufferSync, wrapError };
|
|
5335
|
+
export { BaseWalletAdapter, type CommitmentPoint, ComplianceManager, type CreateIntentOptions, type CreatePaymentOptions, CryptoError, DerivationPath, type EIP1193ConnectInfo, type EIP1193Event, type EIP1193Provider, type EIP1193ProviderRpcError, type EIP1193RequestArguments, type EIP712Domain, type EIP712TypeDefinition, type EIP712TypedData, type EIP712Types, EncryptionNotImplementedError, ErrorCode, type EthereumAdapterConfig, EthereumChainId, type EthereumChainIdType, type EthereumChainMetadata, type EthereumTokenMetadata, type EthereumTransactionReceipt, type EthereumTransactionRequest, EthereumWalletAdapter, type EthereumWalletName, type ExportedViewingKey, type FulfillmentProofParams, type FundingProofParams, type HardwareAccount, type HardwareConnectionStatus, type HardwareDeviceInfo, HardwareErrorCode, type HardwareErrorCodeType, type HardwareEthereumTx, type HardwareSignRequest, type HardwareSignature, type HardwareTransport, type HardwareWalletConfig, HardwareWalletError, type HardwareWalletType, IntentBuilder, IntentError, type LedgerConfig, type LedgerModel, LedgerWalletAdapter, MockEthereumAdapter, type MockEthereumAdapterConfig, type MockHardwareConfig, MockLedgerAdapter, MockProofProvider, MockSolanaAdapter, type MockSolanaAdapterConfig, MockSolver, type MockSolverConfig, MockTrezorAdapter, MockWalletAdapter, NEARIntentsAdapter, type NEARIntentsAdapterConfig, NetworkError, NoirProofProvider, type NoirProviderConfig, OneClickClient, type OracleAttestation, PaymentBuilder, type PedersenCommitment, type PreparedSwap, type PrivacyConfig, type ProductionQuote, ProofError, type ProofFramework, ProofGenerationError, ProofNotImplementedError, type ProofProvider, type ProofResult, type ReceivedNote, SIP, type SIPConfig, SIPError, STABLECOIN_ADDRESSES, STABLECOIN_DECIMALS, STABLECOIN_INFO, type SerializedError, type ShieldedBalance, type ShieldedSendParams, type ShieldedSendResult, type SolanaAdapterConfig, type SolanaCluster, type SolanaConnection, type SolanaPublicKey, type SolanaSendOptions, type SolanaSignature, type SolanaTransaction, type SolanaUnsignedTransaction, type SolanaVersionedTransaction, SolanaWalletAdapter, type SolanaWalletName, type SolanaWalletProvider, type StablecoinInfo, type SwapRequest, type SwapResult, type TransactionData, type TransportType, Treasury, type TrezorConfig, type TrezorModel, TrezorWalletAdapter, ValidationError, type ValidityProofParams, type WalletAdapter, WalletError, ZcashRPCClient, ZcashRPCError, ZcashShieldedService, type ZcashShieldedServiceConfig, addBlindings, addCommitments, attachProofs, base58ToHex, checkStealthAddress, commit, commitZero, createCommitment, createEthereumAdapter, createLedgerAdapter, createMockEthereumAdapter, createMockEthereumProvider, createMockLedgerAdapter, createMockSolanaAdapter, createMockSolanaConnection, createMockSolanaProvider, createMockSolver, createMockTrezorAdapter, createNEARIntentsAdapter, createProductionSIP, createSIP, createShieldedIntent, createShieldedPayment, createSolanaAdapter, createTrezorAdapter, createWalletFactory, createZcashClient, createZcashShieldedService, decodeStealthMetaAddress, decryptMemo, decryptWithViewing, deriveStealthPrivateKey, deriveViewingKey, deserializeIntent, deserializePayment, detectEthereumWallets, detectSolanaWallets, encodeStealthMetaAddress, encryptForViewing, featureNotSupportedError, formatStablecoinAmount, fromHex, fromStablecoinUnits, generateBlinding, generateIntentId, generateRandomBytes, generateStealthAddress, generateStealthMetaAddress, generateViewingKey, getAvailableTransports, getChainsForStablecoin, getDefaultRpcEndpoint, getDerivationPath, getErrorMessage, getEthereumProvider, getGenerators, getIntentSummary, getPaymentSummary, getPaymentTimeRemaining, getPrivacyConfig, getPrivacyDescription, getSolanaProvider, getStablecoin, getStablecoinInfo, getStablecoinsForChain, getSupportedStablecoins, getTimeRemaining, hasErrorCode, hasRequiredProofs, hash, hexToNumber, isExpired, isNonNegativeAmount, isPaymentExpired, isPrivateWalletAdapter, isSIPError, isStablecoin, isStablecoinOnChain, isValidAmount, isValidChainId, isValidCompressedPublicKey, isValidHex, isValidHexLength, isValidPrivacyLevel, isValidPrivateKey, isValidScalar, isValidSlippage, isValidStealthMetaAddress, normalizeAddress, notConnectedError, publicKeyToEthAddress, registerWallet, secureWipe, secureWipeAll, serializeIntent, serializePayment, solanaPublicKeyToHex, subtractBlindings, subtractCommitments, supportsWebBluetooth, supportsWebHID, supportsWebUSB, toHex, toStablecoinUnits, trackIntent, trackPayment, validateAsset, validateCreateIntentParams, validateIntentInput, validateIntentOutput, validateScalar, validateViewingKey, verifyCommitment, verifyOpening, walletRegistry, withSecureBuffer, withSecureBufferSync, wrapError };
|
package/dist/index.js
CHANGED
|
@@ -175,6 +175,7 @@ __export(index_exports, {
|
|
|
175
175
|
isValidStealthMetaAddress: () => isValidStealthMetaAddress,
|
|
176
176
|
normalizeAddress: () => normalizeAddress,
|
|
177
177
|
notConnectedError: () => notConnectedError,
|
|
178
|
+
publicKeyToEthAddress: () => publicKeyToEthAddress,
|
|
178
179
|
registerWallet: () => registerWallet,
|
|
179
180
|
secureWipe: () => secureWipe,
|
|
180
181
|
secureWipeAll: () => secureWipeAll,
|
|
@@ -410,6 +411,7 @@ var import_types = require("@sip-protocol/types");
|
|
|
410
411
|
// src/stealth.ts
|
|
411
412
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
412
413
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
414
|
+
var import_sha3 = require("@noble/hashes/sha3");
|
|
413
415
|
var import_utils2 = require("@noble/hashes/utils");
|
|
414
416
|
|
|
415
417
|
// src/validation.ts
|
|
@@ -868,6 +870,39 @@ function bigIntToBytes(value, length) {
|
|
|
868
870
|
}
|
|
869
871
|
return bytes;
|
|
870
872
|
}
|
|
873
|
+
function publicKeyToEthAddress(publicKey) {
|
|
874
|
+
const keyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
875
|
+
const keyBytes = (0, import_utils2.hexToBytes)(keyHex);
|
|
876
|
+
let uncompressedBytes;
|
|
877
|
+
if (keyBytes.length === 33) {
|
|
878
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex(keyBytes);
|
|
879
|
+
uncompressedBytes = point.toRawBytes(false);
|
|
880
|
+
} else if (keyBytes.length === 65) {
|
|
881
|
+
uncompressedBytes = keyBytes;
|
|
882
|
+
} else {
|
|
883
|
+
throw new ValidationError(
|
|
884
|
+
`invalid public key length: ${keyBytes.length}, expected 33 (compressed) or 65 (uncompressed)`,
|
|
885
|
+
"publicKey"
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
const pubKeyWithoutPrefix = uncompressedBytes.slice(1);
|
|
889
|
+
const hash2 = (0, import_sha3.keccak_256)(pubKeyWithoutPrefix);
|
|
890
|
+
const addressBytes = hash2.slice(-20);
|
|
891
|
+
return toChecksumAddress(`0x${(0, import_utils2.bytesToHex)(addressBytes)}`);
|
|
892
|
+
}
|
|
893
|
+
function toChecksumAddress(address) {
|
|
894
|
+
const addr = address.toLowerCase().replace("0x", "");
|
|
895
|
+
const hash2 = (0, import_utils2.bytesToHex)((0, import_sha3.keccak_256)(new TextEncoder().encode(addr)));
|
|
896
|
+
let checksummed = "0x";
|
|
897
|
+
for (let i = 0; i < addr.length; i++) {
|
|
898
|
+
if (parseInt(hash2[i], 16) >= 8) {
|
|
899
|
+
checksummed += addr[i].toUpperCase();
|
|
900
|
+
} else {
|
|
901
|
+
checksummed += addr[i];
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return checksummed;
|
|
905
|
+
}
|
|
871
906
|
|
|
872
907
|
// src/crypto.ts
|
|
873
908
|
var import_sha2563 = require("@noble/hashes/sha256");
|
|
@@ -1935,6 +1970,7 @@ var NEARIntentsAdapter = class {
|
|
|
1935
1970
|
async prepareSwap(request, recipientMetaAddress, senderAddress) {
|
|
1936
1971
|
this.validateRequest(request);
|
|
1937
1972
|
let recipientAddress;
|
|
1973
|
+
let refundAddress = senderAddress;
|
|
1938
1974
|
let stealthData;
|
|
1939
1975
|
let sharedSecret;
|
|
1940
1976
|
if (request.privacyLevel !== import_types3.PrivacyLevel.TRANSPARENT) {
|
|
@@ -1946,9 +1982,27 @@ var NEARIntentsAdapter = class {
|
|
|
1946
1982
|
}
|
|
1947
1983
|
const metaAddr = typeof recipientMetaAddress === "string" ? decodeStealthMetaAddress(recipientMetaAddress) : recipientMetaAddress;
|
|
1948
1984
|
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr);
|
|
1949
|
-
|
|
1985
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[request.outputAsset.chain];
|
|
1986
|
+
if (outputChainType === "evm") {
|
|
1987
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address);
|
|
1988
|
+
} else {
|
|
1989
|
+
recipientAddress = stealthAddress.address;
|
|
1990
|
+
}
|
|
1950
1991
|
stealthData = stealthAddress;
|
|
1951
1992
|
sharedSecret = secret;
|
|
1993
|
+
if (!senderAddress) {
|
|
1994
|
+
const inputChainType = CHAIN_BLOCKCHAIN_MAP[request.inputAsset.chain];
|
|
1995
|
+
if (inputChainType === "evm") {
|
|
1996
|
+
const refundStealth = generateStealthAddress(metaAddr);
|
|
1997
|
+
refundAddress = publicKeyToEthAddress(refundStealth.stealthAddress.address);
|
|
1998
|
+
} else {
|
|
1999
|
+
throw new ValidationError(
|
|
2000
|
+
`senderAddress is required for refunds on ${request.inputAsset.chain}. Stealth addresses are only supported for EVM-compatible chains. Please connect a wallet or provide a sender address.`,
|
|
2001
|
+
"senderAddress",
|
|
2002
|
+
{ inputChain: request.inputAsset.chain, inputChainType }
|
|
2003
|
+
);
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
1952
2006
|
} else {
|
|
1953
2007
|
if (!senderAddress) {
|
|
1954
2008
|
throw new ValidationError(
|
|
@@ -1958,7 +2012,7 @@ var NEARIntentsAdapter = class {
|
|
|
1958
2012
|
}
|
|
1959
2013
|
recipientAddress = senderAddress;
|
|
1960
2014
|
}
|
|
1961
|
-
const quoteRequest = this.buildQuoteRequest(request, recipientAddress,
|
|
2015
|
+
const quoteRequest = this.buildQuoteRequest(request, recipientAddress, refundAddress);
|
|
1962
2016
|
return {
|
|
1963
2017
|
request,
|
|
1964
2018
|
quoteRequest,
|
|
@@ -11360,6 +11414,7 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11360
11414
|
isValidStealthMetaAddress,
|
|
11361
11415
|
normalizeAddress,
|
|
11362
11416
|
notConnectedError,
|
|
11417
|
+
publicKeyToEthAddress,
|
|
11363
11418
|
registerWallet,
|
|
11364
11419
|
secureWipe,
|
|
11365
11420
|
secureWipeAll,
|
package/dist/index.mjs
CHANGED
|
@@ -210,6 +210,7 @@ import {
|
|
|
210
210
|
// src/stealth.ts
|
|
211
211
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
212
212
|
import { sha256 } from "@noble/hashes/sha256";
|
|
213
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
213
214
|
import { bytesToHex, hexToBytes, randomBytes as randomBytes2 } from "@noble/hashes/utils";
|
|
214
215
|
|
|
215
216
|
// src/validation.ts
|
|
@@ -668,6 +669,39 @@ function bigIntToBytes(value, length) {
|
|
|
668
669
|
}
|
|
669
670
|
return bytes;
|
|
670
671
|
}
|
|
672
|
+
function publicKeyToEthAddress(publicKey) {
|
|
673
|
+
const keyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
674
|
+
const keyBytes = hexToBytes(keyHex);
|
|
675
|
+
let uncompressedBytes;
|
|
676
|
+
if (keyBytes.length === 33) {
|
|
677
|
+
const point = secp256k1.ProjectivePoint.fromHex(keyBytes);
|
|
678
|
+
uncompressedBytes = point.toRawBytes(false);
|
|
679
|
+
} else if (keyBytes.length === 65) {
|
|
680
|
+
uncompressedBytes = keyBytes;
|
|
681
|
+
} else {
|
|
682
|
+
throw new ValidationError(
|
|
683
|
+
`invalid public key length: ${keyBytes.length}, expected 33 (compressed) or 65 (uncompressed)`,
|
|
684
|
+
"publicKey"
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
const pubKeyWithoutPrefix = uncompressedBytes.slice(1);
|
|
688
|
+
const hash2 = keccak_256(pubKeyWithoutPrefix);
|
|
689
|
+
const addressBytes = hash2.slice(-20);
|
|
690
|
+
return toChecksumAddress(`0x${bytesToHex(addressBytes)}`);
|
|
691
|
+
}
|
|
692
|
+
function toChecksumAddress(address) {
|
|
693
|
+
const addr = address.toLowerCase().replace("0x", "");
|
|
694
|
+
const hash2 = bytesToHex(keccak_256(new TextEncoder().encode(addr)));
|
|
695
|
+
let checksummed = "0x";
|
|
696
|
+
for (let i = 0; i < addr.length; i++) {
|
|
697
|
+
if (parseInt(hash2[i], 16) >= 8) {
|
|
698
|
+
checksummed += addr[i].toUpperCase();
|
|
699
|
+
} else {
|
|
700
|
+
checksummed += addr[i];
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return checksummed;
|
|
704
|
+
}
|
|
671
705
|
|
|
672
706
|
// src/crypto.ts
|
|
673
707
|
import { sha256 as sha2563 } from "@noble/hashes/sha256";
|
|
@@ -1745,6 +1779,7 @@ var NEARIntentsAdapter = class {
|
|
|
1745
1779
|
async prepareSwap(request, recipientMetaAddress, senderAddress) {
|
|
1746
1780
|
this.validateRequest(request);
|
|
1747
1781
|
let recipientAddress;
|
|
1782
|
+
let refundAddress = senderAddress;
|
|
1748
1783
|
let stealthData;
|
|
1749
1784
|
let sharedSecret;
|
|
1750
1785
|
if (request.privacyLevel !== PrivacyLevel.TRANSPARENT) {
|
|
@@ -1756,9 +1791,27 @@ var NEARIntentsAdapter = class {
|
|
|
1756
1791
|
}
|
|
1757
1792
|
const metaAddr = typeof recipientMetaAddress === "string" ? decodeStealthMetaAddress(recipientMetaAddress) : recipientMetaAddress;
|
|
1758
1793
|
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr);
|
|
1759
|
-
|
|
1794
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[request.outputAsset.chain];
|
|
1795
|
+
if (outputChainType === "evm") {
|
|
1796
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address);
|
|
1797
|
+
} else {
|
|
1798
|
+
recipientAddress = stealthAddress.address;
|
|
1799
|
+
}
|
|
1760
1800
|
stealthData = stealthAddress;
|
|
1761
1801
|
sharedSecret = secret;
|
|
1802
|
+
if (!senderAddress) {
|
|
1803
|
+
const inputChainType = CHAIN_BLOCKCHAIN_MAP[request.inputAsset.chain];
|
|
1804
|
+
if (inputChainType === "evm") {
|
|
1805
|
+
const refundStealth = generateStealthAddress(metaAddr);
|
|
1806
|
+
refundAddress = publicKeyToEthAddress(refundStealth.stealthAddress.address);
|
|
1807
|
+
} else {
|
|
1808
|
+
throw new ValidationError(
|
|
1809
|
+
`senderAddress is required for refunds on ${request.inputAsset.chain}. Stealth addresses are only supported for EVM-compatible chains. Please connect a wallet or provide a sender address.`,
|
|
1810
|
+
"senderAddress",
|
|
1811
|
+
{ inputChain: request.inputAsset.chain, inputChainType }
|
|
1812
|
+
);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1762
1815
|
} else {
|
|
1763
1816
|
if (!senderAddress) {
|
|
1764
1817
|
throw new ValidationError(
|
|
@@ -1768,7 +1821,7 @@ var NEARIntentsAdapter = class {
|
|
|
1768
1821
|
}
|
|
1769
1822
|
recipientAddress = senderAddress;
|
|
1770
1823
|
}
|
|
1771
|
-
const quoteRequest = this.buildQuoteRequest(request, recipientAddress,
|
|
1824
|
+
const quoteRequest = this.buildQuoteRequest(request, recipientAddress, refundAddress);
|
|
1772
1825
|
return {
|
|
1773
1826
|
request,
|
|
1774
1827
|
quoteRequest,
|
|
@@ -11196,6 +11249,7 @@ export {
|
|
|
11196
11249
|
isValidStealthMetaAddress,
|
|
11197
11250
|
normalizeAddress,
|
|
11198
11251
|
notConnectedError,
|
|
11252
|
+
publicKeyToEthAddress,
|
|
11199
11253
|
registerWallet,
|
|
11200
11254
|
secureWipe,
|
|
11201
11255
|
secureWipeAll,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sip-protocol/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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",
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
OneClickRecipientType,
|
|
23
23
|
} from '@sip-protocol/types'
|
|
24
24
|
import { OneClickClient } from './oneclick-client'
|
|
25
|
-
import { generateStealthAddress, decodeStealthMetaAddress } from '../stealth'
|
|
25
|
+
import { generateStealthAddress, decodeStealthMetaAddress, publicKeyToEthAddress } from '../stealth'
|
|
26
26
|
import { ValidationError } from '../errors'
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -229,6 +229,7 @@ export class NEARIntentsAdapter {
|
|
|
229
229
|
|
|
230
230
|
// Determine recipient address
|
|
231
231
|
let recipientAddress: string
|
|
232
|
+
let refundAddress: string | undefined = senderAddress
|
|
232
233
|
let stealthData: PreparedSwap['stealthAddress']
|
|
233
234
|
let sharedSecret: HexString | undefined
|
|
234
235
|
|
|
@@ -246,12 +247,40 @@ export class NEARIntentsAdapter {
|
|
|
246
247
|
? decodeStealthMetaAddress(recipientMetaAddress)
|
|
247
248
|
: recipientMetaAddress
|
|
248
249
|
|
|
249
|
-
// Generate stealth address
|
|
250
|
+
// Generate stealth address for recipient (output chain)
|
|
250
251
|
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr)
|
|
251
252
|
|
|
252
|
-
|
|
253
|
+
// For EVM chains, convert stealth public key to ETH address format
|
|
254
|
+
// The 1Click API expects 20-byte Ethereum addresses, not 33-byte secp256k1 public keys
|
|
255
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[request.outputAsset.chain]
|
|
256
|
+
if (outputChainType === 'evm') {
|
|
257
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address)
|
|
258
|
+
} else {
|
|
259
|
+
recipientAddress = stealthAddress.address
|
|
260
|
+
}
|
|
253
261
|
stealthData = stealthAddress
|
|
254
262
|
sharedSecret = secret
|
|
263
|
+
|
|
264
|
+
// Generate refund address for input chain (if no sender address provided)
|
|
265
|
+
if (!senderAddress) {
|
|
266
|
+
const inputChainType = CHAIN_BLOCKCHAIN_MAP[request.inputAsset.chain]
|
|
267
|
+
if (inputChainType === 'evm') {
|
|
268
|
+
// For EVM input chains, generate a stealth address and convert to ETH address
|
|
269
|
+
const refundStealth = generateStealthAddress(metaAddr)
|
|
270
|
+
refundAddress = publicKeyToEthAddress(refundStealth.stealthAddress.address)
|
|
271
|
+
} else {
|
|
272
|
+
// For non-EVM input chains (Solana, Bitcoin, etc.), we cannot generate
|
|
273
|
+
// valid stealth addresses because they use different cryptographic schemes.
|
|
274
|
+
// Require sender address for refunds on these chains.
|
|
275
|
+
throw new ValidationError(
|
|
276
|
+
`senderAddress is required for refunds on ${request.inputAsset.chain}. ` +
|
|
277
|
+
`Stealth addresses are only supported for EVM-compatible chains. ` +
|
|
278
|
+
`Please connect a wallet or provide a sender address.`,
|
|
279
|
+
'senderAddress',
|
|
280
|
+
{ inputChain: request.inputAsset.chain, inputChainType }
|
|
281
|
+
)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
255
284
|
} else {
|
|
256
285
|
// Transparent mode uses direct address
|
|
257
286
|
if (!senderAddress) {
|
|
@@ -264,7 +293,7 @@ export class NEARIntentsAdapter {
|
|
|
264
293
|
}
|
|
265
294
|
|
|
266
295
|
// Build quote request
|
|
267
|
-
const quoteRequest = this.buildQuoteRequest(request, recipientAddress,
|
|
296
|
+
const quoteRequest = this.buildQuoteRequest(request, recipientAddress, refundAddress)
|
|
268
297
|
|
|
269
298
|
return {
|
|
270
299
|
request,
|
package/src/index.ts
CHANGED
package/src/stealth.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { secp256k1 } from '@noble/curves/secp256k1'
|
|
16
16
|
import { sha256 } from '@noble/hashes/sha256'
|
|
17
|
+
import { keccak_256 } from '@noble/hashes/sha3'
|
|
17
18
|
import { bytesToHex, hexToBytes, randomBytes } from '@noble/hashes/utils'
|
|
18
19
|
import type {
|
|
19
20
|
StealthMetaAddress,
|
|
@@ -444,3 +445,68 @@ function bigIntToBytes(value: bigint, length: number): Uint8Array {
|
|
|
444
445
|
}
|
|
445
446
|
return bytes
|
|
446
447
|
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Convert a secp256k1 public key to an Ethereum address
|
|
451
|
+
*
|
|
452
|
+
* Algorithm (EIP-5564 style):
|
|
453
|
+
* 1. Decompress the public key to uncompressed form (65 bytes)
|
|
454
|
+
* 2. Remove the 0x04 prefix (take last 64 bytes)
|
|
455
|
+
* 3. keccak256 hash of the 64 bytes
|
|
456
|
+
* 4. Take the last 20 bytes as the address
|
|
457
|
+
*
|
|
458
|
+
* @param publicKey - Compressed (33 bytes) or uncompressed (65 bytes) public key
|
|
459
|
+
* @returns Ethereum address (20 bytes, checksummed)
|
|
460
|
+
*/
|
|
461
|
+
export function publicKeyToEthAddress(publicKey: HexString): HexString {
|
|
462
|
+
// Remove 0x prefix if present
|
|
463
|
+
const keyHex = publicKey.startsWith('0x') ? publicKey.slice(2) : publicKey
|
|
464
|
+
const keyBytes = hexToBytes(keyHex)
|
|
465
|
+
|
|
466
|
+
let uncompressedBytes: Uint8Array
|
|
467
|
+
|
|
468
|
+
// Check if compressed (33 bytes) or uncompressed (65 bytes)
|
|
469
|
+
if (keyBytes.length === 33) {
|
|
470
|
+
// Decompress using secp256k1
|
|
471
|
+
const point = secp256k1.ProjectivePoint.fromHex(keyBytes)
|
|
472
|
+
uncompressedBytes = point.toRawBytes(false) // false = uncompressed
|
|
473
|
+
} else if (keyBytes.length === 65) {
|
|
474
|
+
uncompressedBytes = keyBytes
|
|
475
|
+
} else {
|
|
476
|
+
throw new ValidationError(
|
|
477
|
+
`invalid public key length: ${keyBytes.length}, expected 33 (compressed) or 65 (uncompressed)`,
|
|
478
|
+
'publicKey'
|
|
479
|
+
)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Remove the 0x04 prefix (first byte of uncompressed key)
|
|
483
|
+
const pubKeyWithoutPrefix = uncompressedBytes.slice(1)
|
|
484
|
+
|
|
485
|
+
// keccak256 hash
|
|
486
|
+
const hash = keccak_256(pubKeyWithoutPrefix)
|
|
487
|
+
|
|
488
|
+
// Take last 20 bytes
|
|
489
|
+
const addressBytes = hash.slice(-20)
|
|
490
|
+
|
|
491
|
+
// Convert to checksummed address
|
|
492
|
+
return toChecksumAddress(`0x${bytesToHex(addressBytes)}`)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Convert address to EIP-55 checksummed format
|
|
497
|
+
*/
|
|
498
|
+
function toChecksumAddress(address: string): HexString {
|
|
499
|
+
const addr = address.toLowerCase().replace('0x', '')
|
|
500
|
+
const hash = bytesToHex(keccak_256(new TextEncoder().encode(addr)))
|
|
501
|
+
|
|
502
|
+
let checksummed = '0x'
|
|
503
|
+
for (let i = 0; i < addr.length; i++) {
|
|
504
|
+
if (parseInt(hash[i], 16) >= 8) {
|
|
505
|
+
checksummed += addr[i].toUpperCase()
|
|
506
|
+
} else {
|
|
507
|
+
checksummed += addr[i]
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return checksummed as HexString
|
|
512
|
+
}
|