@bitshard.io/bitshard-sdk 0.0.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.
Files changed (117) hide show
  1. package/dist/BitShardSDK.d.ts +156 -0
  2. package/dist/BitShardSDK.d.ts.map +1 -0
  3. package/dist/BitShardSDK.js +350 -0
  4. package/dist/BitShardSDK.js.map +1 -0
  5. package/dist/chains/bitcoin/BitcoinChain.d.ts +6 -0
  6. package/dist/chains/bitcoin/BitcoinChain.d.ts.map +1 -0
  7. package/dist/chains/bitcoin/BitcoinChain.js +10 -0
  8. package/dist/chains/bitcoin/BitcoinChain.js.map +1 -0
  9. package/dist/chains/config.d.ts +5 -0
  10. package/dist/chains/config.d.ts.map +1 -0
  11. package/dist/chains/config.js +7 -0
  12. package/dist/chains/config.js.map +1 -0
  13. package/dist/chains/evm/EVMChain.d.ts +6 -0
  14. package/dist/chains/evm/EVMChain.d.ts.map +1 -0
  15. package/dist/chains/evm/EVMChain.js +10 -0
  16. package/dist/chains/evm/EVMChain.js.map +1 -0
  17. package/dist/core/DKLSParty.d.ts +132 -0
  18. package/dist/core/DKLSParty.d.ts.map +1 -0
  19. package/dist/core/DKLSParty.js +267 -0
  20. package/dist/core/DKLSParty.js.map +1 -0
  21. package/dist/core/DKLSService.d.ts +83 -0
  22. package/dist/core/DKLSService.d.ts.map +1 -0
  23. package/dist/core/DKLSService.js +325 -0
  24. package/dist/core/DKLSService.js.map +1 -0
  25. package/dist/core/ThresholdConfig.d.ts +76 -0
  26. package/dist/core/ThresholdConfig.d.ts.map +1 -0
  27. package/dist/core/ThresholdConfig.js +127 -0
  28. package/dist/core/ThresholdConfig.js.map +1 -0
  29. package/dist/core/types.d.ts +238 -0
  30. package/dist/core/types.d.ts.map +1 -0
  31. package/dist/core/types.js +3 -0
  32. package/dist/core/types.js.map +1 -0
  33. package/dist/crypto/addresses.d.ts +82 -0
  34. package/dist/crypto/addresses.d.ts.map +1 -0
  35. package/dist/crypto/addresses.js +242 -0
  36. package/dist/crypto/addresses.js.map +1 -0
  37. package/dist/crypto/elliptic.d.ts +19 -0
  38. package/dist/crypto/elliptic.d.ts.map +1 -0
  39. package/dist/crypto/elliptic.js +114 -0
  40. package/dist/crypto/elliptic.js.map +1 -0
  41. package/dist/crypto/encoding.d.ts +111 -0
  42. package/dist/crypto/encoding.d.ts.map +1 -0
  43. package/dist/crypto/encoding.js +224 -0
  44. package/dist/crypto/encoding.js.map +1 -0
  45. package/dist/index.d.ts +23 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +58 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/protocols/keygen.d.ts +6 -0
  50. package/dist/protocols/keygen.d.ts.map +1 -0
  51. package/dist/protocols/keygen.js +12 -0
  52. package/dist/protocols/keygen.js.map +1 -0
  53. package/dist/protocols/presignature.d.ts +68 -0
  54. package/dist/protocols/presignature.d.ts.map +1 -0
  55. package/dist/protocols/presignature.js +147 -0
  56. package/dist/protocols/presignature.js.map +1 -0
  57. package/dist/protocols/refresh.d.ts +5 -0
  58. package/dist/protocols/refresh.d.ts.map +1 -0
  59. package/dist/protocols/refresh.js +10 -0
  60. package/dist/protocols/refresh.js.map +1 -0
  61. package/dist/protocols/signing.d.ts +7 -0
  62. package/dist/protocols/signing.d.ts.map +1 -0
  63. package/dist/protocols/signing.js +12 -0
  64. package/dist/protocols/signing.js.map +1 -0
  65. package/dist/rpc/RPCProvider.d.ts +6 -0
  66. package/dist/rpc/RPCProvider.d.ts.map +1 -0
  67. package/dist/rpc/RPCProvider.js +6 -0
  68. package/dist/rpc/RPCProvider.js.map +1 -0
  69. package/dist/rpc/methods.d.ts +5 -0
  70. package/dist/rpc/methods.d.ts.map +1 -0
  71. package/dist/rpc/methods.js +10 -0
  72. package/dist/rpc/methods.js.map +1 -0
  73. package/dist/websocket/coordinator.d.ts +6 -0
  74. package/dist/websocket/coordinator.d.ts.map +1 -0
  75. package/dist/websocket/coordinator.js +10 -0
  76. package/dist/websocket/coordinator.js.map +1 -0
  77. package/dist/websocket/messages.d.ts +9 -0
  78. package/dist/websocket/messages.d.ts.map +1 -0
  79. package/dist/websocket/messages.js +7 -0
  80. package/dist/websocket/messages.js.map +1 -0
  81. package/dist/websocket/session.d.ts +5 -0
  82. package/dist/websocket/session.d.ts.map +1 -0
  83. package/dist/websocket/session.js +7 -0
  84. package/dist/websocket/session.js.map +1 -0
  85. package/dist/wire/format.d.ts +8 -0
  86. package/dist/wire/format.d.ts.map +1 -0
  87. package/dist/wire/format.js +11 -0
  88. package/dist/wire/format.js.map +1 -0
  89. package/dist/wire/validation.d.ts +6 -0
  90. package/dist/wire/validation.d.ts.map +1 -0
  91. package/dist/wire/validation.js +13 -0
  92. package/dist/wire/validation.js.map +1 -0
  93. package/package.json +67 -0
  94. package/src/BitShardSDK.ts +428 -0
  95. package/src/chains/bitcoin/BitcoinChain.ts +7 -0
  96. package/src/chains/config.ts +7 -0
  97. package/src/chains/evm/EVMChain.ts +7 -0
  98. package/src/core/DKLSParty.ts +317 -0
  99. package/src/core/DKLSService.ts +426 -0
  100. package/src/core/ThresholdConfig.ts +159 -0
  101. package/src/core/types.ts +253 -0
  102. package/src/crypto/addresses.ts +282 -0
  103. package/src/crypto/elliptic.ts +133 -0
  104. package/src/crypto/encoding.ts +227 -0
  105. package/src/index.ts +40 -0
  106. package/src/protocols/keygen.ts +8 -0
  107. package/src/protocols/presignature.ts +196 -0
  108. package/src/protocols/refresh.ts +7 -0
  109. package/src/protocols/signing.ts +9 -0
  110. package/src/rpc/RPCProvider.ts +7 -0
  111. package/src/rpc/methods.ts +7 -0
  112. package/src/websocket/coordinator.ts +7 -0
  113. package/src/websocket/messages.ts +11 -0
  114. package/src/websocket/session.ts +7 -0
  115. package/src/wire/format.ts +10 -0
  116. package/src/wire/validation.ts +14 -0
  117. package/test-sdk.js +234 -0
@@ -0,0 +1,238 @@
1
+ import type { Keyshare } from '@silencelaboratories/dkls-wasm-ll-node';
2
+ /**
3
+ * Result of distributed key generation
4
+ */
5
+ export interface DKGResult {
6
+ /** SHA256 hash of the public key */
7
+ dkgCommitment: string;
8
+ /** SHA256 hash of the server share */
9
+ serverShareCommitment: string;
10
+ /** Master public key in hex format with 0x prefix */
11
+ masterPublicKey: string;
12
+ /** Base64 encoded server keyshare */
13
+ serverShare: string;
14
+ /** Base64 encoded backup keyshare */
15
+ backupShare: string;
16
+ /** Base64 encoded mobile keyshare */
17
+ mobileShare: string;
18
+ /** Public key in hex format with 0x prefix */
19
+ publicKey: string;
20
+ /** Ethereum address */
21
+ ethAddress: string;
22
+ /** Bitcoin address (P2PKH) */
23
+ btcAddress: string;
24
+ /** Cosmos address */
25
+ cosmosAddress: string;
26
+ /** BNB Smart Chain address (same as ETH) */
27
+ bnbAddress: string;
28
+ /** Polygon address (same as ETH) */
29
+ polygonAddress: string;
30
+ /** Avalanche C-Chain address (same as ETH) */
31
+ avaxAddress: string;
32
+ /** Arbitrum address (same as ETH) */
33
+ arbAddress: string;
34
+ }
35
+ /**
36
+ * Extended DKG result for flexible threshold configurations
37
+ */
38
+ export interface FlexibleDKGResult {
39
+ /** Total number of parties */
40
+ totalParties: number;
41
+ /** Threshold required for signing */
42
+ threshold: number;
43
+ /** Public key in hex format with 0x prefix */
44
+ publicKey: string;
45
+ /** SHA256 hash of the public key */
46
+ dkgCommitment: string;
47
+ /** Array of keyshares for each party */
48
+ keyshares: PartyKeyshare[];
49
+ /** Derived blockchain addresses */
50
+ addresses: BlockchainAddresses;
51
+ }
52
+ /**
53
+ * Keyshare data for a specific party
54
+ */
55
+ export interface PartyKeyshare {
56
+ /** Party identifier (0-based index) */
57
+ partyId: number;
58
+ /** Base64 encoded keyshare data */
59
+ share: string;
60
+ /** SHA256 hash of the keyshare */
61
+ commitment: string;
62
+ }
63
+ /**
64
+ * Blockchain addresses derived from public key
65
+ */
66
+ export interface BlockchainAddresses {
67
+ /** Ethereum address */
68
+ ethereum: string;
69
+ /** Bitcoin address (P2PKH) */
70
+ bitcoin: string;
71
+ /** Cosmos address */
72
+ cosmos: string;
73
+ /** Arbitrum address (same as ETH) */
74
+ arbitrum: string;
75
+ /** Polygon address (same as ETH) */
76
+ polygon: string;
77
+ /** BNB Smart Chain address (same as ETH) */
78
+ bnb: string;
79
+ /** Avalanche C-Chain address (same as ETH) */
80
+ avalanche: string;
81
+ }
82
+ /**
83
+ * MPC session for tracking protocol execution
84
+ */
85
+ export interface MPCSession {
86
+ /** Unique session identifier */
87
+ id: string;
88
+ /** Associated wallet ID */
89
+ walletId: string;
90
+ /** Type of MPC operation */
91
+ sessionType: 'keygen' | 'signing' | 'refresh';
92
+ /** Current session status */
93
+ status: 'active' | 'completed' | 'failed';
94
+ /** List of participant IDs */
95
+ participants: string[];
96
+ /** Current protocol round */
97
+ currentRound?: number;
98
+ /** Total number of rounds */
99
+ totalRounds?: number;
100
+ /** Creation timestamp */
101
+ createdAt: Date;
102
+ /** Last update timestamp */
103
+ updatedAt: Date;
104
+ }
105
+ /**
106
+ * Signature result from threshold signing
107
+ */
108
+ export interface SignatureResult {
109
+ /** Full signature in hex format with 0x prefix */
110
+ signature: string;
111
+ /** R component of signature */
112
+ r: string;
113
+ /** S component of signature */
114
+ s: string;
115
+ /** V value for Ethereum signatures */
116
+ v?: number;
117
+ }
118
+ /**
119
+ * Wire format for DKLS messages over network
120
+ */
121
+ export interface WireMessage {
122
+ /** Sender party ID */
123
+ from_id: number;
124
+ /** Recipient party ID (optional for broadcast) */
125
+ to_id?: number;
126
+ /** Base64 encoded message payload */
127
+ payload: string;
128
+ }
129
+ /**
130
+ * Party configuration for distributed setup
131
+ */
132
+ export interface PartyConfig {
133
+ /** Unique party identifier (0-based) */
134
+ partyId: number;
135
+ /** Total number of parties */
136
+ totalParties: number;
137
+ /** Threshold required for operations */
138
+ threshold: number;
139
+ /** Role of this party */
140
+ role?: 'coordinator' | 'signer';
141
+ }
142
+ /**
143
+ * Local wallet for testing (all parties in one process)
144
+ */
145
+ export interface LocalWallet {
146
+ /** Public key in hex format */
147
+ publicKey: string;
148
+ /** All keyshares for local testing */
149
+ keyshares: Keyshare[];
150
+ /** Threshold configuration */
151
+ config: {
152
+ totalParties: number;
153
+ threshold: number;
154
+ partyIds: number[];
155
+ };
156
+ }
157
+ /**
158
+ * Pre-signature data structure
159
+ */
160
+ export interface PreSignature {
161
+ /** Unique identifier for tracking */
162
+ id: string;
163
+ /** Sign sessions ready for final round */
164
+ parties: any[];
165
+ /** Creation timestamp */
166
+ createdAt: Date;
167
+ /** Whether this pre-signature has been consumed */
168
+ consumed: boolean;
169
+ }
170
+ /**
171
+ * Chain configuration for multi-chain support
172
+ */
173
+ export interface ChainConfig {
174
+ /** Chain ID */
175
+ chainId: number;
176
+ /** Human-readable chain name */
177
+ name: string;
178
+ /** RPC endpoint URL */
179
+ rpcUrl: string;
180
+ /** Block explorer URL */
181
+ explorer?: string;
182
+ /** Native currency info */
183
+ nativeCurrency: {
184
+ name: string;
185
+ symbol: string;
186
+ decimals: number;
187
+ };
188
+ /** Gas configuration */
189
+ gasConfig?: {
190
+ maxFeePerGas?: string;
191
+ maxPriorityFeePerGas?: string;
192
+ };
193
+ }
194
+ /**
195
+ * Bitcoin network configuration
196
+ */
197
+ export interface BitcoinConfig {
198
+ /** Network type */
199
+ network: 'mainnet' | 'testnet' | 'regtest';
200
+ /** RPC endpoint URL */
201
+ rpcUrl?: string;
202
+ /** API URL for UTXO queries */
203
+ apiUrl?: string;
204
+ /** Default fee rate in sats/vbyte */
205
+ feeRate?: number;
206
+ }
207
+ /**
208
+ * WebSocket session for protocol coordination
209
+ */
210
+ export interface WebSocketSession {
211
+ /** Session identifier */
212
+ sessionId: string;
213
+ /** Session type */
214
+ type: 'keygen' | 'signing' | 'refresh';
215
+ /** Connected parties */
216
+ parties: Set<number>;
217
+ /** Message queue */
218
+ messages: WireMessage[];
219
+ /** Session metadata */
220
+ metadata?: Record<string, any>;
221
+ }
222
+ /**
223
+ * SDK configuration options
224
+ */
225
+ export interface SDKConfig {
226
+ /** WebSocket server URL for coordination */
227
+ websocketUrl?: string;
228
+ /** Default chain configuration */
229
+ defaultChain?: string;
230
+ /** Custom chain configurations */
231
+ chains?: Record<string, ChainConfig>;
232
+ /** Bitcoin network configuration */
233
+ bitcoin?: BitcoinConfig;
234
+ /** Enable debug logging */
235
+ debug?: boolean;
236
+ }
237
+ export type { Message, Keyshare } from '@silencelaboratories/dkls-wasm-ll-node';
238
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,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CAAC,CAAC;IACrC,oCAAoC;IACpC,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAGD,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
1
+ import type { BlockchainAddresses } from '../core/types';
2
+ /**
3
+ * Derive Ethereum address from ECDSA public key
4
+ * @param publicKeyHex - Hex string of public key (compressed or uncompressed)
5
+ * @returns Ethereum address with 0x prefix
6
+ */
7
+ export declare function deriveEthereumAddress(publicKeyHex: string): string;
8
+ /**
9
+ * Derive Ethereum address from public key bytes
10
+ * @param publicKey - Uint8Array of the public key
11
+ * @returns Ethereum address with 0x prefix
12
+ */
13
+ export declare function deriveEthereumAddressFromBytes(publicKey: Uint8Array): string;
14
+ /**
15
+ * Derive Bitcoin P2PKH address from ECDSA public key
16
+ * @param publicKeyHex - Hex string of the public key
17
+ * @param network - Network type: 'mainnet', 'testnet', or 'regtest'
18
+ * @returns Bitcoin address in base58check format
19
+ */
20
+ export declare function deriveBitcoinAddress(publicKeyHex: string, network?: 'mainnet' | 'testnet' | 'regtest'): string;
21
+ /**
22
+ * Derive Bitcoin address from public key bytes
23
+ * @param publicKey - Uint8Array of the public key
24
+ * @param network - Network type
25
+ * @returns Bitcoin address in base58check format
26
+ */
27
+ export declare function deriveBitcoinAddressFromBytes(publicKey: Uint8Array, network?: 'mainnet' | 'testnet' | 'regtest'): string;
28
+ /**
29
+ * Derive Cosmos address from ECDSA public key
30
+ * @param publicKeyHex - Hex string of the public key
31
+ * @param prefix - Bech32 prefix (default: 'cosmos')
32
+ * @returns Cosmos address with bech32 encoding
33
+ */
34
+ export declare function deriveCosmosAddress(publicKeyHex: string, prefix?: string): string;
35
+ /**
36
+ * Compress an uncompressed ECDSA public key
37
+ * @param publicKeyHex - Hex string of uncompressed public key (with or without 04 prefix)
38
+ * @returns Compressed public key hex string (33 bytes)
39
+ */
40
+ export declare function compressPublicKey(publicKeyHex: string): string;
41
+ /**
42
+ * Base58 encoding (for Bitcoin addresses)
43
+ */
44
+ export declare function base58Encode(buffer: Buffer): string;
45
+ /**
46
+ * Base58 decoding (for Bitcoin addresses)
47
+ */
48
+ export declare function base58Decode(encoded: string): Buffer;
49
+ /**
50
+ * Derive addresses for all supported blockchains from public key
51
+ * @param publicKeyHex - Hex string of the public key
52
+ * @returns Object with addresses for all supported chains
53
+ */
54
+ export declare function deriveAddresses(publicKeyHex: string): {
55
+ ethereum: string;
56
+ bitcoin: string;
57
+ bitcoinTestnet: string;
58
+ cosmos: string;
59
+ arbitrum: string;
60
+ polygon: string;
61
+ bnb: string;
62
+ avalanche: string;
63
+ };
64
+ /**
65
+ * Derive addresses from public key bytes
66
+ * @param publicKey - Uint8Array of the public key
67
+ * @returns BlockchainAddresses object
68
+ */
69
+ export declare function deriveAddressesFromBytes(publicKey: Uint8Array): BlockchainAddresses;
70
+ /**
71
+ * Validate Ethereum address format
72
+ * @param address - Address to validate
73
+ * @returns True if valid Ethereum address
74
+ */
75
+ export declare function isValidEthereumAddress(address: string): boolean;
76
+ /**
77
+ * Validate Bitcoin address format (basic validation)
78
+ * @param address - Address to validate
79
+ * @returns True if valid Bitcoin address format
80
+ */
81
+ export declare function isValidBitcoinAddress(address: string): boolean;
82
+ //# sourceMappingURL=addresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/crypto/addresses.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGzD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE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,MAAM,GAAG,OAAO,CAI9D"}
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deriveEthereumAddress = deriveEthereumAddress;
7
+ exports.deriveEthereumAddressFromBytes = deriveEthereumAddressFromBytes;
8
+ exports.deriveBitcoinAddress = deriveBitcoinAddress;
9
+ exports.deriveBitcoinAddressFromBytes = deriveBitcoinAddressFromBytes;
10
+ exports.deriveCosmosAddress = deriveCosmosAddress;
11
+ exports.compressPublicKey = compressPublicKey;
12
+ exports.base58Encode = base58Encode;
13
+ exports.base58Decode = base58Decode;
14
+ exports.deriveAddresses = deriveAddresses;
15
+ exports.deriveAddressesFromBytes = deriveAddressesFromBytes;
16
+ exports.isValidEthereumAddress = isValidEthereumAddress;
17
+ exports.isValidBitcoinAddress = isValidBitcoinAddress;
18
+ const crypto_1 = __importDefault(require("crypto"));
19
+ const viem_1 = require("viem");
20
+ const elliptic_1 = require("./elliptic");
21
+ /**
22
+ * Derive Ethereum address from ECDSA public key
23
+ * @param publicKeyHex - Hex string of public key (compressed or uncompressed)
24
+ * @returns Ethereum address with 0x prefix
25
+ */
26
+ function deriveEthereumAddress(publicKeyHex) {
27
+ // Remove 0x prefix if present
28
+ const cleanHex = publicKeyHex.replace(/^0x/, '');
29
+ // Get uncompressed public key (64 bytes, no 04 prefix)
30
+ const uncompressedKey = (0, elliptic_1.getUncompressedPublicKey)(cleanHex);
31
+ // Keccak256 hash of the uncompressed public key
32
+ const hash = (0, viem_1.keccak256)(`0x${uncompressedKey}`);
33
+ // Take the last 20 bytes (40 hex chars) as the address
34
+ const address = '0x' + hash.slice(-40);
35
+ return address.toLowerCase();
36
+ }
37
+ /**
38
+ * Derive Ethereum address from public key bytes
39
+ * @param publicKey - Uint8Array of the public key
40
+ * @returns Ethereum address with 0x prefix
41
+ */
42
+ function deriveEthereumAddressFromBytes(publicKey) {
43
+ // Remove the first byte (0x04 for uncompressed key) if present
44
+ const pubKeyBytes = publicKey[0] === 0x04 ? publicKey.slice(1) : publicKey;
45
+ // Convert to hex and derive address
46
+ const pubKeyHex = Buffer.from(pubKeyBytes).toString('hex');
47
+ return deriveEthereumAddress(pubKeyHex);
48
+ }
49
+ /**
50
+ * Derive Bitcoin P2PKH address from ECDSA public key
51
+ * @param publicKeyHex - Hex string of the public key
52
+ * @param network - Network type: 'mainnet', 'testnet', or 'regtest'
53
+ * @returns Bitcoin address in base58check format
54
+ */
55
+ function deriveBitcoinAddress(publicKeyHex, network = 'mainnet') {
56
+ // Remove 0x prefix if present
57
+ const cleanHex = publicKeyHex.replace(/^0x/, '');
58
+ // Convert to compressed public key format if uncompressed
59
+ const compressedPubKey = compressPublicKey(cleanHex);
60
+ // Step 1: SHA256 hash of the public key
61
+ const sha256Hash = crypto_1.default.createHash('sha256')
62
+ .update(Buffer.from(compressedPubKey, 'hex'))
63
+ .digest();
64
+ // Step 2: RIPEMD160 hash of the SHA256 hash
65
+ const ripemd160Hash = crypto_1.default.createHash('ripemd160')
66
+ .update(sha256Hash)
67
+ .digest();
68
+ // Step 3: Add version byte
69
+ // 0x00 for mainnet P2PKH
70
+ // 0x6f for testnet/regtest P2PKH
71
+ const versionByte = network === 'mainnet' ? 0x00 : 0x6f;
72
+ const versionedPayload = Buffer.concat([
73
+ Buffer.from([versionByte]),
74
+ ripemd160Hash
75
+ ]);
76
+ // Step 4: Calculate checksum (first 4 bytes of double SHA256)
77
+ const checksum = crypto_1.default.createHash('sha256')
78
+ .update(crypto_1.default.createHash('sha256').update(versionedPayload).digest())
79
+ .digest()
80
+ .slice(0, 4);
81
+ // Step 5: Append checksum
82
+ const finalPayload = Buffer.concat([versionedPayload, checksum]);
83
+ // Step 6: Base58 encode
84
+ return base58Encode(finalPayload);
85
+ }
86
+ /**
87
+ * Derive Bitcoin address from public key bytes
88
+ * @param publicKey - Uint8Array of the public key
89
+ * @param network - Network type
90
+ * @returns Bitcoin address in base58check format
91
+ */
92
+ function deriveBitcoinAddressFromBytes(publicKey, network = 'mainnet') {
93
+ const pubKeyHex = Buffer.from(publicKey).toString('hex');
94
+ return deriveBitcoinAddress(pubKeyHex, network);
95
+ }
96
+ /**
97
+ * Derive Cosmos address from ECDSA public key
98
+ * @param publicKeyHex - Hex string of the public key
99
+ * @param prefix - Bech32 prefix (default: 'cosmos')
100
+ * @returns Cosmos address with bech32 encoding
101
+ */
102
+ function deriveCosmosAddress(publicKeyHex, prefix = 'cosmos') {
103
+ // Remove 0x prefix if present
104
+ const cleanHex = publicKeyHex.replace(/^0x/, '');
105
+ // Convert to compressed format
106
+ const compressedPubKey = compressPublicKey(cleanHex);
107
+ // SHA256 hash
108
+ const sha256Hash = crypto_1.default.createHash('sha256')
109
+ .update(Buffer.from(compressedPubKey, 'hex'))
110
+ .digest();
111
+ // RIPEMD160 hash
112
+ const ripemd160Hash = crypto_1.default.createHash('ripemd160')
113
+ .update(sha256Hash)
114
+ .digest();
115
+ // TODO: Implement proper bech32 encoding
116
+ // For now, return a simplified version
117
+ return prefix + '1' + ripemd160Hash.toString('hex').substring(0, 38);
118
+ }
119
+ /**
120
+ * Compress an uncompressed ECDSA public key
121
+ * @param publicKeyHex - Hex string of uncompressed public key (with or without 04 prefix)
122
+ * @returns Compressed public key hex string (33 bytes)
123
+ */
124
+ function compressPublicKey(publicKeyHex) {
125
+ // Remove 04 prefix if present (uncompressed marker)
126
+ const cleanHex = publicKeyHex.startsWith('04') ? publicKeyHex.slice(2) : publicKeyHex;
127
+ // Split into x and y coordinates (32 bytes each)
128
+ const x = cleanHex.slice(0, 64);
129
+ const y = cleanHex.slice(64, 128);
130
+ // Determine prefix based on y coordinate parity
131
+ const yBigInt = BigInt('0x' + y);
132
+ const prefix = (yBigInt % 2n === 0n) ? '02' : '03';
133
+ return prefix + x;
134
+ }
135
+ /**
136
+ * Base58 encoding (for Bitcoin addresses)
137
+ */
138
+ function base58Encode(buffer) {
139
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
140
+ const base = BigInt(58);
141
+ let num = BigInt('0x' + buffer.toString('hex'));
142
+ let encoded = '';
143
+ while (num > 0n) {
144
+ const remainder = num % base;
145
+ num = num / base;
146
+ encoded = ALPHABET[Number(remainder)] + encoded;
147
+ }
148
+ // Handle leading zeros
149
+ for (let i = 0; i < buffer.length && buffer[i] === 0; i++) {
150
+ encoded = '1' + encoded;
151
+ }
152
+ return encoded;
153
+ }
154
+ /**
155
+ * Base58 decoding (for Bitcoin addresses)
156
+ */
157
+ function base58Decode(encoded) {
158
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
159
+ const ALPHABET_MAP = {};
160
+ for (let i = 0; i < ALPHABET.length; i++) {
161
+ ALPHABET_MAP[ALPHABET[i]] = BigInt(i);
162
+ }
163
+ let num = 0n;
164
+ const base = 58n;
165
+ for (const char of encoded) {
166
+ num = num * base + ALPHABET_MAP[char];
167
+ }
168
+ // Convert to hex and then to buffer
169
+ let hex = num.toString(16);
170
+ // Ensure even length
171
+ if (hex.length % 2 !== 0) {
172
+ hex = '0' + hex;
173
+ }
174
+ const buffer = Buffer.from(hex, 'hex');
175
+ // Add leading zeros for each leading '1' in the input
176
+ let leadingZeros = 0;
177
+ for (const char of encoded) {
178
+ if (char === '1') {
179
+ leadingZeros++;
180
+ }
181
+ else {
182
+ break;
183
+ }
184
+ }
185
+ return Buffer.concat([Buffer.alloc(leadingZeros), buffer]);
186
+ }
187
+ /**
188
+ * Derive addresses for all supported blockchains from public key
189
+ * @param publicKeyHex - Hex string of the public key
190
+ * @returns Object with addresses for all supported chains
191
+ */
192
+ function deriveAddresses(publicKeyHex) {
193
+ const ethAddress = deriveEthereumAddress(publicKeyHex);
194
+ return {
195
+ ethereum: ethAddress,
196
+ bitcoin: deriveBitcoinAddress(publicKeyHex, 'mainnet'),
197
+ bitcoinTestnet: deriveBitcoinAddress(publicKeyHex, 'testnet'),
198
+ cosmos: deriveCosmosAddress(publicKeyHex),
199
+ // EVM-compatible chains use the same address as Ethereum
200
+ arbitrum: ethAddress,
201
+ polygon: ethAddress,
202
+ bnb: ethAddress,
203
+ avalanche: ethAddress
204
+ };
205
+ }
206
+ /**
207
+ * Derive addresses from public key bytes
208
+ * @param publicKey - Uint8Array of the public key
209
+ * @returns BlockchainAddresses object
210
+ */
211
+ function deriveAddressesFromBytes(publicKey) {
212
+ const pubKeyHex = Buffer.from(publicKey).toString('hex');
213
+ const addresses = deriveAddresses(pubKeyHex);
214
+ return {
215
+ ethereum: addresses.ethereum,
216
+ bitcoin: addresses.bitcoin,
217
+ cosmos: addresses.cosmos,
218
+ arbitrum: addresses.arbitrum,
219
+ polygon: addresses.polygon,
220
+ bnb: addresses.bnb,
221
+ avalanche: addresses.avalanche
222
+ };
223
+ }
224
+ /**
225
+ * Validate Ethereum address format
226
+ * @param address - Address to validate
227
+ * @returns True if valid Ethereum address
228
+ */
229
+ function isValidEthereumAddress(address) {
230
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
231
+ }
232
+ /**
233
+ * Validate Bitcoin address format (basic validation)
234
+ * @param address - Address to validate
235
+ * @returns True if valid Bitcoin address format
236
+ */
237
+ function isValidBitcoinAddress(address) {
238
+ // Basic format check - proper validation would verify checksum
239
+ return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/.test(address) || // P2PKH/P2SH
240
+ /^bc1[a-z0-9]{39,59}$/.test(address); // Bech32
241
+ }
242
+ //# sourceMappingURL=addresses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../src/crypto/addresses.ts"],"names":[],"mappings":";;;;;AAUA,sDAcC;AAOD,wEAOC;AAQD,oDAwCC;AAQD,sEAMC;AAQD,kDAoBC;AAOD,8CAaC;AAKD,oCAmBC;AAKD,oCAkCC;AAOD,0CAuBC;AAOD,4DAaC;AAO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AAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE7C,OAAO;QACH,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,SAAS,EAAE,SAAS,CAAC,SAAS;KACjC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IAClD,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACjD,+DAA+D;IAC/D,OAAO,mCAAmC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,aAAa;QACrE,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;AACvD,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Decompress a compressed ECDSA public key
3
+ * @param compressedHex - Hex string of compressed public key (33 bytes)
4
+ * @returns Uncompressed public key hex string (64 bytes, without 04 prefix)
5
+ */
6
+ export declare function decompressPublicKey(compressedHex: string): string;
7
+ /**
8
+ * Check if a public key is compressed
9
+ * @param publicKeyHex - Hex string of public key
10
+ * @returns True if compressed (33 bytes), false if uncompressed (64 or 65 bytes)
11
+ */
12
+ export declare function isCompressedPublicKey(publicKeyHex: string): boolean;
13
+ /**
14
+ * Get uncompressed public key, handling both compressed and uncompressed inputs
15
+ * @param publicKeyHex - Hex string of public key (compressed or uncompressed)
16
+ * @returns Uncompressed public key hex string (64 bytes, without 04 prefix)
17
+ */
18
+ export declare function getUncompressedPublicKey(publicKeyHex: string): string;
19
+ //# sourceMappingURL=elliptic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elliptic.d.ts","sourceRoot":"","sources":["../../src/crypto/elliptic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CA8CjE;AAwCD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAUnE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAmBrE"}