@dynamic-labs-wallet/aleo 0.0.351 → 0.0.353

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1051,6 +1051,64 @@ var RedcoastRecordScanner = /*#__PURE__*/ function() {
1051
1051
  return RedcoastRecordScanner;
1052
1052
  }();
1053
1053
 
1054
+ /**
1055
+ * Encodes Sodot's raw EdBls12377 private key export into Aleo's canonical
1056
+ * bech32 form (`APrivateKey1zk…`) using the Provable SDK.
1057
+ *
1058
+ * The MPC ceremony's `exportFullPrivateKey` returns the reconstructed private
1059
+ * key as a hex-encoded byte string. Aleo's snarkVM `PrivateKey` is built from
1060
+ * the first 32 bytes of that material (the canonical seed scalar); the
1061
+ * Provable SDK's `PrivateKey.fromBytesLe` is lenient about trailing bytes,
1062
+ * but we slice explicitly to 32 so the encoder behaves identically across
1063
+ * SDK versions.
1064
+ *
1065
+ * Sanity check: after encoding we re-derive the address from the resulting
1066
+ * `PrivateKey` and assert it matches the wallet's address, so a corrupted /
1067
+ * truncated export can't silently surface a key for the wrong account.
1068
+ *
1069
+ * `expectedAddress` is required even though encoding is technically
1070
+ * network-agnostic: the address derivation is the only end-to-end signal
1071
+ * that the seed bytes are intact, so we always run it.
1072
+ */ var ALEO_PRIVATE_KEY_BECH32_PREFIX = 'APrivateKey1';
1073
+ var ALEO_PRIVATE_KEY_SEED_BYTES = 32;
1074
+ var HEX_PREFIX = '0x';
1075
+ var HEX_REGEX = /^[0-9a-fA-F]+$/;
1076
+ var stripHexPrefix = function(value) {
1077
+ return value.startsWith(HEX_PREFIX) ? value.slice(HEX_PREFIX.length) : value;
1078
+ };
1079
+ var hexToBytes = function(hex) {
1080
+ var evenHex = hex.length % 2 === 0 ? hex : hex.slice(0, -1);
1081
+ var _evenHex_match;
1082
+ var matched = (_evenHex_match = evenHex.match(/.{2}/g)) !== null && _evenHex_match !== void 0 ? _evenHex_match : [];
1083
+ return new Uint8Array(matched.map(function(byte) {
1084
+ return Number.parseInt(byte, 16);
1085
+ }));
1086
+ };
1087
+ var encodeAleoPrivateKey = function(param) {
1088
+ var rawKey = param.rawKey, expectedAddress = param.expectedAddress, sdk = param.sdk;
1089
+ if (!rawKey) {
1090
+ throw new Error('Cannot encode empty Aleo private key');
1091
+ }
1092
+ if (rawKey.startsWith(ALEO_PRIVATE_KEY_BECH32_PREFIX)) {
1093
+ return rawKey;
1094
+ }
1095
+ var hex = stripHexPrefix(rawKey);
1096
+ if (!HEX_REGEX.test(hex)) {
1097
+ throw new Error('Aleo private key export is neither bech32 nor hex');
1098
+ }
1099
+ var bytes = hexToBytes(hex);
1100
+ if (bytes.length < ALEO_PRIVATE_KEY_SEED_BYTES) {
1101
+ throw new Error("Aleo private key export is ".concat(bytes.length, " bytes; expected at least ").concat(ALEO_PRIVATE_KEY_SEED_BYTES));
1102
+ }
1103
+ var seedBytes = bytes.slice(0, ALEO_PRIVATE_KEY_SEED_BYTES);
1104
+ var privateKey = sdk.PrivateKey.from_seed_unchecked(seedBytes);
1105
+ var derivedAddress = privateKey.to_address().to_string();
1106
+ if (derivedAddress !== expectedAddress) {
1107
+ throw new Error("Encoded Aleo private key derives ".concat(derivedAddress, ", expected ").concat(expectedAddress));
1108
+ }
1109
+ return privateKey.to_string();
1110
+ };
1111
+
1054
1112
  function _array_like_to_array(arr, len) {
1055
1113
  if (len == null || len > arr.length) len = arr.length;
1056
1114
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -1700,13 +1758,18 @@ var DynamicAleoWalletClient = /*#__PURE__*/ function(DynamicWalletClient) {
1700
1758
  if (!derivedPrivateKey) {
1701
1759
  throw new Error('Derived private key is undefined');
1702
1760
  }
1703
- // For Aleo, `derivedPrivateKey` is the raw hex scalar produced by Sodot's
1704
- // EdBls12377 exportFullPrivateKey. Aleo's canonical format is `APrivateKey1...`
1705
- // (bech32-encoded via @provablehq/sdk). Encoding to that format requires the
1706
- // Provable SDK and is done by the consumer (connector) for now.
1761
+ // Sodot's EdBls12377 `exportFullPrivateKey` returns the raw scalar as a
1762
+ // hex string. Aleo wallets / explorers consume the bech32 `APrivateKey1zk…`
1763
+ // form, so we encode via the Provable SDK before returning. Bech32
1764
+ // encoding is network-agnostic (same HRP on testnet and mainnet) so we
1765
+ // use the testnet build, which is already loaded eagerly.
1707
1766
  return [
1708
1767
  2,
1709
- derivedPrivateKey
1768
+ encodeAleoPrivateKey({
1769
+ rawKey: derivedPrivateKey,
1770
+ expectedAddress: accountAddress,
1771
+ sdk: AleoSdkTestnet__namespace
1772
+ })
1710
1773
  ];
1711
1774
  case 2:
1712
1775
  error = _state.sent();
package/index.esm.js CHANGED
@@ -1029,6 +1029,64 @@ var RedcoastRecordScanner = /*#__PURE__*/ function() {
1029
1029
  return RedcoastRecordScanner;
1030
1030
  }();
1031
1031
 
1032
+ /**
1033
+ * Encodes Sodot's raw EdBls12377 private key export into Aleo's canonical
1034
+ * bech32 form (`APrivateKey1zk…`) using the Provable SDK.
1035
+ *
1036
+ * The MPC ceremony's `exportFullPrivateKey` returns the reconstructed private
1037
+ * key as a hex-encoded byte string. Aleo's snarkVM `PrivateKey` is built from
1038
+ * the first 32 bytes of that material (the canonical seed scalar); the
1039
+ * Provable SDK's `PrivateKey.fromBytesLe` is lenient about trailing bytes,
1040
+ * but we slice explicitly to 32 so the encoder behaves identically across
1041
+ * SDK versions.
1042
+ *
1043
+ * Sanity check: after encoding we re-derive the address from the resulting
1044
+ * `PrivateKey` and assert it matches the wallet's address, so a corrupted /
1045
+ * truncated export can't silently surface a key for the wrong account.
1046
+ *
1047
+ * `expectedAddress` is required even though encoding is technically
1048
+ * network-agnostic: the address derivation is the only end-to-end signal
1049
+ * that the seed bytes are intact, so we always run it.
1050
+ */ var ALEO_PRIVATE_KEY_BECH32_PREFIX = 'APrivateKey1';
1051
+ var ALEO_PRIVATE_KEY_SEED_BYTES = 32;
1052
+ var HEX_PREFIX = '0x';
1053
+ var HEX_REGEX = /^[0-9a-fA-F]+$/;
1054
+ var stripHexPrefix = function(value) {
1055
+ return value.startsWith(HEX_PREFIX) ? value.slice(HEX_PREFIX.length) : value;
1056
+ };
1057
+ var hexToBytes = function(hex) {
1058
+ var evenHex = hex.length % 2 === 0 ? hex : hex.slice(0, -1);
1059
+ var _evenHex_match;
1060
+ var matched = (_evenHex_match = evenHex.match(/.{2}/g)) !== null && _evenHex_match !== void 0 ? _evenHex_match : [];
1061
+ return new Uint8Array(matched.map(function(byte) {
1062
+ return Number.parseInt(byte, 16);
1063
+ }));
1064
+ };
1065
+ var encodeAleoPrivateKey = function(param) {
1066
+ var rawKey = param.rawKey, expectedAddress = param.expectedAddress, sdk = param.sdk;
1067
+ if (!rawKey) {
1068
+ throw new Error('Cannot encode empty Aleo private key');
1069
+ }
1070
+ if (rawKey.startsWith(ALEO_PRIVATE_KEY_BECH32_PREFIX)) {
1071
+ return rawKey;
1072
+ }
1073
+ var hex = stripHexPrefix(rawKey);
1074
+ if (!HEX_REGEX.test(hex)) {
1075
+ throw new Error('Aleo private key export is neither bech32 nor hex');
1076
+ }
1077
+ var bytes = hexToBytes(hex);
1078
+ if (bytes.length < ALEO_PRIVATE_KEY_SEED_BYTES) {
1079
+ throw new Error("Aleo private key export is ".concat(bytes.length, " bytes; expected at least ").concat(ALEO_PRIVATE_KEY_SEED_BYTES));
1080
+ }
1081
+ var seedBytes = bytes.slice(0, ALEO_PRIVATE_KEY_SEED_BYTES);
1082
+ var privateKey = sdk.PrivateKey.from_seed_unchecked(seedBytes);
1083
+ var derivedAddress = privateKey.to_address().to_string();
1084
+ if (derivedAddress !== expectedAddress) {
1085
+ throw new Error("Encoded Aleo private key derives ".concat(derivedAddress, ", expected ").concat(expectedAddress));
1086
+ }
1087
+ return privateKey.to_string();
1088
+ };
1089
+
1032
1090
  function _array_like_to_array(arr, len) {
1033
1091
  if (len == null || len > arr.length) len = arr.length;
1034
1092
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -1678,13 +1736,18 @@ var DynamicAleoWalletClient = /*#__PURE__*/ function(DynamicWalletClient) {
1678
1736
  if (!derivedPrivateKey) {
1679
1737
  throw new Error('Derived private key is undefined');
1680
1738
  }
1681
- // For Aleo, `derivedPrivateKey` is the raw hex scalar produced by Sodot's
1682
- // EdBls12377 exportFullPrivateKey. Aleo's canonical format is `APrivateKey1...`
1683
- // (bech32-encoded via @provablehq/sdk). Encoding to that format requires the
1684
- // Provable SDK and is done by the consumer (connector) for now.
1739
+ // Sodot's EdBls12377 `exportFullPrivateKey` returns the raw scalar as a
1740
+ // hex string. Aleo wallets / explorers consume the bech32 `APrivateKey1zk…`
1741
+ // form, so we encode via the Provable SDK before returning. Bech32
1742
+ // encoding is network-agnostic (same HRP on testnet and mainnet) so we
1743
+ // use the testnet build, which is already loaded eagerly.
1685
1744
  return [
1686
1745
  2,
1687
- derivedPrivateKey
1746
+ encodeAleoPrivateKey({
1747
+ rawKey: derivedPrivateKey,
1748
+ expectedAddress: accountAddress,
1749
+ sdk: AleoSdkTestnet
1750
+ })
1688
1751
  ];
1689
1752
  case 2:
1690
1753
  error = _state.sent();
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/aleo",
3
- "version": "0.0.351",
3
+ "version": "0.0.353",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/browser": "0.0.351",
8
- "@dynamic-labs-wallet/core": "0.0.351",
7
+ "@dynamic-labs-wallet/browser": "0.0.353",
8
+ "@dynamic-labs-wallet/core": "0.0.353",
9
9
  "@provablehq/sdk": "0.10.4"
10
10
  },
11
11
  "publishConfig": {
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAMnB,KAAK,kCAAkC,EACvC,KAAK,wBAAwB,EAC7B,KAAK,SAAS,EACd,KAAK,8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AAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;wDAEgD;QAChD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC3B,CAAC,GACD,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;YAsBpB,qBAAqB;IAyDnC;;;;OAIG;YACW,kBAAkB;IAahC;;;;OAIG;YACW,sBAAsB;IAepC;;;;;;OAMG;YACW,wBAAwB;IAyDtC;;;;OAIG;YACW,qBAAqB;IA+BnC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAqCzB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;CAgB7B"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Encodes Sodot's raw EdBls12377 private key export into Aleo's canonical
3
+ * bech32 form (`APrivateKey1zk…`) using the Provable SDK.
4
+ *
5
+ * The MPC ceremony's `exportFullPrivateKey` returns the reconstructed private
6
+ * key as a hex-encoded byte string. Aleo's snarkVM `PrivateKey` is built from
7
+ * the first 32 bytes of that material (the canonical seed scalar); the
8
+ * Provable SDK's `PrivateKey.fromBytesLe` is lenient about trailing bytes,
9
+ * but we slice explicitly to 32 so the encoder behaves identically across
10
+ * SDK versions.
11
+ *
12
+ * Sanity check: after encoding we re-derive the address from the resulting
13
+ * `PrivateKey` and assert it matches the wallet's address, so a corrupted /
14
+ * truncated export can't silently surface a key for the wrong account.
15
+ *
16
+ * `expectedAddress` is required even though encoding is technically
17
+ * network-agnostic: the address derivation is the only end-to-end signal
18
+ * that the seed bytes are intact, so we always run it.
19
+ */
20
+ import type * as AleoSdkMainnet from '@provablehq/sdk/mainnet.js';
21
+ import type * as AleoSdkTestnet from '@provablehq/sdk/testnet.js';
22
+ export type AleoSdkModule = typeof AleoSdkMainnet | typeof AleoSdkTestnet;
23
+ export declare const ALEO_PRIVATE_KEY_BECH32_PREFIX = "APrivateKey1";
24
+ export type EncodeAleoPrivateKeyParams = {
25
+ rawKey: string;
26
+ expectedAddress: string;
27
+ sdk: AleoSdkModule;
28
+ };
29
+ export declare const encodeAleoPrivateKey: ({ rawKey, expectedAddress, sdk }: EncodeAleoPrivateKeyParams) => string;
30
+ //# sourceMappingURL=encodeAleoPrivateKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encodeAleoPrivateKey.d.ts","sourceRoot":"","sources":["../../src/client/encodeAleoPrivateKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG,OAAO,cAAc,GAAG,OAAO,cAAc,CAAC;AAE1E,eAAO,MAAM,8BAA8B,iBAAiB,CAAC;AAQ7D,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,aAAa,CAAC;CACpB,CAAC;AAWF,eAAO,MAAM,oBAAoB,qCAAsC,0BAA0B,KAAG,MA6BnG,CAAC"}