@cardano-sdk/key-management 0.27.11 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Bip32Account.d.ts +12 -5
- package/dist/cjs/Bip32Account.d.ts.map +1 -1
- package/dist/cjs/Bip32Account.js +41 -38
- package/dist/cjs/Bip32Account.js.map +1 -1
- package/dist/cjs/KeyAgentBase.d.ts.map +1 -1
- package/dist/cjs/KeyAgentBase.js +3 -2
- package/dist/cjs/KeyAgentBase.js.map +1 -1
- package/dist/cjs/cip8/cip30signData.js +4 -2
- package/dist/cjs/cip8/cip30signData.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/util/ownSignatureKeyPaths.d.ts +0 -1
- package/dist/cjs/util/ownSignatureKeyPaths.d.ts.map +1 -1
- package/dist/cjs/util/ownSignatureKeyPaths.js +6 -13
- package/dist/cjs/util/ownSignatureKeyPaths.js.map +1 -1
- package/dist/esm/Bip32Account.d.ts +12 -5
- package/dist/esm/Bip32Account.d.ts.map +1 -1
- package/dist/esm/Bip32Account.js +42 -16
- package/dist/esm/Bip32Account.js.map +1 -1
- package/dist/esm/KeyAgentBase.d.ts.map +1 -1
- package/dist/esm/KeyAgentBase.js +3 -2
- package/dist/esm/KeyAgentBase.js.map +1 -1
- package/dist/esm/cip8/cip30signData.js +4 -2
- package/dist/esm/cip8/cip30signData.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/util/ownSignatureKeyPaths.d.ts +0 -1
- package/dist/esm/util/ownSignatureKeyPaths.d.ts.map +1 -1
- package/dist/esm/util/ownSignatureKeyPaths.js +7 -14
- package/dist/esm/util/ownSignatureKeyPaths.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import * as Crypto from '@cardano-sdk/crypto';
|
|
2
2
|
import { AccountAddressDerivationPath, AccountKeyDerivationPath, AsyncKeyAgent, GroupedAddress } from './types';
|
|
3
|
+
import { Bip32Ed25519, Blake2b } from '@cardano-sdk/crypto';
|
|
3
4
|
import { Cardano } from '@cardano-sdk/core';
|
|
4
5
|
declare type Bip32AccountProps = {
|
|
5
6
|
extendedAccountPublicKey: Crypto.Bip32PublicKeyHex;
|
|
6
7
|
accountIndex: number;
|
|
7
8
|
chainId: Cardano.ChainId;
|
|
8
9
|
};
|
|
10
|
+
export declare type Bip32AccountDependencies = {
|
|
11
|
+
bip32Ed25519: Pick<Bip32Ed25519, 'derivePublicKey'>;
|
|
12
|
+
blake2b: Blake2b;
|
|
13
|
+
};
|
|
9
14
|
export declare class Bip32Account {
|
|
10
|
-
|
|
15
|
+
#private;
|
|
16
|
+
readonly extendedAccountPublicKeyHex: Crypto.Bip32PublicKeyHex;
|
|
11
17
|
readonly chainId: Cardano.ChainId;
|
|
12
18
|
readonly accountIndex: number;
|
|
13
|
-
constructor({ extendedAccountPublicKey, chainId, accountIndex }: Bip32AccountProps);
|
|
14
|
-
derivePublicKey(derivationPath: AccountKeyDerivationPath):
|
|
15
|
-
deriveAddress(paymentKeyDerivationPath: AccountAddressDerivationPath, stakeKeyDerivationIndex: number):
|
|
16
|
-
static
|
|
19
|
+
constructor({ extendedAccountPublicKey, chainId, accountIndex }: Bip32AccountProps, dependencies: Bip32AccountDependencies);
|
|
20
|
+
derivePublicKey(derivationPath: AccountKeyDerivationPath): Crypto.Ed25519PublicKeyHex;
|
|
21
|
+
deriveAddress(paymentKeyDerivationPath: AccountAddressDerivationPath, stakeKeyDerivationIndex: number): GroupedAddress;
|
|
22
|
+
static createDefaultDependencies(): Promise<Bip32AccountDependencies>;
|
|
23
|
+
static fromAsyncKeyAgent(keyAgent: AsyncKeyAgent, dependencies?: Bip32AccountDependencies): Promise<Bip32Account>;
|
|
17
24
|
}
|
|
18
25
|
export {};
|
|
19
26
|
//# sourceMappingURL=Bip32Account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bip32Account.d.ts","sourceRoot":"","sources":["../../src/Bip32Account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EACb,cAAc,EAEf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Bip32Account.d.ts","sourceRoot":"","sources":["../../src/Bip32Account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EACb,cAAc,EAEf,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,YAAY,EACZ,OAAO,EAIR,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,aAAK,iBAAiB,GAAG;IACvB,wBAAwB,EAAE,MAAM,CAAC,iBAAiB,CAAC;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;CAC1B,CAAC;AAEF,oBAAY,wBAAwB,GAAG;IACrC,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACpD,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAGF,qBAAa,YAAY;;IACvB,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC,iBAAiB,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;gBAM5B,EAAE,wBAAwB,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,iBAAiB,EACtE,YAAY,EAAE,wBAAwB;IASxC,eAAe,CAAC,cAAc,EAAE,wBAAwB;IAQxD,aAAa,CACX,wBAAwB,EAAE,4BAA4B,EACtD,uBAAuB,EAAE,MAAM,GAC9B,cAAc;WAoCJ,yBAAyB,IAAI,OAAO,CAAC,wBAAwB,CAAC;WAY9D,iBAAiB,CAC5B,QAAQ,EAAE,aAAa,EACvB,YAAY,CAAC,EAAE,wBAAwB,GACtC,OAAO,CAAC,YAAY,CAAC;CAWzB"}
|
package/dist/cjs/Bip32Account.js
CHANGED
|
@@ -1,57 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
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;
|
|
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);
|
|
24
12
|
};
|
|
13
|
+
var _Bip32Account_bip32Ed25519, _Bip32Account_blake2b;
|
|
25
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
15
|
exports.Bip32Account = void 0;
|
|
27
|
-
const Crypto = __importStar(require("@cardano-sdk/crypto"));
|
|
28
16
|
const types_1 = require("./types");
|
|
29
|
-
const core_1 = require("@cardano-sdk/core");
|
|
30
17
|
const crypto_1 = require("@cardano-sdk/crypto");
|
|
18
|
+
const core_1 = require("@cardano-sdk/core");
|
|
31
19
|
class Bip32Account {
|
|
32
|
-
constructor({ extendedAccountPublicKey, chainId, accountIndex }) {
|
|
33
|
-
this
|
|
20
|
+
constructor({ extendedAccountPublicKey, chainId, accountIndex }, dependencies) {
|
|
21
|
+
_Bip32Account_bip32Ed25519.set(this, void 0);
|
|
22
|
+
_Bip32Account_blake2b.set(this, void 0);
|
|
23
|
+
this.extendedAccountPublicKeyHex = extendedAccountPublicKey;
|
|
24
|
+
__classPrivateFieldSet(this, _Bip32Account_bip32Ed25519, dependencies.bip32Ed25519, "f");
|
|
25
|
+
__classPrivateFieldSet(this, _Bip32Account_blake2b, dependencies.blake2b, "f");
|
|
34
26
|
this.chainId = chainId;
|
|
35
27
|
this.accountIndex = accountIndex;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
29
|
+
derivePublicKey(derivationPath) {
|
|
30
|
+
const extendedKey = __classPrivateFieldGet(this, _Bip32Account_bip32Ed25519, "f").derivePublicKey(this.extendedAccountPublicKeyHex, [
|
|
31
|
+
derivationPath.role,
|
|
32
|
+
derivationPath.index
|
|
33
|
+
]);
|
|
34
|
+
return crypto_1.Ed25519PublicKeyHex.fromBip32PublicKey(extendedKey);
|
|
40
35
|
}
|
|
41
|
-
|
|
36
|
+
deriveAddress(paymentKeyDerivationPath, stakeKeyDerivationIndex) {
|
|
42
37
|
const stakeKeyDerivationPath = {
|
|
43
38
|
index: stakeKeyDerivationIndex,
|
|
44
39
|
role: types_1.KeyRole.Stake
|
|
45
40
|
};
|
|
46
|
-
const derivedPublicPaymentKey =
|
|
41
|
+
const derivedPublicPaymentKey = this.derivePublicKey({
|
|
47
42
|
index: paymentKeyDerivationPath.index,
|
|
48
43
|
role: Number(paymentKeyDerivationPath.type)
|
|
49
44
|
});
|
|
50
|
-
const derivedPublicPaymentKeyHash =
|
|
51
|
-
const publicStakeKey =
|
|
52
|
-
const publicStakeKeyHash =
|
|
53
|
-
const stakeCredential = { hash:
|
|
54
|
-
const address = core_1.Cardano.BaseAddress.fromCredentials(this.chainId.networkId, { hash:
|
|
45
|
+
const derivedPublicPaymentKeyHash = __classPrivateFieldGet(this, _Bip32Account_blake2b, "f").hash(derivedPublicPaymentKey, crypto_1.BIP32_PUBLIC_KEY_HASH_LENGTH);
|
|
46
|
+
const publicStakeKey = this.derivePublicKey(stakeKeyDerivationPath);
|
|
47
|
+
const publicStakeKeyHash = __classPrivateFieldGet(this, _Bip32Account_blake2b, "f").hash(publicStakeKey, crypto_1.BIP32_PUBLIC_KEY_HASH_LENGTH);
|
|
48
|
+
const stakeCredential = { hash: publicStakeKeyHash, type: core_1.Cardano.CredentialType.KeyHash };
|
|
49
|
+
const address = core_1.Cardano.BaseAddress.fromCredentials(this.chainId.networkId, { hash: derivedPublicPaymentKeyHash, type: core_1.Cardano.CredentialType.KeyHash }, stakeCredential).toAddress();
|
|
55
50
|
const rewardAccount = core_1.Cardano.RewardAddress.fromCredentials(this.chainId.networkId, stakeCredential).toAddress();
|
|
56
51
|
return {
|
|
57
52
|
accountIndex: this.accountIndex,
|
|
@@ -62,13 +57,21 @@ class Bip32Account {
|
|
|
62
57
|
...paymentKeyDerivationPath
|
|
63
58
|
};
|
|
64
59
|
}
|
|
65
|
-
static async
|
|
60
|
+
static async createDefaultDependencies() {
|
|
61
|
+
return {
|
|
62
|
+
bip32Ed25519: await crypto_1.SodiumBip32Ed25519.create(),
|
|
63
|
+
blake2b: crypto_1.blake2b
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static async fromAsyncKeyAgent(keyAgent, dependencies) {
|
|
67
|
+
dependencies ||= await Bip32Account.createDefaultDependencies();
|
|
66
68
|
return new Bip32Account({
|
|
67
69
|
accountIndex: await keyAgent.getAccountIndex(),
|
|
68
70
|
chainId: await keyAgent.getChainId(),
|
|
69
71
|
extendedAccountPublicKey: await keyAgent.getExtendedAccountPublicKey()
|
|
70
|
-
});
|
|
72
|
+
}, dependencies);
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
exports.Bip32Account = Bip32Account;
|
|
76
|
+
_Bip32Account_bip32Ed25519 = new WeakMap(), _Bip32Account_blake2b = new WeakMap();
|
|
74
77
|
//# sourceMappingURL=Bip32Account.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bip32Account.js","sourceRoot":"","sources":["../../src/Bip32Account.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Bip32Account.js","sourceRoot":"","sources":["../../src/Bip32Account.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mCAMiB;AACjB,gDAO6B;AAC7B,4CAA4C;AAc5C,MAAa,YAAY;IAQvB,YACE,EAAE,wBAAwB,EAAE,OAAO,EAAE,YAAY,EAAqB,EACtE,YAAsC;QANxC,6CAAiE;QACjE,wCAA2B;QAOzB,IAAI,CAAC,2BAA2B,GAAG,wBAAwB,CAAC;QAC5D,uBAAA,IAAI,8BAAiB,YAAY,CAAC,YAAY,MAAA,CAAC;QAC/C,uBAAA,IAAI,yBAAY,YAAY,CAAC,OAAO,MAAA,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,Y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kBAAkB,CAAC;IAChF,QAAQ,CAAC,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC;IACnE,QAAQ,CAAC,eAAe,CACtB,MAAM,EAAE,aAAa,CAAC,eAAe,EACrC,OAAO,EAAE,sBAAsB,EAC/B,sBAAsB,CAAC,EAAE,sBAAsB,GAC9C,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;gBAElB,gBAAgB,EAAE,wBAAwB,EAAE,EAAE,YAAY,EAAE,EAAE,oBAAoB;IAOxF,aAAa,CACjB,wBAAwB,EAAE,4BAA4B,EACtD,uBAAuB,EAAE,MAAM,GAC9B,OAAO,CAAC,cAAc,CAAC;IAIpB,eAAe,CAAC,cAAc,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC;CAGrG"}
|
package/dist/cjs/KeyAgentBase.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.KeyAgentBase = void 0;
|
|
16
16
|
const types_1 = require("./types");
|
|
17
17
|
const Bip32Account_1 = require("./Bip32Account");
|
|
18
|
+
const crypto_1 = require("@cardano-sdk/crypto");
|
|
18
19
|
class KeyAgentBase {
|
|
19
20
|
constructor(serializableData, { bip32Ed25519 }) {
|
|
20
21
|
_KeyAgentBase_serializableData.set(this, void 0);
|
|
@@ -22,7 +23,7 @@ class KeyAgentBase {
|
|
|
22
23
|
_KeyAgentBase_account.set(this, void 0);
|
|
23
24
|
__classPrivateFieldSet(this, _KeyAgentBase_serializableData, serializableData, "f");
|
|
24
25
|
__classPrivateFieldSet(this, _KeyAgentBase_bip32Ed25519, bip32Ed25519, "f");
|
|
25
|
-
__classPrivateFieldSet(this, _KeyAgentBase_account, new Bip32Account_1.Bip32Account(serializableData), "f");
|
|
26
|
+
__classPrivateFieldSet(this, _KeyAgentBase_account, new Bip32Account_1.Bip32Account(serializableData, { bip32Ed25519, blake2b: crypto_1.blake2b }), "f");
|
|
26
27
|
}
|
|
27
28
|
get serializableData() {
|
|
28
29
|
return __classPrivateFieldGet(this, _KeyAgentBase_serializableData, "f");
|
|
@@ -46,7 +47,7 @@ class KeyAgentBase {
|
|
|
46
47
|
return __classPrivateFieldGet(this, _KeyAgentBase_account, "f").deriveAddress(paymentKeyDerivationPath, stakeKeyDerivationIndex);
|
|
47
48
|
}
|
|
48
49
|
async derivePublicKey(derivationPath) {
|
|
49
|
-
return
|
|
50
|
+
return __classPrivateFieldGet(this, _KeyAgentBase_account, "f").derivePublicKey(derivationPath);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
exports.KeyAgentBase = KeyAgentBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyAgentBase.js","sourceRoot":"","sources":["../../src/KeyAgentBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mCAWiB;AACjB,iDAA8C;
|
|
1
|
+
{"version":3,"file":"KeyAgentBase.js","sourceRoot":"","sources":["../../src/KeyAgentBase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mCAWiB;AACjB,iDAA8C;AAK9C,gDAA8C;AAE9C,MAAsB,YAAY;IAkChC,YAAY,gBAA0C,EAAE,EAAE,YAAY,EAAwB;QAjC9F,iDAAqD;QACrD,6CAA4C;QAC5C,wCAAgC;QAgC9B,uBAAA,IAAI,kCAAqB,gBAAgB,MAAA,CAAC;QAC1C,uBAAA,IAAI,8BAAiB,YAAY,MAAA,CAAC;QAClC,uBAAA,IAAI,yBAAY,IAAI,2BAAY,CAAC,gBAAgB,EAAE,EAAE,YAAY,EAAE,OAAO,EAAP,gBAAO,EAAE,CAAC,MAAA,CAAC;IAChF,CAAC;IAjCD,IAAI,gBAAgB;QAClB,OAAO,uBAAA,IAAI,sCAAkB,CAAC;IAChC,CAAC;IACD,IAAI,wBAAwB;QAC1B,OAAO,IAAI,CAAC,gBAAgB,CAAC,wBAAwB,CAAC;IACxD,CAAC;IACD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;IACvC,CAAC;IACD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC;IAC5C,CAAC;IACD,IAAI,YAAY;QACd,OAAO,uBAAA,IAAI,kCAAc,CAAC;IAC5B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,IAAI,kBAAU,CAAC,QAAQ,CAAC;IAC9D,CAAC;IAkBD,KAAK,CAAC,aAAa,CACjB,wBAAsD,EACtD,uBAA+B;QAE/B,OAAO,uBAAA,IAAI,6BAAS,CAAC,aAAa,CAAC,wBAAwB,EAAE,uBAAuB,CAAC,CAAC;IACxF,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,cAAwC;QAC5D,OAAO,uBAAA,IAAI,6BAAS,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IACvD,CAAC;CACF;AAnDD,oCAmDC"}
|
|
@@ -64,7 +64,7 @@ const getDerivationPath = async (signWith, knownAddresses, dRepKeyHash) => {
|
|
|
64
64
|
if (isPaymentAddress(signWith)) {
|
|
65
65
|
const drepAddr = core_1.Cardano.Address.fromString(signWith);
|
|
66
66
|
if (drepAddr?.getType() === core_1.Cardano.AddressType.EnterpriseKey &&
|
|
67
|
-
drepAddr?.getProps().paymentPart?.hash ===
|
|
67
|
+
drepAddr?.getProps().paymentPart?.hash === dRepKeyHash) {
|
|
68
68
|
return util_3.DREP_KEY_DERIVATION_PATH;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -99,7 +99,9 @@ const createCoseKey = (addressBytes, publicKey) => {
|
|
|
99
99
|
};
|
|
100
100
|
exports.createCoseKey = createCoseKey;
|
|
101
101
|
const cip30signData = async (keyAgent, { knownAddresses, signWith, payload }) => {
|
|
102
|
-
const dRepKeyHash =
|
|
102
|
+
const dRepKeyHash = Crypto.Ed25519PublicKey.fromHex(await keyAgent.derivePublicKey(util_3.DREP_KEY_DERIVATION_PATH))
|
|
103
|
+
.hash()
|
|
104
|
+
.hex();
|
|
103
105
|
const addressBytes = (0, exports.getAddressBytes)(signWith);
|
|
104
106
|
const derivationPath = await getDerivationPath(signWith, knownAddresses, dRepKeyHash);
|
|
105
107
|
const builder = cardano_message_signing_nodejs_1.COSESign1Builder.new(cardano_message_signing_nodejs_1.Headers.new(cardano_message_signing_nodejs_1.ProtectedHeaderMap.new(createSigStructureHeaders(addressBytes)), cardano_message_signing_nodejs_1.HeaderMap.new()), Buffer.from(payload, 'hex'), false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cip30signData.js","sourceRoot":"","sources":["../../../src/cip8/cip30signData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8C;AAE9C,2FAYgD;AAChD,4CAAkD;AAGlD,4CAA6D;AAC7D,iCAAmC;AACnC,kCAA8E;AAS9E,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,yFAAmB,CAAA;IACnB,mFAAgB,CAAA;IAChB,mFAAgB,CAAA;AAClB,CAAC,EAJW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAIjC;AAED,MAAa,kBAAyC,SAAQ,sBAA2B;IACvF,YAA4B,IAA4B,EAAkB,IAAY,EAAE,UAAuB;QAC7G,KAAK,CAAC,uBAAuB,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;QADvB,SAAI,GAAJ,IAAI,CAAwB;QAAkB,SAAI,GAAJ,IAAI,CAAQ;IAEtF,CAAC;CACF;AAJD,gDAIC;AAEM,MAAM,eAAe,GAAG,CAAC,QAAwD,EAAE,EAAE;IAC1F,MAAM,OAAO,GAAG,cAAO,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAErD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,kBAAkB,CAAC,sBAAsB,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;KACtF;IAED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