@sphereon/ssi-sdk-ext.did-resolver-key 0.28.0 → 0.28.1-feature.esm.cjs.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.
- package/dist/index.cjs +527 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +18 -5
- package/dist/index.js +491 -87
- package/dist/index.js.map +1 -1
- package/package.json +22 -10
- package/src/__tests__/__snapshots__/secp256r1.test.ts.snap +249 -1
- package/src/__tests__/__snapshots__/secp384r1.test.ts.snap +249 -1
- package/src/__tests__/__snapshots__/secp521r1.test.ts.snap +280 -1
- package/src/__tests__/key_resolver.test.ts +2 -1
- package/src/__tests__/secp256r1.test.ts +4 -4
- package/src/__tests__/secp384r1.test.ts +3 -3
- package/src/__tests__/secp521r1.test.ts +3 -2
- package/src/drivers/bls12381g2.ts +3 -1
- package/src/drivers/ed25519.ts +6 -4
- package/src/drivers/secp256k1.ts +3 -1
- package/src/drivers/secp256r1.ts +4 -3
- package/src/drivers/secp384r1.ts +3 -1
- package/src/drivers/secp521r1.ts +3 -1
- package/src/index.ts +3 -1
- package/dist/drivers/bls12381g2.d.ts +0 -8
- package/dist/drivers/bls12381g2.d.ts.map +0 -1
- package/dist/drivers/bls12381g2.js +0 -49
- package/dist/drivers/bls12381g2.js.map +0 -1
- package/dist/drivers/ed25519.d.ts +0 -8
- package/dist/drivers/ed25519.d.ts.map +0 -1
- package/dist/drivers/ed25519.js +0 -118
- package/dist/drivers/ed25519.js.map +0 -1
- package/dist/drivers/jwk.jcs.d.ts +0 -8
- package/dist/drivers/jwk.jcs.d.ts.map +0 -1
- package/dist/drivers/jwk.jcs.js +0 -23
- package/dist/drivers/jwk.jcs.js.map +0 -1
- package/dist/drivers/secp256k1.d.ts +0 -8
- package/dist/drivers/secp256k1.d.ts.map +0 -1
- package/dist/drivers/secp256k1.js +0 -49
- package/dist/drivers/secp256k1.js.map +0 -1
- package/dist/drivers/secp256r1.d.ts +0 -24
- package/dist/drivers/secp256r1.d.ts.map +0 -1
- package/dist/drivers/secp256r1.js +0 -99
- package/dist/drivers/secp256r1.js.map +0 -1
- package/dist/drivers/secp384r1.d.ts +0 -24
- package/dist/drivers/secp384r1.d.ts.map +0 -1
- package/dist/drivers/secp384r1.js +0 -99
- package/dist/drivers/secp384r1.js.map +0 -1
- package/dist/drivers/secp521r1.d.ts +0 -23
- package/dist/drivers/secp521r1.d.ts.map +0 -1
- package/dist/drivers/secp521r1.js +0 -87
- package/dist/drivers/secp521r1.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -14
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
package/dist/drivers/ed25519.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.keyToDidDoc = void 0;
|
|
27
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
28
|
-
// import { edwardsToMontgomery } from '@noble/curves/ed25519'
|
|
29
|
-
const ed25519_1 = require("@stablelib/ed25519");
|
|
30
|
-
const types_1 = require("../types");
|
|
31
|
-
function encodeKey(key, encodeKey) {
|
|
32
|
-
const bytes = new Uint8Array(key.length + 2);
|
|
33
|
-
bytes[0] = encodeKey !== null && encodeKey !== void 0 ? encodeKey : 0xec;
|
|
34
|
-
// The multicodec is encoded as a varint so we need to add this.
|
|
35
|
-
// See js-multicodec for a general implementation
|
|
36
|
-
bytes[1] = 0x01;
|
|
37
|
-
bytes.set(key, 2);
|
|
38
|
-
return `z${u8a.toString(bytes, 'base58btc')}`;
|
|
39
|
-
}
|
|
40
|
-
const keyToDidDoc = (args) => {
|
|
41
|
-
const { options } = args;
|
|
42
|
-
if (!(options === null || options === void 0 ? void 0 : options.publicKeyFormat)) {
|
|
43
|
-
return keyToDidDoc2020(args);
|
|
44
|
-
}
|
|
45
|
-
switch (options.publicKeyFormat) {
|
|
46
|
-
case 'Ed25519VerificationKey2018':
|
|
47
|
-
case 'X25519KeyAgreementKey2019':
|
|
48
|
-
return keyToDidDoc2018_2019(args);
|
|
49
|
-
case 'Ed25519VerificationKey2020':
|
|
50
|
-
case 'X25519KeyAgreementKey2020':
|
|
51
|
-
case 'Multikey':
|
|
52
|
-
return keyToDidDoc2020(args);
|
|
53
|
-
default:
|
|
54
|
-
throw Error(`${options.publicKeyFormat} not supported yet for the ed25519 driver`);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
exports.keyToDidDoc = keyToDidDoc;
|
|
58
|
-
const keyToDidDoc2018_2019 = ({ pubKeyBytes, fingerprint, contentType }) => {
|
|
59
|
-
const did = `did:key:${fingerprint}`;
|
|
60
|
-
const keyId = `${did}#${fingerprint}`;
|
|
61
|
-
//todo: Move to noble lib. x25519 values differ between below methods. Current implementation is correct according to DID:key spec
|
|
62
|
-
// const pubKeyHex = u8a.toString(pubKeyBytes, 'base16')
|
|
63
|
-
// const x25519PubBytes = edwardsToMontgomery(pubKeyHex)
|
|
64
|
-
const x25519PubBytes = (0, ed25519_1.convertPublicKeyToX25519)(pubKeyBytes);
|
|
65
|
-
const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`;
|
|
66
|
-
return Object.assign(Object.assign({}, (contentType === types_1.DID_LD_JSON && {
|
|
67
|
-
'@context': [
|
|
68
|
-
'https://www.w3.org/ns/did/v1',
|
|
69
|
-
'https://w3id.org/security/suites/ed25519-2018/v1',
|
|
70
|
-
'https://w3id.org/security/suites/x25519-2019/v1',
|
|
71
|
-
],
|
|
72
|
-
})), { id: did, verificationMethod: [
|
|
73
|
-
{
|
|
74
|
-
id: keyId,
|
|
75
|
-
type: 'Ed25519VerificationKey2018',
|
|
76
|
-
controller: did,
|
|
77
|
-
publicKeyBase58: u8a.toString(pubKeyBytes, 'base58btc'),
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: x25519KeyId,
|
|
81
|
-
type: 'X25519KeyAgreementKey2019',
|
|
82
|
-
controller: did,
|
|
83
|
-
publicKeyBase58: u8a.toString(x25519PubBytes, 'base58btc'),
|
|
84
|
-
},
|
|
85
|
-
], authentication: [keyId], assertionMethod: [keyId], capabilityDelegation: [keyId], capabilityInvocation: [keyId], keyAgreement: [x25519KeyId] });
|
|
86
|
-
};
|
|
87
|
-
const keyToDidDoc2020 = ({ pubKeyBytes, fingerprint, contentType }) => {
|
|
88
|
-
const did = `did:key:${fingerprint}`;
|
|
89
|
-
const keyId = `${did}#${fingerprint}`;
|
|
90
|
-
//todo: Move to noble lib. x25519 values differ between below methods. Current implementation is correct according to DID:key spec
|
|
91
|
-
// const pubKeyHex = u8a.toString(pubKeyBytes, 'base16')
|
|
92
|
-
// const x25519PubBytes = edwardsToMontgomery(pubKeyBytes)
|
|
93
|
-
const x25519PubBytes = (0, ed25519_1.convertPublicKeyToX25519)(pubKeyBytes);
|
|
94
|
-
const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`;
|
|
95
|
-
return Object.assign(Object.assign({}, (contentType === types_1.DID_LD_JSON && {
|
|
96
|
-
'@context': [
|
|
97
|
-
'https://www.w3.org/ns/did/v1',
|
|
98
|
-
'https://w3id.org/security/suites/ed25519-2020/v1',
|
|
99
|
-
'https://w3id.org/security/suites/x25519-2020/v1',
|
|
100
|
-
],
|
|
101
|
-
})), { id: did, verificationMethod: [
|
|
102
|
-
{
|
|
103
|
-
id: keyId,
|
|
104
|
-
type: 'Ed25519VerificationKey2020',
|
|
105
|
-
controller: did,
|
|
106
|
-
publicKeyMultibase: encodeKey(pubKeyBytes, 0xed),
|
|
107
|
-
},
|
|
108
|
-
], authentication: [keyId], assertionMethod: [keyId], capabilityDelegation: [keyId], capabilityInvocation: [keyId], keyAgreement: [
|
|
109
|
-
{
|
|
110
|
-
id: x25519KeyId,
|
|
111
|
-
type: 'X25519KeyAgreementKey2020',
|
|
112
|
-
controller: did,
|
|
113
|
-
publicKeyMultibase: encodeKey(x25519PubBytes, 0xec),
|
|
114
|
-
},
|
|
115
|
-
] });
|
|
116
|
-
};
|
|
117
|
-
exports.default = { keyToDidDoc: exports.keyToDidDoc };
|
|
118
|
-
//# sourceMappingURL=ed25519.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../src/drivers/ed25519.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAElC,8DAA8D;AAC9D,gDAA6D;AAC7D,oCAAuD;AAEvD,SAAS,SAAS,CAAC,GAAe,EAAE,SAAkB;IACpD,MAAM,KAAK,GAAG,IAAI,UAAU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AW,IAAI;QACjC,UAAU,EAAE;YACV,8BAA8B;YAC9B,kDAAkD;YAClD,iDAAiD;SAClD;KACF,CAAC,KACF,EAAE,EAAE,GAAG,EACP,kBAAkB,EAAE;YAClB;gBACE,EAAE,EAAE,KAAK;gBACT,IAAI,EAAE,4BAA4B;gBAClC,UAAU,EAAE,GAAG;gBACf,kBAAkB,EAAE,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;aACjD;SACF,EACD,cAAc,EAAE,CAAC,KAAK,CAAC,EACvB,eAAe,EAAE,CAAC,KAAK,CAAC,EACxB,oBAAoB,EAAE,CAAC,KAAK,CAAC,EAC7B,oBAAoB,EAAE,CAAC,KAAK,CAAC,EAC7B,YAAY,EAAE;YACZ;gBACE,EAAE,EAAE,WAAW;gBACf,IAAI,EAAE,2BAA2B;gBACjC,UAAU,EAAE,GAAG;gBACf,kBAAkB,EAAE,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC;aACpD;SACF,IACF;AACH,CAAC,CAAA;AACD,kBAAe,EAAE,WAAW,EAAX,mBAAW,EAAE,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DIDDocument } from 'did-resolver';
|
|
2
|
-
import { KeyToDidDocArgs } from '../index';
|
|
3
|
-
export declare const keyToDidDoc: ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs) => DIDDocument;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
keyToDidDoc: ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs) => DIDDocument;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
//# sourceMappingURL=jwk.jcs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk.jcs.d.ts","sourceRoot":"","sources":["../../src/drivers/jwk.jcs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwB,MAAM,cAAc,CAAA;AAChE,OAAO,EAAe,eAAe,EAAE,MAAM,UAAU,CAAA;AAGvD,eAAO,MAAM,WAAW,8CAA+C,eAAe,KAAG,WAsBxF,CAAA;;6DAtBsE,eAAe,KAAG,WAAW;;AAuBpG,wBAA8B"}
|
package/dist/drivers/jwk.jcs.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyToDidDoc = void 0;
|
|
4
|
-
const index_1 = require("../index");
|
|
5
|
-
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
6
|
-
const keyToDidDoc = ({ pubKeyBytes, fingerprint, contentType }) => {
|
|
7
|
-
const did = `did:key:${fingerprint}`;
|
|
8
|
-
const keyId = `${did}#${fingerprint}`;
|
|
9
|
-
const publicKeyJwk = (0, ssi_sdk_ext_key_utils_1.jwkJcsDecode)(pubKeyBytes);
|
|
10
|
-
return Object.assign(Object.assign({}, (contentType === index_1.DID_LD_JSON && {
|
|
11
|
-
'@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/jws-2020/v1'],
|
|
12
|
-
})), { id: did, verificationMethod: [
|
|
13
|
-
{
|
|
14
|
-
id: keyId,
|
|
15
|
-
type: 'JsonWebKey2020',
|
|
16
|
-
controller: did,
|
|
17
|
-
publicKeyJwk,
|
|
18
|
-
},
|
|
19
|
-
], authentication: [keyId], assertionMethod: [keyId], capabilityDelegation: [keyId], capabilityInvocation: [keyId] });
|
|
20
|
-
};
|
|
21
|
-
exports.keyToDidDoc = keyToDidDoc;
|
|
22
|
-
exports.default = { keyToDidDoc: exports.keyToDidDoc };
|
|
23
|
-
//# sourceMappingURL=jwk.jcs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwk.jcs.js","sourceRoot":"","sources":["../../src/drivers/jwk.jcs.ts"],"names":[],"mappings":";;;AACA,oCAAuD;AACvD,2EAA8D;AAEvD,MAAM,WAAW,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAmB,EAAe,EAAE;IACrG,MAAM,GAAG,GAAG,WAAW,WAAW,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,MAAM,YAAY,GAAG,IAAA,oCAAY,EAAC,WAAW,CAAW,CAAA;IACxD,uCACK,CAAC,WAAW,KAAK,mBAAW,IAAI;QACjC,UAAU,EAAE,CAAC,8BAA8B,EAAE,8CAA8C,CAAC;KAC7F,CAAC,KACF,EAAE,EAAE,GAAG,EACP,kBAAkB,EAAE;YAClB;gBACE,EAAE,EAAE,KAAK;gBACT,IAAI,EAAE,gBAAgB;gBACtB,UAAU,EAAE,GAAG;gBACf,YAAY;aACb;SACF,EACD,cAAc,EAAE,CAAC,KAAK,CAAC,EACvB,eAAe,EAAE,CAAC,KAAK,CAAC,EACxB,oBAAoB,EAAE,CAAC,KAAK,CAAC,EAC7B,oBAAoB,EAAE,CAAC,KAAK,CAAC,IAC9B;AACH,CAAC,CAAA;AAtBY,QAAA,WAAW,eAsBvB;AACD,kBAAe,EAAE,WAAW,EAAX,mBAAW,EAAE,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DIDDocument } from 'did-resolver';
|
|
2
|
-
import { KeyToDidDocArgs } from '../types';
|
|
3
|
-
export declare const keyToDidDoc: ({ pubKeyBytes, fingerprint }: KeyToDidDocArgs) => DIDDocument;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
keyToDidDoc: ({ pubKeyBytes, fingerprint }: KeyToDidDocArgs) => DIDDocument;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
//# sourceMappingURL=secp256k1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["../../src/drivers/secp256k1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,eAAO,MAAM,WAAW,iCAAkC,eAAe,KAAG,WAkB3E,CAAA;;gDAlByD,eAAe,KAAG,WAAW;;AAoBvF,wBAA8B"}
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.keyToDidDoc = void 0;
|
|
27
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
28
|
-
const keyToDidDoc = ({ pubKeyBytes, fingerprint }) => {
|
|
29
|
-
const did = `did:key:${fingerprint}`;
|
|
30
|
-
const keyId = `${did}#${fingerprint}`;
|
|
31
|
-
return {
|
|
32
|
-
id: did,
|
|
33
|
-
verificationMethod: [
|
|
34
|
-
{
|
|
35
|
-
id: keyId,
|
|
36
|
-
type: 'Secp256k1VerificationKey2018',
|
|
37
|
-
controller: did,
|
|
38
|
-
publicKeyBase58: u8a.toString(pubKeyBytes, 'base58btc'),
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
authentication: [keyId],
|
|
42
|
-
assertionMethod: [keyId],
|
|
43
|
-
capabilityDelegation: [keyId],
|
|
44
|
-
capabilityInvocation: [keyId],
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
exports.keyToDidDoc = keyToDidDoc;
|
|
48
|
-
exports.default = { keyToDidDoc: exports.keyToDidDoc };
|
|
49
|
-
//# sourceMappingURL=secp256k1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../src/drivers/secp256k1.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAI3B,MAAM,WAAW,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,EAAmB,EAAe,EAAE;IACxF,MAAM,GAAG,GAAG,WAAW,WAAW,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,OAAO;QACL,EAAE,EAAE,GAAG;QACP,kBAAkB,EAAE;YAClB;gBACE,EAAE,EAAE,KAAK;gBACT,IAAI,EAAE,8BAA8B;gBACpC,UAAU,EAAE,GAAG;gBACf,eAAe,EAAE,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;aACxD;SACF;QACD,cAAc,EAAE,CAAC,KAAK,CAAC;QACvB,eAAe,EAAE,CAAC,KAAK,CAAC;QACxB,oBAAoB,EAAE,CAAC,KAAK,CAAC;QAC7B,oBAAoB,EAAE,CAAC,KAAK,CAAC;KAC9B,CAAA;AACH,CAAC,CAAA;AAlBY,QAAA,WAAW,eAkBvB;AAED,kBAAe,EAAE,WAAW,EAAX,mBAAW,EAAE,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { base64urlPoint } from 'nist-weierstrauss';
|
|
2
|
-
import { KeyToDidDocArgs } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Constructs the document based on the method key
|
|
5
|
-
*/
|
|
6
|
-
export declare function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),
|
|
10
|
-
* uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
11
|
-
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
12
|
-
*
|
|
13
|
-
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-256.
|
|
14
|
-
* At present only raw p-256 keys are covered in the specification.
|
|
15
|
-
* @throws TypeError: input cannot be null or undefined.
|
|
16
|
-
* @throws Error: Unexpected pubKeyBytes
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint;
|
|
20
|
-
declare const _default: {
|
|
21
|
-
keyToDidDoc: typeof keyToDidDoc;
|
|
22
|
-
};
|
|
23
|
-
export default _default;
|
|
24
|
-
//# sourceMappingURL=secp256r1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp256r1.d.ts","sourceRoot":"","sources":["../../src/drivers/secp256r1.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,GAAG,CAwB9E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,UAAU,GAAG,cAAc,CA8BvE;;;;AAED,wBAA8B"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.keyToDidDoc = keyToDidDoc;
|
|
28
|
-
exports.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
29
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
30
|
-
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
31
|
-
/**
|
|
32
|
-
* Constructs the document based on the method key
|
|
33
|
-
*/
|
|
34
|
-
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
35
|
-
const did = `did:key:${fingerprint}`;
|
|
36
|
-
const keyId = `${did}#${fingerprint}`;
|
|
37
|
-
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
38
|
-
return {
|
|
39
|
-
id: did,
|
|
40
|
-
verificationMethod: [
|
|
41
|
-
{
|
|
42
|
-
id: keyId,
|
|
43
|
-
type: 'JsonWebKey2020',
|
|
44
|
-
controller: did,
|
|
45
|
-
publicKeyJwk: {
|
|
46
|
-
kty: 'EC',
|
|
47
|
-
crv: 'P-256',
|
|
48
|
-
x: key.xm,
|
|
49
|
-
y: key.ym,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
authentication: [keyId],
|
|
54
|
-
assertionMethod: [keyId],
|
|
55
|
-
capabilityDelegation: [keyId],
|
|
56
|
-
capabilityInvocation: [keyId],
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),
|
|
62
|
-
* uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
63
|
-
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
64
|
-
*
|
|
65
|
-
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-256.
|
|
66
|
-
* At present only raw p-256 keys are covered in the specification.
|
|
67
|
-
* @throws TypeError: input cannot be null or undefined.
|
|
68
|
-
* @throws Error: Unexpected pubKeyBytes
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
function pubKeyBytesToXY(pubKeyBytes) {
|
|
72
|
-
if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
|
|
73
|
-
throw new TypeError('input must be a Uint8Array');
|
|
74
|
-
}
|
|
75
|
-
const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
|
|
76
|
-
const bytesCount = publicKeyHex.length / 2;
|
|
77
|
-
// raw p-256 key
|
|
78
|
-
if (bytesCount == 64) {
|
|
79
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex);
|
|
80
|
-
}
|
|
81
|
-
// uncompressed p-256 key, SEC format
|
|
82
|
-
if (bytesCount == 65) {
|
|
83
|
-
if (publicKeyHex.slice(0, 2) == '04') {
|
|
84
|
-
const publicKey = publicKeyHex.slice(2);
|
|
85
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// compressed p-256 key, SEC format
|
|
89
|
-
if (bytesCount == 33) {
|
|
90
|
-
if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {
|
|
91
|
-
const publicKey = u8a.fromString(publicKeyHex, 'base16');
|
|
92
|
-
const point = nist_weierstrauss.secp256r1.ECPointDecompress(publicKey);
|
|
93
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
throw new Error('Unexpected pubKeyBytes');
|
|
97
|
-
}
|
|
98
|
-
exports.default = { keyToDidDoc };
|
|
99
|
-
//# sourceMappingURL=secp256r1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp256r1.js","sourceRoot":"","sources":["../../src/drivers/secp256r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;AAWrD,kCAwBC;AAcD,0CA8BC;AA7ED,iDAAkC;AAElC,qEAAsD;AAItD;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAmB;IACvE,MAAM,GAAG,GAAG,WAAW,WAAW,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,M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,wBAAwB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAC5E,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,IAAI,UAAU,IAAI,EAAE,EAAE,CAAC;QACrB,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;YACzE,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YACxD,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA;YACtE,OAAO,iBAAiB,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;AAC3C,CAAC;AAED,kBAAe,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { base64urlPoint } from 'nist-weierstrauss';
|
|
2
|
-
import { KeyToDidDocArgs } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Constructs the document based on the method key
|
|
5
|
-
*/
|
|
6
|
-
export declare function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),
|
|
10
|
-
* uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
11
|
-
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
12
|
-
*
|
|
13
|
-
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-384.
|
|
14
|
-
* At present only raw p-384 keys are covered in the specification.
|
|
15
|
-
* @throws TypeError: input cannot be null or undefined.
|
|
16
|
-
* @throws Error: Unexpected pubKeyBytes
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint;
|
|
20
|
-
declare const _default: {
|
|
21
|
-
keyToDidDoc: typeof keyToDidDoc;
|
|
22
|
-
};
|
|
23
|
-
export default _default;
|
|
24
|
-
//# sourceMappingURL=secp384r1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp384r1.d.ts","sourceRoot":"","sources":["../../src/drivers/secp384r1.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,GAAG,CAwB9E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,UAAU,GAAG,cAAc,CA8BvE;;;;AAED,wBAA8B"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.keyToDidDoc = keyToDidDoc;
|
|
28
|
-
exports.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
29
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
30
|
-
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
31
|
-
/**
|
|
32
|
-
* Constructs the document based on the method key
|
|
33
|
-
*/
|
|
34
|
-
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
35
|
-
const did = `did:key:${fingerprint}`;
|
|
36
|
-
const keyId = `${did}#${fingerprint}`;
|
|
37
|
-
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
38
|
-
return {
|
|
39
|
-
id: did,
|
|
40
|
-
verificationMethod: [
|
|
41
|
-
{
|
|
42
|
-
id: keyId,
|
|
43
|
-
type: 'JsonWebKey2020',
|
|
44
|
-
controller: did,
|
|
45
|
-
publicKeyJwk: {
|
|
46
|
-
kty: 'EC',
|
|
47
|
-
crv: 'P-384',
|
|
48
|
-
x: key.xm,
|
|
49
|
-
y: key.ym,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
authentication: [keyId],
|
|
54
|
-
assertionMethod: [keyId],
|
|
55
|
-
capabilityDelegation: [keyId],
|
|
56
|
-
capabilityInvocation: [keyId],
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),
|
|
62
|
-
* uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
63
|
-
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
64
|
-
*
|
|
65
|
-
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-384.
|
|
66
|
-
* At present only raw p-384 keys are covered in the specification.
|
|
67
|
-
* @throws TypeError: input cannot be null or undefined.
|
|
68
|
-
* @throws Error: Unexpected pubKeyBytes
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
function pubKeyBytesToXY(pubKeyBytes) {
|
|
72
|
-
if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
|
|
73
|
-
throw new TypeError('input must be a Uint8Array');
|
|
74
|
-
}
|
|
75
|
-
const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
|
|
76
|
-
const bytesCount = publicKeyHex.length / 2;
|
|
77
|
-
// raw p-384 key
|
|
78
|
-
if (bytesCount == 96) {
|
|
79
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex);
|
|
80
|
-
}
|
|
81
|
-
// uncompressed p-384 key, SEC format
|
|
82
|
-
if (bytesCount == 97) {
|
|
83
|
-
if (publicKeyHex.slice(0, 2) == '04') {
|
|
84
|
-
const publicKey = publicKeyHex.slice(2);
|
|
85
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// compressed p-384 key, SEC format
|
|
89
|
-
if (bytesCount == 49) {
|
|
90
|
-
if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {
|
|
91
|
-
const publicKey = u8a.fromString(publicKeyHex, 'base16');
|
|
92
|
-
const point = nist_weierstrauss.secp384r1.ECPointDecompress(publicKey);
|
|
93
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
throw new Error('Unexpected pubKeyBytes');
|
|
97
|
-
}
|
|
98
|
-
exports.default = { keyToDidDoc };
|
|
99
|
-
//# sourceMappingURL=secp384r1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp384r1.js","sourceRoot":"","sources":["../../src/drivers/secp384r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;AAWrD,kCAwBC;AAcD,0CA8BC;AA7ED,iDAAkC;AAElC,qEAAsD;AAItD;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAmB;IACvE,MAAM,GAAG,GAAG,WAAW,WAAW,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,MAAM,GAAG,GAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IACxC,OAAO;QACL,EAAE,EAAE,GAAG;QACP,kBAAkB,EAAE;YAClB;gBACE,EAAE,EAAE,KAAK;gBACT,IAAI,EAAE,gBAAgB;gBACtB,UAAU,EAAE,GAAG;gBACf,YAAY,EAAE;oBACZ,GAAG,EAAE,IAAI;oBACT,GAAG,EAAE,OAAO;oBACZ,CAAC,EAAE,GAAG,CAAC,EAAE;oBACT,CAAC,EAAE,GAAG,CAAC,EAAE;iBACV;aACF;SACF;QACD,cAAc,EAAE,CAAC,KAAK,CAAC;QACvB,eAAe,EAAE,CAAC,KAAK,CAAC;QACxB,oBAAoB,EAAE,CAAC,KAAK,CAAC;QAC7B,oBAAoB,EAAE,CAAC,KAAK,CAAC;KAC9B,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,WAAuB;IACrD,IAAI,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5E,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@@
|
|
|
1
|
-
import { base64urlPoint } from 'nist-weierstrauss';
|
|
2
|
-
import { KeyToDidDocArgs } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Constructs the document based on the method key
|
|
5
|
-
*/
|
|
6
|
-
export declare function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param pubKeyBytes - public key as compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
10
|
-
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
11
|
-
*
|
|
12
|
-
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-521.
|
|
13
|
-
* For compression see: https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#rfc.section.3
|
|
14
|
-
* @throws TypeError: input cannot be null or undefined.
|
|
15
|
-
* @throws Error: Unexpected pubKeyBytes
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export declare function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint;
|
|
19
|
-
declare const _default: {
|
|
20
|
-
keyToDidDoc: typeof keyToDidDoc;
|
|
21
|
-
};
|
|
22
|
-
export default _default;
|
|
23
|
-
//# sourceMappingURL=secp521r1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp521r1.d.ts","sourceRoot":"","sources":["../../src/drivers/secp521r1.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,GAAG,CAwB9E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,UAAU,GAAG,cAAc,CAiBvE;;;;AAED,wBAA8B"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.keyToDidDoc = keyToDidDoc;
|
|
28
|
-
exports.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
29
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
30
|
-
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
31
|
-
/**
|
|
32
|
-
* Constructs the document based on the method key
|
|
33
|
-
*/
|
|
34
|
-
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
35
|
-
const did = `did:key:${fingerprint}`;
|
|
36
|
-
const keyId = `${did}#${fingerprint}`;
|
|
37
|
-
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
38
|
-
return {
|
|
39
|
-
id: did,
|
|
40
|
-
verificationMethod: [
|
|
41
|
-
{
|
|
42
|
-
id: keyId,
|
|
43
|
-
type: 'JsonWebKey2020',
|
|
44
|
-
controller: did,
|
|
45
|
-
publicKeyJwk: {
|
|
46
|
-
kty: 'EC',
|
|
47
|
-
crv: 'P-521',
|
|
48
|
-
x: key.xm,
|
|
49
|
-
y: key.ym,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
authentication: [keyId],
|
|
54
|
-
assertionMethod: [keyId],
|
|
55
|
-
capabilityDelegation: [keyId],
|
|
56
|
-
capabilityInvocation: [keyId],
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param pubKeyBytes - public key as compressed with 0x02 prefix if even and 0x03 prefix if odd.
|
|
62
|
-
* @returns point x,y with coordinates as multibase encoded base64urls
|
|
63
|
-
*
|
|
64
|
-
* See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-521.
|
|
65
|
-
* For compression see: https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#rfc.section.3
|
|
66
|
-
* @throws TypeError: input cannot be null or undefined.
|
|
67
|
-
* @throws Error: Unexpected pubKeyBytes
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
function pubKeyBytesToXY(pubKeyBytes) {
|
|
71
|
-
if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
|
|
72
|
-
throw new TypeError('input must be a Uint8Array');
|
|
73
|
-
}
|
|
74
|
-
const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
|
|
75
|
-
// compressed p-521 key, SEC format
|
|
76
|
-
// publicKeyHex.length / 2.0 = 67.0 bytes
|
|
77
|
-
if (132 <= publicKeyHex.length && publicKeyHex.length <= 134) {
|
|
78
|
-
if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {
|
|
79
|
-
const publicKey = u8a.fromString(publicKeyHex, 'base16');
|
|
80
|
-
const point = nist_weierstrauss.secp521r1.ECPointDecompress(publicKey);
|
|
81
|
-
return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
throw new Error('Unexpected pubKeyBytes');
|
|
85
|
-
}
|
|
86
|
-
exports.default = { keyToDidDoc };
|
|
87
|
-
//# sourceMappingURL=secp521r1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secp521r1.js","sourceRoot":"","sources":["../../src/drivers/secp521r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;AAWrD,kCAwBC;AAaD,0CAiBC;AA/DD,iDAAkC;AAElC,qEAAsD;AAItD;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAmB;IACvE,MAAM,GAAG,GAAG,WAAW,WAAW,EAAE,CAAA;IACpC,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,MAAM,GAAG,GAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IACxC,OAAO;QACL,EAAE,EAAE,GAAG;QACP,kBAAkB,EAAE;YAClB;gBACE,EAAE,EAAE,KAAK;gBACT,IAAI,EAAE,gBAAgB;gBACtB,UAAU,EAAE,GAAG;gBACf,YAAY,EAAE;oBACZ,GAAG,EAAE,IAAI;oBACT,GAAG,EAAE,OAAO;oBACZ,CAAC,EAAE,GAAG,CAAC,EAAE;oBACT,CAAC,EAAE,GAAG,CAAC,EAAE;iBACV;aACF;SACF;QACD,cAAc,EAAE,CAAC,KAAK,CAAC;QACvB,eAAe,EAAE,CAAC,KAAK,CAAC;QACxB,oBAAoB,EAAE,CAAC,KAAK,CAAC;QAC7B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AgB;;AAwC/C,wBAA8B"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DIDResolutionOptions } from 'did-resolver';
|
|
2
|
-
export declare const DID_LD_JSON = "application/did+ld+json";
|
|
3
|
-
export declare const DID_JSON = "application/did+json";
|
|
4
|
-
export type PublicKeyFormat = 'JsonWebKey2020' | 'Ed25519VerificationKey2018' | 'X25519KeyAgreementKey2019' | 'Ed25519VerificationKey2020' | 'X25519KeyAgreementKey2020' | 'Multikey';
|
|
5
|
-
export interface KeyToDidDocArgs {
|
|
6
|
-
pubKeyBytes: Uint8Array;
|
|
7
|
-
fingerprint: string;
|
|
8
|
-
contentType?: string;
|
|
9
|
-
options?: DIDKeyResolutionOptions;
|
|
10
|
-
}
|
|
11
|
-
export interface DIDKeyResolutionOptions extends DIDResolutionOptions {
|
|
12
|
-
publicKeyFormat?: PublicKeyFormat;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,WAAW,4BAA4B,CAAA;AACpD,eAAO,MAAM,QAAQ,yBAAyB,CAAA;AAE9C,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,4BAA4B,GAC5B,2BAA2B,GAC3B,4BAA4B,GAC5B,2BAA2B,GAC3B,UAAU,CAAA;AACd,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,uBAAuB,CAAA;CAClC;AAED,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IACnE,eAAe,CAAC,EAAE,eAAe,CAAA;CAClC"}
|