@sphereon/ssi-sdk-ext.did-resolver-key 0.10.2-unstable.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +10 -0
- package/dist/drivers/bls12381g2.d.ts +8 -0
- package/dist/drivers/bls12381g2.d.ts.map +1 -0
- package/dist/drivers/bls12381g2.js +49 -0
- package/dist/drivers/bls12381g2.js.map +1 -0
- package/dist/drivers/ed25519.d.ts +8 -0
- package/dist/drivers/ed25519.d.ts.map +1 -0
- package/dist/drivers/ed25519.js +118 -0
- package/dist/drivers/ed25519.js.map +1 -0
- package/dist/drivers/jwk.jcs.d.ts +8 -0
- package/dist/drivers/jwk.jcs.d.ts.map +1 -0
- package/dist/drivers/jwk.jcs.js +23 -0
- package/dist/drivers/jwk.jcs.js.map +1 -0
- package/dist/drivers/secp256k1.d.ts +8 -0
- package/dist/drivers/secp256k1.d.ts.map +1 -0
- package/dist/drivers/secp256k1.js +49 -0
- package/dist/drivers/secp256k1.js.map +1 -0
- package/dist/drivers/secp256r1.d.ts +24 -0
- package/dist/drivers/secp256r1.d.ts.map +1 -0
- package/dist/drivers/secp256r1.js +100 -0
- package/dist/drivers/secp256r1.js.map +1 -0
- package/dist/drivers/secp384r1.d.ts +24 -0
- package/dist/drivers/secp384r1.d.ts.map +1 -0
- package/dist/drivers/secp384r1.js +100 -0
- package/dist/drivers/secp384r1.js.map +1 -0
- package/dist/drivers/secp521r1.d.ts +23 -0
- package/dist/drivers/secp521r1.d.ts.map +1 -0
- package/dist/drivers/secp521r1.js +88 -0
- package/dist/drivers/secp521r1.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +94 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
- package/src/__tests__/__snapshots__/secp256r1.test.ts.snap +218 -0
- package/src/__tests__/__snapshots__/secp384r1.test.ts.snap +249 -0
- package/src/__tests__/__snapshots__/secp521r1.test.ts.snap +280 -0
- package/src/__tests__/fixtures/bls_did_doc.json +29 -0
- package/src/__tests__/fixtures/ed25519-x25519.json +240 -0
- package/src/__tests__/fixtures/ed25519_did_doc.json +24 -0
- package/src/__tests__/fixtures/jwk_jcs_did_doc.json +35 -0
- package/src/__tests__/fixtures/secp256k1_did_doc.json +21 -0
- package/src/__tests__/key_resolver.test.ts +44 -0
- package/src/__tests__/secp256r1.test.ts +207 -0
- package/src/__tests__/secp384r1.test.ts +233 -0
- package/src/__tests__/secp521r1.test.ts +202 -0
- package/src/drivers/bls12381g2.ts +24 -0
- package/src/drivers/ed25519.ts +115 -0
- package/src/drivers/jwk.jcs.ts +28 -0
- package/src/drivers/secp256k1.ts +25 -0
- package/src/drivers/secp256r1.ts +82 -0
- package/src/drivers/secp384r1.ts +82 -0
- package/src/drivers/secp521r1.ts +68 -0
- package/src/index.ts +65 -0
- package/src/types.ts +22 -0
|
@@ -0,0 +1,100 @@
|
|
|
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.pubKeyBytesToXY = exports.keyToDidDoc = void 0;
|
|
28
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
29
|
+
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
30
|
+
/**
|
|
31
|
+
* Constructs the document based on the method key
|
|
32
|
+
*/
|
|
33
|
+
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
34
|
+
const did = `did:key:${fingerprint}`;
|
|
35
|
+
const keyId = `${did}#${fingerprint}`;
|
|
36
|
+
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
37
|
+
return {
|
|
38
|
+
id: did,
|
|
39
|
+
verificationMethod: [
|
|
40
|
+
{
|
|
41
|
+
id: keyId,
|
|
42
|
+
type: 'JsonWebKey2020',
|
|
43
|
+
controller: did,
|
|
44
|
+
publicKeyJwk: {
|
|
45
|
+
kty: 'EC',
|
|
46
|
+
crv: 'P-256',
|
|
47
|
+
x: key.xm,
|
|
48
|
+
y: key.ym,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
authentication: [keyId],
|
|
53
|
+
assertionMethod: [keyId],
|
|
54
|
+
capabilityDelegation: [keyId],
|
|
55
|
+
capabilityInvocation: [keyId],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.keyToDidDoc = keyToDidDoc;
|
|
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.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
99
|
+
exports.default = { keyToDidDoc };
|
|
100
|
+
//# sourceMappingURL=secp256r1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secp256r1.js","sourceRoot":"","sources":["../../src/drivers/secp256r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,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;AAxBD,kCAwBC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,WAAuB;IACrD,IAAI,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,cAAc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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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,100 @@
|
|
|
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.pubKeyBytesToXY = exports.keyToDidDoc = void 0;
|
|
28
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
29
|
+
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
30
|
+
/**
|
|
31
|
+
* Constructs the document based on the method key
|
|
32
|
+
*/
|
|
33
|
+
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
34
|
+
const did = `did:key:${fingerprint}`;
|
|
35
|
+
const keyId = `${did}#${fingerprint}`;
|
|
36
|
+
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
37
|
+
return {
|
|
38
|
+
id: did,
|
|
39
|
+
verificationMethod: [
|
|
40
|
+
{
|
|
41
|
+
id: keyId,
|
|
42
|
+
type: 'JsonWebKey2020',
|
|
43
|
+
controller: did,
|
|
44
|
+
publicKeyJwk: {
|
|
45
|
+
kty: 'EC',
|
|
46
|
+
crv: 'P-384',
|
|
47
|
+
x: key.xm,
|
|
48
|
+
y: key.ym,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
authentication: [keyId],
|
|
53
|
+
assertionMethod: [keyId],
|
|
54
|
+
capabilityDelegation: [keyId],
|
|
55
|
+
capabilityInvocation: [keyId],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.keyToDidDoc = keyToDidDoc;
|
|
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.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
99
|
+
exports.default = { keyToDidDoc };
|
|
100
|
+
//# sourceMappingURL=secp384r1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secp384r1.js","sourceRoot":"","sources":["../../src/drivers/secp384r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,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,GAA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,EAAE;QACpB,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE;YACxE,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;SAC1E;KACF;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;AAC3C,CAAC;AA9BD,0CA8BC;AAED,kBAAe,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
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.pubKeyBytesToXY = exports.keyToDidDoc = void 0;
|
|
28
|
+
const u8a = __importStar(require("uint8arrays"));
|
|
29
|
+
const nist_weierstrauss = __importStar(require("nist-weierstrauss"));
|
|
30
|
+
/**
|
|
31
|
+
* Constructs the document based on the method key
|
|
32
|
+
*/
|
|
33
|
+
function keyToDidDoc({ pubKeyBytes, fingerprint }) {
|
|
34
|
+
const did = `did:key:${fingerprint}`;
|
|
35
|
+
const keyId = `${did}#${fingerprint}`;
|
|
36
|
+
const key = pubKeyBytesToXY(pubKeyBytes);
|
|
37
|
+
return {
|
|
38
|
+
id: did,
|
|
39
|
+
verificationMethod: [
|
|
40
|
+
{
|
|
41
|
+
id: keyId,
|
|
42
|
+
type: 'JsonWebKey2020',
|
|
43
|
+
controller: did,
|
|
44
|
+
publicKeyJwk: {
|
|
45
|
+
kty: 'EC',
|
|
46
|
+
crv: 'P-521',
|
|
47
|
+
x: key.xm,
|
|
48
|
+
y: key.ym,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
authentication: [keyId],
|
|
53
|
+
assertionMethod: [keyId],
|
|
54
|
+
capabilityDelegation: [keyId],
|
|
55
|
+
capabilityInvocation: [keyId],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.keyToDidDoc = keyToDidDoc;
|
|
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.pubKeyBytesToXY = pubKeyBytesToXY;
|
|
87
|
+
exports.default = { keyToDidDoc };
|
|
88
|
+
//# sourceMappingURL=secp521r1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secp521r1.js","sourceRoot":"","sources":["../../src/drivers/secp521r1.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,iDAAkC;AAElC,qEAAsD;AAItD;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAE,WAAW,EAAE,WAAW,EAAmB;IACvE,MAAM,G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AC,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;SAC1E;KACF;IAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;AAC3C,CAAC;AAjBD,0CAiBC;AAED,kBAAe,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResolverRegistry } from 'did-resolver';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export declare const getResolver: () => ResolverRegistry;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
getResolver: () => ResolverRegistry;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAI3F,cAAc,SAAS,CAAA;AAYvB,eAAO,MAAM,WAAW,QAAO,gBAuC9B,CAAA;;;;AACD,wBAA8B"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getResolver = void 0;
|
|
30
|
+
const varint_1 = __importDefault(require("varint"));
|
|
31
|
+
const base58_1 = require("multiformats/bases/base58");
|
|
32
|
+
const ed25519_1 = __importDefault(require("./drivers/ed25519"));
|
|
33
|
+
const bls12381g2_1 = __importDefault(require("./drivers/bls12381g2"));
|
|
34
|
+
const secp256k1_1 = __importDefault(require("./drivers/secp256k1"));
|
|
35
|
+
const secp256r1_1 = __importDefault(require("./drivers/secp256r1"));
|
|
36
|
+
const secp384r1_1 = __importDefault(require("./drivers/secp384r1"));
|
|
37
|
+
const secp521r1_1 = __importDefault(require("./drivers/secp521r1"));
|
|
38
|
+
const jwk_jcs_1 = __importDefault(require("./drivers/jwk.jcs"));
|
|
39
|
+
const types_1 = require("./types");
|
|
40
|
+
__exportStar(require("./types"), exports);
|
|
41
|
+
const prefixToDriverMap = {
|
|
42
|
+
0xe7: secp256k1_1.default,
|
|
43
|
+
0xed: ed25519_1.default,
|
|
44
|
+
0x1200: secp256r1_1.default,
|
|
45
|
+
0x1201: secp384r1_1.default,
|
|
46
|
+
0x1202: secp521r1_1.default,
|
|
47
|
+
0xeb: bls12381g2_1.default,
|
|
48
|
+
0xeb51: jwk_jcs_1.default,
|
|
49
|
+
};
|
|
50
|
+
const getResolver = () => {
|
|
51
|
+
return {
|
|
52
|
+
key: (did, parsed, r, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const contentType = options.accept || types_1.DID_LD_JSON;
|
|
54
|
+
const response = {
|
|
55
|
+
didResolutionMetadata: { contentType },
|
|
56
|
+
didDocument: null,
|
|
57
|
+
didDocumentMetadata: {},
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
const multicodecPubKey = base58_1.base58btc.decode(parsed.id);
|
|
61
|
+
const keyType = varint_1.default.decode(multicodecPubKey);
|
|
62
|
+
const pubKeyBytes = multicodecPubKey.slice(varint_1.default.decode.bytes);
|
|
63
|
+
const args = { pubKeyBytes, fingerprint: parsed.id, contentType, options };
|
|
64
|
+
const doc = yield prefixToDriverMap[keyType].keyToDidDoc(args);
|
|
65
|
+
if (contentType === types_1.DID_LD_JSON) {
|
|
66
|
+
if (!doc['@context']) {
|
|
67
|
+
doc['@context'] = 'https://w3id.org/did/v1';
|
|
68
|
+
}
|
|
69
|
+
else if (Array.isArray(doc['@context']) &&
|
|
70
|
+
!doc['@context'].includes('https://w3id.org/did/v1') &&
|
|
71
|
+
!doc['@context'].includes('https://www.w3.org/ns/did/v1')) {
|
|
72
|
+
doc['@context'].push('https://w3id.org/did/v1');
|
|
73
|
+
}
|
|
74
|
+
response.didDocument = doc;
|
|
75
|
+
}
|
|
76
|
+
else if (contentType === types_1.DID_JSON) {
|
|
77
|
+
response.didDocument = doc;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
delete response.didResolutionMetadata.contentType;
|
|
81
|
+
response.didResolutionMetadata.error = 'representationNotSupported';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
response.didResolutionMetadata.error = 'invalidDid';
|
|
86
|
+
response.didResolutionMetadata.message = e.toString();
|
|
87
|
+
}
|
|
88
|
+
return response;
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.getResolver = getResolver;
|
|
93
|
+
exports.default = { getResolver: exports.getResolver };
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2B;AAC3B,sDAAqD;AACrD,gEAAuC;AACvC,sEAA6C;AAC7C,oEAA2C;AAC3C,oEAA2C;AAC3C,oEAA2C;AAC3C,oEAA2C;AAE3C,gEAAsC;AACtC,mCAAyF;AAEzF,0CAAuB;AAEvB,MAAM,iBAAiB,GAAQ;IAC7B,IAAI,EAAE,mBAAS;IACf,IAAI,EAAE,iBAAO;IACb,MAAM,EAAE,mBAAS;IACjB,MAAM,EAAE,mBAAS;IACjB,MAAM,EAAE,mBAAS;IACjB,IAAI,EAAE,oBAAU;IAChB,MAAM,EAAE,iBAAM;CACf,CAAA;AAEM,MAAM,WAAW,GAAG,GAAqB,EAAE;IAChD,OAAO;QACL,GAAG,EAAE,CAAO,GAAW,EAAE,MAAiB,EAAE,CAAa,EAAE,OAAgC,EAAE,EAAE;YAC7F,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,IAAI,mBAAW,CAAA;YACjD,MAAM,QAAQ,GAAwB;gBACpC,qBAAqB,EAAE,EAAE,WAAW,EAAE;gBACtC,WAAW,EAAE,IAAI;gBACjB,mBAAmB,EAAE,EAAE;aACxB,CAAA;YACD,IAAI;gBACF,MAAM,gBAAgB,GAAG,kBAAS,CAAC,MAAM,C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AAqB,CAAC,OAAO,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;aACtD;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC,CAAA;KACF,CAAA;AACH,CAAC,CAAA;AAvCY,QAAA,WAAW,eAuCvB;AACD,kBAAe,EAAE,WAAW,EAAX,mBAAW,EAAE,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG,yBAAyB,CAAA;AACvC,QAAA,QAAQ,GAAG,sBAAsB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sphereon/ssi-sdk-ext.did-resolver-key",
|
|
3
|
+
"description": "Sphereon did:key resolver with BBS+/BLS and EBSI support.",
|
|
4
|
+
"version": "0.10.2-unstable.14+0543254",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.10.2-unstable.14+0543254",
|
|
13
|
+
"@stablelib/ed25519": "^1.0.3",
|
|
14
|
+
"bigint-mod-arith": "^3.2.1",
|
|
15
|
+
"did-resolver": "^4.1.0",
|
|
16
|
+
"enhanced-resolve": "^5.12.0",
|
|
17
|
+
"lodash.isplainobject": "^4.0.6",
|
|
18
|
+
"multiformats": "^9.9.0",
|
|
19
|
+
"nist-weierstrauss": "^1.6.1",
|
|
20
|
+
"uint8arrays": "^3.1.1",
|
|
21
|
+
"varint": "^6.0.0",
|
|
22
|
+
"web-encoding": "^1.1.5"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/lodash.isplainobject": "^4.0.7",
|
|
26
|
+
"@types/varint": "^6.0.1"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/**/*",
|
|
30
|
+
"src/**/*",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"repository": "git@github.com:Sphereon-Opensource/SSI-SDK-crypto-extensions.git",
|
|
38
|
+
"author": "Sphereon <dev@sphereon.com>",
|
|
39
|
+
"contributors": [],
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"Sphereon",
|
|
43
|
+
"did:key resolver",
|
|
44
|
+
"DID",
|
|
45
|
+
"KEY",
|
|
46
|
+
"EBSI",
|
|
47
|
+
"BLS",
|
|
48
|
+
"BBS+",
|
|
49
|
+
"ed25519",
|
|
50
|
+
"secp256r1",
|
|
51
|
+
"secp256r1",
|
|
52
|
+
"RSA"
|
|
53
|
+
],
|
|
54
|
+
"gitHead": "0543254d14b4ba54adeeab944315db5ba6221d47"
|
|
55
|
+
}
|