@cardano-sdk/key-management 0.2.0-nightly.13 → 0.2.0-nightly.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/InMemoryKeyAgent.js +3 -3
- package/dist/cjs/KeyAgentBase.d.ts +2 -2
- package/dist/cjs/KeyAgentBase.js +8 -8
- package/dist/cjs/LedgerKeyAgent.js +1 -1
- package/dist/cjs/TrezorKeyAgent.js +1 -1
- package/dist/cjs/cip8/cip30signData.js +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/util/key.d.ts +3 -3
- package/dist/cjs/util/key.js +4 -4
- package/dist/cjs/util/mapHardwareSigningData.d.ts +3 -3
- package/dist/cjs/util/mapHardwareSigningData.js +9 -9
- package/dist/cjs/util/mapHardwareSigningData.js.map +1 -1
- package/dist/esm/InMemoryKeyAgent.js +4 -4
- package/dist/esm/KeyAgentBase.d.ts +2 -2
- package/dist/esm/KeyAgentBase.js +9 -9
- package/dist/esm/LedgerKeyAgent.js +2 -2
- package/dist/esm/TrezorKeyAgent.js +2 -2
- package/dist/esm/cip8/cip30signData.js +2 -2
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/util/key.d.ts +3 -3
- package/dist/esm/util/key.js +5 -5
- package/dist/esm/util/mapHardwareSigningData.d.ts +3 -3
- package/dist/esm/util/mapHardwareSigningData.js +10 -10
- package/dist/esm/util/mapHardwareSigningData.js.map +1 -1
- package/package.json +3 -3
|
@@ -82,7 +82,7 @@ class InMemoryKeyAgent extends KeyAgentBase_1.KeyAgentBase {
|
|
|
82
82
|
if (!validMnemonic)
|
|
83
83
|
throw new errors.InvalidMnemonicError();
|
|
84
84
|
const entropy = Buffer.from((0, util_1.mnemonicWordsToEntropy)(mnemonicWords), 'hex');
|
|
85
|
-
const rootPrivateKey = core_1.
|
|
85
|
+
const rootPrivateKey = core_1.CML.Bip32PrivateKey.from_bip39_entropy(entropy, mnemonic2ndFactorPassphrase);
|
|
86
86
|
const password = await getPasswordRethrowTypedError(getPassword);
|
|
87
87
|
const encryptedRootPrivateKey = await (0, emip3_1.emip3encrypt)(rootPrivateKey.as_bytes(), password);
|
|
88
88
|
const accountPrivateKey = (0, util_1.deriveAccountPrivateKey)({
|
|
@@ -110,7 +110,7 @@ class InMemoryKeyAgent extends KeyAgentBase_1.KeyAgentBase {
|
|
|
110
110
|
}
|
|
111
111
|
async exportExtendedKeyPair(derivationPath) {
|
|
112
112
|
const rootPrivateKey = await this.exportRootPrivateKey();
|
|
113
|
-
const cslRootPrivateKey = core_1.
|
|
113
|
+
const cslRootPrivateKey = core_1.CML.Bip32PrivateKey.from_bytes(Buffer.from(rootPrivateKey, 'hex'));
|
|
114
114
|
let cslPrivateKey = cslRootPrivateKey;
|
|
115
115
|
for (const val of derivationPath) {
|
|
116
116
|
cslPrivateKey = cslPrivateKey.derive((0, util_1.harden)(val));
|
|
@@ -131,6 +131,6 @@ _InMemoryKeyAgent_getPassword = new WeakMap(), _InMemoryKeyAgent_instances = new
|
|
|
131
131
|
catch (error) {
|
|
132
132
|
throw new errors.AuthenticationError('Failed to decrypt root private key', error);
|
|
133
133
|
}
|
|
134
|
-
return core_1.
|
|
134
|
+
return core_1.CML.Bip32PrivateKey.from_bytes(decryptedRootKeyBytes);
|
|
135
135
|
};
|
|
136
136
|
//# sourceMappingURL=InMemoryKeyAgent.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccountAddressDerivationPath, AccountKeyDerivationPath, GroupedAddress, KeyAgent, KeyAgentDependencies, SerializableKeyAgentData, SignBlobResult, SignTransactionOptions } from './types';
|
|
2
|
-
import {
|
|
2
|
+
import { CML, Cardano } from '@cardano-sdk/core';
|
|
3
3
|
export declare abstract class KeyAgentBase implements KeyAgent {
|
|
4
4
|
#private;
|
|
5
5
|
protected readonly inputResolver: Cardano.util.InputResolver;
|
|
@@ -15,6 +15,6 @@ export declare abstract class KeyAgentBase implements KeyAgent {
|
|
|
15
15
|
constructor(serializableData: SerializableKeyAgentData, { inputResolver }: KeyAgentDependencies);
|
|
16
16
|
deriveAddress({ index, type }: AccountAddressDerivationPath): Promise<GroupedAddress>;
|
|
17
17
|
derivePublicKey(derivationPath: AccountKeyDerivationPath): Promise<Cardano.Ed25519PublicKey>;
|
|
18
|
-
protected
|
|
18
|
+
protected deriveCmlPublicKey({ index, role: type }: AccountKeyDerivationPath): Promise<CML.PublicKey>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=KeyAgentBase.d.ts.map
|
package/dist/cjs/KeyAgentBase.js
CHANGED
|
@@ -43,14 +43,14 @@ class KeyAgentBase {
|
|
|
43
43
|
const knownAddress = this.knownAddresses.find((addr) => addr.type === type && addr.index === index);
|
|
44
44
|
if (knownAddress)
|
|
45
45
|
return knownAddress;
|
|
46
|
-
const derivedPublicPaymentKey = await this.
|
|
46
|
+
const derivedPublicPaymentKey = await this.deriveCmlPublicKey({
|
|
47
47
|
index,
|
|
48
48
|
role: type
|
|
49
49
|
});
|
|
50
|
-
const publicStakeKey = await this.
|
|
51
|
-
const stakeKeyCredential = core_1.
|
|
52
|
-
const address = core_1.
|
|
53
|
-
const rewardAccount = core_1.
|
|
50
|
+
const publicStakeKey = await this.deriveCmlPublicKey(util_1.STAKE_KEY_DERIVATION_PATH);
|
|
51
|
+
const stakeKeyCredential = core_1.CML.StakeCredential.from_keyhash(publicStakeKey.hash());
|
|
52
|
+
const address = core_1.CML.BaseAddress.new(this.networkId, core_1.CML.StakeCredential.from_keyhash(derivedPublicPaymentKey.hash()), stakeKeyCredential).to_address();
|
|
53
|
+
const rewardAccount = core_1.CML.RewardAddress.new(this.networkId, stakeKeyCredential).to_address();
|
|
54
54
|
const groupedAddress = {
|
|
55
55
|
accountIndex: this.accountIndex,
|
|
56
56
|
address: core_1.Cardano.Address(address.to_bech32()),
|
|
@@ -63,12 +63,12 @@ class KeyAgentBase {
|
|
|
63
63
|
return groupedAddress;
|
|
64
64
|
}
|
|
65
65
|
async derivePublicKey(derivationPath) {
|
|
66
|
-
const cslPublicKey = await this.
|
|
66
|
+
const cslPublicKey = await this.deriveCmlPublicKey(derivationPath);
|
|
67
67
|
return core_1.Cardano.Ed25519PublicKey.fromHexBlob(core_1.util.bytesToHex(cslPublicKey.as_bytes()));
|
|
68
68
|
}
|
|
69
|
-
async
|
|
69
|
+
async deriveCmlPublicKey({ index, role: type }) {
|
|
70
70
|
const accountPublicKeyBytes = Buffer.from(this.extendedAccountPublicKey, 'hex');
|
|
71
|
-
const accountPublicKey = core_1.
|
|
71
|
+
const accountPublicKey = core_1.CML.Bip32PublicKey.from_bytes(accountPublicKeyBytes);
|
|
72
72
|
return accountPublicKey.derive(type).derive(index).to_raw_key();
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -172,7 +172,7 @@ class LedgerKeyAgent extends KeyAgentBase_1.KeyAgentBase {
|
|
|
172
172
|
async signTransaction({ body }) {
|
|
173
173
|
const scope = new util_1.ManagedFreeableScope();
|
|
174
174
|
try {
|
|
175
|
-
const cslTxBody = core_1.
|
|
175
|
+
const cslTxBody = core_1.coreToCml.txBody(scope, body);
|
|
176
176
|
const ledgerTxData = await (0, util_2.txToLedger)({
|
|
177
177
|
cslTxBody,
|
|
178
178
|
inputResolver: this.inputResolver,
|
|
@@ -97,7 +97,7 @@ class TrezorKeyAgent extends KeyAgentBase_1.KeyAgentBase {
|
|
|
97
97
|
const scope = new util_1.ManagedFreeableScope();
|
|
98
98
|
try {
|
|
99
99
|
await this.isTrezorInitialized;
|
|
100
|
-
const cslTxBody = core_1.
|
|
100
|
+
const cslTxBody = core_1.coreToCml.txBody(scope, body);
|
|
101
101
|
const trezorTxData = await (0, util_2.txToTrezor)({
|
|
102
102
|
accountIndex: this.accountIndex,
|
|
103
103
|
cslTxBody,
|
|
@@ -22,7 +22,7 @@ class Cip30DataSignError extends core_1.ComposableError {
|
|
|
22
22
|
}
|
|
23
23
|
exports.Cip30DataSignError = Cip30DataSignError;
|
|
24
24
|
const getAddressBytes = (signWith) => (0, util_3.usingAutoFree)((scope) => {
|
|
25
|
-
const cslAddress = (0, core_1.
|
|
25
|
+
const cslAddress = (0, core_1.parseCmlAddress)(scope, signWith.toString());
|
|
26
26
|
if (!cslAddress) {
|
|
27
27
|
throw new Cip30DataSignError(Cip30DataSignErrorCode.AddressNotPK, 'Invalid address');
|
|
28
28
|
}
|