@hwlt/era-connect 0.2.0 → 0.4.0

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 (112) hide show
  1. package/README.md +6 -6
  2. package/cardano/package.json +6 -0
  3. package/cosmos/package.json +6 -0
  4. package/dist/{btc-DfQ0q79G.d.ts → btc-B8LfSEkv.d.ts} +11 -2
  5. package/dist/{btc-VyJKXq7d.js → btc-B_Nq2H4T.js} +16 -7
  6. package/dist/btc-B_Nq2H4T.js.map +1 -0
  7. package/dist/{btc-Fr6Jz4Fi.cjs → btc-ByzjzUKs.cjs} +19 -10
  8. package/dist/btc-ByzjzUKs.cjs.map +1 -0
  9. package/dist/{btc-Dn6_Y12c.d.cts → btc-C4dVkxHb.d.cts} +11 -2
  10. package/dist/btc.cjs +2 -2
  11. package/dist/btc.d.cts +1 -1
  12. package/dist/btc.d.ts +1 -1
  13. package/dist/btc.js +2 -2
  14. package/dist/cardano-BCT55gwf.js +95 -0
  15. package/dist/cardano-BCT55gwf.js.map +1 -0
  16. package/dist/cardano-CzYswGzK.cjs +106 -0
  17. package/dist/cardano-CzYswGzK.cjs.map +1 -0
  18. package/dist/cardano-Do1ahUlK.d.cts +62 -0
  19. package/dist/cardano-OzjWZHh6.d.ts +62 -0
  20. package/dist/cardano.cjs +10 -0
  21. package/dist/cardano.d.cts +3 -0
  22. package/dist/cardano.d.ts +3 -0
  23. package/dist/cardano.js +3 -0
  24. package/dist/cosmos-BYrhIqRk.d.cts +77 -0
  25. package/dist/cosmos-DDsgtUki.cjs +113 -0
  26. package/dist/cosmos-DDsgtUki.cjs.map +1 -0
  27. package/dist/cosmos-DqyjA6lg.d.ts +77 -0
  28. package/dist/cosmos-jUHNxgWC.js +102 -0
  29. package/dist/cosmos-jUHNxgWC.js.map +1 -0
  30. package/dist/cosmos.cjs +10 -0
  31. package/dist/cosmos.d.cts +3 -0
  32. package/dist/cosmos.d.ts +3 -0
  33. package/dist/cosmos.js +3 -0
  34. package/dist/derive-BayrpfJk.cjs +188 -0
  35. package/dist/derive-BayrpfJk.cjs.map +1 -0
  36. package/dist/derive-CK9Nc9Jc.js +123 -0
  37. package/dist/derive-CK9Nc9Jc.js.map +1 -0
  38. package/dist/{evm-kJb3-oiR.js → evm-CI1cuZsp.js} +3 -2
  39. package/dist/{evm-kJb3-oiR.js.map → evm-CI1cuZsp.js.map} +1 -1
  40. package/dist/{evm-BHj_2OTG.cjs → evm-yfKOc2dy.cjs} +6 -5
  41. package/dist/{evm-BHj_2OTG.cjs.map → evm-yfKOc2dy.cjs.map} +1 -1
  42. package/dist/evm.cjs +2 -2
  43. package/dist/evm.js +2 -2
  44. package/dist/index.cjs +156 -116
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.cts +68 -9
  47. package/dist/index.d.ts +68 -9
  48. package/dist/index.js +125 -94
  49. package/dist/index.js.map +1 -1
  50. package/dist/keypath-Bvv_cfHt.js +75 -0
  51. package/dist/keypath-Bvv_cfHt.js.map +1 -0
  52. package/dist/keypath-pzm_YIfN.cjs +116 -0
  53. package/dist/keypath-pzm_YIfN.cjs.map +1 -0
  54. package/dist/{messages-BzcdWlg1.cjs → messages-BZXDY29v.cjs} +2 -2
  55. package/dist/{messages-BzcdWlg1.cjs.map → messages-BZXDY29v.cjs.map} +1 -1
  56. package/dist/{messages-17Oup0-Z.js → messages-DbnXy3dC.js} +2 -2
  57. package/dist/{messages-17Oup0-Z.js.map → messages-DbnXy3dC.js.map} +1 -1
  58. package/dist/{shared-B8Wc7ViU.js → shared-Bbgejrus.js} +2 -73
  59. package/dist/shared-Bbgejrus.js.map +1 -0
  60. package/dist/{shared-nISrEktU.cjs → shared-Cu2yynP9.cjs} +13 -114
  61. package/dist/shared-Cu2yynP9.cjs.map +1 -0
  62. package/dist/{solana-DdEn24X4.cjs → solana-BoQBy0hu.cjs} +6 -5
  63. package/dist/{solana-DdEn24X4.cjs.map → solana-BoQBy0hu.cjs.map} +1 -1
  64. package/dist/{solana-C7JQEAec.js → solana-BukH3AI3.js} +3 -2
  65. package/dist/{solana-C7JQEAec.js.map → solana-BukH3AI3.js.map} +1 -1
  66. package/dist/solana.cjs +2 -2
  67. package/dist/solana.js +2 -2
  68. package/dist/sui-6WX6VPlW.d.cts +49 -0
  69. package/dist/sui-BtbPG6Xt.js +71 -0
  70. package/dist/sui-BtbPG6Xt.js.map +1 -0
  71. package/dist/sui-CYRn331O.cjs +82 -0
  72. package/dist/sui-CYRn331O.cjs.map +1 -0
  73. package/dist/sui-DI0ruW7E.d.ts +49 -0
  74. package/dist/sui.cjs +10 -0
  75. package/dist/sui.d.cts +3 -0
  76. package/dist/sui.d.ts +3 -0
  77. package/dist/sui.js +3 -0
  78. package/dist/{ton-5Uvi5ifg.js → ton-BSPKU5B9.js} +3 -2
  79. package/dist/{ton-5Uvi5ifg.js.map → ton-BSPKU5B9.js.map} +1 -1
  80. package/dist/{ton-DUJGXdGa.cjs → ton-CI2s9puH.cjs} +6 -5
  81. package/dist/{ton-DUJGXdGa.cjs.map → ton-CI2s9puH.cjs.map} +1 -1
  82. package/dist/ton.cjs +2 -2
  83. package/dist/ton.js +2 -2
  84. package/dist/{tron-CQIEqjCA.cjs → tron-B9wXdzlA.cjs} +7 -6
  85. package/dist/{tron-CQIEqjCA.cjs.map → tron-B9wXdzlA.cjs.map} +1 -1
  86. package/dist/{tron-Bo9HnvVE.js → tron-fufBDNuQ.js} +4 -3
  87. package/dist/{tron-Bo9HnvVE.js.map → tron-fufBDNuQ.js.map} +1 -1
  88. package/dist/tron.cjs +3 -3
  89. package/dist/tron.js +3 -3
  90. package/dist/verify.cjs +335 -4
  91. package/dist/verify.cjs.map +1 -1
  92. package/dist/verify.d.cts +86 -1
  93. package/dist/verify.d.ts +86 -1
  94. package/dist/verify.js +333 -6
  95. package/dist/verify.js.map +1 -1
  96. package/dist/xrp-BXAeK4iH.d.cts +32 -0
  97. package/dist/xrp-BrHXUnX5.cjs +52 -0
  98. package/dist/xrp-BrHXUnX5.cjs.map +1 -0
  99. package/dist/xrp-C8LJO5b-.js +47 -0
  100. package/dist/xrp-C8LJO5b-.js.map +1 -0
  101. package/dist/xrp-DqCXGYEk.d.ts +32 -0
  102. package/dist/xrp.cjs +9 -0
  103. package/dist/xrp.d.cts +3 -0
  104. package/dist/xrp.d.ts +3 -0
  105. package/dist/xrp.js +3 -0
  106. package/package.json +49 -1
  107. package/sui/package.json +6 -0
  108. package/xrp/package.json +6 -0
  109. package/dist/btc-Fr6Jz4Fi.cjs.map +0 -1
  110. package/dist/btc-VyJKXq7d.js.map +0 -1
  111. package/dist/shared-B8Wc7ViU.js.map +0 -1
  112. package/dist/shared-nISrEktU.cjs.map +0 -1
@@ -0,0 +1,188 @@
1
+ const require_shared = require("./shared-Cu2yynP9.cjs");
2
+ let _noble_curves_secp256k1 = require("@noble/curves/secp256k1");
3
+ let _noble_hashes_blake2b = require("@noble/hashes/blake2b");
4
+ let _noble_hashes_ripemd160 = require("@noble/hashes/ripemd160");
5
+ let _noble_hashes_sha2 = require("@noble/hashes/sha2");
6
+ let _noble_hashes_sha3 = require("@noble/hashes/sha3");
7
+ let _scure_base = require("@scure/base");
8
+ let _scure_bip32 = require("@scure/bip32");
9
+ let _noble_curves_ed25519 = require("@noble/curves/ed25519");
10
+ let _noble_hashes_hmac = require("@noble/hashes/hmac");
11
+ //#region src/accounts/derive.ts
12
+ const base58check = (0, _scure_base.createBase58check)(_noble_hashes_sha2.sha256);
13
+ /** Non-hardened BIP-32 child public key from an account-level (publicKey, chainCode). */
14
+ function derivePublicKey(publicKey, chainCode, change, index) {
15
+ const child = new _scure_bip32.HDKey({
16
+ publicKey,
17
+ chainCode
18
+ }).deriveChild(change).deriveChild(index);
19
+ if (!child.publicKey) throw new require_shared.EraSdkError("invalid-props", "child derivation produced no public key");
20
+ return child.publicKey;
21
+ }
22
+ function uncompressed(publicKey33) {
23
+ return _noble_curves_secp256k1.secp256k1.ProjectivePoint.fromHex(publicKey33).toRawBytes(false);
24
+ }
25
+ /** EIP-55 checksummed address from a compressed secp256k1 public key. */
26
+ function evmAddressFromPublicKey(publicKey33) {
27
+ const hash = (0, _noble_hashes_sha3.keccak_256)(uncompressed(publicKey33).slice(1));
28
+ const addr = require_shared.bytesToHex(hash.slice(12));
29
+ const check = (0, _noble_hashes_sha3.keccak_256)(new Uint8Array([...addr].map((c) => c.charCodeAt(0))));
30
+ let out = "";
31
+ for (let i = 0; i < addr.length; i++) {
32
+ const nibble = i % 2 === 0 ? check[i >> 1] >> 4 : check[i >> 1] & 15;
33
+ out += nibble >= 8 ? addr[i].toUpperCase() : addr[i];
34
+ }
35
+ return `0x${out}`;
36
+ }
37
+ function hash160(data) {
38
+ return (0, _noble_hashes_ripemd160.ripemd160)((0, _noble_hashes_sha2.sha256)(data));
39
+ }
40
+ /** P2WPKH (witness v0) bech32 address. */
41
+ function btcP2wpkhAddressFromPublicKey(publicKey33, hrp = "bc") {
42
+ return _scure_base.bech32.encode(hrp, [0, ..._scure_base.bech32.toWords(hash160(publicKey33))]);
43
+ }
44
+ /** Legacy P2PKH base58check address (`1...`) — the kind the device signs messages for. */
45
+ function btcP2pkhAddressFromPublicKey(publicKey33, testnet = false) {
46
+ return base58check.encode(require_shared.concatBytes(new Uint8Array([testnet ? 111 : 0]), hash160(publicKey33)));
47
+ }
48
+ /** Nested segwit (P2SH-P2WPKH) base58check address (`3...`). */
49
+ function btcNestedSegwitAddressFromPublicKey(publicKey33, testnet = false) {
50
+ const redeemScript = require_shared.concatBytes(new Uint8Array([0, 20]), hash160(publicKey33));
51
+ return base58check.encode(require_shared.concatBytes(new Uint8Array([testnet ? 196 : 5]), hash160(redeemScript)));
52
+ }
53
+ /** Tron base58check address (0x41-prefixed keccak hash). */
54
+ function tronAddressFromPublicKey(publicKey33) {
55
+ const hash = (0, _noble_hashes_sha3.keccak_256)(uncompressed(publicKey33).slice(1));
56
+ return base58check.encode(require_shared.concatBytes(new Uint8Array([65]), hash.slice(12)));
57
+ }
58
+ /** `0x` Sui address: BLAKE2b-256 of the scheme flag (0x00 = Ed25519) plus the public key. */
59
+ function suiAddressFromPublicKey(publicKey32) {
60
+ const digest = (0, _noble_hashes_blake2b.blake2b)(require_shared.concatBytes(new Uint8Array([0]), publicKey32), { dkLen: 32 });
61
+ return `0x${require_shared.bytesToHex(digest)}`;
62
+ }
63
+ /** A Solana address IS the Ed25519 public key, base58. */
64
+ function solanaAddressFromPublicKey(publicKey32) {
65
+ return _scure_base.base58.encode(publicKey32);
66
+ }
67
+ const XPUB_VERSION = 76067358;
68
+ const ZPUB_VERSION = 78792518;
69
+ /** BIP-32 extended public key serialization. */
70
+ function serializeExtendedPublicKey(args) {
71
+ const { version = XPUB_VERSION, depth, parentFingerprint, childNumber, chainCode, publicKey } = args;
72
+ if (chainCode.length !== 32 || publicKey.length !== 33) throw new require_shared.EraSdkError("invalid-props", "extended key needs a 32-byte chain code and 33-byte key");
73
+ return base58check.encode(require_shared.concatBytes(require_shared.u32be(version), new Uint8Array([depth & 255]), require_shared.u32be(parentFingerprint), require_shared.u32be(childNumber), chainCode, publicKey));
74
+ }
75
+ function u32le(value) {
76
+ return new Uint8Array([
77
+ value & 255,
78
+ value >> 8 & 255,
79
+ value >> 16 & 255,
80
+ value >> 24 & 255
81
+ ]);
82
+ }
83
+ function leBytesToBigint(bytes) {
84
+ let out = 0n;
85
+ for (let i = bytes.length - 1; i >= 0; i--) out = out << 8n | BigInt(bytes[i]);
86
+ return out;
87
+ }
88
+ /**
89
+ * Public (soft) child of a BIP32-Ed25519 extended public key — the scheme
90
+ * Cardano wallets share account xpubs under (CIP-3/V2):
91
+ *
92
+ * Z = HMAC-SHA512(chainCode, 0x02 || A || le32(index))
93
+ * childA = A + [8 * ZL[0..28]] * B
94
+ * childCC = HMAC-SHA512(chainCode, 0x03 || A || le32(index))[32..]
95
+ *
96
+ * Only non-hardened indices are derivable publicly, which is exactly what the
97
+ * role/index tail of a CIP-1852 path uses.
98
+ */
99
+ function cardanoSoftDeriveChild(publicKey, chainCode, index) {
100
+ if (publicKey.length !== 32 || chainCode.length !== 32) throw new require_shared.EraSdkError("invalid-props", "Cardano derivation needs a 32-byte key and chain code");
101
+ if (!Number.isSafeInteger(index) || index < 0 || index >= 2147483648) throw new require_shared.EraSdkError("invalid-props", "Cardano public derivation is soft-index only");
102
+ const z = (0, _noble_hashes_hmac.hmac)(_noble_hashes_sha2.sha512, chainCode, require_shared.concatBytes(new Uint8Array([2]), publicKey, u32le(index)));
103
+ const cc = (0, _noble_hashes_hmac.hmac)(_noble_hashes_sha2.sha512, chainCode, require_shared.concatBytes(new Uint8Array([3]), publicKey, u32le(index))).slice(32);
104
+ const scalar = 8n * leBytesToBigint(z.slice(0, 28));
105
+ const parent = _noble_curves_ed25519.ed25519.ExtendedPoint.fromHex(require_shared.bytesToHex(publicKey));
106
+ return {
107
+ publicKey: (scalar === 0n ? parent : parent.add(_noble_curves_ed25519.ed25519.ExtendedPoint.BASE.multiply(scalar))).toRawBytes(),
108
+ chainCode: cc
109
+ };
110
+ }
111
+ /** Soft-derive along several indices (e.g. role, then address index). */
112
+ function cardanoSoftDerivePath(publicKey, chainCode, indices) {
113
+ let node = {
114
+ publicKey,
115
+ chainCode
116
+ };
117
+ for (const index of indices) node = cardanoSoftDeriveChild(node.publicKey, node.chainCode, index);
118
+ return node.publicKey;
119
+ }
120
+ //#endregion
121
+ Object.defineProperty(exports, "ZPUB_VERSION", {
122
+ enumerable: true,
123
+ get: function() {
124
+ return ZPUB_VERSION;
125
+ }
126
+ });
127
+ Object.defineProperty(exports, "btcNestedSegwitAddressFromPublicKey", {
128
+ enumerable: true,
129
+ get: function() {
130
+ return btcNestedSegwitAddressFromPublicKey;
131
+ }
132
+ });
133
+ Object.defineProperty(exports, "btcP2pkhAddressFromPublicKey", {
134
+ enumerable: true,
135
+ get: function() {
136
+ return btcP2pkhAddressFromPublicKey;
137
+ }
138
+ });
139
+ Object.defineProperty(exports, "btcP2wpkhAddressFromPublicKey", {
140
+ enumerable: true,
141
+ get: function() {
142
+ return btcP2wpkhAddressFromPublicKey;
143
+ }
144
+ });
145
+ Object.defineProperty(exports, "cardanoSoftDerivePath", {
146
+ enumerable: true,
147
+ get: function() {
148
+ return cardanoSoftDerivePath;
149
+ }
150
+ });
151
+ Object.defineProperty(exports, "derivePublicKey", {
152
+ enumerable: true,
153
+ get: function() {
154
+ return derivePublicKey;
155
+ }
156
+ });
157
+ Object.defineProperty(exports, "evmAddressFromPublicKey", {
158
+ enumerable: true,
159
+ get: function() {
160
+ return evmAddressFromPublicKey;
161
+ }
162
+ });
163
+ Object.defineProperty(exports, "serializeExtendedPublicKey", {
164
+ enumerable: true,
165
+ get: function() {
166
+ return serializeExtendedPublicKey;
167
+ }
168
+ });
169
+ Object.defineProperty(exports, "solanaAddressFromPublicKey", {
170
+ enumerable: true,
171
+ get: function() {
172
+ return solanaAddressFromPublicKey;
173
+ }
174
+ });
175
+ Object.defineProperty(exports, "suiAddressFromPublicKey", {
176
+ enumerable: true,
177
+ get: function() {
178
+ return suiAddressFromPublicKey;
179
+ }
180
+ });
181
+ Object.defineProperty(exports, "tronAddressFromPublicKey", {
182
+ enumerable: true,
183
+ get: function() {
184
+ return tronAddressFromPublicKey;
185
+ }
186
+ });
187
+
188
+ //# sourceMappingURL=derive-BayrpfJk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive-BayrpfJk.cjs","names":["createBase58check","sha256","HDKey","EraSdkError","secp256k1","keccak_256","bytesToHex","ripemd160","bech32","concatBytes","blake2b","base58","u32be","hmac","sha512","ed25519"],"sources":["../src/accounts/derive.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { blake2b } from '@noble/hashes/blake2b';\nimport { ripemd160 } from '@noble/hashes/ripemd160';\nimport { sha256 } from '@noble/hashes/sha2';\nimport { keccak_256 } from '@noble/hashes/sha3';\nimport { base58, bech32, createBase58check } from '@scure/base';\nimport { HDKey } from '@scure/bip32';\nimport { bytesToHex, concatBytes, u32be } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\n\nconst base58check = createBase58check(sha256);\n\n/** Non-hardened BIP-32 child public key from an account-level (publicKey, chainCode). */\nexport function derivePublicKey(\n publicKey: Uint8Array,\n chainCode: Uint8Array,\n change: number,\n index: number,\n): Uint8Array {\n const node = new HDKey({ publicKey, chainCode });\n const child = node.deriveChild(change).deriveChild(index);\n if (!child.publicKey) {\n throw new EraSdkError('invalid-props', 'child derivation produced no public key');\n }\n return child.publicKey;\n}\n\nfunction uncompressed(publicKey33: Uint8Array): Uint8Array {\n return secp256k1.ProjectivePoint.fromHex(publicKey33).toRawBytes(false);\n}\n\n/** EIP-55 checksummed address from a compressed secp256k1 public key. */\nexport function evmAddressFromPublicKey(publicKey33: Uint8Array): `0x${string}` {\n const hash = keccak_256(uncompressed(publicKey33).slice(1));\n const addr = bytesToHex(hash.slice(12));\n const check = keccak_256(new Uint8Array([...addr].map((c) => c.charCodeAt(0))));\n let out = '';\n for (let i = 0; i < addr.length; i++) {\n const nibble = i % 2 === 0 ? check[i >> 1]! >> 4 : check[i >> 1]! & 0x0f;\n out += nibble >= 8 ? addr[i]!.toUpperCase() : addr[i]!;\n }\n return `0x${out}`;\n}\n\nfunction hash160(data: Uint8Array): Uint8Array {\n return ripemd160(sha256(data));\n}\n\n/** P2WPKH (witness v0) bech32 address. */\nexport function btcP2wpkhAddressFromPublicKey(\n publicKey33: Uint8Array,\n hrp: 'bc' | 'tb' = 'bc',\n): string {\n return bech32.encode(hrp, [0, ...bech32.toWords(hash160(publicKey33))]);\n}\n\n/** Legacy P2PKH base58check address (`1...`) — the kind the device signs messages for. */\nexport function btcP2pkhAddressFromPublicKey(publicKey33: Uint8Array, testnet = false): string {\n return base58check.encode(\n concatBytes(new Uint8Array([testnet ? 0x6f : 0x00]), hash160(publicKey33)),\n );\n}\n\n/** Nested segwit (P2SH-P2WPKH) base58check address (`3...`). */\nexport function btcNestedSegwitAddressFromPublicKey(\n publicKey33: Uint8Array,\n testnet = false,\n): string {\n const redeemScript = concatBytes(new Uint8Array([0x00, 0x14]), hash160(publicKey33));\n return base58check.encode(\n concatBytes(new Uint8Array([testnet ? 0xc4 : 0x05]), hash160(redeemScript)),\n );\n}\n\n/** Tron base58check address (0x41-prefixed keccak hash). */\nexport function tronAddressFromPublicKey(publicKey33: Uint8Array): string {\n const hash = keccak_256(uncompressed(publicKey33).slice(1));\n return base58check.encode(concatBytes(new Uint8Array([0x41]), hash.slice(12)));\n}\n\n/** `0x` Sui address: BLAKE2b-256 of the scheme flag (0x00 = Ed25519) plus the public key. */\nexport function suiAddressFromPublicKey(publicKey32: Uint8Array): string {\n const digest = blake2b(concatBytes(new Uint8Array([0x00]), publicKey32), { dkLen: 32 });\n return `0x${bytesToHex(digest)}`;\n}\n\n/** A Solana address IS the Ed25519 public key, base58. */\nexport function solanaAddressFromPublicKey(publicKey32: Uint8Array): string {\n return base58.encode(publicKey32);\n}\n\nconst XPUB_VERSION = 0x0488b21e;\nconst ZPUB_VERSION = 0x04b24746; // SLIP-132, BIP-84 P2WPKH\n\n/** BIP-32 extended public key serialization. */\nexport function serializeExtendedPublicKey(args: {\n version?: number;\n depth: number;\n parentFingerprint: number;\n childNumber: number;\n chainCode: Uint8Array;\n publicKey: Uint8Array;\n}): string {\n const {\n version = XPUB_VERSION,\n depth,\n parentFingerprint,\n childNumber,\n chainCode,\n publicKey,\n } = args;\n if (chainCode.length !== 32 || publicKey.length !== 33) {\n throw new EraSdkError(\n 'invalid-props',\n 'extended key needs a 32-byte chain code and 33-byte key',\n );\n }\n return base58check.encode(\n concatBytes(\n u32be(version),\n new Uint8Array([depth & 0xff]),\n u32be(parentFingerprint),\n u32be(childNumber),\n chainCode,\n publicKey,\n ),\n );\n}\n\nexport { XPUB_VERSION, ZPUB_VERSION };\n\n// ---------------------------------------------------------------------------\n// Cardano (BIP32-Ed25519 / CIP-3 \"V2\") soft public derivation\n// ---------------------------------------------------------------------------\n\nimport { ed25519 } from '@noble/curves/ed25519';\nimport { hmac } from '@noble/hashes/hmac';\nimport { sha512 } from '@noble/hashes/sha2';\n\nfunction u32le(value: number): Uint8Array {\n return new Uint8Array([\n value & 0xff,\n (value >> 8) & 0xff,\n (value >> 16) & 0xff,\n (value >> 24) & 0xff,\n ]);\n}\n\nfunction leBytesToBigint(bytes: Uint8Array): bigint {\n let out = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) out = (out << 8n) | BigInt(bytes[i]!);\n return out;\n}\n\n/**\n * Public (soft) child of a BIP32-Ed25519 extended public key — the scheme\n * Cardano wallets share account xpubs under (CIP-3/V2):\n *\n * Z = HMAC-SHA512(chainCode, 0x02 || A || le32(index))\n * childA = A + [8 * ZL[0..28]] * B\n * childCC = HMAC-SHA512(chainCode, 0x03 || A || le32(index))[32..]\n *\n * Only non-hardened indices are derivable publicly, which is exactly what the\n * role/index tail of a CIP-1852 path uses.\n */\nexport function cardanoSoftDeriveChild(\n publicKey: Uint8Array,\n chainCode: Uint8Array,\n index: number,\n): { publicKey: Uint8Array; chainCode: Uint8Array } {\n if (publicKey.length !== 32 || chainCode.length !== 32) {\n throw new EraSdkError('invalid-props', 'Cardano derivation needs a 32-byte key and chain code');\n }\n if (!Number.isSafeInteger(index) || index < 0 || index >= 0x80000000) {\n throw new EraSdkError('invalid-props', 'Cardano public derivation is soft-index only');\n }\n const z = hmac(sha512, chainCode, concatBytes(new Uint8Array([0x02]), publicKey, u32le(index)));\n const cc = hmac(\n sha512,\n chainCode,\n concatBytes(new Uint8Array([0x03]), publicKey, u32le(index)),\n ).slice(32);\n const scalar = 8n * leBytesToBigint(z.slice(0, 28));\n const parent = ed25519.ExtendedPoint.fromHex(bytesToHex(publicKey));\n const child = scalar === 0n ? parent : parent.add(ed25519.ExtendedPoint.BASE.multiply(scalar));\n return { publicKey: child.toRawBytes(), chainCode: cc };\n}\n\n/** Soft-derive along several indices (e.g. role, then address index). */\nexport function cardanoSoftDerivePath(\n publicKey: Uint8Array,\n chainCode: Uint8Array,\n indices: readonly number[],\n): Uint8Array {\n let node = { publicKey, chainCode };\n for (const index of indices) {\n node = cardanoSoftDeriveChild(node.publicKey, node.chainCode, index);\n }\n return node.publicKey;\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,eAAA,GAAcA,YAAAA,kBAAAA,CAAkBC,mBAAAA,MAAM;;AAG5C,SAAgB,gBACd,WACA,WACA,QACA,OACY;CAEZ,MAAM,QAAQ,IADGC,aAAAA,MAAM;EAAE;EAAW;CAAU,CAC7B,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,YAAY,KAAK;CACxD,IAAI,CAAC,MAAM,WACT,MAAM,IAAIC,eAAAA,YAAY,iBAAiB,yCAAyC;CAElF,OAAO,MAAM;AACf;AAEA,SAAS,aAAa,aAAqC;CACzD,OAAOC,wBAAAA,UAAU,gBAAgB,QAAQ,WAAW,CAAC,CAAC,WAAW,KAAK;AACxE;;AAGA,SAAgB,wBAAwB,aAAwC;CAC9E,MAAM,QAAA,GAAOC,mBAAAA,WAAAA,CAAW,aAAa,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;CAC1D,MAAM,OAAOC,eAAAA,WAAW,KAAK,MAAM,EAAE,CAAC;CACtC,MAAM,SAAA,GAAQD,mBAAAA,WAAAA,CAAW,IAAI,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CAC9E,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,SAAS,IAAI,MAAM,IAAI,MAAM,KAAK,MAAO,IAAI,MAAM,KAAK,KAAM;EACpE,OAAO,UAAU,IAAI,KAAK,EAAE,CAAE,YAAY,IAAI,KAAK;CACrD;CACA,OAAO,KAAK;AACd;AAEA,SAAS,QAAQ,MAA8B;CAC7C,QAAA,GAAOE,wBAAAA,UAAAA,EAAAA,GAAUN,mBAAAA,OAAAA,CAAO,IAAI,CAAC;AAC/B;;AAGA,SAAgB,8BACd,aACA,MAAmB,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AAS,OAAO,IAAIS,sBAAAA,QAAQ,cAAc,KAAK,SAAS,MAAM,CAAC,EAAA,CACnE,WAAW;EAAG,WAAW;CAAG;AACxD;;AAGA,SAAgB,sBACd,WACA,WACA,SACY;CACZ,IAAI,OAAO;EAAE;EAAW;CAAU;CAClC,KAAK,MAAM,SAAS,SAClB,OAAO,uBAAuB,KAAK,WAAW,KAAK,WAAW,KAAK;CAErE,OAAO,KAAK;AACd"}
@@ -0,0 +1,123 @@
1
+ import { K as EraSdkError, O as u32be, T as concatBytes, w as bytesToHex } from "./shared-Bbgejrus.js";
2
+ import { secp256k1 } from "@noble/curves/secp256k1";
3
+ import { blake2b } from "@noble/hashes/blake2b";
4
+ import { ripemd160 } from "@noble/hashes/ripemd160";
5
+ import { sha256, sha512 } from "@noble/hashes/sha2";
6
+ import { keccak_256 } from "@noble/hashes/sha3";
7
+ import { base58, bech32, createBase58check } from "@scure/base";
8
+ import { HDKey } from "@scure/bip32";
9
+ import { ed25519 } from "@noble/curves/ed25519";
10
+ import { hmac } from "@noble/hashes/hmac";
11
+ //#region src/accounts/derive.ts
12
+ const base58check = createBase58check(sha256);
13
+ /** Non-hardened BIP-32 child public key from an account-level (publicKey, chainCode). */
14
+ function derivePublicKey(publicKey, chainCode, change, index) {
15
+ const child = new HDKey({
16
+ publicKey,
17
+ chainCode
18
+ }).deriveChild(change).deriveChild(index);
19
+ if (!child.publicKey) throw new EraSdkError("invalid-props", "child derivation produced no public key");
20
+ return child.publicKey;
21
+ }
22
+ function uncompressed(publicKey33) {
23
+ return secp256k1.ProjectivePoint.fromHex(publicKey33).toRawBytes(false);
24
+ }
25
+ /** EIP-55 checksummed address from a compressed secp256k1 public key. */
26
+ function evmAddressFromPublicKey(publicKey33) {
27
+ const hash = keccak_256(uncompressed(publicKey33).slice(1));
28
+ const addr = bytesToHex(hash.slice(12));
29
+ const check = keccak_256(new Uint8Array([...addr].map((c) => c.charCodeAt(0))));
30
+ let out = "";
31
+ for (let i = 0; i < addr.length; i++) {
32
+ const nibble = i % 2 === 0 ? check[i >> 1] >> 4 : check[i >> 1] & 15;
33
+ out += nibble >= 8 ? addr[i].toUpperCase() : addr[i];
34
+ }
35
+ return `0x${out}`;
36
+ }
37
+ function hash160(data) {
38
+ return ripemd160(sha256(data));
39
+ }
40
+ /** P2WPKH (witness v0) bech32 address. */
41
+ function btcP2wpkhAddressFromPublicKey(publicKey33, hrp = "bc") {
42
+ return bech32.encode(hrp, [0, ...bech32.toWords(hash160(publicKey33))]);
43
+ }
44
+ /** Legacy P2PKH base58check address (`1...`) — the kind the device signs messages for. */
45
+ function btcP2pkhAddressFromPublicKey(publicKey33, testnet = false) {
46
+ return base58check.encode(concatBytes(new Uint8Array([testnet ? 111 : 0]), hash160(publicKey33)));
47
+ }
48
+ /** Nested segwit (P2SH-P2WPKH) base58check address (`3...`). */
49
+ function btcNestedSegwitAddressFromPublicKey(publicKey33, testnet = false) {
50
+ const redeemScript = concatBytes(new Uint8Array([0, 20]), hash160(publicKey33));
51
+ return base58check.encode(concatBytes(new Uint8Array([testnet ? 196 : 5]), hash160(redeemScript)));
52
+ }
53
+ /** Tron base58check address (0x41-prefixed keccak hash). */
54
+ function tronAddressFromPublicKey(publicKey33) {
55
+ const hash = keccak_256(uncompressed(publicKey33).slice(1));
56
+ return base58check.encode(concatBytes(new Uint8Array([65]), hash.slice(12)));
57
+ }
58
+ /** `0x` Sui address: BLAKE2b-256 of the scheme flag (0x00 = Ed25519) plus the public key. */
59
+ function suiAddressFromPublicKey(publicKey32) {
60
+ const digest = blake2b(concatBytes(new Uint8Array([0]), publicKey32), { dkLen: 32 });
61
+ return `0x${bytesToHex(digest)}`;
62
+ }
63
+ /** A Solana address IS the Ed25519 public key, base58. */
64
+ function solanaAddressFromPublicKey(publicKey32) {
65
+ return base58.encode(publicKey32);
66
+ }
67
+ const XPUB_VERSION = 76067358;
68
+ const ZPUB_VERSION = 78792518;
69
+ /** BIP-32 extended public key serialization. */
70
+ function serializeExtendedPublicKey(args) {
71
+ const { version = XPUB_VERSION, depth, parentFingerprint, childNumber, chainCode, publicKey } = args;
72
+ if (chainCode.length !== 32 || publicKey.length !== 33) throw new EraSdkError("invalid-props", "extended key needs a 32-byte chain code and 33-byte key");
73
+ return base58check.encode(concatBytes(u32be(version), new Uint8Array([depth & 255]), u32be(parentFingerprint), u32be(childNumber), chainCode, publicKey));
74
+ }
75
+ function u32le(value) {
76
+ return new Uint8Array([
77
+ value & 255,
78
+ value >> 8 & 255,
79
+ value >> 16 & 255,
80
+ value >> 24 & 255
81
+ ]);
82
+ }
83
+ function leBytesToBigint(bytes) {
84
+ let out = 0n;
85
+ for (let i = bytes.length - 1; i >= 0; i--) out = out << 8n | BigInt(bytes[i]);
86
+ return out;
87
+ }
88
+ /**
89
+ * Public (soft) child of a BIP32-Ed25519 extended public key — the scheme
90
+ * Cardano wallets share account xpubs under (CIP-3/V2):
91
+ *
92
+ * Z = HMAC-SHA512(chainCode, 0x02 || A || le32(index))
93
+ * childA = A + [8 * ZL[0..28]] * B
94
+ * childCC = HMAC-SHA512(chainCode, 0x03 || A || le32(index))[32..]
95
+ *
96
+ * Only non-hardened indices are derivable publicly, which is exactly what the
97
+ * role/index tail of a CIP-1852 path uses.
98
+ */
99
+ function cardanoSoftDeriveChild(publicKey, chainCode, index) {
100
+ if (publicKey.length !== 32 || chainCode.length !== 32) throw new EraSdkError("invalid-props", "Cardano derivation needs a 32-byte key and chain code");
101
+ if (!Number.isSafeInteger(index) || index < 0 || index >= 2147483648) throw new EraSdkError("invalid-props", "Cardano public derivation is soft-index only");
102
+ const z = hmac(sha512, chainCode, concatBytes(new Uint8Array([2]), publicKey, u32le(index)));
103
+ const cc = hmac(sha512, chainCode, concatBytes(new Uint8Array([3]), publicKey, u32le(index))).slice(32);
104
+ const scalar = 8n * leBytesToBigint(z.slice(0, 28));
105
+ const parent = ed25519.ExtendedPoint.fromHex(bytesToHex(publicKey));
106
+ return {
107
+ publicKey: (scalar === 0n ? parent : parent.add(ed25519.ExtendedPoint.BASE.multiply(scalar))).toRawBytes(),
108
+ chainCode: cc
109
+ };
110
+ }
111
+ /** Soft-derive along several indices (e.g. role, then address index). */
112
+ function cardanoSoftDerivePath(publicKey, chainCode, indices) {
113
+ let node = {
114
+ publicKey,
115
+ chainCode
116
+ };
117
+ for (const index of indices) node = cardanoSoftDeriveChild(node.publicKey, node.chainCode, index);
118
+ return node.publicKey;
119
+ }
120
+ //#endregion
121
+ export { cardanoSoftDerivePath as a, serializeExtendedPublicKey as c, tronAddressFromPublicKey as d, btcP2wpkhAddressFromPublicKey as i, solanaAddressFromPublicKey as l, btcNestedSegwitAddressFromPublicKey as n, derivePublicKey as o, btcP2pkhAddressFromPublicKey as r, evmAddressFromPublicKey as s, ZPUB_VERSION as t, suiAddressFromPublicKey as u };
122
+
123
+ //# sourceMappingURL=derive-CK9Nc9Jc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derive-CK9Nc9Jc.js","names":[],"sources":["../src/accounts/derive.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1';\nimport { blake2b } from '@noble/hashes/blake2b';\nimport { ripemd160 } from '@noble/hashes/ripemd160';\nimport { sha256 } from '@noble/hashes/sha2';\nimport { keccak_256 } from '@noble/hashes/sha3';\nimport { base58, bech32, createBase58check } from '@scure/base';\nimport { HDKey } from '@scure/bip32';\nimport { bytesToHex, concatBytes, u32be } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\n\nconst base58check = createBase58check(sha256);\n\n/** Non-hardened BIP-32 child public key from an account-level (publicKey, chainCode). */\nexport function derivePublicKey(\n publicKey: Uint8Array,\n chainCode: Uint8Array,\n change: number,\n index: number,\n): Uint8Array {\n const node = new HDKey({ publicKey, chainCode });\n const child = node.deriveChild(change).deriveChild(index);\n if (!child.publicKey) {\n throw new EraSdkError('invalid-props', 'child derivation produced no public key');\n }\n return child.publicKey;\n}\n\nfunction uncompressed(publicKey33: Uint8Array): Uint8Array {\n return secp256k1.ProjectivePoint.fromHex(publicKey33).toRawBytes(false);\n}\n\n/** EIP-55 checksummed address from a compressed secp256k1 public key. */\nexport function evmAddressFromPublicKey(publicKey33: Uint8Array): `0x${string}` {\n const hash = keccak_256(uncompressed(publicKey33).slice(1));\n const addr = bytesToHex(hash.slice(12));\n const check = keccak_256(new Uint8Array([...addr].map((c) => c.charCodeAt(0))));\n let out = '';\n for (let i = 0; i < addr.length; i++) {\n const nibble = i % 2 === 0 ? check[i >> 1]! >> 4 : check[i >> 1]! & 0x0f;\n out += nibble >= 8 ? addr[i]!.toUpperCase() : addr[i]!;\n }\n return `0x${out}`;\n}\n\nfunction hash160(data: Uint8Array): Uint8Array {\n return ripemd160(sha256(data));\n}\n\n/** P2WPKH (witness v0) bech32 address. */\nexport function btcP2wpkhAddressFromPublicKey(\n publicKey33: Uint8Array,\n hrp: 'bc' | 'tb' = 'bc',\n): string {\n return bech32.encode(hrp, [0, ...bech32.toWords(hash160(publicKey33))]);\n}\n\n/** Legacy P2PKH base58check address (`1...`) — the kind the device signs messages for. */\nexport function btcP2pkhAddressFromPublicKey(publicKey33: Uint8Array, testnet = false): string {\n return base58check.encode(\n concatBytes(new Uint8Array([testnet ? 0x6f : 0x00]), hash160(publicKey33)),\n );\n}\n\n/** Nested segwit (P2SH-P2WPKH) base58check address (`3...`). */\nexport function btcNestedSegwitAddressFromPublicKey(\n publicKey33: Uint8Array,\n testnet = false,\n): string {\n const redeemScript = concatBytes(new Uint8Array([0x00, 0x14]), hash160(publicKey33));\n return base58check.encode(\n concatBytes(new Uint8Array([testnet ? 0xc4 : 0x05]), hash160(redeemScript)),\n );\n}\n\n/** Tron base58check address (0x41-prefixed keccak hash). */\nexport function tronAddressFromPublicKey(publicKey33: Uint8Array): string {\n const hash = keccak_256(uncompressed(publicKey33).slice(1));\n return base58check.encode(concatBytes(new Uint8Array([0x41]), hash.slice(12)));\n}\n\n/** `0x` Sui address: BLAKE2b-256 of the scheme flag (0x00 = Ed25519) plus the public key. */\nexport function suiAddressFromPublicKey(publicKey32: Uint8Array): string {\n const digest = blake2b(concatBytes(new Uint8Array([0x00]), publicKey32), { dkLen: 32 });\n return `0x${bytesToHex(digest)}`;\n}\n\n/** A Solana address IS the Ed25519 public key, base58. */\nexport function solanaAddressFromPublicKey(publicKey32: Uint8Array): string {\n return base58.encode(publicKey32);\n}\n\nconst XPUB_VERSION = 0x0488b21e;\nconst ZPUB_VERSION = 0x04b24746; // SLIP-132, BIP-84 P2WPKH\n\n/** BIP-32 extended public key serialization. */\nexport function serializeExtendedPublicKey(args: {\n version?: number;\n depth: number;\n parentFingerprint: number;\n childNumber: number;\n chainCode: Uint8Array;\n publicKey: Uint8Array;\n}): string {\n const {\n version = XPUB_VERSION,\n depth,\n parentFingerprint,\n childNumber,\n chainCode,\n publicKey,\n } = args;\n if (chainCode.length !== 32 || publicKey.length !== 33) {\n throw new EraSdkError(\n 'invalid-props',\n 'extended key needs a 32-byte chain code and 33-byte key',\n );\n }\n return base58check.encode(\n concatBytes(\n u32be(version),\n new Uint8Array([depth & 0xff]),\n u32be(parentFingerprint),\n u32be(childNumber),\n chainCode,\n publicKey,\n ),\n );\n}\n\nexport { XPUB_VERSION, ZPUB_VERSION };\n\n// ---------------------------------------------------------------------------\n// Cardano (BIP32-Ed25519 / CIP-3 \"V2\") soft public derivation\n// ---------------------------------------------------------------------------\n\nimport { ed25519 } from '@noble/curves/ed25519';\nimport { hmac } from '@noble/hashes/hmac';\nimport { sha512 } from '@noble/hashes/sha2';\n\nfunction u32le(value: number): Uint8Array {\n return new Uint8Array([\n value & 0xff,\n (value >> 8) & 0xff,\n (value >> 16) & 0xff,\n (value >> 24) & 0xff,\n ]);\n}\n\nfunction leBytesToBigint(bytes: Uint8Array): bigint {\n let out = 0n;\n for (let i = bytes.length - 1; i >= 0; i--) out = (out << 8n) | BigInt(bytes[i]!);\n return out;\n}\n\n/**\n * Public (soft) child of a BIP32-Ed25519 extended public key — the scheme\n * Cardano wallets share account xpubs under (CIP-3/V2):\n *\n * Z = HMAC-SHA512(chainCode, 0x02 || A || le32(index))\n * childA = A + [8 * ZL[0..28]] * B\n * childCC = HMAC-SHA512(chainCode, 0x03 || A || le32(index))[32..]\n *\n * Only non-hardened indices are derivable publicly, which is exactly what the\n * role/index tail of a CIP-1852 path uses.\n */\nexport function cardanoSoftDeriveChild(\n publicKey: Uint8Array,\n chainCode: Uint8Array,\n index: number,\n): { publicKey: Uint8Array; chainCode: Uint8Array } {\n if (publicKey.length !== 32 || chainCode.length !== 32) {\n throw new EraSdkError('invalid-props', 'Cardano derivation needs a 32-byte key and chain code');\n }\n if (!Number.isSafeInteger(index) || index < 0 || index >= 0x80000000) {\n throw new EraSdkError('invalid-props', 'Cardano public derivation is soft-index only');\n }\n const z = hmac(sha512, chainCode, concatBytes(new Uint8Array([0x02]), publicKey, u32le(index)));\n const cc = hmac(\n sha512,\n chainCode,\n concatBytes(new Uint8Array([0x03]), publicKey, u32le(index)),\n ).slice(32);\n const scalar = 8n * leBytesToBigint(z.slice(0, 28));\n const parent = ed25519.ExtendedPoint.fromHex(bytesToHex(publicKey));\n const child = scalar === 0n ? parent : parent.add(ed25519.ExtendedPoint.BASE.multiply(scalar));\n return { publicKey: child.toRawBytes(), chainCode: cc };\n}\n\n/** Soft-derive along several indices (e.g. role, then address index). */\nexport function cardanoSoftDerivePath(\n publicKey: Uint8Array,\n chainCode: Uint8Array,\n indices: readonly number[],\n): Uint8Array {\n let node = { publicKey, chainCode };\n for (const index of indices) {\n node = cardanoSoftDeriveChild(node.publicKey, node.chainCode, index);\n }\n return node.publicKey;\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,cAAc,kBAAkB,MAAM;;AAG5C,SAAgB,gBACd,WACA,WACA,QACA,OACY;CAEZ,MAAM,QAAQ,IADG,MAAM;EAAE;EAAW;CAAU,CAC7B,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,YAAY,KAAK;CACxD,IAAI,CAAC,MAAM,WACT,MAAM,IAAI,YAAY,iBAAiB,yCAAyC;CAElF,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AS,YACxD,MAAM,IAAI,YAAY,iBAAiB,8CAA8C;CAEvF,MAAM,IAAI,KAAK,QAAQ,WAAW,YAAY,IAAI,WAAW,CAAC,CAAI,CAAC,GAAG,WAAW,MAAM,KAAK,CAAC,CAAC;CAC9F,MAAM,KAAK,KACT,QACA,WACA,YAAY,IAAI,WAAW,CAAC,CAAI,CAAC,GAAG,WAAW,MAAM,KAAK,CAAC,CAC7D,CAAC,CAAC,MAAM,EAAE;CACV,MAAM,SAAS,KAAK,gBAAgB,EAAE,MAAM,GAAG,EAAE,CAAC;CAClD,MAAM,SAAS,QAAQ,cAAc,QAAQ,WAAW,SAAS,CAAC;CAElE,OAAO;EAAE,YADK,WAAW,KAAK,SAAS,OAAO,IAAI,QAAQ,cAAc,KAAK,SAAS,MAAM,CAAC,EAAA,CACnE,WAAW;EAAG,WAAW;CAAG;AACxD;;AAGA,SAAgB,sBACd,WACA,WACA,SACY;CACZ,IAAI,OAAO;EAAE;EAAW;CAAU;CAClC,KAAK,MAAM,SAAS,SAClB,OAAO,uBAAuB,KAAK,WAAW,KAAK,WAAW,KAAK;CAErE,OAAO,KAAK;AACd"}
@@ -1,4 +1,5 @@
1
- import { C as bytesToBigint, D as hexToBytes, G as cbMap, J as cbUint, M as keypath304, N as normalizeXfp, P as parsePath, W as cbBytes, Y as mapGet, Z as EraSdkError, _ as Ur, a as requireSignatureBytes, c as resolveRequestId, h as normalizeRequestId, i as requireRequestIdEcho, l as toUr, n as makeSignRequest, o as requireUrType, q as cbText, r as requireReplyMap, s as resolveContext, x as cborEncode } from "./shared-B8Wc7ViU.js";
1
+ import { B as cbMap, C as bytesToBigint, D as hexToBytes, H as cbText, K as EraSdkError, U as cbUint, W as mapGet, _ as Ur, a as requireSignatureBytes, c as resolveRequestId, h as normalizeRequestId, i as requireRequestIdEcho, l as toUr, n as makeSignRequest, o as requireUrType, r as requireReplyMap, s as resolveContext, x as cborEncode, z as cbBytes } from "./shared-Bbgejrus.js";
2
+ import { i as parsePath, n as keypath304, r as normalizeXfp } from "./keypath-Bvv_cfHt.js";
2
3
  //#region src/chains/evm.ts
3
4
  /** `eth-sign-request` dataType (CBOR key 3). */
4
5
  const EvmDataType = {
@@ -114,4 +115,4 @@ function foldRecoveryId(v) {
114
115
  //#endregion
115
116
  export { EvmDataType as n, foldRecoveryId as r, EvmChain as t };
116
117
 
117
- //# sourceMappingURL=evm-kJb3-oiR.js.map
118
+ //# sourceMappingURL=evm-CI1cuZsp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"evm-kJb3-oiR.js","names":["UrValue"],"sources":["../src/chains/evm.ts"],"sourcesContent":["import { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbBytes, cbMap, cbText, cbUint, mapGet } from '../cbor/model';\nimport { bytesToBigint, hexToBytes } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { normalizeRequestId } from '../core/rand';\nimport { keypath304, normalizeXfp, parsePath } from '../registry/keypath';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\nimport type { ChainContext, EraConnectConfig, ExpectedReply, SignRequest } from './shared';\nimport {\n makeSignRequest,\n requireReplyMap,\n requireRequestIdEcho,\n requireSignatureBytes,\n requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\n/** `eth-sign-request` dataType (CBOR key 3). */\nexport const EvmDataType = {\n /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */\n transaction: 1,\n /** EIP-712 typed data JSON (UTF-8 bytes). */\n typedData: 2,\n /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */\n personalMessage: 3,\n /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */\n typedTransaction: 4,\n} as const;\nexport type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];\n\nexport interface EvmSignRequestProps {\n /** 16 bytes or a UUID string; minted if omitted. */\n readonly requestId?: Uint8Array | string;\n /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */\n readonly signData: Uint8Array;\n readonly dataType: EvmDataType;\n /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */\n readonly path: string;\n /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */\n readonly xfp: string | number;\n /**\n * Required for transactions (it derives the legal reply width). The device\n * reads it as an unsigned 32-bit value — larger chain ids are refused here,\n * because a silently truncated id would sign for a different chain.\n */\n readonly chainId?: number;\n /** 20-byte signer address; recommended (enables verification helpers). */\n readonly address?: Uint8Array | `0x${string}`;\n /** Overrides the SDK-level origin label for this request. */\n readonly origin?: string;\n}\n\nexport interface EvmSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */\n readonly signature: Uint8Array;\n readonly r: Uint8Array;\n readonly s: Uint8Array;\n /**\n * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28\n * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for\n * legacy transactions. Do NOT re-apply the EIP-155 formula.\n */\n readonly v: bigint;\n /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */\n readonly recoveryId: 0 | 1;\n}\n\n/** Over this size the device skips transaction decoding and falls back to blind signing. */\nconst BLIND_SIGN_THRESHOLD = 32 * 1024;\n\nconst REPLY_TYPES = ['eth-signature', 'evm-signature'] as const;\n\nexport class EvmChain {\n static readonly DataType = EvmDataType;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */\n generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n const isTransaction =\n props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction;\n\n if (isTransaction && props.chainId === undefined) {\n throw new EraSdkError('invalid-props', 'chainId is required for transaction sign requests');\n }\n if (props.chainId !== undefined) {\n if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) {\n throw new EraSdkError('invalid-props', 'chainId must be a non-negative integer');\n }\n if (props.chainId > 0xffffffff) {\n throw new EraSdkError(\n 'invalid-props',\n `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; ` +\n 'a truncated id would produce a signature for a different chain',\n { chainId: props.chainId },\n );\n }\n }\n\n const entries: [number, CborValue][] = [\n [1, cbBytes(requestId)],\n [2, cbBytes(props.signData)],\n [3, cbUint(props.dataType)],\n ];\n if (props.chainId !== undefined) entries.push([4, cbUint(props.chainId)]);\n entries.push([5, keypath304(path, xfp)]);\n if (props.address !== undefined) entries.push([6, cbBytes(normalizeAddress(props.address))]);\n entries.push([7, cbText(props.origin ?? this.context.origin)]);\n\n const ur = new UrValue('eth-sign-request', cborEncode(cbMap(entries)));\n const warnings: string[] = [];\n if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push('blind-sign-threshold');\n\n const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: REPLY_TYPES,\n warnings,\n context: this.context,\n parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength),\n });\n }\n\n /**\n * Parse an `eth-signature` standalone. Without `expect.requestId` the echo\n * is returned but not validated — prefer `SignRequest.scanner().parse()`.\n */\n parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult {\n const expected =\n expect?.requestId === undefined\n ? undefined\n : { requestId: normalizeRequestId(expect.requestId) };\n return parseEvmSignature(toUr(input), expected, 64 + 8);\n }\n}\n\nfunction normalizeAddress(address: Uint8Array | `0x${string}`): Uint8Array {\n const bytes = address instanceof Uint8Array ? address : hexToBytes(address);\n if (bytes.length !== 20) {\n throw new EraSdkError('invalid-props', 'EVM address must be 20 bytes');\n }\n return bytes;\n}\n\n/**\n * Width of the widest `v` the device can legitimately return.\n *\n * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes\n * past chain id 110, 4 bytes for Aurora. Messages and typed data always\n * answer with one byte (27/28). A flat ceiling either refuses genuine replies\n * on large-id chains or accepts implausibly wide values; the exact bound\n * comes from the request.\n */\nfunction maxVBytes(dataType: EvmDataType, chainId: number | undefined): number {\n if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;\n if (chainId === undefined) return 8;\n let widest = BigInt(chainId) * 2n + 36n;\n if (widest < 28n) widest = 28n;\n let bytes = 0;\n while (widest > 0n) {\n bytes += 1;\n widest >>= 8n;\n }\n return bytes;\n}\n\nfunction parseEvmSignature(\n ur: Ur,\n expect: { requestId: Uint8Array } | undefined,\n maxSigLength: number,\n): EvmSignatureResult {\n requireUrType(ur, [...REPLY_TYPES], 'eth-signature');\n const map = requireReplyMap(ur, 'eth-signature');\n const requestId = requireRequestIdEcho(map, 1, expect?.requestId, 'eth-signature');\n const signature = requireSignatureBytes(mapGet(map, 2), 'eth-signature', 65, maxSigLength);\n\n const r = signature.slice(0, 32);\n const s = signature.slice(32, 64);\n const v = bytesToBigint(signature.slice(64));\n const recoveryId = foldRecoveryId(v);\n if (recoveryId !== 0 && recoveryId !== 1) {\n throw new EraSdkError(\n 'malformed-reply',\n `eth-signature carries an implausible recovery value ${v}`,\n );\n }\n return { requestId, signature, r, s, v, recoveryId };\n}\n\n/** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */\nexport function foldRecoveryId(v: bigint): number {\n if (v >= 35n) return Number((v - 35n) & 1n);\n if (v >= 27n) return Number(v - 27n);\n return Number(v);\n}\n"],"mappings":";;;AAsBA,MAAa,cAAc;;CAEzB,aAAa;;CAEb,WAAW;;CAEX,iBAAiB;;CAEjB,kBAAkB;AACpB;;AA0CA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,CAAC,iBAAiB,eAAe;AAErD,IAAa,WAAb,MAAsB;CAKpB,YAAY,QAA2B;EACrC,KAAK,UAAU,eAAe,MAAM;CACtC;;CAGA,oBAAoB,OAA6D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,eAAe,GACrC,MAAM,IAAI,YACR,mBACA,uDAAuD,GACzD;CAEF,OAAO;EAAE;EAAW;EAAW;EAAG;EAAG;EAAG;CAAW;AACrD;;AAGA,SAAgB,eAAe,GAAmB;CAChD,IAAI,KAAK,KAAK,OAAO,OAAQ,IAAI,MAAO,EAAE;CAC1C,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,GAAG;CACnC,OAAO,OAAO,CAAC;AACjB"}
1
+ {"version":3,"file":"evm-CI1cuZsp.js","names":["UrValue"],"sources":["../src/chains/evm.ts"],"sourcesContent":["import { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbBytes, cbMap, cbText, cbUint, mapGet } from '../cbor/model';\nimport { bytesToBigint, hexToBytes } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { normalizeRequestId } from '../core/rand';\nimport { keypath304, normalizeXfp, parsePath } from '../registry/keypath';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\nimport type { ChainContext, EraConnectConfig, ExpectedReply, SignRequest } from './shared';\nimport {\n makeSignRequest,\n requireReplyMap,\n requireRequestIdEcho,\n requireSignatureBytes,\n requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\n/** `eth-sign-request` dataType (CBOR key 3). */\nexport const EvmDataType = {\n /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */\n transaction: 1,\n /** EIP-712 typed data JSON (UTF-8 bytes). */\n typedData: 2,\n /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */\n personalMessage: 3,\n /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */\n typedTransaction: 4,\n} as const;\nexport type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];\n\nexport interface EvmSignRequestProps {\n /** 16 bytes or a UUID string; minted if omitted. */\n readonly requestId?: Uint8Array | string;\n /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */\n readonly signData: Uint8Array;\n readonly dataType: EvmDataType;\n /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */\n readonly path: string;\n /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */\n readonly xfp: string | number;\n /**\n * Required for transactions (it derives the legal reply width). The device\n * reads it as an unsigned 32-bit value — larger chain ids are refused here,\n * because a silently truncated id would sign for a different chain.\n */\n readonly chainId?: number;\n /** 20-byte signer address; recommended (enables verification helpers). */\n readonly address?: Uint8Array | `0x${string}`;\n /** Overrides the SDK-level origin label for this request. */\n readonly origin?: string;\n}\n\nexport interface EvmSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */\n readonly signature: Uint8Array;\n readonly r: Uint8Array;\n readonly s: Uint8Array;\n /**\n * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28\n * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for\n * legacy transactions. Do NOT re-apply the EIP-155 formula.\n */\n readonly v: bigint;\n /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */\n readonly recoveryId: 0 | 1;\n}\n\n/** Over this size the device skips transaction decoding and falls back to blind signing. */\nconst BLIND_SIGN_THRESHOLD = 32 * 1024;\n\nconst REPLY_TYPES = ['eth-signature', 'evm-signature'] as const;\n\nexport class EvmChain {\n static readonly DataType = EvmDataType;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */\n generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n const isTransaction =\n props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction;\n\n if (isTransaction && props.chainId === undefined) {\n throw new EraSdkError('invalid-props', 'chainId is required for transaction sign requests');\n }\n if (props.chainId !== undefined) {\n if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) {\n throw new EraSdkError('invalid-props', 'chainId must be a non-negative integer');\n }\n if (props.chainId > 0xffffffff) {\n throw new EraSdkError(\n 'invalid-props',\n `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; ` +\n 'a truncated id would produce a signature for a different chain',\n { chainId: props.chainId },\n );\n }\n }\n\n const entries: [number, CborValue][] = [\n [1, cbBytes(requestId)],\n [2, cbBytes(props.signData)],\n [3, cbUint(props.dataType)],\n ];\n if (props.chainId !== undefined) entries.push([4, cbUint(props.chainId)]);\n entries.push([5, keypath304(path, xfp)]);\n if (props.address !== undefined) entries.push([6, cbBytes(normalizeAddress(props.address))]);\n entries.push([7, cbText(props.origin ?? this.context.origin)]);\n\n const ur = new UrValue('eth-sign-request', cborEncode(cbMap(entries)));\n const warnings: string[] = [];\n if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push('blind-sign-threshold');\n\n const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: REPLY_TYPES,\n warnings,\n context: this.context,\n parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength),\n });\n }\n\n /**\n * Parse an `eth-signature` standalone. Without `expect.requestId` the echo\n * is returned but not validated — prefer `SignRequest.scanner().parse()`.\n */\n parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult {\n const expected =\n expect?.requestId === undefined\n ? undefined\n : { requestId: normalizeRequestId(expect.requestId) };\n return parseEvmSignature(toUr(input), expected, 64 + 8);\n }\n}\n\nfunction normalizeAddress(address: Uint8Array | `0x${string}`): Uint8Array {\n const bytes = address instanceof Uint8Array ? address : hexToBytes(address);\n if (bytes.length !== 20) {\n throw new EraSdkError('invalid-props', 'EVM address must be 20 bytes');\n }\n return bytes;\n}\n\n/**\n * Width of the widest `v` the device can legitimately return.\n *\n * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes\n * past chain id 110, 4 bytes for Aurora. Messages and typed data always\n * answer with one byte (27/28). A flat ceiling either refuses genuine replies\n * on large-id chains or accepts implausibly wide values; the exact bound\n * comes from the request.\n */\nfunction maxVBytes(dataType: EvmDataType, chainId: number | undefined): number {\n if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;\n if (chainId === undefined) return 8;\n let widest = BigInt(chainId) * 2n + 36n;\n if (widest < 28n) widest = 28n;\n let bytes = 0;\n while (widest > 0n) {\n bytes += 1;\n widest >>= 8n;\n }\n return bytes;\n}\n\nfunction parseEvmSignature(\n ur: Ur,\n expect: { requestId: Uint8Array } | undefined,\n maxSigLength: number,\n): EvmSignatureResult {\n requireUrType(ur, [...REPLY_TYPES], 'eth-signature');\n const map = requireReplyMap(ur, 'eth-signature');\n const requestId = requireRequestIdEcho(map, 1, expect?.requestId, 'eth-signature');\n const signature = requireSignatureBytes(mapGet(map, 2), 'eth-signature', 65, maxSigLength);\n\n const r = signature.slice(0, 32);\n const s = signature.slice(32, 64);\n const v = bytesToBigint(signature.slice(64));\n const recoveryId = foldRecoveryId(v);\n if (recoveryId !== 0 && recoveryId !== 1) {\n throw new EraSdkError(\n 'malformed-reply',\n `eth-signature carries an implausible recovery value ${v}`,\n );\n }\n return { requestId, signature, r, s, v, recoveryId };\n}\n\n/** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */\nexport function foldRecoveryId(v: bigint): number {\n if (v >= 35n) return Number((v - 35n) & 1n);\n if (v >= 27n) return Number(v - 27n);\n return Number(v);\n}\n"],"mappings":";;;;AAsBA,MAAa,cAAc;;CAEzB,aAAa;;CAEb,WAAW;;CAEX,iBAAiB;;CAEjB,kBAAkB;AACpB;;AA0CA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,CAAC,iBAAiB,eAAe;AAErD,IAAa,WAAb,MAAsB;CAKpB,YAAY,QAA2B;EACrC,KAAK,UAAU,eAAe,MAAM;CACtC;;CAGA,oBAAoB,OAA6D;EAC/E,MAAM,YAAY,iBAAiB,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,mBACA,uDAAuD,GACzD;CAEF,OAAO;EAAE;EAAW;EAAW;EAAG;EAAG;EAAG;CAAW;AACrD;;AAGA,SAAgB,eAAe,GAAmB;CAChD,IAAI,KAAK,KAAK,OAAO,OAAQ,IAAI,MAAO,EAAE;CAC1C,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,GAAG;CACnC,OAAO,OAAO,CAAC;AACjB"}
@@ -1,4 +1,5 @@
1
- const require_shared = require("./shared-nISrEktU.cjs");
1
+ const require_shared = require("./shared-Cu2yynP9.cjs");
2
+ const require_keypath = require("./keypath-pzm_YIfN.cjs");
2
3
  //#region src/chains/evm.ts
3
4
  /** `eth-sign-request` dataType (CBOR key 3). */
4
5
  const EvmDataType = {
@@ -21,8 +22,8 @@ var EvmChain = class {
21
22
  /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */
22
23
  generateSignRequest(props) {
23
24
  const requestId = require_shared.resolveRequestId(this.context, props.requestId);
24
- const path = require_shared.parsePath(props.path);
25
- const xfp = require_shared.normalizeXfp(props.xfp);
25
+ const path = require_keypath.parsePath(props.path);
26
+ const xfp = require_keypath.normalizeXfp(props.xfp);
26
27
  if ((props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction) && props.chainId === void 0) throw new require_shared.EraSdkError("invalid-props", "chainId is required for transaction sign requests");
27
28
  if (props.chainId !== void 0) {
28
29
  if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) throw new require_shared.EraSdkError("invalid-props", "chainId must be a non-negative integer");
@@ -34,7 +35,7 @@ var EvmChain = class {
34
35
  [3, require_shared.cbUint(props.dataType)]
35
36
  ];
36
37
  if (props.chainId !== void 0) entries.push([4, require_shared.cbUint(props.chainId)]);
37
- entries.push([5, require_shared.keypath304(path, xfp)]);
38
+ entries.push([5, require_keypath.keypath304(path, xfp)]);
38
39
  if (props.address !== void 0) entries.push([6, require_shared.cbBytes(normalizeAddress(props.address))]);
39
40
  entries.push([7, require_shared.cbText(props.origin ?? this.context.origin)]);
40
41
  const ur = new require_shared.Ur("eth-sign-request", require_shared.cborEncode(require_shared.cbMap(entries)));
@@ -131,4 +132,4 @@ Object.defineProperty(exports, "foldRecoveryId", {
131
132
  }
132
133
  });
133
134
 
134
- //# sourceMappingURL=evm-BHj_2OTG.cjs.map
135
+ //# sourceMappingURL=evm-yfKOc2dy.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"evm-BHj_2OTG.cjs","names":["resolveContext","resolveRequestId","parsePath","normalizeXfp","EraSdkError","cbBytes","cbUint","keypath304","cbText","UrValue","cborEncode","cbMap","makeSignRequest","normalizeRequestId","toUr","hexToBytes","requireReplyMap","requireRequestIdEcho","requireSignatureBytes","mapGet","bytesToBigint"],"sources":["../src/chains/evm.ts"],"sourcesContent":["import { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbBytes, cbMap, cbText, cbUint, mapGet } from '../cbor/model';\nimport { bytesToBigint, hexToBytes } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { normalizeRequestId } from '../core/rand';\nimport { keypath304, normalizeXfp, parsePath } from '../registry/keypath';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\nimport type { ChainContext, EraConnectConfig, ExpectedReply, SignRequest } from './shared';\nimport {\n makeSignRequest,\n requireReplyMap,\n requireRequestIdEcho,\n requireSignatureBytes,\n requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\n/** `eth-sign-request` dataType (CBOR key 3). */\nexport const EvmDataType = {\n /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */\n transaction: 1,\n /** EIP-712 typed data JSON (UTF-8 bytes). */\n typedData: 2,\n /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */\n personalMessage: 3,\n /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */\n typedTransaction: 4,\n} as const;\nexport type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];\n\nexport interface EvmSignRequestProps {\n /** 16 bytes or a UUID string; minted if omitted. */\n readonly requestId?: Uint8Array | string;\n /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */\n readonly signData: Uint8Array;\n readonly dataType: EvmDataType;\n /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */\n readonly path: string;\n /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */\n readonly xfp: string | number;\n /**\n * Required for transactions (it derives the legal reply width). The device\n * reads it as an unsigned 32-bit value — larger chain ids are refused here,\n * because a silently truncated id would sign for a different chain.\n */\n readonly chainId?: number;\n /** 20-byte signer address; recommended (enables verification helpers). */\n readonly address?: Uint8Array | `0x${string}`;\n /** Overrides the SDK-level origin label for this request. */\n readonly origin?: string;\n}\n\nexport interface EvmSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */\n readonly signature: Uint8Array;\n readonly r: Uint8Array;\n readonly s: Uint8Array;\n /**\n * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28\n * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for\n * legacy transactions. Do NOT re-apply the EIP-155 formula.\n */\n readonly v: bigint;\n /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */\n readonly recoveryId: 0 | 1;\n}\n\n/** Over this size the device skips transaction decoding and falls back to blind signing. */\nconst BLIND_SIGN_THRESHOLD = 32 * 1024;\n\nconst REPLY_TYPES = ['eth-signature', 'evm-signature'] as const;\n\nexport class EvmChain {\n static readonly DataType = EvmDataType;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */\n generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n const isTransaction =\n props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction;\n\n if (isTransaction && props.chainId === undefined) {\n throw new EraSdkError('invalid-props', 'chainId is required for transaction sign requests');\n }\n if (props.chainId !== undefined) {\n if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) {\n throw new EraSdkError('invalid-props', 'chainId must be a non-negative integer');\n }\n if (props.chainId > 0xffffffff) {\n throw new EraSdkError(\n 'invalid-props',\n `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; ` +\n 'a truncated id would produce a signature for a different chain',\n { chainId: props.chainId },\n );\n }\n }\n\n const entries: [number, CborValue][] = [\n [1, cbBytes(requestId)],\n [2, cbBytes(props.signData)],\n [3, cbUint(props.dataType)],\n ];\n if (props.chainId !== undefined) entries.push([4, cbUint(props.chainId)]);\n entries.push([5, keypath304(path, xfp)]);\n if (props.address !== undefined) entries.push([6, cbBytes(normalizeAddress(props.address))]);\n entries.push([7, cbText(props.origin ?? this.context.origin)]);\n\n const ur = new UrValue('eth-sign-request', cborEncode(cbMap(entries)));\n const warnings: string[] = [];\n if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push('blind-sign-threshold');\n\n const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: REPLY_TYPES,\n warnings,\n context: this.context,\n parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength),\n });\n }\n\n /**\n * Parse an `eth-signature` standalone. Without `expect.requestId` the echo\n * is returned but not validated — prefer `SignRequest.scanner().parse()`.\n */\n parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult {\n const expected =\n expect?.requestId === undefined\n ? undefined\n : { requestId: normalizeRequestId(expect.requestId) };\n return parseEvmSignature(toUr(input), expected, 64 + 8);\n }\n}\n\nfunction normalizeAddress(address: Uint8Array | `0x${string}`): Uint8Array {\n const bytes = address instanceof Uint8Array ? address : hexToBytes(address);\n if (bytes.length !== 20) {\n throw new EraSdkError('invalid-props', 'EVM address must be 20 bytes');\n }\n return bytes;\n}\n\n/**\n * Width of the widest `v` the device can legitimately return.\n *\n * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes\n * past chain id 110, 4 bytes for Aurora. Messages and typed data always\n * answer with one byte (27/28). A flat ceiling either refuses genuine replies\n * on large-id chains or accepts implausibly wide values; the exact bound\n * comes from the request.\n */\nfunction maxVBytes(dataType: EvmDataType, chainId: number | undefined): number {\n if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;\n if (chainId === undefined) return 8;\n let widest = BigInt(chainId) * 2n + 36n;\n if (widest < 28n) widest = 28n;\n let bytes = 0;\n while (widest > 0n) {\n bytes += 1;\n widest >>= 8n;\n }\n return bytes;\n}\n\nfunction parseEvmSignature(\n ur: Ur,\n expect: { requestId: Uint8Array } | undefined,\n maxSigLength: number,\n): EvmSignatureResult {\n requireUrType(ur, [...REPLY_TYPES], 'eth-signature');\n const map = requireReplyMap(ur, 'eth-signature');\n const requestId = requireRequestIdEcho(map, 1, expect?.requestId, 'eth-signature');\n const signature = requireSignatureBytes(mapGet(map, 2), 'eth-signature', 65, maxSigLength);\n\n const r = signature.slice(0, 32);\n const s = signature.slice(32, 64);\n const v = bytesToBigint(signature.slice(64));\n const recoveryId = foldRecoveryId(v);\n if (recoveryId !== 0 && recoveryId !== 1) {\n throw new EraSdkError(\n 'malformed-reply',\n `eth-signature carries an implausible recovery value ${v}`,\n );\n }\n return { requestId, signature, r, s, v, recoveryId };\n}\n\n/** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */\nexport function foldRecoveryId(v: bigint): number {\n if (v >= 35n) return Number((v - 35n) & 1n);\n if (v >= 27n) return Number(v - 27n);\n return Number(v);\n}\n"],"mappings":";;;AAsBA,MAAa,cAAc;;CAEzB,aAAa;;CAEb,WAAW;;CAEX,iBAAiB;;CAEjB,kBAAkB;AACpB;;AA0CA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,CAAC,iBAAiB,eAAe;AAErD,IAAa,WA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AqB,KAAK,GAAG,QAAQ,WAAW,eAAe;CACjF,MAAM,YAAYC,eAAAA,sBAAsBC,eAAAA,OAAO,KAAK,CAAC,GAAG,iBAAiB,IAAI,YAAY;CAEzF,MAAM,IAAI,UAAU,MAAM,GAAG,EAAE;CAC/B,MAAM,IAAI,UAAU,MAAM,IAAI,EAAE;CAChC,MAAM,IAAIC,eAAAA,cAAc,UAAU,MAAM,EAAE,CAAC;CAC3C,MAAM,aAAa,eAAe,CAAC;CACnC,IAAI,eAAe,KAAK,eAAe,GACrC,MAAM,IAAIhB,eAAAA,YACR,mBACA,uDAAuD,GACzD;CAEF,OAAO;EAAE;EAAW;EAAW;EAAG;EAAG;EAAG;CAAW;AACrD;;AAGA,SAAgB,eAAe,GAAmB;CAChD,IAAI,KAAK,KAAK,OAAO,OAAQ,IAAI,MAAO,EAAE;CAC1C,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,GAAG;CACnC,OAAO,OAAO,CAAC;AACjB"}
1
+ {"version":3,"file":"evm-yfKOc2dy.cjs","names":["resolveContext","resolveRequestId","parsePath","normalizeXfp","EraSdkError","cbBytes","cbUint","keypath304","cbText","UrValue","cborEncode","cbMap","makeSignRequest","normalizeRequestId","toUr","hexToBytes","requireReplyMap","requireRequestIdEcho","requireSignatureBytes","mapGet","bytesToBigint"],"sources":["../src/chains/evm.ts"],"sourcesContent":["import { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbBytes, cbMap, cbText, cbUint, mapGet } from '../cbor/model';\nimport { bytesToBigint, hexToBytes } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { normalizeRequestId } from '../core/rand';\nimport { keypath304, normalizeXfp, parsePath } from '../registry/keypath';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\nimport type { ChainContext, EraConnectConfig, ExpectedReply, SignRequest } from './shared';\nimport {\n makeSignRequest,\n requireReplyMap,\n requireRequestIdEcho,\n requireSignatureBytes,\n requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\n/** `eth-sign-request` dataType (CBOR key 3). */\nexport const EvmDataType = {\n /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */\n transaction: 1,\n /** EIP-712 typed data JSON (UTF-8 bytes). */\n typedData: 2,\n /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */\n personalMessage: 3,\n /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */\n typedTransaction: 4,\n} as const;\nexport type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];\n\nexport interface EvmSignRequestProps {\n /** 16 bytes or a UUID string; minted if omitted. */\n readonly requestId?: Uint8Array | string;\n /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */\n readonly signData: Uint8Array;\n readonly dataType: EvmDataType;\n /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */\n readonly path: string;\n /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */\n readonly xfp: string | number;\n /**\n * Required for transactions (it derives the legal reply width). The device\n * reads it as an unsigned 32-bit value — larger chain ids are refused here,\n * because a silently truncated id would sign for a different chain.\n */\n readonly chainId?: number;\n /** 20-byte signer address; recommended (enables verification helpers). */\n readonly address?: Uint8Array | `0x${string}`;\n /** Overrides the SDK-level origin label for this request. */\n readonly origin?: string;\n}\n\nexport interface EvmSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */\n readonly signature: Uint8Array;\n readonly r: Uint8Array;\n readonly s: Uint8Array;\n /**\n * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28\n * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for\n * legacy transactions. Do NOT re-apply the EIP-155 formula.\n */\n readonly v: bigint;\n /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */\n readonly recoveryId: 0 | 1;\n}\n\n/** Over this size the device skips transaction decoding and falls back to blind signing. */\nconst BLIND_SIGN_THRESHOLD = 32 * 1024;\n\nconst REPLY_TYPES = ['eth-signature', 'evm-signature'] as const;\n\nexport class EvmChain {\n static readonly DataType = EvmDataType;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */\n generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n const isTransaction =\n props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction;\n\n if (isTransaction && props.chainId === undefined) {\n throw new EraSdkError('invalid-props', 'chainId is required for transaction sign requests');\n }\n if (props.chainId !== undefined) {\n if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) {\n throw new EraSdkError('invalid-props', 'chainId must be a non-negative integer');\n }\n if (props.chainId > 0xffffffff) {\n throw new EraSdkError(\n 'invalid-props',\n `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; ` +\n 'a truncated id would produce a signature for a different chain',\n { chainId: props.chainId },\n );\n }\n }\n\n const entries: [number, CborValue][] = [\n [1, cbBytes(requestId)],\n [2, cbBytes(props.signData)],\n [3, cbUint(props.dataType)],\n ];\n if (props.chainId !== undefined) entries.push([4, cbUint(props.chainId)]);\n entries.push([5, keypath304(path, xfp)]);\n if (props.address !== undefined) entries.push([6, cbBytes(normalizeAddress(props.address))]);\n entries.push([7, cbText(props.origin ?? this.context.origin)]);\n\n const ur = new UrValue('eth-sign-request', cborEncode(cbMap(entries)));\n const warnings: string[] = [];\n if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push('blind-sign-threshold');\n\n const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: REPLY_TYPES,\n warnings,\n context: this.context,\n parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength),\n });\n }\n\n /**\n * Parse an `eth-signature` standalone. Without `expect.requestId` the echo\n * is returned but not validated — prefer `SignRequest.scanner().parse()`.\n */\n parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult {\n const expected =\n expect?.requestId === undefined\n ? undefined\n : { requestId: normalizeRequestId(expect.requestId) };\n return parseEvmSignature(toUr(input), expected, 64 + 8);\n }\n}\n\nfunction normalizeAddress(address: Uint8Array | `0x${string}`): Uint8Array {\n const bytes = address instanceof Uint8Array ? address : hexToBytes(address);\n if (bytes.length !== 20) {\n throw new EraSdkError('invalid-props', 'EVM address must be 20 bytes');\n }\n return bytes;\n}\n\n/**\n * Width of the widest `v` the device can legitimately return.\n *\n * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes\n * past chain id 110, 4 bytes for Aurora. Messages and typed data always\n * answer with one byte (27/28). A flat ceiling either refuses genuine replies\n * on large-id chains or accepts implausibly wide values; the exact bound\n * comes from the request.\n */\nfunction maxVBytes(dataType: EvmDataType, chainId: number | undefined): number {\n if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;\n if (chainId === undefined) return 8;\n let widest = BigInt(chainId) * 2n + 36n;\n if (widest < 28n) widest = 28n;\n let bytes = 0;\n while (widest > 0n) {\n bytes += 1;\n widest >>= 8n;\n }\n return bytes;\n}\n\nfunction parseEvmSignature(\n ur: Ur,\n expect: { requestId: Uint8Array } | undefined,\n maxSigLength: number,\n): EvmSignatureResult {\n requireUrType(ur, [...REPLY_TYPES], 'eth-signature');\n const map = requireReplyMap(ur, 'eth-signature');\n const requestId = requireRequestIdEcho(map, 1, expect?.requestId, 'eth-signature');\n const signature = requireSignatureBytes(mapGet(map, 2), 'eth-signature', 65, maxSigLength);\n\n const r = signature.slice(0, 32);\n const s = signature.slice(32, 64);\n const v = bytesToBigint(signature.slice(64));\n const recoveryId = foldRecoveryId(v);\n if (recoveryId !== 0 && recoveryId !== 1) {\n throw new EraSdkError(\n 'malformed-reply',\n `eth-signature carries an implausible recovery value ${v}`,\n );\n }\n return { requestId, signature, r, s, v, recoveryId };\n}\n\n/** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */\nexport function foldRecoveryId(v: bigint): number {\n if (v >= 35n) return Number((v - 35n) & 1n);\n if (v >= 27n) return Number(v - 27n);\n return Number(v);\n}\n"],"mappings":";;;;AAsBA,MAAa,cAAc;;CAEzB,aAAa;;CAEb,WAAW;;CAEX,iBAAiB;;CAEjB,kBAAkB;AACpB;;AA0CA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,CAAC,iBAAiB,eAAe;AAErD,IAAa,WAAb,MAAsB;CAKpB,YAAY,QAA2B;EACrC,KAAK,UAAUA,eAAAA,eAAe,MAAM;CACtC;;CAGA,oBAAoB,OAA6D;EAC/E,MAAM,YAAYC,eAAAA,iBAAiB,KAAK,SAAS,MAAM,SAAS;EAChE,MAAM,OAAOC,gBAAAA,UAAU,MAAM,IAAI;EACjC,MAAM,MAAMC,gBAAAA,aAAa,MAAM,GAAG;EAIlC,KAFE,MAAM,aAAa,YAAY,eAAe,MAAM,aAAa,YAAY,qBAE1D,MAAM,YAAY,KAAA,GACrC,MAAM,IAAIC,eAAAA,YAAY,iBAAiB,mDAAmD;EAE5F,IAAI,MAAM,YAAY,KAAA,GAAW;GAC/B,IAAI,CAAC,OAAO,cAAc,MAAM,OAAO,KAAK,MAAM,UAAU,GAC1D,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,wCAAwC;GAEjF,IAAI,MAAM,UAAU,YAClB,MAAM,IAAIA,eAAAA,YACR,iBACA,WAAW,MAAM,QAAQ,8GAEzB,EAAE,SAAS,MAAM,QAAQ,CAC3B;EAEJ;EAEA,MAAM,UAAiC;GACrC,CAAC,GAAGC,eAAAA,QAAQ,SAAS,CAAC;GACtB,CAAC,GAAGA,eAAAA,QAAQ,MAAM,QAAQ,CAAC;GAC3B,CAAC,GAAGC,eAAAA,OAAO,MAAM,QAAQ,CAAC;EAC5B;EACA,IAAI,MAAM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AY,kBAAkB,OAAO;CAC9F,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,IAAI,SAAS,OAAO,OAAO,IAAI,KAAK;CACpC,IAAI,SAAS,KAAK,SAAS;CAC3B,IAAI,QAAQ;CACZ,OAAO,SAAS,IAAI;EAClB,SAAS;EACT,WAAW;CACb;CACA,OAAO;AACT;AAEA,SAAS,kBACP,IACA,QACA,cACoB;CACpB,eAAA,cAAc,IAAI,CAAC,GAAG,WAAW,GAAG,eAAe;CACnD,MAAM,MAAMY,eAAAA,gBAAgB,IAAI,eAAe;CAC/C,MAAM,YAAYC,eAAAA,qBAAqB,KAAK,GAAG,QAAQ,WAAW,eAAe;CACjF,MAAM,YAAYC,eAAAA,sBAAsBC,eAAAA,OAAO,KAAK,CAAC,GAAG,iBAAiB,IAAI,YAAY;CAEzF,MAAM,IAAI,UAAU,MAAM,GAAG,EAAE;CAC/B,MAAM,IAAI,UAAU,MAAM,IAAI,EAAE;CAChC,MAAM,IAAIC,eAAAA,cAAc,UAAU,MAAM,EAAE,CAAC;CAC3C,MAAM,aAAa,eAAe,CAAC;CACnC,IAAI,eAAe,KAAK,eAAe,GACrC,MAAM,IAAIhB,eAAAA,YACR,mBACA,uDAAuD,GACzD;CAEF,OAAO;EAAE;EAAW;EAAW;EAAG;EAAG;EAAG;CAAW;AACrD;;AAGA,SAAgB,eAAe,GAAmB;CAChD,IAAI,KAAK,KAAK,OAAO,OAAQ,IAAI,MAAO,EAAE;CAC1C,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,GAAG;CACnC,OAAO,OAAO,CAAC;AACjB"}
package/dist/evm.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_shared = require("./shared-nISrEktU.cjs");
3
- const require_evm = require("./evm-BHj_2OTG.cjs");
2
+ const require_shared = require("./shared-Cu2yynP9.cjs");
3
+ const require_evm = require("./evm-yfKOc2dy.cjs");
4
4
  exports.AnimatedUr = require_shared.AnimatedUr;
5
5
  exports.EraSdkError = require_shared.EraSdkError;
6
6
  exports.EvmChain = require_evm.EvmChain;
package/dist/evm.js CHANGED
@@ -1,3 +1,3 @@
1
- import { Z as EraSdkError, _ as Ur, d as UrScanner, f as AnimatedUr, u as TypedUrScanner } from "./shared-B8Wc7ViU.js";
2
- import { n as EvmDataType, r as foldRecoveryId, t as EvmChain } from "./evm-kJb3-oiR.js";
1
+ import { K as EraSdkError, _ as Ur, d as UrScanner, f as AnimatedUr, u as TypedUrScanner } from "./shared-Bbgejrus.js";
2
+ import { n as EvmDataType, r as foldRecoveryId, t as EvmChain } from "./evm-CI1cuZsp.js";
3
3
  export { AnimatedUr, EraSdkError, EvmChain, EvmDataType, TypedUrScanner, Ur, UrScanner, foldRecoveryId };