@docknetwork/wallet-sdk-wasm 1.5.9 → 1.5.10
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/lib/core/format-utils.js +0 -28
- package/lib/core/format-utils.mjs +1 -24
- package/lib/core/validation.js +1 -24
- package/lib/core/validation.mjs +2 -21
- package/lib/index.js +13 -23
- package/lib/index.mjs +13 -23
- package/lib/rpc-server.js +13 -23
- package/lib/rpc-server.mjs +13 -23
- package/lib/rpc-util.js +14 -0
- package/lib/rpc-util.mjs +14 -0
- package/lib/services/blockchain/index.js +3 -6
- package/lib/services/blockchain/index.mjs +3 -6
- package/lib/services/blockchain/service.js +4 -6
- package/lib/services/blockchain/service.mjs +4 -6
- package/lib/services/credential/bbs-revocation.js +4 -7
- package/lib/services/credential/bbs-revocation.mjs +3 -6
- package/lib/services/credential/bound-check.js +9 -4
- package/lib/services/credential/bound-check.mjs +9 -4
- package/lib/services/credential/index.js +11 -13
- package/lib/services/credential/index.mjs +11 -13
- package/lib/services/credential/service.js +18 -18
- package/lib/services/credential/service.mjs +15 -15
- package/lib/services/credential/utils.js +65 -28
- package/lib/services/credential/utils.mjs +62 -32
- package/lib/services/dids/index.js +11 -14
- package/lib/services/dids/index.mjs +11 -14
- package/lib/services/dids/keypair-utils.js +142 -0
- package/lib/services/dids/keypair-utils.mjs +113 -0
- package/lib/services/dids/service.js +15 -34
- package/lib/services/dids/service.mjs +15 -34
- package/lib/services/edv/index.js +8 -14
- package/lib/services/edv/index.mjs +8 -14
- package/lib/services/edv/service.js +10 -22
- package/lib/services/edv/service.mjs +10 -22
- package/lib/services/index.js +13 -25
- package/lib/services/index.mjs +13 -25
- package/lib/services/relay-service/configs.js +0 -1
- package/lib/services/relay-service/configs.mjs +0 -1
- package/lib/services/relay-service/index.android.js +0 -1
- package/lib/services/relay-service/index.android.mjs +0 -1
- package/lib/services/relay-service/index.ios.js +0 -1
- package/lib/services/relay-service/index.ios.mjs +0 -1
- package/lib/services/relay-service/index.js +0 -1
- package/lib/services/relay-service/index.mjs +0 -1
- package/lib/services/relay-service/service-rpc.js +0 -1
- package/lib/services/relay-service/service-rpc.mjs +0 -1
- package/lib/services/relay-service/service.js +0 -1
- package/lib/services/relay-service/service.mjs +0 -1
- package/lib/services/test-utils.js +0 -44
- package/lib/services/test-utils.mjs +1 -44
- package/lib/services/util-crypto/configs.js +0 -12
- package/lib/services/util-crypto/configs.mjs +0 -12
- package/lib/services/util-crypto/index.android.js +0 -3
- package/lib/services/util-crypto/index.android.mjs +0 -3
- package/lib/services/util-crypto/index.ios.js +0 -3
- package/lib/services/util-crypto/index.ios.mjs +0 -3
- package/lib/services/util-crypto/index.js +4 -7
- package/lib/services/util-crypto/index.mjs +4 -7
- package/lib/services/util-crypto/service-rpc.js +0 -23
- package/lib/services/util-crypto/service-rpc.mjs +0 -23
- package/lib/services/util-crypto/service.js +68 -61
- package/lib/services/util-crypto/service.mjs +50 -59
- package/lib/services/wallet/configs.js +0 -63
- package/lib/services/wallet/configs.mjs +1 -64
- package/lib/services/wallet/index.android.js +0 -1
- package/lib/services/wallet/index.android.mjs +0 -1
- package/lib/services/wallet/index.ios.js +0 -1
- package/lib/services/wallet/index.ios.mjs +0 -1
- package/lib/services/wallet/index.js +2 -12
- package/lib/services/wallet/index.mjs +2 -12
- package/lib/services/wallet/service-rpc.js +0 -77
- package/lib/services/wallet/service-rpc.mjs +0 -77
- package/lib/services/wallet/service.js +1 -215
- package/lib/services/wallet/service.mjs +1 -211
- package/lib/setup-nodejs.js +13 -23
- package/lib/setup-nodejs.mjs +13 -23
- package/lib/setup-tests.js +13 -23
- package/lib/setup-tests.mjs +13 -23
- package/lib/src/core/format-utils.d.ts +0 -5
- package/lib/src/core/format-utils.d.ts.map +1 -1
- package/lib/src/core/validation.d.ts +0 -3
- package/lib/src/core/validation.d.ts.map +1 -1
- package/lib/src/rpc-util.d.ts.map +1 -1
- package/lib/src/services/blockchain/service.d.ts.map +1 -1
- package/lib/src/services/credential/bbs-revocation.d.ts.map +1 -1
- package/lib/src/services/credential/bound-check.d.ts +1 -1
- package/lib/src/services/credential/bound-check.d.ts.map +1 -1
- package/lib/src/services/credential/service.d.ts.map +1 -1
- package/lib/src/services/credential/utils.d.ts +2 -1
- package/lib/src/services/credential/utils.d.ts.map +1 -1
- package/lib/src/services/dids/keypair-utils.d.ts +15 -0
- package/lib/src/services/dids/keypair-utils.d.ts.map +1 -0
- package/lib/src/services/dids/service.d.ts +6 -6
- package/lib/src/services/dids/service.d.ts.map +1 -1
- package/lib/src/services/edv/service.d.ts.map +1 -1
- package/lib/src/services/util-crypto/configs.d.ts +0 -3
- package/lib/src/services/util-crypto/configs.d.ts.map +1 -1
- package/lib/src/services/util-crypto/service.d.ts +3 -8
- package/lib/src/services/util-crypto/service.d.ts.map +1 -1
- package/lib/src/services/wallet/configs.d.ts +13 -0
- package/lib/src/services/wallet/configs.d.ts.map +1 -0
- package/lib/src/services/wallet/service.d.ts +1 -44
- package/lib/src/services/wallet/service.d.ts.map +1 -1
- package/lib/test-utils.js +0 -4
- package/lib/test-utils.mjs +1 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -25
- package/readme.md +0 -61
- package/src/core/format-utils.test.js +1 -28
- package/src/core/format-utils.ts +0 -33
- package/src/core/validation.test.js +1 -33
- package/src/core/validation.ts +1 -25
- package/src/rpc-server.test.js +2 -9
- package/src/rpc-util.js +14 -0
- package/src/services/blockchain/service.ts +1 -0
- package/src/services/credential/bbs-revocation.ts +2 -1
- package/src/services/credential/bound-check.test.ts +6 -6
- package/src/services/credential/bound-check.ts +4 -4
- package/src/services/credential/index.test.js +0 -2
- package/src/services/credential/service.ts +5 -2
- package/src/services/credential/utils.js +65 -23
- package/src/services/dids/index.test.js +8 -19
- package/src/services/dids/keypair-utils.js +111 -0
- package/src/services/dids/service.ts +6 -25
- package/src/services/edv/service.ts +2 -9
- package/src/services/index.js +0 -4
- package/src/services/test-utils.js +0 -29
- package/src/services/util-crypto/configs.ts +0 -12
- package/src/services/util-crypto/index.test.js +6 -83
- package/src/services/util-crypto/service-rpc.js +0 -20
- package/src/services/util-crypto/service.ts +62 -75
- package/src/services/wallet/configs.ts +1 -113
- package/src/services/wallet/index.test.js +0 -159
- package/src/services/wallet/service-rpc.js +1 -88
- package/src/services/wallet/service.ts +0 -258
- package/src/test-utils.js +0 -13
- package/lib/account-357ab05d.js +0 -742
- package/lib/account-399e6053.js +0 -752
- package/lib/core/polkadot-utils.js +0 -119
- package/lib/core/polkadot-utils.mjs +0 -94
- package/lib/core/realm-schemas.js +0 -50
- package/lib/core/realm-schemas.mjs +0 -44
- package/lib/core/subscan.js +0 -75
- package/lib/core/subscan.mjs +0 -64
- package/lib/fixtures.js +0 -56
- package/lib/fixtures.mjs +0 -52
- package/lib/modules/account.js +0 -48
- package/lib/modules/account.mjs +0 -40
- package/lib/modules/accounts.js +0 -49
- package/lib/modules/accounts.mjs +0 -40
- package/lib/modules/data-migration.js +0 -72
- package/lib/modules/data-migration.mjs +0 -68
- package/lib/modules/wallet-backup.js +0 -82
- package/lib/modules/wallet-backup.mjs +0 -71
- package/lib/modules/wallet.js +0 -49
- package/lib/modules/wallet.mjs +0 -40
- package/lib/services/example/configs.js +0 -21
- package/lib/services/example/configs.mjs +0 -13
- package/lib/services/example/index.js +0 -18
- package/lib/services/example/index.mjs +0 -14
- package/lib/services/example/service-rpc.js +0 -25
- package/lib/services/example/service-rpc.mjs +0 -21
- package/lib/services/example/service.js +0 -25
- package/lib/services/example/service.mjs +0 -20
- package/lib/services/keyring/configs.js +0 -70
- package/lib/services/keyring/configs.mjs +0 -61
- package/lib/services/keyring/index.android.js +0 -22
- package/lib/services/keyring/index.android.mjs +0 -18
- package/lib/services/keyring/index.ios.js +0 -22
- package/lib/services/keyring/index.ios.mjs +0 -18
- package/lib/services/keyring/index.js +0 -16
- package/lib/services/keyring/index.mjs +0 -8
- package/lib/services/keyring/service-rpc.js +0 -65
- package/lib/services/keyring/service-rpc.mjs +0 -61
- package/lib/services/keyring/service.js +0 -84
- package/lib/services/keyring/service.mjs +0 -74
- package/lib/services/polkadot/configs.js +0 -17
- package/lib/services/polkadot/configs.mjs +0 -13
- package/lib/services/polkadot/index.android.js +0 -22
- package/lib/services/polkadot/index.android.mjs +0 -18
- package/lib/services/polkadot/index.ios.js +0 -22
- package/lib/services/polkadot/index.ios.mjs +0 -18
- package/lib/services/polkadot/index.js +0 -15
- package/lib/services/polkadot/index.mjs +0 -7
- package/lib/services/polkadot/service-rpc.js +0 -30
- package/lib/services/polkadot/service-rpc.mjs +0 -26
- package/lib/services/polkadot/service.js +0 -28
- package/lib/services/polkadot/service.mjs +0 -23
- package/lib/src/core/polkadot-utils.d.ts +0 -11
- package/lib/src/core/polkadot-utils.d.ts.map +0 -1
- package/lib/src/modules/account.d.ts +0 -60
- package/lib/src/modules/account.d.ts.map +0 -1
- package/lib/src/modules/accounts.d.ts +0 -48
- package/lib/src/modules/accounts.d.ts.map +0 -1
- package/lib/src/modules/data-migration.d.ts +0 -7
- package/lib/src/modules/data-migration.d.ts.map +0 -1
- package/lib/src/modules/wallet-backup.d.ts +0 -12
- package/lib/src/modules/wallet-backup.d.ts.map +0 -1
- package/lib/src/modules/wallet.d.ts +0 -134
- package/lib/src/modules/wallet.d.ts.map +0 -1
- package/lib/src/services/blockchain/index.d.ts +0 -2
- package/lib/src/services/blockchain/index.d.ts.map +0 -1
- package/lib/src/services/example/configs.d.ts +0 -9
- package/lib/src/services/example/configs.d.ts.map +0 -1
- package/lib/src/services/example/service.d.ts +0 -8
- package/lib/src/services/example/service.d.ts.map +0 -1
- package/lib/src/services/keyring/configs.d.ts +0 -39
- package/lib/src/services/keyring/configs.d.ts.map +0 -1
- package/lib/src/services/keyring/index.d.ts +0 -2
- package/lib/src/services/keyring/index.d.ts.map +0 -1
- package/lib/src/services/polkadot/configs.d.ts +0 -8
- package/lib/src/services/polkadot/configs.d.ts.map +0 -1
- package/lib/src/services/polkadot/index.d.ts +0 -2
- package/lib/src/services/polkadot/index.d.ts.map +0 -1
- package/lib/src/services/polkadot/service.d.ts +0 -8
- package/lib/src/services/polkadot/service.d.ts.map +0 -1
- package/lib/src/services/wallet/index.d.ts +0 -2
- package/lib/src/services/wallet/index.d.ts.map +0 -1
- package/lib/test/axiosMocks.js +0 -431
- package/lib/test/axiosMocks.mjs +0 -420
- package/lib/test/setup-test-state.js +0 -81
- package/lib/test/setup-test-state.mjs +0 -73
- package/src/core/polkadot-utils.js +0 -99
- package/src/core/realm-schemas.js +0 -42
- package/src/core/subscan.js +0 -62
- package/src/core/subscan.test.js +0 -56
- package/src/fixtures.js +0 -43
- package/src/modules/account.test.js +0 -56
- package/src/modules/account.ts +0 -128
- package/src/modules/accounts.test.js +0 -63
- package/src/modules/accounts.ts +0 -231
- package/src/modules/data-migration.test.js +0 -61
- package/src/modules/data-migration.ts +0 -86
- package/src/modules/wallet-backup.test.js +0 -24
- package/src/modules/wallet-backup.ts +0 -68
- package/src/modules/wallet.test.js +0 -216
- package/src/modules/wallet.ts +0 -424
- package/src/services/example/configs.js +0 -14
- package/src/services/example/index.js +0 -3
- package/src/services/example/index.test.js +0 -28
- package/src/services/example/service-rpc.js +0 -11
- package/src/services/example/service.ts +0 -18
- package/src/services/keyring/configs.ts +0 -110
- package/src/services/keyring/index.android.js +0 -3
- package/src/services/keyring/index.ios.js +0 -3
- package/src/services/keyring/index.js +0 -1
- package/src/services/keyring/index.test.js +0 -48
- package/src/services/keyring/service-rpc.js +0 -56
- package/src/services/keyring/service.ts +0 -111
- package/src/services/polkadot/configs.ts +0 -13
- package/src/services/polkadot/index.android.js +0 -3
- package/src/services/polkadot/index.ios.js +0 -3
- package/src/services/polkadot/index.js +0 -1
- package/src/services/polkadot/index.test.js +0 -52
- package/src/services/polkadot/service-rpc.js +0 -13
- package/src/services/polkadot/service.ts +0 -21
- package/src/test/axiosMocks.js +0 -20
- package/src/test/fixtures/subscan-failure.json +0 -5
- package/src/test/fixtures/subscan-success.json +0 -370
- package/src/test/fixtures/subscan-too-many-requests.json +0 -9
- package/src/test/setup-test-state.js +0 -35
- package/src/test/test-wallet.test.js +0 -15
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var cryptoWasmTs = require('@docknetwork/crypto-wasm-ts');
|
|
6
|
-
var
|
|
6
|
+
var utils = require('@docknetwork/credential-sdk/utils');
|
|
7
7
|
var services_blockchain_service = require('../blockchain/service.js');
|
|
8
8
|
require('@cosmjs/proto-signing');
|
|
9
9
|
require('@docknetwork/cheqd-blockchain-api');
|
|
@@ -16,12 +16,9 @@ require('../../core/logger.js');
|
|
|
16
16
|
require('../../modules/event-manager.js');
|
|
17
17
|
require('assert');
|
|
18
18
|
require('../util-crypto/service.js');
|
|
19
|
-
require('@
|
|
20
|
-
require('@
|
|
19
|
+
require('@scure/bip39');
|
|
20
|
+
require('@scure/bip39/wordlists/english');
|
|
21
21
|
require('../util-crypto/configs.js');
|
|
22
|
-
require('../../core/validation.js');
|
|
23
|
-
require('bignumber.js');
|
|
24
|
-
require('../../types.js');
|
|
25
22
|
require('@docknetwork/credential-sdk/types');
|
|
26
23
|
|
|
27
24
|
const getWitnessDetails = async (credential, _membershipWitness) => {
|
|
@@ -45,7 +42,7 @@ const getWitnessDetails = async (credential, _membershipWitness) => {
|
|
|
45
42
|
const publicKey = await services_blockchain_service.blockchainService.modules.accumulator.getPublicKey(queriedAccumulator.keyRef[0], queriedAccumulator.keyRef[1]);
|
|
46
43
|
const params = cryptoWasmTs.dockAccumulatorParams();
|
|
47
44
|
const pk = new cryptoWasmTs.AccumulatorPublicKey(publicKey.bytes);
|
|
48
|
-
const membershipWitness = new cryptoWasmTs.VBMembershipWitness(
|
|
45
|
+
const membershipWitness = new cryptoWasmTs.VBMembershipWitness(utils.hexToU8a(witness));
|
|
49
46
|
try {
|
|
50
47
|
const credentialStatusId = credential.credentialStatus.id;
|
|
51
48
|
const accumulatorId = services_blockchain_service.blockchainService
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PositiveAccumulator, Encoder, dockAccumulatorParams, AccumulatorPublicKey, VBMembershipWitness } from '@docknetwork/crypto-wasm-ts';
|
|
2
|
-
import { hexToU8a } from '@
|
|
2
|
+
import { hexToU8a } from '@docknetwork/credential-sdk/utils';
|
|
3
3
|
import { blockchainService } from '../blockchain/service.mjs';
|
|
4
4
|
import '@cosmjs/proto-signing';
|
|
5
5
|
import '@docknetwork/cheqd-blockchain-api';
|
|
@@ -12,12 +12,9 @@ import '../../core/logger.mjs';
|
|
|
12
12
|
import '../../modules/event-manager.mjs';
|
|
13
13
|
import 'assert';
|
|
14
14
|
import '../util-crypto/service.mjs';
|
|
15
|
-
import '@
|
|
16
|
-
import '@
|
|
15
|
+
import '@scure/bip39';
|
|
16
|
+
import '@scure/bip39/wordlists/english';
|
|
17
17
|
import '../util-crypto/configs.mjs';
|
|
18
|
-
import '../../core/validation.mjs';
|
|
19
|
-
import 'bignumber.js';
|
|
20
|
-
import '../../types.mjs';
|
|
21
18
|
import '@docknetwork/credential-sdk/types';
|
|
22
19
|
|
|
23
20
|
const getWitnessDetails = async (credential, _membershipWitness) => {
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var legosnark = require('@docknetwork/crypto-wasm-ts/lib/legosnark');
|
|
6
|
-
var utilCrypto = require('@polkadot/util-crypto');
|
|
7
6
|
var base64url = require('base64url');
|
|
8
7
|
var services_credential_pexHelpers = require('./pex-helpers.js');
|
|
8
|
+
var services_utilCrypto_service = require('../util-crypto/service.js');
|
|
9
9
|
require('@astronautlabs/jsonpath');
|
|
10
|
+
require('@docknetwork/credential-sdk/utils');
|
|
11
|
+
require('@scure/bip39');
|
|
12
|
+
require('@scure/bip39/wordlists/english');
|
|
13
|
+
require('../util-crypto/configs.js');
|
|
14
|
+
require('assert');
|
|
10
15
|
|
|
11
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
17
|
|
|
@@ -45,13 +50,13 @@ function blobFromBase64(base64String) {
|
|
|
45
50
|
const cleanedBase64 = base64String.replace(/^data:application\/octet-stream;base64,/, '');
|
|
46
51
|
return base64url__default["default"].toBuffer(cleanedBase64);
|
|
47
52
|
}
|
|
48
|
-
function isBase64OrDataUrl(str) {
|
|
49
|
-
return (
|
|
53
|
+
async function isBase64OrDataUrl(str) {
|
|
54
|
+
return ((await services_utilCrypto_service.utilCryptoService.isBase64(str)) ||
|
|
50
55
|
str.indexOf('data:application/octet-stream') > -1);
|
|
51
56
|
}
|
|
52
57
|
async function fetchProvingKey(proofRequest) {
|
|
53
58
|
let blob;
|
|
54
|
-
if (isBase64OrDataUrl(proofRequest.boundCheckSnarkKey)) {
|
|
59
|
+
if (await isBase64OrDataUrl(proofRequest.boundCheckSnarkKey)) {
|
|
55
60
|
console.log('Is base64');
|
|
56
61
|
blob = blobFromBase64(proofRequest.boundCheckSnarkKey);
|
|
57
62
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { LegoProvingKey } from '@docknetwork/crypto-wasm-ts/lib/legosnark';
|
|
2
|
-
import { isBase64 } from '@polkadot/util-crypto';
|
|
3
2
|
import base64url from 'base64url';
|
|
4
3
|
import { pexToBounds } from './pex-helpers.mjs';
|
|
4
|
+
import { utilCryptoService } from '../util-crypto/service.mjs';
|
|
5
5
|
import '@astronautlabs/jsonpath';
|
|
6
|
+
import '@docknetwork/credential-sdk/utils';
|
|
7
|
+
import '@scure/bip39';
|
|
8
|
+
import '@scure/bip39/wordlists/english';
|
|
9
|
+
import '../util-crypto/configs.mjs';
|
|
10
|
+
import 'assert';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Receive a presentation builder and a proof request template
|
|
@@ -37,13 +42,13 @@ function blobFromBase64(base64String) {
|
|
|
37
42
|
const cleanedBase64 = base64String.replace(/^data:application\/octet-stream;base64,/, '');
|
|
38
43
|
return base64url.toBuffer(cleanedBase64);
|
|
39
44
|
}
|
|
40
|
-
function isBase64OrDataUrl(str) {
|
|
41
|
-
return (isBase64(str) ||
|
|
45
|
+
async function isBase64OrDataUrl(str) {
|
|
46
|
+
return ((await utilCryptoService.isBase64(str)) ||
|
|
42
47
|
str.indexOf('data:application/octet-stream') > -1);
|
|
43
48
|
}
|
|
44
49
|
async function fetchProvingKey(proofRequest) {
|
|
45
50
|
let blob;
|
|
46
|
-
if (isBase64OrDataUrl(proofRequest.boundCheckSnarkKey)) {
|
|
51
|
+
if (await isBase64OrDataUrl(proofRequest.boundCheckSnarkKey)) {
|
|
47
52
|
console.log('Is base64');
|
|
48
53
|
blob = blobFromBase64(proofRequest.boundCheckSnarkKey);
|
|
49
54
|
}
|
|
@@ -9,18 +9,9 @@ require('@docknetwork/crypto-wasm-ts');
|
|
|
9
9
|
require('@sphereon/oid4vci-client');
|
|
10
10
|
require('@sphereon/oid4vci-common');
|
|
11
11
|
require('@docknetwork/universal-wallet/methods/keypairs');
|
|
12
|
+
require('@docknetwork/credential-sdk/utils');
|
|
12
13
|
require('@docknetwork/credential-sdk/vc');
|
|
13
14
|
require('@sphereon/pex');
|
|
14
|
-
require('./utils.js');
|
|
15
|
-
require('base58-universal');
|
|
16
|
-
require('@docknetwork/credential-sdk/vc/crypto');
|
|
17
|
-
require('../keyring/service.js');
|
|
18
|
-
require('@polkadot/keyring');
|
|
19
|
-
require('@polkadot/util-crypto');
|
|
20
|
-
require('../keyring/configs.js');
|
|
21
|
-
require('../../core/validation.js');
|
|
22
|
-
require('bignumber.js');
|
|
23
|
-
require('../../types.js');
|
|
24
15
|
require('../blockchain/service.js');
|
|
25
16
|
require('@cosmjs/proto-signing');
|
|
26
17
|
require('@docknetwork/cheqd-blockchain-api');
|
|
@@ -32,7 +23,8 @@ require('events');
|
|
|
32
23
|
require('../../core/logger.js');
|
|
33
24
|
require('../../modules/event-manager.js');
|
|
34
25
|
require('../util-crypto/service.js');
|
|
35
|
-
require('@
|
|
26
|
+
require('@scure/bip39');
|
|
27
|
+
require('@scure/bip39/wordlists/english');
|
|
36
28
|
require('../util-crypto/configs.js');
|
|
37
29
|
require('@docknetwork/credential-sdk/types');
|
|
38
30
|
require('./bound-check.js');
|
|
@@ -44,9 +36,15 @@ require('./bbs-revocation.js');
|
|
|
44
36
|
require('../dids/service.js');
|
|
45
37
|
require('@docknetwork/wallet-sdk-dids/lib');
|
|
46
38
|
require('../dids/config.js');
|
|
47
|
-
require('../../core/polkadot-utils.js');
|
|
48
39
|
require('@docknetwork/credential-sdk/keypairs');
|
|
49
|
-
require('
|
|
40
|
+
require('./utils.js');
|
|
41
|
+
require('base58-universal');
|
|
42
|
+
require('@docknetwork/credential-sdk/vc/crypto');
|
|
43
|
+
require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
44
|
+
require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
45
|
+
require('@digitalbazaar/ed25519-verification-key-2018');
|
|
46
|
+
require('@digitalbazaar/ed25519-verification-key-2020');
|
|
47
|
+
require('../dids/keypair-utils.js');
|
|
50
48
|
|
|
51
49
|
// @ts-nocheck
|
|
52
50
|
// TODO: rename it to credentialService, will need to update dock-app
|
|
@@ -5,18 +5,9 @@ import '@docknetwork/crypto-wasm-ts';
|
|
|
5
5
|
import '@sphereon/oid4vci-client';
|
|
6
6
|
import '@sphereon/oid4vci-common';
|
|
7
7
|
import '@docknetwork/universal-wallet/methods/keypairs';
|
|
8
|
+
import '@docknetwork/credential-sdk/utils';
|
|
8
9
|
import '@docknetwork/credential-sdk/vc';
|
|
9
10
|
import '@sphereon/pex';
|
|
10
|
-
import './utils.mjs';
|
|
11
|
-
import 'base58-universal';
|
|
12
|
-
import '@docknetwork/credential-sdk/vc/crypto';
|
|
13
|
-
import '../keyring/service.mjs';
|
|
14
|
-
import '@polkadot/keyring';
|
|
15
|
-
import '@polkadot/util-crypto';
|
|
16
|
-
import '../keyring/configs.mjs';
|
|
17
|
-
import '../../core/validation.mjs';
|
|
18
|
-
import 'bignumber.js';
|
|
19
|
-
import '../../types.mjs';
|
|
20
11
|
import '../blockchain/service.mjs';
|
|
21
12
|
import '@cosmjs/proto-signing';
|
|
22
13
|
import '@docknetwork/cheqd-blockchain-api';
|
|
@@ -28,7 +19,8 @@ import 'events';
|
|
|
28
19
|
import '../../core/logger.mjs';
|
|
29
20
|
import '../../modules/event-manager.mjs';
|
|
30
21
|
import '../util-crypto/service.mjs';
|
|
31
|
-
import '@
|
|
22
|
+
import '@scure/bip39';
|
|
23
|
+
import '@scure/bip39/wordlists/english';
|
|
32
24
|
import '../util-crypto/configs.mjs';
|
|
33
25
|
import '@docknetwork/credential-sdk/types';
|
|
34
26
|
import './bound-check.mjs';
|
|
@@ -40,9 +32,15 @@ import './bbs-revocation.mjs';
|
|
|
40
32
|
import '../dids/service.mjs';
|
|
41
33
|
import '@docknetwork/wallet-sdk-dids/lib';
|
|
42
34
|
import '../dids/config.mjs';
|
|
43
|
-
import '../../core/polkadot-utils.mjs';
|
|
44
35
|
import '@docknetwork/credential-sdk/keypairs';
|
|
45
|
-
import '
|
|
36
|
+
import './utils.mjs';
|
|
37
|
+
import 'base58-universal';
|
|
38
|
+
import '@docknetwork/credential-sdk/vc/crypto';
|
|
39
|
+
import '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
40
|
+
import '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
41
|
+
import '@digitalbazaar/ed25519-verification-key-2018';
|
|
42
|
+
import '@digitalbazaar/ed25519-verification-key-2020';
|
|
43
|
+
import '../dids/keypair-utils.mjs';
|
|
46
44
|
|
|
47
45
|
// @ts-nocheck
|
|
48
46
|
// TODO: rename it to credentialService, will need to update dock-app
|
|
@@ -7,24 +7,15 @@ var cryptoWasmTs = require('@docknetwork/crypto-wasm-ts');
|
|
|
7
7
|
var oid4vciClient = require('@sphereon/oid4vci-client');
|
|
8
8
|
var oid4vciCommon = require('@sphereon/oid4vci-common');
|
|
9
9
|
var keypairs = require('@docknetwork/universal-wallet/methods/keypairs');
|
|
10
|
+
var utils = require('@docknetwork/credential-sdk/utils');
|
|
10
11
|
var vc = require('@docknetwork/credential-sdk/vc');
|
|
11
12
|
var pex$1 = require('@sphereon/pex');
|
|
12
|
-
var services_credential_utils = require('./utils.js');
|
|
13
13
|
var services_blockchain_service = require('../blockchain/service.js');
|
|
14
14
|
var services_credential_boundCheck = require('./bound-check.js');
|
|
15
15
|
var assert = require('assert');
|
|
16
16
|
var services_credential_bbsRevocation = require('./bbs-revocation.js');
|
|
17
17
|
var services_credential_pexHelpers = require('./pex-helpers.js');
|
|
18
18
|
var services_dids_service = require('../dids/service.js');
|
|
19
|
-
require('base58-universal');
|
|
20
|
-
require('@docknetwork/credential-sdk/vc/crypto');
|
|
21
|
-
require('../keyring/service.js');
|
|
22
|
-
require('@polkadot/keyring');
|
|
23
|
-
require('@polkadot/util-crypto');
|
|
24
|
-
require('../keyring/configs.js');
|
|
25
|
-
require('../../core/validation.js');
|
|
26
|
-
require('bignumber.js');
|
|
27
|
-
require('../../types.js');
|
|
28
19
|
require('@cosmjs/proto-signing');
|
|
29
20
|
require('@docknetwork/cheqd-blockchain-api');
|
|
30
21
|
require('@docknetwork/cheqd-blockchain-modules');
|
|
@@ -35,7 +26,8 @@ require('events');
|
|
|
35
26
|
require('../../core/logger.js');
|
|
36
27
|
require('../../modules/event-manager.js');
|
|
37
28
|
require('../util-crypto/service.js');
|
|
38
|
-
require('@
|
|
29
|
+
require('@scure/bip39');
|
|
30
|
+
require('@scure/bip39/wordlists/english');
|
|
39
31
|
require('../util-crypto/configs.js');
|
|
40
32
|
require('@docknetwork/credential-sdk/types');
|
|
41
33
|
require('@docknetwork/crypto-wasm-ts/lib/legosnark');
|
|
@@ -43,9 +35,15 @@ require('base64url');
|
|
|
43
35
|
require('@astronautlabs/jsonpath');
|
|
44
36
|
require('@docknetwork/wallet-sdk-dids/lib');
|
|
45
37
|
require('../dids/config.js');
|
|
46
|
-
require('../../core/polkadot-utils.js');
|
|
47
38
|
require('@docknetwork/credential-sdk/keypairs');
|
|
48
|
-
require('
|
|
39
|
+
require('./utils.js');
|
|
40
|
+
require('base58-universal');
|
|
41
|
+
require('@docknetwork/credential-sdk/vc/crypto');
|
|
42
|
+
require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
43
|
+
require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
44
|
+
require('@digitalbazaar/ed25519-verification-key-2018');
|
|
45
|
+
require('@digitalbazaar/ed25519-verification-key-2020');
|
|
46
|
+
require('../dids/keypair-utils.js');
|
|
49
47
|
|
|
50
48
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
51
49
|
|
|
@@ -122,11 +120,13 @@ class CredentialService {
|
|
|
122
120
|
if (!shouldSkipSigning) {
|
|
123
121
|
vp.setHolder(keyDoc.controller);
|
|
124
122
|
}
|
|
125
|
-
|
|
123
|
+
const keyPair = keypairs.getKeypairFromDoc(keyDoc);
|
|
124
|
+
keyPair.signer = keyPair.signer();
|
|
125
|
+
const suite = await vc.getSuiteFromKeyDoc(keyPair);
|
|
126
126
|
if (shouldSkipSigning) {
|
|
127
127
|
return vp.toJSON();
|
|
128
128
|
}
|
|
129
|
-
return vp.sign(
|
|
129
|
+
return vp.sign(suite, challenge, domain, services_blockchain_service.blockchainService.resolver);
|
|
130
130
|
}
|
|
131
131
|
async verifyPresentation({ presentation, options }) {
|
|
132
132
|
return vc.verifyPresentation(presentation, options);
|
|
@@ -288,15 +288,15 @@ class CredentialService {
|
|
|
288
288
|
const removals = [];
|
|
289
289
|
if (updates.length && updates[0].additions !== null) {
|
|
290
290
|
for (const a of updates[0].additions) {
|
|
291
|
-
additions.push(hexToU8a(a));
|
|
291
|
+
additions.push(utils.hexToU8a(a));
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
if (updates.length && updates[0].removals !== null) {
|
|
295
295
|
for (const a of updates[0].removals) {
|
|
296
|
-
removals.push(hexToU8a(a));
|
|
296
|
+
removals.push(utils.hexToU8a(a));
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
const queriedWitnessInfo = new cryptoWasmTs.WitnessUpdatePublicInfo(hexToU8a(updates[0].witnessUpdateInfo));
|
|
299
|
+
const queriedWitnessInfo = new cryptoWasmTs.WitnessUpdatePublicInfo(utils.hexToU8a(updates[0].witnessUpdateInfo));
|
|
300
300
|
const witness = cryptoWasmTs.MembershipWitness.fromJSON(membershipWitnessJSON);
|
|
301
301
|
witness.updateUsingPublicInfoPostBatchUpdate(member, additions, removals, queriedWitnessInfo);
|
|
302
302
|
return witness.toJSON();
|
|
@@ -3,24 +3,15 @@ import { Accumulator, WitnessUpdatePublicInfo, MembershipWitness, VB_ACCUMULATOR
|
|
|
3
3
|
import { OpenID4VCIClientV1_0_13 } from '@sphereon/oid4vci-client';
|
|
4
4
|
import { Alg } from '@sphereon/oid4vci-common';
|
|
5
5
|
import { getKeypairFromDoc } from '@docknetwork/universal-wallet/methods/keypairs';
|
|
6
|
+
import { hexToU8a } from '@docknetwork/credential-sdk/utils';
|
|
6
7
|
import { VerifiableCredential, getSuiteFromKeyDoc, VerifiablePresentation, verifyPresentation, verifyCredential, Presentation } from '@docknetwork/credential-sdk/vc';
|
|
7
8
|
import { PEX } from '@sphereon/pex';
|
|
8
|
-
import { keyDocToKeypair } from './utils.mjs';
|
|
9
9
|
import { blockchainService } from '../blockchain/service.mjs';
|
|
10
10
|
import { hasProvingKey, fetchProvingKey, applyEnforceBounds } from './bound-check.mjs';
|
|
11
11
|
import assert from 'assert';
|
|
12
12
|
import { getIsRevoked, getWitnessDetails } from './bbs-revocation.mjs';
|
|
13
13
|
import { getPexRequiredAttributes } from './pex-helpers.mjs';
|
|
14
14
|
import { didService } from '../dids/service.mjs';
|
|
15
|
-
import 'base58-universal';
|
|
16
|
-
import '@docknetwork/credential-sdk/vc/crypto';
|
|
17
|
-
import '../keyring/service.mjs';
|
|
18
|
-
import '@polkadot/keyring';
|
|
19
|
-
import '@polkadot/util-crypto';
|
|
20
|
-
import '../keyring/configs.mjs';
|
|
21
|
-
import '../../core/validation.mjs';
|
|
22
|
-
import 'bignumber.js';
|
|
23
|
-
import '../../types.mjs';
|
|
24
15
|
import '@cosmjs/proto-signing';
|
|
25
16
|
import '@docknetwork/cheqd-blockchain-api';
|
|
26
17
|
import '@docknetwork/cheqd-blockchain-modules';
|
|
@@ -31,7 +22,8 @@ import 'events';
|
|
|
31
22
|
import '../../core/logger.mjs';
|
|
32
23
|
import '../../modules/event-manager.mjs';
|
|
33
24
|
import '../util-crypto/service.mjs';
|
|
34
|
-
import '@
|
|
25
|
+
import '@scure/bip39';
|
|
26
|
+
import '@scure/bip39/wordlists/english';
|
|
35
27
|
import '../util-crypto/configs.mjs';
|
|
36
28
|
import '@docknetwork/credential-sdk/types';
|
|
37
29
|
import '@docknetwork/crypto-wasm-ts/lib/legosnark';
|
|
@@ -39,9 +31,15 @@ import 'base64url';
|
|
|
39
31
|
import '@astronautlabs/jsonpath';
|
|
40
32
|
import '@docknetwork/wallet-sdk-dids/lib';
|
|
41
33
|
import '../dids/config.mjs';
|
|
42
|
-
import '../../core/polkadot-utils.mjs';
|
|
43
34
|
import '@docknetwork/credential-sdk/keypairs';
|
|
44
|
-
import '
|
|
35
|
+
import './utils.mjs';
|
|
36
|
+
import 'base58-universal';
|
|
37
|
+
import '@docknetwork/credential-sdk/vc/crypto';
|
|
38
|
+
import '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
39
|
+
import '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
40
|
+
import '@digitalbazaar/ed25519-verification-key-2018';
|
|
41
|
+
import '@digitalbazaar/ed25519-verification-key-2020';
|
|
42
|
+
import '../dids/keypair-utils.mjs';
|
|
45
43
|
|
|
46
44
|
// @ts-nocheck
|
|
47
45
|
const pex = new PEX();
|
|
@@ -114,11 +112,13 @@ class CredentialService {
|
|
|
114
112
|
if (!shouldSkipSigning) {
|
|
115
113
|
vp.setHolder(keyDoc.controller);
|
|
116
114
|
}
|
|
117
|
-
|
|
115
|
+
const keyPair = getKeypairFromDoc(keyDoc);
|
|
116
|
+
keyPair.signer = keyPair.signer();
|
|
117
|
+
const suite = await getSuiteFromKeyDoc(keyPair);
|
|
118
118
|
if (shouldSkipSigning) {
|
|
119
119
|
return vp.toJSON();
|
|
120
120
|
}
|
|
121
|
-
return vp.sign(
|
|
121
|
+
return vp.sign(suite, challenge, domain, blockchainService.resolver);
|
|
122
122
|
}
|
|
123
123
|
async verifyPresentation({ presentation, options }) {
|
|
124
124
|
return verifyPresentation(presentation, options);
|
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var bs58 = require('base58-universal');
|
|
6
6
|
var crypto = require('@docknetwork/credential-sdk/vc/crypto');
|
|
7
|
-
var
|
|
8
|
-
require('@
|
|
9
|
-
require('@
|
|
10
|
-
require('
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
var utils = require('@docknetwork/credential-sdk/utils');
|
|
8
|
+
var x25519KeyAgreementKey2020 = require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
9
|
+
var x25519KeyAgreementKey2019 = require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
10
|
+
var ed25519VerificationKey2018 = require('@digitalbazaar/ed25519-verification-key-2018');
|
|
11
|
+
var ed25519VerificationKey2020 = require('@digitalbazaar/ed25519-verification-key-2020');
|
|
12
|
+
var keypairs = require('@docknetwork/credential-sdk/keypairs');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
15
|
|
|
16
16
|
function _interopNamespace(e) {
|
|
17
17
|
if (e && e.__esModule) return e;
|
|
@@ -32,13 +32,16 @@ function _interopNamespace(e) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
var bs58__namespace = /*#__PURE__*/_interopNamespace(bs58);
|
|
35
|
+
var x25519KeyAgreementKey2020__default = /*#__PURE__*/_interopDefaultLegacy(x25519KeyAgreementKey2020);
|
|
36
|
+
var x25519KeyAgreementKey2019__default = /*#__PURE__*/_interopDefaultLegacy(x25519KeyAgreementKey2019);
|
|
37
|
+
var ed25519VerificationKey2018__default = /*#__PURE__*/_interopDefaultLegacy(ed25519VerificationKey2018);
|
|
38
|
+
var ed25519VerificationKey2020__default = /*#__PURE__*/_interopDefaultLegacy(ed25519VerificationKey2020);
|
|
39
|
+
|
|
40
|
+
async function keyDocToKeypair(keyDoc) {
|
|
41
|
+
if (keyDoc.keypair) {
|
|
42
|
+
return keyDoc;
|
|
43
|
+
}
|
|
35
44
|
|
|
36
|
-
const docToKeyMap = {
|
|
37
|
-
Sr25519VerificationKey2020: 'sr25519',
|
|
38
|
-
Ed25519VerificationKey2018: 'ed25519',
|
|
39
|
-
};
|
|
40
|
-
function keyDocToKeypair(keyDoc, dock) {
|
|
41
|
-
// For now we expect multibase to just be b58, this needs fixing later if/when we support more keys
|
|
42
45
|
const {
|
|
43
46
|
type,
|
|
44
47
|
privateKeyBase58,
|
|
@@ -46,27 +49,61 @@ function keyDocToKeypair(keyDoc, dock) {
|
|
|
46
49
|
privateKeyMultibase,
|
|
47
50
|
publicKeyMultibase,
|
|
48
51
|
} = keyDoc;
|
|
49
|
-
|
|
52
|
+
|
|
53
|
+
const publicKeyEncoded = publicKeyBase58 || publicKeyMultibase.substr(1);
|
|
54
|
+
const privateKeyEncoded =
|
|
55
|
+
privateKeyBase58 || (privateKeyMultibase && privateKeyMultibase.substr(1));
|
|
56
|
+
if (!privateKeyEncoded) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`No private key in document found, this should not happen. Got: ${JSON.stringify(
|
|
59
|
+
keyDoc,
|
|
60
|
+
null,
|
|
61
|
+
2,
|
|
62
|
+
)}`,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
const privateKeyBytes = bs58__namespace.decode(privateKeyEncoded);
|
|
67
|
+
const publicKeyBytes = bs58__namespace.decode(publicKeyEncoded);
|
|
51
68
|
|
|
52
69
|
if (type === 'Bls12381G2VerificationKeyDock2022') {
|
|
53
70
|
return new crypto.Bls12381G2KeyPairDock2022(keyDoc);
|
|
71
|
+
} else if (type === 'Bls12381BBSVerificationKeyDock2023') {
|
|
72
|
+
return new crypto.Bls12381BBSKeyPairDock2023(keyDoc);
|
|
73
|
+
} else if (type === 'Bls12381BBDT16VerificationKeyDock2024') {
|
|
74
|
+
return new crypto.Bls12381BBDT16KeyPairDock2024(keyDoc);
|
|
75
|
+
} else if (
|
|
76
|
+
type === 'Ed25519VerificationKey2020' ||
|
|
77
|
+
type === 'Ed25519VerificationKey2018'
|
|
78
|
+
) {
|
|
79
|
+
const key = new keypairs.Ed25519Keypair(utils.randomAsHex(32));
|
|
80
|
+
key.keyPair.publicKey = publicKeyBytes;
|
|
81
|
+
key.keyPair.secretKey = privateKeyBytes;
|
|
82
|
+
return key;
|
|
54
83
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new Error(`Unsupported key type: ${type}`);
|
|
59
|
-
}
|
|
84
|
+
throw new Error(`Unsupported key type: ${type}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
60
87
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
const keyConstructors = {
|
|
89
|
+
Ed25519VerificationKey2018: keypairOptions =>
|
|
90
|
+
new ed25519VerificationKey2018__default["default"].Ed25519VerificationKey2018(keypairOptions),
|
|
91
|
+
Ed25519VerificationKey2020: keypairOptions =>
|
|
92
|
+
new ed25519VerificationKey2020__default["default"].Ed25519VerificationKey2020(keypairOptions),
|
|
93
|
+
X25519KeyAgreementKey2019: keypairOptions =>
|
|
94
|
+
new x25519KeyAgreementKey2019__default["default"].X25519KeyAgreementKey2019(keypairOptions),
|
|
95
|
+
X25519KeyAgreementKey2020: keypairOptions =>
|
|
96
|
+
new x25519KeyAgreementKey2020__default["default"].X25519KeyAgreementKey2020(keypairOptions),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function getKeypairFromDoc(keypairOptions) {
|
|
100
|
+
const {type} = keypairOptions;
|
|
101
|
+
const keyConstructor = keyConstructors[type];
|
|
102
|
+
if (!keyConstructor) {
|
|
103
|
+
throw new Error(`Unrecognized keypair type to construct: ${type}`);
|
|
69
104
|
}
|
|
105
|
+
return keyConstructor(keypairOptions);
|
|
70
106
|
}
|
|
71
107
|
|
|
108
|
+
exports.getKeypairFromDoc = getKeypairFromDoc;
|
|
72
109
|
exports.keyDocToKeypair = keyDocToKeypair;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import * as bs58 from 'base58-universal';
|
|
2
|
-
import { Bls12381G2KeyPairDock2022 } from '@docknetwork/credential-sdk/vc/crypto';
|
|
3
|
-
import {
|
|
4
|
-
import '@
|
|
5
|
-
import '@
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
function keyDocToKeypair(keyDoc, dock) {
|
|
17
|
-
// For now we expect multibase to just be b58, this needs fixing later if/when we support more keys
|
|
2
|
+
import { Bls12381G2KeyPairDock2022, Bls12381BBSKeyPairDock2023, Bls12381BBDT16KeyPairDock2024 } from '@docknetwork/credential-sdk/vc/crypto';
|
|
3
|
+
import { randomAsHex } from '@docknetwork/credential-sdk/utils';
|
|
4
|
+
import x25519KeyAgreementKey2020 from '@digitalbazaar/x25519-key-agreement-key-2020';
|
|
5
|
+
import x25519KeyAgreementKey2019 from '@digitalbazaar/x25519-key-agreement-key-2019';
|
|
6
|
+
import ed25519VerificationKey2018 from '@digitalbazaar/ed25519-verification-key-2018';
|
|
7
|
+
import ed25519VerificationKey2020 from '@digitalbazaar/ed25519-verification-key-2020';
|
|
8
|
+
import { Ed25519Keypair } from '@docknetwork/credential-sdk/keypairs';
|
|
9
|
+
|
|
10
|
+
async function keyDocToKeypair(keyDoc) {
|
|
11
|
+
if (keyDoc.keypair) {
|
|
12
|
+
return keyDoc;
|
|
13
|
+
}
|
|
14
|
+
|
|
18
15
|
const {
|
|
19
16
|
type,
|
|
20
17
|
privateKeyBase58,
|
|
@@ -22,27 +19,60 @@ function keyDocToKeypair(keyDoc, dock) {
|
|
|
22
19
|
privateKeyMultibase,
|
|
23
20
|
publicKeyMultibase,
|
|
24
21
|
} = keyDoc;
|
|
25
|
-
|
|
22
|
+
|
|
23
|
+
const publicKeyEncoded = publicKeyBase58 || publicKeyMultibase.substr(1);
|
|
24
|
+
const privateKeyEncoded =
|
|
25
|
+
privateKeyBase58 || (privateKeyMultibase && privateKeyMultibase.substr(1));
|
|
26
|
+
if (!privateKeyEncoded) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`No private key in document found, this should not happen. Got: ${JSON.stringify(
|
|
29
|
+
keyDoc,
|
|
30
|
+
null,
|
|
31
|
+
2,
|
|
32
|
+
)}`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
const privateKeyBytes = bs58.decode(privateKeyEncoded);
|
|
37
|
+
const publicKeyBytes = bs58.decode(publicKeyEncoded);
|
|
27
38
|
|
|
28
39
|
if (type === 'Bls12381G2VerificationKeyDock2022') {
|
|
29
40
|
return new Bls12381G2KeyPairDock2022(keyDoc);
|
|
41
|
+
} else if (type === 'Bls12381BBSVerificationKeyDock2023') {
|
|
42
|
+
return new Bls12381BBSKeyPairDock2023(keyDoc);
|
|
43
|
+
} else if (type === 'Bls12381BBDT16VerificationKeyDock2024') {
|
|
44
|
+
return new Bls12381BBDT16KeyPairDock2024(keyDoc);
|
|
45
|
+
} else if (
|
|
46
|
+
type === 'Ed25519VerificationKey2020' ||
|
|
47
|
+
type === 'Ed25519VerificationKey2018'
|
|
48
|
+
) {
|
|
49
|
+
const key = new Ed25519Keypair(randomAsHex(32));
|
|
50
|
+
key.keyPair.publicKey = publicKeyBytes;
|
|
51
|
+
key.keyPair.secretKey = privateKeyBytes;
|
|
52
|
+
return key;
|
|
30
53
|
} else {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
throw new Error(`Unsupported key type: ${type}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const keyConstructors = {
|
|
59
|
+
Ed25519VerificationKey2018: keypairOptions =>
|
|
60
|
+
new ed25519VerificationKey2018.Ed25519VerificationKey2018(keypairOptions),
|
|
61
|
+
Ed25519VerificationKey2020: keypairOptions =>
|
|
62
|
+
new ed25519VerificationKey2020.Ed25519VerificationKey2020(keypairOptions),
|
|
63
|
+
X25519KeyAgreementKey2019: keypairOptions =>
|
|
64
|
+
new x25519KeyAgreementKey2019.X25519KeyAgreementKey2019(keypairOptions),
|
|
65
|
+
X25519KeyAgreementKey2020: keypairOptions =>
|
|
66
|
+
new x25519KeyAgreementKey2020.X25519KeyAgreementKey2020(keypairOptions),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function getKeypairFromDoc(keypairOptions) {
|
|
70
|
+
const {type} = keypairOptions;
|
|
71
|
+
const keyConstructor = keyConstructors[type];
|
|
72
|
+
if (!keyConstructor) {
|
|
73
|
+
throw new Error(`Unrecognized keypair type to construct: ${type}`);
|
|
45
74
|
}
|
|
75
|
+
return keyConstructor(keypairOptions);
|
|
46
76
|
}
|
|
47
77
|
|
|
48
|
-
export { keyDocToKeypair };
|
|
78
|
+
export { getKeypairFromDoc, keyDocToKeypair };
|
|
@@ -6,16 +6,6 @@ var services_dids_service = require('./service.js');
|
|
|
6
6
|
require('@docknetwork/wallet-sdk-dids/lib');
|
|
7
7
|
require('./config.js');
|
|
8
8
|
require('assert');
|
|
9
|
-
require('../keyring/service.js');
|
|
10
|
-
require('@polkadot/keyring');
|
|
11
|
-
require('@polkadot/util-crypto');
|
|
12
|
-
require('../keyring/configs.js');
|
|
13
|
-
require('../../core/validation.js');
|
|
14
|
-
require('bignumber.js');
|
|
15
|
-
require('../../types.js');
|
|
16
|
-
require('../util-crypto/service.js');
|
|
17
|
-
require('@polkadot/util');
|
|
18
|
-
require('../util-crypto/configs.js');
|
|
19
9
|
require('../blockchain/service.js');
|
|
20
10
|
require('@cosmjs/proto-signing');
|
|
21
11
|
require('@docknetwork/cheqd-blockchain-api');
|
|
@@ -26,15 +16,22 @@ require('@docknetwork/crypto-wasm-ts/lib/index');
|
|
|
26
16
|
require('events');
|
|
27
17
|
require('../../core/logger.js');
|
|
28
18
|
require('../../modules/event-manager.js');
|
|
19
|
+
require('../util-crypto/service.js');
|
|
20
|
+
require('@docknetwork/credential-sdk/utils');
|
|
21
|
+
require('@scure/bip39');
|
|
22
|
+
require('@scure/bip39/wordlists/english');
|
|
23
|
+
require('../util-crypto/configs.js');
|
|
29
24
|
require('@docknetwork/credential-sdk/types');
|
|
30
|
-
require('../../core/polkadot-utils.js');
|
|
31
25
|
require('@docknetwork/credential-sdk/keypairs');
|
|
32
|
-
require('@polkadot/keyring/pair/decode');
|
|
33
|
-
require('base58-universal');
|
|
34
|
-
require('@docknetwork/universal-wallet/methods/keypairs');
|
|
35
26
|
require('base64url');
|
|
36
27
|
require('../credential/utils.js');
|
|
28
|
+
require('base58-universal');
|
|
37
29
|
require('@docknetwork/credential-sdk/vc/crypto');
|
|
30
|
+
require('@digitalbazaar/x25519-key-agreement-key-2020');
|
|
31
|
+
require('@digitalbazaar/x25519-key-agreement-key-2019');
|
|
32
|
+
require('@digitalbazaar/ed25519-verification-key-2018');
|
|
33
|
+
require('@digitalbazaar/ed25519-verification-key-2020');
|
|
34
|
+
require('./keypair-utils.js');
|
|
38
35
|
|
|
39
36
|
const didServiceRPC = services_dids_service.didService;
|
|
40
37
|
|