@sip-protocol/sdk 0.1.6 → 0.1.7
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 +42 -1
- package/dist/index.mjs +41 -1
- package/package.json +1 -1
- package/src/adapters/near-intents.ts +9 -2
- 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");
|
|
@@ -1946,7 +1981,12 @@ var NEARIntentsAdapter = class {
|
|
|
1946
1981
|
}
|
|
1947
1982
|
const metaAddr = typeof recipientMetaAddress === "string" ? decodeStealthMetaAddress(recipientMetaAddress) : recipientMetaAddress;
|
|
1948
1983
|
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr);
|
|
1949
|
-
|
|
1984
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[request.outputAsset.chain];
|
|
1985
|
+
if (outputChainType === "evm") {
|
|
1986
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address);
|
|
1987
|
+
} else {
|
|
1988
|
+
recipientAddress = stealthAddress.address;
|
|
1989
|
+
}
|
|
1950
1990
|
stealthData = stealthAddress;
|
|
1951
1991
|
sharedSecret = secret;
|
|
1952
1992
|
} else {
|
|
@@ -11360,6 +11400,7 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11360
11400
|
isValidStealthMetaAddress,
|
|
11361
11401
|
normalizeAddress,
|
|
11362
11402
|
notConnectedError,
|
|
11403
|
+
publicKeyToEthAddress,
|
|
11363
11404
|
registerWallet,
|
|
11364
11405
|
secureWipe,
|
|
11365
11406
|
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";
|
|
@@ -1756,7 +1790,12 @@ var NEARIntentsAdapter = class {
|
|
|
1756
1790
|
}
|
|
1757
1791
|
const metaAddr = typeof recipientMetaAddress === "string" ? decodeStealthMetaAddress(recipientMetaAddress) : recipientMetaAddress;
|
|
1758
1792
|
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr);
|
|
1759
|
-
|
|
1793
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[request.outputAsset.chain];
|
|
1794
|
+
if (outputChainType === "evm") {
|
|
1795
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address);
|
|
1796
|
+
} else {
|
|
1797
|
+
recipientAddress = stealthAddress.address;
|
|
1798
|
+
}
|
|
1760
1799
|
stealthData = stealthAddress;
|
|
1761
1800
|
sharedSecret = secret;
|
|
1762
1801
|
} else {
|
|
@@ -11196,6 +11235,7 @@ export {
|
|
|
11196
11235
|
isValidStealthMetaAddress,
|
|
11197
11236
|
normalizeAddress,
|
|
11198
11237
|
notConnectedError,
|
|
11238
|
+
publicKeyToEthAddress,
|
|
11199
11239
|
registerWallet,
|
|
11200
11240
|
secureWipe,
|
|
11201
11241
|
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.7",
|
|
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
|
/**
|
|
@@ -249,7 +249,14 @@ export class NEARIntentsAdapter {
|
|
|
249
249
|
// Generate stealth address
|
|
250
250
|
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr)
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
// For EVM chains, convert stealth public key to ETH address format
|
|
253
|
+
// The 1Click API expects 20-byte Ethereum addresses, not 33-byte secp256k1 public keys
|
|
254
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[request.outputAsset.chain]
|
|
255
|
+
if (outputChainType === 'evm') {
|
|
256
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address)
|
|
257
|
+
} else {
|
|
258
|
+
recipientAddress = stealthAddress.address
|
|
259
|
+
}
|
|
253
260
|
stealthData = stealthAddress
|
|
254
261
|
sharedSecret = secret
|
|
255
262
|
} else {
|
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
|
+
}
|