@cardano-sdk/crypto 0.1.11 → 0.1.13

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 (100) hide show
  1. package/README.md +3 -0
  2. package/dist/cjs/Bip32/Bip32KeyDerivation.d.ts +3 -0
  3. package/dist/cjs/Bip32/Bip32KeyDerivation.d.ts.map +1 -0
  4. package/dist/cjs/Bip32/Bip32KeyDerivation.js +73 -0
  5. package/dist/cjs/Bip32/Bip32KeyDerivation.js.map +1 -0
  6. package/dist/cjs/Bip32/Bip32PrivateKey.d.ts +19 -0
  7. package/dist/cjs/Bip32/Bip32PrivateKey.d.ts.map +1 -0
  8. package/dist/cjs/Bip32/Bip32PrivateKey.js +111 -0
  9. package/dist/cjs/Bip32/Bip32PrivateKey.js.map +1 -0
  10. package/dist/cjs/Bip32/Bip32PublicKey.d.ts +14 -0
  11. package/dist/cjs/Bip32/Bip32PublicKey.d.ts.map +1 -0
  12. package/dist/cjs/Bip32/Bip32PublicKey.js +78 -0
  13. package/dist/cjs/Bip32/Bip32PublicKey.js.map +1 -0
  14. package/dist/cjs/Bip32/index.d.ts +3 -0
  15. package/dist/cjs/Bip32/index.d.ts.map +1 -0
  16. package/dist/cjs/Bip32/index.js +19 -0
  17. package/dist/cjs/Bip32/index.js.map +1 -0
  18. package/dist/cjs/Ed25519e/Ed25519KeyHash.d.ts +11 -0
  19. package/dist/cjs/Ed25519e/Ed25519KeyHash.d.ts.map +1 -0
  20. package/dist/cjs/Ed25519e/Ed25519KeyHash.js +41 -0
  21. package/dist/cjs/Ed25519e/Ed25519KeyHash.js.map +1 -0
  22. package/dist/cjs/Ed25519e/Ed25519PrivateKey.d.ts +24 -0
  23. package/dist/cjs/Ed25519e/Ed25519PrivateKey.d.ts.map +1 -0
  24. package/dist/cjs/Ed25519e/Ed25519PrivateKey.js +88 -0
  25. package/dist/cjs/Ed25519e/Ed25519PrivateKey.js.map +1 -0
  26. package/dist/cjs/Ed25519e/Ed25519PublicKey.d.ts +16 -0
  27. package/dist/cjs/Ed25519e/Ed25519PublicKey.d.ts.map +1 -0
  28. package/dist/cjs/Ed25519e/Ed25519PublicKey.js +52 -0
  29. package/dist/cjs/Ed25519e/Ed25519PublicKey.js.map +1 -0
  30. package/dist/cjs/Ed25519e/Ed25519Signature.d.ts +11 -0
  31. package/dist/cjs/Ed25519e/Ed25519Signature.d.ts.map +1 -0
  32. package/dist/cjs/Ed25519e/Ed25519Signature.js +41 -0
  33. package/dist/cjs/Ed25519e/Ed25519Signature.js.map +1 -0
  34. package/dist/cjs/Ed25519e/index.d.ts +5 -0
  35. package/dist/cjs/Ed25519e/index.d.ts.map +1 -0
  36. package/dist/cjs/Ed25519e/index.js +21 -0
  37. package/dist/cjs/Ed25519e/index.js.map +1 -0
  38. package/dist/cjs/index.d.ts +2 -0
  39. package/dist/cjs/index.d.ts.map +1 -1
  40. package/dist/cjs/index.js +2 -0
  41. package/dist/cjs/index.js.map +1 -1
  42. package/dist/cjs/strategies/SodiumBip32Ed25519.d.ts +19 -0
  43. package/dist/cjs/strategies/SodiumBip32Ed25519.d.ts.map +1 -0
  44. package/dist/cjs/strategies/SodiumBip32Ed25519.js +52 -0
  45. package/dist/cjs/strategies/SodiumBip32Ed25519.js.map +1 -0
  46. package/dist/cjs/strategies/index.d.ts +1 -0
  47. package/dist/cjs/strategies/index.d.ts.map +1 -1
  48. package/dist/cjs/strategies/index.js +1 -0
  49. package/dist/cjs/strategies/index.js.map +1 -1
  50. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  51. package/dist/esm/Bip32/Bip32KeyDerivation.d.ts +3 -0
  52. package/dist/esm/Bip32/Bip32KeyDerivation.d.ts.map +1 -0
  53. package/dist/esm/Bip32/Bip32KeyDerivation.js +68 -0
  54. package/dist/esm/Bip32/Bip32KeyDerivation.js.map +1 -0
  55. package/dist/esm/Bip32/Bip32PrivateKey.d.ts +19 -0
  56. package/dist/esm/Bip32/Bip32PrivateKey.d.ts.map +1 -0
  57. package/dist/esm/Bip32/Bip32PrivateKey.js +84 -0
  58. package/dist/esm/Bip32/Bip32PrivateKey.js.map +1 -0
  59. package/dist/esm/Bip32/Bip32PublicKey.d.ts +14 -0
  60. package/dist/esm/Bip32/Bip32PublicKey.d.ts.map +1 -0
  61. package/dist/esm/Bip32/Bip32PublicKey.js +51 -0
  62. package/dist/esm/Bip32/Bip32PublicKey.js.map +1 -0
  63. package/dist/esm/Bip32/index.d.ts +3 -0
  64. package/dist/esm/Bip32/index.d.ts.map +1 -0
  65. package/dist/esm/Bip32/index.js +3 -0
  66. package/dist/esm/Bip32/index.js.map +1 -0
  67. package/dist/esm/Ed25519e/Ed25519KeyHash.d.ts +11 -0
  68. package/dist/esm/Ed25519e/Ed25519KeyHash.d.ts.map +1 -0
  69. package/dist/esm/Ed25519e/Ed25519KeyHash.js +37 -0
  70. package/dist/esm/Ed25519e/Ed25519KeyHash.js.map +1 -0
  71. package/dist/esm/Ed25519e/Ed25519PrivateKey.d.ts +24 -0
  72. package/dist/esm/Ed25519e/Ed25519PrivateKey.d.ts.map +1 -0
  73. package/dist/esm/Ed25519e/Ed25519PrivateKey.js +84 -0
  74. package/dist/esm/Ed25519e/Ed25519PrivateKey.js.map +1 -0
  75. package/dist/esm/Ed25519e/Ed25519PublicKey.d.ts +16 -0
  76. package/dist/esm/Ed25519e/Ed25519PublicKey.d.ts.map +1 -0
  77. package/dist/esm/Ed25519e/Ed25519PublicKey.js +48 -0
  78. package/dist/esm/Ed25519e/Ed25519PublicKey.js.map +1 -0
  79. package/dist/esm/Ed25519e/Ed25519Signature.d.ts +11 -0
  80. package/dist/esm/Ed25519e/Ed25519Signature.d.ts.map +1 -0
  81. package/dist/esm/Ed25519e/Ed25519Signature.js +37 -0
  82. package/dist/esm/Ed25519e/Ed25519Signature.js.map +1 -0
  83. package/dist/esm/Ed25519e/index.d.ts +5 -0
  84. package/dist/esm/Ed25519e/index.d.ts.map +1 -0
  85. package/dist/esm/Ed25519e/index.js +5 -0
  86. package/dist/esm/Ed25519e/index.js.map +1 -0
  87. package/dist/esm/index.d.ts +2 -0
  88. package/dist/esm/index.d.ts.map +1 -1
  89. package/dist/esm/index.js +2 -0
  90. package/dist/esm/index.js.map +1 -1
  91. package/dist/esm/strategies/SodiumBip32Ed25519.d.ts +19 -0
  92. package/dist/esm/strategies/SodiumBip32Ed25519.d.ts.map +1 -0
  93. package/dist/esm/strategies/SodiumBip32Ed25519.js +48 -0
  94. package/dist/esm/strategies/SodiumBip32Ed25519.js.map +1 -0
  95. package/dist/esm/strategies/index.d.ts +1 -0
  96. package/dist/esm/strategies/index.d.ts.map +1 -1
  97. package/dist/esm/strategies/index.js +1 -0
  98. package/dist/esm/strategies/index.js.map +1 -1
  99. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  100. package/package.json +4 -4
package/README.md CHANGED
@@ -2,3 +2,6 @@
2
2
 
3
3
  This package provides a set of high level primitives to perform hashing, signature generation/verification, import private keys from BIP39
4
4
  mnemonics, and derive BIP32-Ed25519 extended signing keys.
5
+
6
+ > **Warning**
7
+ > The libsodium crypto provider has not yet been audited. Use at this stage is at own risk
@@ -0,0 +1,3 @@
1
+ export declare const derivePrivate: (key: Buffer, index: number) => Buffer;
2
+ export declare const derivePublic: (key: Buffer, index: number) => Buffer;
3
+ //# sourceMappingURL=Bip32KeyDerivation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32KeyDerivation.d.ts","sourceRoot":"","sources":["../../../src/Bip32/Bip32KeyDerivation.ts"],"names":[],"mappings":"AA8HA,eAAO,MAAM,aAAa,QAAS,MAAM,SAAS,MAAM,KAAG,MAe1D,CAAC;AAWF,eAAO,MAAM,YAAY,QAAS,MAAM,SAAS,MAAM,KAAG,MAuBzD,CAAC"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.derivePublic = exports.derivePrivate = void 0;
4
+ const bn_js_1 = require("bn.js");
5
+ const util_1 = require("@cardano-sdk/util");
6
+ const libsodium_wrappers_sumo_1 = require("libsodium-wrappers-sumo");
7
+ const isHardenedDerivation = (index) => index >= 2147483648;
8
+ const deriveHardened = (index, scalar, iv, chainCode) => {
9
+ const data = Buffer.allocUnsafe(1 + 64 + 4);
10
+ data.writeUInt32LE(index, 1 + 64);
11
+ scalar.copy(data, 1);
12
+ iv.copy(data, 1 + 32);
13
+ data[0] = 0x00;
14
+ const zMac = (0, libsodium_wrappers_sumo_1.crypto_auth_hmacsha512)(data, chainCode);
15
+ data[0] = 0x01;
16
+ const ccMac = (0, libsodium_wrappers_sumo_1.crypto_auth_hmacsha512)(data, chainCode);
17
+ return { ccMac, zMac };
18
+ };
19
+ const deriveSoft = (index, scalar, chainCode) => {
20
+ const data = Buffer.allocUnsafe(1 + 32 + 4);
21
+ data.writeUInt32LE(index, 1 + 32);
22
+ const vk = Buffer.from((0, libsodium_wrappers_sumo_1.crypto_scalarmult_ed25519_base_noclamp)(scalar));
23
+ vk.copy(data, 1);
24
+ data[0] = 0x02;
25
+ const zMac = (0, libsodium_wrappers_sumo_1.crypto_auth_hmacsha512)(data, chainCode);
26
+ data[0] = 0x03;
27
+ const ccMac = (0, libsodium_wrappers_sumo_1.crypto_auth_hmacsha512)(data, chainCode);
28
+ return { ccMac, zMac };
29
+ };
30
+ const truc28Mul8 = (lhs, rhs) => new bn_js_1.BN(lhs, 16, 'le').add(new bn_js_1.BN(rhs.slice(0, 28), 16, 'le').mul(new bn_js_1.BN(8))).toArrayLike(Buffer, 'le', 32);
31
+ const pointOfTrunc28Mul8 = (sk) => {
32
+ const left = new bn_js_1.BN(sk.slice(0, 28), 16, 'le').mul(new bn_js_1.BN(8)).toArrayLike(Buffer, 'le', 32);
33
+ return (0, libsodium_wrappers_sumo_1.crypto_scalarmult_ed25519_base_noclamp)(left);
34
+ };
35
+ const add = (lhs, rhs) => {
36
+ let r = new bn_js_1.BN(lhs, 16, 'le').add(new bn_js_1.BN(rhs, 16, 'le')).toArrayLike(Buffer, 'le').subarray(0, 32);
37
+ if (r.length !== 32) {
38
+ r = Buffer.from(r.toString('hex').padEnd(32, '0'), 'hex');
39
+ }
40
+ return r;
41
+ };
42
+ const derivePrivate = (key, index) => {
43
+ const kl = key.subarray(0, 32);
44
+ const kr = key.subarray(32, 64);
45
+ const cc = key.subarray(64, 96);
46
+ const { ccMac, zMac } = isHardenedDerivation(index) ? deriveHardened(index, kl, kr, cc) : deriveSoft(index, kl, cc);
47
+ const chainCode = ccMac.slice(32, 64);
48
+ const zl = zMac.slice(0, 32);
49
+ const zr = zMac.slice(32, 64);
50
+ const left = truc28Mul8(kl, zl);
51
+ const right = add(kr, zr);
52
+ return Buffer.concat([left, right, chainCode]);
53
+ };
54
+ exports.derivePrivate = derivePrivate;
55
+ const derivePublic = (key, index) => {
56
+ const pk = key.subarray(0, 32);
57
+ const cc = key.subarray(32, 64);
58
+ const data = Buffer.allocUnsafe(1 + 32 + 4);
59
+ data.writeUInt32LE(index, 1 + 32);
60
+ if (isHardenedDerivation(index))
61
+ throw new util_1.InvalidArgumentError('index', 'Public key can not be derived from a hardened index.');
62
+ pk.copy(data, 1);
63
+ data[0] = 0x02;
64
+ const z = (0, libsodium_wrappers_sumo_1.crypto_auth_hmacsha512)(data, cc);
65
+ data[0] = 0x03;
66
+ const c = (0, libsodium_wrappers_sumo_1.crypto_auth_hmacsha512)(data, cc);
67
+ const chainCode = c.slice(32, 64);
68
+ const zl = z.slice(0, 32);
69
+ const p = pointOfTrunc28Mul8(zl);
70
+ return Buffer.concat([(0, libsodium_wrappers_sumo_1.crypto_core_ed25519_add)(p, pk), chainCode]);
71
+ };
72
+ exports.derivePublic = derivePublic;
73
+ //# sourceMappingURL=Bip32KeyDerivation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32KeyDerivation.js","sourceRoot":"","sources":["../../../src/Bip32/Bip32KeyDerivation.ts"],"names":[],"mappings":";;;AAAA,iCAA2B;AAC3B,4CAAyD;AACzD,qEAIiC;AAQj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AAY,gBAuBvB"}
@@ -0,0 +1,19 @@
1
+ /// <reference types="pouchdb-core" />
2
+ /// <reference types="node" />
3
+ import { Bip32PrivateKeyHex } from '../hexTypes';
4
+ import { Bip32PublicKey } from './Bip32PublicKey';
5
+ import { Ed25519PrivateKey } from '../Ed25519e';
6
+ export declare const BIP32_ED25519_PRIVATE_KEY_LENGTH = 96;
7
+ export declare class Bip32PrivateKey {
8
+ #private;
9
+ constructor(key: Uint8Array);
10
+ static fromBip39Entropy(entropy: Buffer, password: string): Promise<Bip32PrivateKey>;
11
+ static fromBytes(key: Uint8Array): Bip32PrivateKey;
12
+ static fromHex(key: Bip32PrivateKeyHex): Bip32PrivateKey;
13
+ derive(derivationIndices: number[]): Promise<Bip32PrivateKey>;
14
+ toRawKey(): Ed25519PrivateKey;
15
+ toPublic(): Promise<Bip32PublicKey>;
16
+ bytes(): Uint8Array;
17
+ hex(): Bip32PrivateKeyHex;
18
+ }
19
+ //# sourceMappingURL=Bip32PrivateKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32PrivateKey.d.ts","sourceRoot":"","sources":["../../../src/Bip32/Bip32PrivateKey.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAuC,iBAAiB,EAAqC,MAAM,aAAa,CAAC;AAqCxH,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAUnD,qBAAa,eAAe;;gBAQd,GAAG,EAAE,UAAU;IAkB3B,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBpF,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU;IAchC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB;IA2BhC,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAcnE,QAAQ,IAAI,iBAAiB;IASvB,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAazC,KAAK,IAAI,UAAU;IAOnB,GAAG,IAAI,kBAAkB;CAG1B"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
34
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
+ };
36
+ var _Bip32PrivateKey_key;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.Bip32PrivateKey = exports.BIP32_ED25519_PRIVATE_KEY_LENGTH = void 0;
39
+ const Bip32KeyDerivation = __importStar(require("./Bip32KeyDerivation"));
40
+ const hexTypes_1 = require("../hexTypes");
41
+ const Bip32PublicKey_1 = require("./Bip32PublicKey");
42
+ const Ed25519e_1 = require("../Ed25519e");
43
+ const util_1 = require("@cardano-sdk/util");
44
+ const libsodium_wrappers_sumo_1 = require("libsodium-wrappers-sumo");
45
+ const pbkdf2_1 = require("pbkdf2");
46
+ const SCALAR_INDEX = 0;
47
+ const SCALAR_SIZE = 32;
48
+ const PBKDF2_ITERATIONS = 4096;
49
+ const PBKDF2_KEY_SIZE = 96;
50
+ const PBKDF2_DIGEST_ALGORITHM = 'sha512';
51
+ const CHAIN_CODE_INDEX = 64;
52
+ const CHAIN_CODE_SIZE = 32;
53
+ const clampScalar = (scalar) => {
54
+ scalar[0] &= 248;
55
+ scalar[31] &= 31;
56
+ scalar[31] |= 64;
57
+ return scalar;
58
+ };
59
+ const extendedScalar = (extendedKey) => extendedKey.slice(SCALAR_INDEX, SCALAR_SIZE);
60
+ exports.BIP32_ED25519_PRIVATE_KEY_LENGTH = 96;
61
+ class Bip32PrivateKey {
62
+ constructor(key) {
63
+ _Bip32PrivateKey_key.set(this, void 0);
64
+ __classPrivateFieldSet(this, _Bip32PrivateKey_key, key, "f");
65
+ }
66
+ static fromBip39Entropy(entropy, password) {
67
+ return new Promise((resolve, reject) => {
68
+ (0, pbkdf2_1.pbkdf2)(password, entropy, PBKDF2_ITERATIONS, PBKDF2_KEY_SIZE, PBKDF2_DIGEST_ALGORITHM, (err, xprv) => {
69
+ if (err) {
70
+ reject(err);
71
+ }
72
+ xprv = clampScalar(xprv);
73
+ resolve(Bip32PrivateKey.fromBytes(xprv));
74
+ });
75
+ });
76
+ }
77
+ static fromBytes(key) {
78
+ if (key.length !== exports.BIP32_ED25519_PRIVATE_KEY_LENGTH)
79
+ throw new util_1.InvalidArgumentError('key', `Key should be ${Ed25519e_1.NORMAL_ED25519_PRIVATE_KEY_LENGTH} bytes; however ${key.length} bytes were provided.`);
80
+ return new Bip32PrivateKey(key);
81
+ }
82
+ static fromHex(key) {
83
+ return Bip32PrivateKey.fromBytes(Buffer.from(key, 'hex'));
84
+ }
85
+ async derive(derivationIndices) {
86
+ await libsodium_wrappers_sumo_1.ready;
87
+ let key = Buffer.from(__classPrivateFieldGet(this, _Bip32PrivateKey_key, "f"));
88
+ for (const index of derivationIndices) {
89
+ key = Bip32KeyDerivation.derivePrivate(key, index);
90
+ }
91
+ return Bip32PrivateKey.fromBytes(key);
92
+ }
93
+ toRawKey() {
94
+ return Ed25519e_1.Ed25519PrivateKey.fromExtendedBytes(__classPrivateFieldGet(this, _Bip32PrivateKey_key, "f").slice(0, Ed25519e_1.EXTENDED_ED25519_PRIVATE_KEY_LENGTH));
95
+ }
96
+ async toPublic() {
97
+ await libsodium_wrappers_sumo_1.ready;
98
+ const scalar = extendedScalar(__classPrivateFieldGet(this, _Bip32PrivateKey_key, "f").slice(0, Ed25519e_1.EXTENDED_ED25519_PRIVATE_KEY_LENGTH));
99
+ const publicKey = (0, libsodium_wrappers_sumo_1.crypto_scalarmult_ed25519_base_noclamp)(scalar);
100
+ return Bip32PublicKey_1.Bip32PublicKey.fromBytes(Buffer.concat([publicKey, __classPrivateFieldGet(this, _Bip32PrivateKey_key, "f").slice(CHAIN_CODE_INDEX, CHAIN_CODE_INDEX + CHAIN_CODE_SIZE)]));
101
+ }
102
+ bytes() {
103
+ return __classPrivateFieldGet(this, _Bip32PrivateKey_key, "f");
104
+ }
105
+ hex() {
106
+ return (0, hexTypes_1.Bip32PrivateKeyHex)(Buffer.from(__classPrivateFieldGet(this, _Bip32PrivateKey_key, "f")).toString('hex'));
107
+ }
108
+ }
109
+ exports.Bip32PrivateKey = Bip32PrivateKey;
110
+ _Bip32PrivateKey_key = new WeakMap();
111
+ //# sourceMappingURL=Bip32PrivateKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32PrivateKey.js","sourceRoot":"","sources":["../../../src/Bip32/Bip32PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yEAA2D;AAC3D,0CAAiD;AACjD,qDAAkD;AAClD,0CAAwH;AACxH,4CAAyD;AACzD,qEAAwF;AACxF,mCAAgC;AAEhC,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,uBAAuB,GAAG,QAAQ,CAAC;AACzC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AAW3B,MAAM,WAAW,GAAG,CAAC,MAAc,EAAU,EAAE;IAC7C,MAAM,CAAC,CAAC,CAAC,IAAI,GAAW,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAW,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAQF,MAAM,cAAc,GAAG,CAAC,WAAuB,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AAEpF,QAAA,gCAAgC,GAAG,EAAE,CAAC;AAUnD,MAAa,eAAe;IAQ1B,YAAY,GAAe;QAP3B,uCAA0B;QAQxB,uBAAA,IAAI,wBAAQ,GAAG,MAAA,CAAC;IAClB,CAAC;IAgBD,MAAM,CAAC,gBAAgB,CAAC,OAAe,EAAE,QA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,IAAI,4BAAK,CAAC,KAAK,CAAC,CAAC,EAAE,8CAAmC,CAAC,CAAC,CAAC;IACtG,CAAC;IAOD,KAAK,CAAC,QAAQ;QACZ,MAAM,+BAAK,CAAC;QACZ,MAAM,MAAM,GAAG,cAAc,CAAC,uBAAA,IAAI,4BAAK,CAAC,KAAK,CAAC,CAAC,EAAE,8CAAmC,CAAC,CAAC,CAAC;QACvF,MAAM,SAAS,GAAG,IAAA,gEAAsC,EAAC,MAAM,CAAC,CAAC;QAEjE,OAAO,+BAAc,CAAC,SAAS,CAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,uBAAA,IAAI,4BAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,eAAe,CAAC,CAAC,CAAC,CAClG,CAAC;IACJ,CAAC;IAKD,KAAK;QACH,OAAO,uBAAA,IAAI,4BAAK,CAAC;IACnB,CAAC;IAKD,GAAG;QACD,OAAO,IAAA,6BAAkB,EAAC,MAAM,CAAC,IAAI,CAAC,uBAAA,IAAI,4BAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,CAAC;CACF;AAnID,0CAmIC"}
@@ -0,0 +1,14 @@
1
+ import { Bip32PublicKeyHex } from '../hexTypes';
2
+ import { Ed25519PublicKey } from '../Ed25519e';
3
+ export declare const BIP32_ED25519_PUBLIC_KEY_LENGTH = 64;
4
+ export declare class Bip32PublicKey {
5
+ #private;
6
+ private constructor();
7
+ static fromBytes(key: Uint8Array): Bip32PublicKey;
8
+ static fromHex(key: Bip32PublicKeyHex): Bip32PublicKey;
9
+ toRawKey(): Ed25519PublicKey;
10
+ derive(derivationIndices: number[]): Promise<Bip32PublicKey>;
11
+ bytes(): Uint8Array;
12
+ hex(): Bip32PublicKeyHex;
13
+ }
14
+ //# sourceMappingURL=Bip32PublicKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32PublicKey.d.ts","sourceRoot":"","sources":["../../../src/Bip32/Bip32PublicKey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA6B,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI1E,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAKlD,qBAAa,cAAc;;IAQzB,OAAO;IASP,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,cAAc;IAcjD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,iBAAiB,GAAG,cAAc;IAQtD,QAAQ,IAAI,gBAAgB;IAUtB,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAclE,KAAK,IAAI,UAAU;IAOnB,GAAG,IAAI,iBAAiB;CAGzB"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
34
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
+ };
36
+ var _Bip32PublicKey_key;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.Bip32PublicKey = exports.BIP32_ED25519_PUBLIC_KEY_LENGTH = void 0;
39
+ const Bip32KeyDerivation = __importStar(require("./Bip32KeyDerivation"));
40
+ const hexTypes_1 = require("../hexTypes");
41
+ const Ed25519e_1 = require("../Ed25519e");
42
+ const util_1 = require("@cardano-sdk/util");
43
+ const libsodium_wrappers_sumo_1 = require("libsodium-wrappers-sumo");
44
+ exports.BIP32_ED25519_PUBLIC_KEY_LENGTH = 64;
45
+ class Bip32PublicKey {
46
+ constructor(key) {
47
+ _Bip32PublicKey_key.set(this, void 0);
48
+ __classPrivateFieldSet(this, _Bip32PublicKey_key, key, "f");
49
+ }
50
+ static fromBytes(key) {
51
+ if (key.length !== exports.BIP32_ED25519_PUBLIC_KEY_LENGTH)
52
+ throw new util_1.InvalidArgumentError('key', `Key should be ${exports.BIP32_ED25519_PUBLIC_KEY_LENGTH} bytes; however ${key.length} bytes were provided.`);
53
+ return new Bip32PublicKey(key);
54
+ }
55
+ static fromHex(key) {
56
+ return Bip32PublicKey.fromBytes(Buffer.from(key, 'hex'));
57
+ }
58
+ toRawKey() {
59
+ return Ed25519e_1.Ed25519PublicKey.fromBytes(__classPrivateFieldGet(this, _Bip32PublicKey_key, "f").slice(0, Ed25519e_1.ED25519_PUBLIC_KEY_LENGTH));
60
+ }
61
+ async derive(derivationIndices) {
62
+ await libsodium_wrappers_sumo_1.ready;
63
+ let key = Buffer.from(__classPrivateFieldGet(this, _Bip32PublicKey_key, "f"));
64
+ for (const index of derivationIndices) {
65
+ key = Bip32KeyDerivation.derivePublic(key, index);
66
+ }
67
+ return Bip32PublicKey.fromBytes(key);
68
+ }
69
+ bytes() {
70
+ return __classPrivateFieldGet(this, _Bip32PublicKey_key, "f");
71
+ }
72
+ hex() {
73
+ return (0, hexTypes_1.Bip32PublicKeyHex)(Buffer.from(__classPrivateFieldGet(this, _Bip32PublicKey_key, "f")).toString('hex'));
74
+ }
75
+ }
76
+ exports.Bip32PublicKey = Bip32PublicKey;
77
+ _Bip32PublicKey_key = new WeakMap();
78
+ //# sourceMappingURL=Bip32PublicKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bip32PublicKey.js","sourceRoot":"","sources":["../../../src/Bip32/Bip32PublicKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAA2D;AAC3D,0CAAgD;AAChD,0CAA0E;AAC1E,4CAAyD;AACzD,qEAAgD;AAEnC,QAAA,+BAA+B,GAAG,EAAE,CAAC;AAKlD,MAAa,cAAc;IAQzB,YAAoB,GAAe;QAPnC,sCAA0B;QAQxB,uBAAA,IAAI,uBAAQ,GAAG,MAAA,CAAC;IAClB,CAAC;IAOD,MAAM,CAAC,SAAS,CAAC,GAAe;QAC9B,IAAI,GAAG,CAAC,MAAM,KAAK,uCAA+B;YAChD,MAAM,IAAI,2BAAoB,CAC5B,KAAK,EACL,iBAAiB,uCAA+B,mBAAmB,GAAG,CAAC,MAAM,uBAAuB,CACrG,CAAC;QACJ,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAOD,MAAM,CAAC,OAAO,CAAC,GAAsB;QACnC,OAAO,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;IAMD,QAAQ;QACN,OAAO,2BAAgB,CAAC,SAAS,CAAC,uBAAA,IAAI,2BAAK,CAAC,KAAK,CAAC,CAAC,EAAE,oCAAyB,CAAC,CAAC,CAAC;IACnF,CAAC;IAQD,KAAK,CAAC,MAAM,CAAC,iBAA2B;QACtC,MAAM,+BAAK,CAAC;QACZ,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,uBAAA,IAAI,2BAAK,CAAC,CAAC;QAEjC,KAAK,MAAM,KAAK,IAAI,iBAAiB,EAAE;YACrC,GAAG,GAAG,kBAAkB,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SACnD;QAED,OAAO,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAKD,KAAK;QACH,OAAO,uBAAA,IAAI,2BAAK,CAAC;IACnB,CAAC;IAKD,GAAG;QACD,OAAO,IAAA,4BAAiB,EAAC,MAAM,CAAC,IAAI,CAAC,uBAAA,IAAI,2BAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;CACF;AAzED,wCAyEC"}
@@ -0,0 +1,3 @@
1
+ export * from './Bip32PrivateKey';
2
+ export * from './Bip32PublicKey';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Bip32/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Bip32PrivateKey"), exports);
18
+ __exportStar(require("./Bip32PublicKey"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Bip32/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC"}
@@ -0,0 +1,11 @@
1
+ import { Ed25519KeyHashHex } from '../hexTypes';
2
+ export declare const ED25519_PUBLIC_KEY_HASH_LENGTH = 28;
3
+ export declare class Ed25519KeyHash {
4
+ #private;
5
+ private constructor();
6
+ static fromBytes(hash: Uint8Array): Ed25519KeyHash;
7
+ static fromHex(hash: Ed25519KeyHashHex): Ed25519KeyHash;
8
+ bytes(): Uint8Array;
9
+ hex(): Ed25519KeyHashHex;
10
+ }
11
+ //# sourceMappingURL=Ed25519KeyHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519KeyHash.d.ts","sourceRoot":"","sources":["../../../src/Ed25519e/Ed25519KeyHash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAKjD,qBAAa,cAAc;;IAQzB,OAAO;IASP,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU;IAcjC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,iBAAiB;IAOtC,KAAK,IAAI,UAAU;IAOnB,GAAG,IAAI,iBAAiB;CAGzB"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Ed25519KeyHash_hash;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Ed25519KeyHash = exports.ED25519_PUBLIC_KEY_HASH_LENGTH = void 0;
16
+ const hexTypes_1 = require("../hexTypes");
17
+ const util_1 = require("@cardano-sdk/util");
18
+ exports.ED25519_PUBLIC_KEY_HASH_LENGTH = 28;
19
+ class Ed25519KeyHash {
20
+ constructor(hash) {
21
+ _Ed25519KeyHash_hash.set(this, void 0);
22
+ __classPrivateFieldSet(this, _Ed25519KeyHash_hash, hash, "f");
23
+ }
24
+ static fromBytes(hash) {
25
+ if (hash.length !== exports.ED25519_PUBLIC_KEY_HASH_LENGTH)
26
+ throw new util_1.InvalidArgumentError('hash', `Hash should be ${exports.ED25519_PUBLIC_KEY_HASH_LENGTH} bytes; however ${hash.length} bytes were provided.`);
27
+ return new Ed25519KeyHash(hash);
28
+ }
29
+ static fromHex(hash) {
30
+ return Ed25519KeyHash.fromBytes(Buffer.from(hash, 'hex'));
31
+ }
32
+ bytes() {
33
+ return __classPrivateFieldGet(this, _Ed25519KeyHash_hash, "f");
34
+ }
35
+ hex() {
36
+ return (0, hexTypes_1.Ed25519KeyHashHex)(Buffer.from(__classPrivateFieldGet(this, _Ed25519KeyHash_hash, "f")).toString('hex'));
37
+ }
38
+ }
39
+ exports.Ed25519KeyHash = Ed25519KeyHash;
40
+ _Ed25519KeyHash_hash = new WeakMap();
41
+ //# sourceMappingURL=Ed25519KeyHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519KeyHash.js","sourceRoot":"","sources":["../../../src/Ed25519e/Ed25519KeyHash.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAAgD;AAChD,4CAAyD;AAE5C,QAAA,8BAA8B,GAAG,EAAE,CAAC;AAKjD,MAAa,cAAc;IAQzB,YAAoB,IAAgB;QAPpC,uCAA2B;QAQzB,uBAAA,IAAI,wBAAS,IAAI,MAAA,CAAC;IACpB,CAAC;IAOD,MAAM,CAAC,SAAS,CAAC,IAAgB;QAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,sCAA8B;YAChD,MAAM,IAAI,2BAAoB,CAC5B,MAAM,EACN,kBAAkB,sCAA8B,mBAAmB,IAAI,CAAC,MAAM,uBAAuB,CACtG,CAAC;QACJ,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAOD,MAAM,CAAC,OAAO,CAAC,IAAuB;QACpC,OAAO,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5D,CAAC;IAKD,KAAK;QACH,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACpB,CAAC;IAKD,GAAG;QACD,OAAO,IAAA,4BAAiB,EAAC,MAAM,CAAC,IAAI,CAAC,uBAAA,IAAI,4BAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,CAAC;CACF;AAhDD,wCAgDC"}
@@ -0,0 +1,24 @@
1
+ import { Ed25519PrivateExtendedKeyHex, Ed25519PrivateNormalKeyHex } from '../hexTypes';
2
+ import { Ed25519PublicKey } from './Ed25519PublicKey';
3
+ import { Ed25519Signature } from './Ed25519Signature';
4
+ import { HexBlob } from '@cardano-sdk/util';
5
+ export declare const NORMAL_ED25519_PRIVATE_KEY_LENGTH = 32;
6
+ export declare const EXTENDED_ED25519_PRIVATE_KEY_LENGTH = 64;
7
+ export declare enum Ed25519PrivateKeyType {
8
+ Normal = "Normal",
9
+ Extended = "Extended"
10
+ }
11
+ export declare class Ed25519PrivateKey {
12
+ #private;
13
+ readonly __type: Ed25519PrivateKeyType;
14
+ private constructor();
15
+ toPublic(): Promise<Ed25519PublicKey>;
16
+ sign(message: HexBlob): Promise<Ed25519Signature>;
17
+ static fromNormalBytes(keyMaterial: Uint8Array): Ed25519PrivateKey;
18
+ static fromExtendedBytes(keyMaterial: Uint8Array): Ed25519PrivateKey;
19
+ static fromNormalHex(keyMaterial: Ed25519PrivateNormalKeyHex): Ed25519PrivateKey;
20
+ static fromExtendedHex(keyMaterial: Ed25519PrivateExtendedKeyHex): Ed25519PrivateKey;
21
+ bytes(): Uint8Array;
22
+ hex(): Ed25519PrivateNormalKeyHex | Ed25519PrivateExtendedKeyHex;
23
+ }
24
+ //# sourceMappingURL=Ed25519PrivateKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519PrivateKey.d.ts","sourceRoot":"","sources":["../../../src/Ed25519e/Ed25519PrivateKey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAwB,MAAM,mBAAmB,CAAC;AAiBlE,eAAO,MAAM,iCAAiC,KAAK,CAAC;AACpD,eAAO,MAAM,mCAAmC,KAAK,CAAC;AA0CtD,oBAAY,qBAAqB;IAC/B,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAKD,qBAAa,iBAAiB;;IAE5B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAQvC,OAAO;IAUD,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAgBrC,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiBvD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,UAAU,GAAG,iBAAiB;IAelE,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,UAAU,GAAG,iBAAiB;IAcpE,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,0BAA0B,GAAG,iBAAiB;IAShF,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,4BAA4B,GAAG,iBAAiB;IAOpF,KAAK,IAAI,UAAU;IAOnB,GAAG,IAAI,0BAA0B,GAAG,4BAA4B;CAKjE"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Ed25519PrivateKey_keyMaterial;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Ed25519PrivateKey = exports.Ed25519PrivateKeyType = exports.EXTENDED_ED25519_PRIVATE_KEY_LENGTH = exports.NORMAL_ED25519_PRIVATE_KEY_LENGTH = void 0;
16
+ const hexTypes_1 = require("../hexTypes");
17
+ const Ed25519PublicKey_1 = require("./Ed25519PublicKey");
18
+ const Ed25519Signature_1 = require("./Ed25519Signature");
19
+ const util_1 = require("@cardano-sdk/util");
20
+ const libsodium_wrappers_sumo_1 = require("libsodium-wrappers-sumo");
21
+ const SCALAR_INDEX = 0;
22
+ const SCALAR_SIZE = 32;
23
+ const IV_INDEX = 32;
24
+ const IV_SIZE = 32;
25
+ exports.NORMAL_ED25519_PRIVATE_KEY_LENGTH = 32;
26
+ exports.EXTENDED_ED25519_PRIVATE_KEY_LENGTH = 64;
27
+ const extendedScalar = (extendedKey) => extendedKey.slice(SCALAR_INDEX, SCALAR_SIZE);
28
+ const extendedIv = (extendedKey) => extendedKey.slice(IV_INDEX, IV_INDEX + IV_SIZE);
29
+ const signExtendedDetached = (extendedKey, message) => {
30
+ const scalar = extendedScalar(extendedKey);
31
+ const publicKey = (0, libsodium_wrappers_sumo_1.crypto_scalarmult_ed25519_base_noclamp)(scalar);
32
+ const nonce = (0, libsodium_wrappers_sumo_1.crypto_core_ed25519_scalar_reduce)((0, libsodium_wrappers_sumo_1.crypto_hash_sha512)(Buffer.concat([extendedIv(extendedKey), message])));
33
+ const r = (0, libsodium_wrappers_sumo_1.crypto_scalarmult_ed25519_base_noclamp)(nonce);
34
+ let hram = (0, libsodium_wrappers_sumo_1.crypto_hash_sha512)(Buffer.concat([r, publicKey, message]));
35
+ hram = (0, libsodium_wrappers_sumo_1.crypto_core_ed25519_scalar_reduce)(hram);
36
+ return Buffer.concat([r, (0, libsodium_wrappers_sumo_1.crypto_core_ed25519_scalar_add)((0, libsodium_wrappers_sumo_1.crypto_core_ed25519_scalar_mul)(hram, scalar), nonce)]);
37
+ };
38
+ var Ed25519PrivateKeyType;
39
+ (function (Ed25519PrivateKeyType) {
40
+ Ed25519PrivateKeyType["Normal"] = "Normal";
41
+ Ed25519PrivateKeyType["Extended"] = "Extended";
42
+ })(Ed25519PrivateKeyType = exports.Ed25519PrivateKeyType || (exports.Ed25519PrivateKeyType = {}));
43
+ class Ed25519PrivateKey {
44
+ constructor(keyMaterial, type) {
45
+ _Ed25519PrivateKey_keyMaterial.set(this, void 0);
46
+ __classPrivateFieldSet(this, _Ed25519PrivateKey_keyMaterial, keyMaterial, "f");
47
+ this.__type = type;
48
+ }
49
+ async toPublic() {
50
+ await libsodium_wrappers_sumo_1.ready;
51
+ return Ed25519PublicKey_1.Ed25519PublicKey.fromBytes(this.__type === Ed25519PrivateKeyType.Extended
52
+ ? (0, libsodium_wrappers_sumo_1.crypto_scalarmult_ed25519_base_noclamp)(extendedScalar(__classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f")))
53
+ : (0, libsodium_wrappers_sumo_1.crypto_sign_seed_keypair)(__classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f")).publicKey);
54
+ }
55
+ async sign(message) {
56
+ await libsodium_wrappers_sumo_1.ready;
57
+ return Ed25519Signature_1.Ed25519Signature.fromBytes(this.__type === Ed25519PrivateKeyType.Extended
58
+ ? signExtendedDetached(__classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f"), Buffer.from(message, 'hex'))
59
+ : (0, libsodium_wrappers_sumo_1.crypto_sign_detached)(Buffer.from(message, 'hex'), Buffer.concat([__classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f"), (await this.toPublic()).bytes()])));
60
+ }
61
+ static fromNormalBytes(keyMaterial) {
62
+ if (keyMaterial.length !== exports.NORMAL_ED25519_PRIVATE_KEY_LENGTH)
63
+ throw new util_1.InvalidArgumentError('keyMaterial', `Key should be ${exports.NORMAL_ED25519_PRIVATE_KEY_LENGTH} bytes; however ${keyMaterial.length} bytes were provided.`);
64
+ return new Ed25519PrivateKey(keyMaterial, Ed25519PrivateKeyType.Normal);
65
+ }
66
+ static fromExtendedBytes(keyMaterial) {
67
+ if (keyMaterial.length !== exports.EXTENDED_ED25519_PRIVATE_KEY_LENGTH)
68
+ throw new util_1.InvalidArgumentError('keyMaterial', `Key should be ${exports.EXTENDED_ED25519_PRIVATE_KEY_LENGTH} bytes; however ${keyMaterial.length} bytes were provided.`);
69
+ return new Ed25519PrivateKey(keyMaterial, Ed25519PrivateKeyType.Extended);
70
+ }
71
+ static fromNormalHex(keyMaterial) {
72
+ return Ed25519PrivateKey.fromNormalBytes(Buffer.from(keyMaterial, 'hex'));
73
+ }
74
+ static fromExtendedHex(keyMaterial) {
75
+ return Ed25519PrivateKey.fromExtendedBytes(Buffer.from(keyMaterial, 'hex'));
76
+ }
77
+ bytes() {
78
+ return __classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f");
79
+ }
80
+ hex() {
81
+ return this.__type === Ed25519PrivateKeyType.Extended
82
+ ? (0, hexTypes_1.Ed25519PrivateExtendedKeyHex)(Buffer.from(__classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f")).toString('hex'))
83
+ : (0, hexTypes_1.Ed25519PrivateNormalKeyHex)(Buffer.from(__classPrivateFieldGet(this, _Ed25519PrivateKey_keyMaterial, "f")).toString('hex'));
84
+ }
85
+ }
86
+ exports.Ed25519PrivateKey = Ed25519PrivateKey;
87
+ _Ed25519PrivateKey_keyMaterial = new WeakMap();
88
+ //# sourceMappingURL=Ed25519PrivateKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519PrivateKey.js","sourceRoot":"","sources":["../../../src/Ed25519e/Ed25519PrivateKey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0CAAuF;AACvF,yDAAsD;AACtD,yDAAsD;AACtD,4CAAkE;AAClE,qEASiC;AAEjC,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,WAAW,GAAG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ublicKeyHex } from '../hexTypes';
3
+ import { Ed25519Signature } from './Ed25519Signature';
4
+ import { HexBlob } from '@cardano-sdk/util';
5
+ export declare const ED25519_PUBLIC_KEY_LENGTH = 32;
6
+ export declare class Ed25519PublicKey {
7
+ #private;
8
+ constructor(keyMaterial: Uint8Array);
9
+ verify(signature: Ed25519Signature, message: HexBlob): Promise<boolean>;
10
+ static fromBytes(keyMaterial: Uint8Array): Ed25519PublicKey;
11
+ static fromHex(keyMaterial: Ed25519PublicKeyHex): Ed25519PublicKey;
12
+ hash(): Promise<Ed25519KeyHash>;
13
+ bytes(): Uint8Array;
14
+ hex(): Ed25519PublicKeyHex;
15
+ }
16
+ //# sourceMappingURL=Ed25519PublicKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ed25519PublicKey.d.ts","sourceRoot":"","sources":["../../../src/Ed25519e/Ed25519PublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAwB,MAAM,mBAAmB,CAAC;AAGlE,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAM5C,qBAAa,gBAAgB;;gBAQf,WAAW,EAAE,UAAU;IAY7B,MAAM,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAU7E,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,UAAU;IAcxC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,mBAAmB;IAOzC,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC;IASrC,KAAK,IAAI,UAAU;IAOnB,GAAG,IAAI,mBAAmB;CAG3B"}