@atproto/crypto 0.4.3 → 0.4.5
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/CHANGELOG.md +14 -0
- package/LICENSE.txt +1 -1
- package/dist/const.d.ts +2 -2
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js.map +1 -1
- package/dist/did.d.ts +1 -1
- package/dist/did.d.ts.map +1 -1
- package/dist/did.js +25 -18
- package/dist/did.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/multibase.d.ts.map +1 -1
- package/dist/multibase.js +17 -7
- package/dist/multibase.js.map +1 -1
- package/dist/p256/encoding.d.ts.map +1 -1
- package/dist/p256/encoding.js.map +1 -1
- package/dist/p256/keypair.d.ts +0 -1
- package/dist/p256/keypair.d.ts.map +1 -1
- package/dist/p256/keypair.js +18 -9
- package/dist/p256/keypair.js.map +1 -1
- package/dist/p256/operations.d.ts.map +1 -1
- package/dist/p256/operations.js.map +1 -1
- package/dist/p256/plugin.d.ts +0 -1
- package/dist/p256/plugin.d.ts.map +1 -1
- package/dist/p256/plugin.js +2 -3
- package/dist/p256/plugin.js.map +1 -1
- package/dist/plugins.d.ts +0 -1
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +3 -7
- package/dist/plugins.js.map +1 -1
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js +17 -7
- package/dist/random.js.map +1 -1
- package/dist/secp256k1/encoding.d.ts.map +1 -1
- package/dist/secp256k1/encoding.js.map +1 -1
- package/dist/secp256k1/keypair.d.ts +0 -1
- package/dist/secp256k1/keypair.d.ts.map +1 -1
- package/dist/secp256k1/keypair.js +17 -8
- package/dist/secp256k1/keypair.js.map +1 -1
- package/dist/secp256k1/operations.d.ts.map +1 -1
- package/dist/secp256k1/operations.js +17 -7
- package/dist/secp256k1/operations.js.map +1 -1
- package/dist/secp256k1/plugin.d.ts +0 -1
- package/dist/secp256k1/plugin.d.ts.map +1 -1
- package/dist/secp256k1/plugin.js +2 -3
- package/dist/secp256k1/plugin.js.map +1 -1
- package/dist/sha.d.ts.map +1 -1
- package/dist/sha.js +17 -7
- package/dist/sha.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +17 -7
- package/dist/utils.js.map +1 -1
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +19 -12
- package/dist/verify.js.map +1 -1
- package/jest.config.js +1 -0
- package/package.json +5 -2
- package/src/did.ts +6 -4
- package/src/p256/keypair.ts +2 -5
- package/src/p256/operations.ts +0 -1
- package/src/p256/plugin.ts +3 -6
- package/src/plugins.ts +2 -4
- package/src/secp256k1/keypair.ts +0 -3
- package/src/secp256k1/operations.ts +0 -1
- package/src/secp256k1/plugin.ts +3 -6
- package/src/verify.ts +1 -1
- package/tests/did.test.ts +1 -1
- package/tests/key-compression.test.ts +4 -4
- package/tests/keypairs.test.ts +3 -3
- package/tests/random.test.ts +1 -1
- package/tests/signatures.test.ts +11 -9
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atproto/crypto
|
|
2
2
|
|
|
3
|
+
## 0.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4384](https://github.com/bluesky-social/atproto/pull/4384) [`d396de0`](https://github.com/bluesky-social/atproto/commit/d396de016d1d55d08cfad1dabd3ffd9eaeea76ea) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update `formatDidKey` return type to `did:key:${string}`
|
|
8
|
+
|
|
9
|
+
## 0.4.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#3220](https://github.com/bluesky-social/atproto/pull/3220) [`61dc0d60e`](https://github.com/bluesky-social/atproto/commit/61dc0d60e19b88c6427a54c6d95a391b5f4da7bd) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Apply new linting rules regarding import order
|
|
14
|
+
|
|
15
|
+
- [#3220](https://github.com/bluesky-social/atproto/pull/3220) [`61dc0d60e`](https://github.com/bluesky-social/atproto/commit/61dc0d60e19b88c6427a54c6d95a391b5f4da7bd) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update NodeJS engine requirement to >=18.7.0
|
|
16
|
+
|
|
3
17
|
## 0.4.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2025 Bluesky Social PBC, and Contributors
|
|
4
4
|
|
|
5
5
|
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
6
|
|
package/dist/const.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const P256_DID_PREFIX: Uint8Array
|
|
2
|
-
export declare const SECP256K1_DID_PREFIX: Uint8Array
|
|
1
|
+
export declare const P256_DID_PREFIX: Uint8Array<ArrayBuffer>;
|
|
2
|
+
export declare const SECP256K1_DID_PREFIX: Uint8Array<ArrayBuffer>;
|
|
3
3
|
export declare const BASE58_MULTIBASE_PREFIX = "z";
|
|
4
4
|
export declare const DID_KEY_PREFIX = "did:key:";
|
|
5
5
|
export declare const P256_JWT_ALG = "ES256";
|
package/dist/const.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,yBAA+B,CAAA;AAC3D,eAAO,MAAM,oBAAoB,yBAA+B,CAAA;AAChE,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAC1C,eAAO,MAAM,cAAc,aAAa,CAAA;AAExC,eAAO,MAAM,YAAY,UAAU,CAAA;AACnC,eAAO,MAAM,iBAAiB,WAAW,CAAA"}
|
package/dist/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AAC9C,QAAA,oBAAoB,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,QAAA,uBAAuB,GAAG,GAAG,CAAA;AAC7B,QAAA,cAAc,GAAG,UAAU,CAAA;AAE3B,QAAA,YAAY,GAAG,OAAO,CAAA;AACtB,QAAA,iBAAiB,GAAG,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AAC9C,QAAA,oBAAoB,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,QAAA,uBAAuB,GAAG,GAAG,CAAA;AAC7B,QAAA,cAAc,GAAG,UAAU,CAAA;AAE3B,QAAA,YAAY,GAAG,OAAO,CAAA;AACtB,QAAA,iBAAiB,GAAG,QAAQ,CAAA","sourcesContent":["export const P256_DID_PREFIX = new Uint8Array([0x80, 0x24])\nexport const SECP256K1_DID_PREFIX = new Uint8Array([0xe7, 0x01])\nexport const BASE58_MULTIBASE_PREFIX = 'z'\nexport const DID_KEY_PREFIX = 'did:key:'\n\nexport const P256_JWT_ALG = 'ES256'\nexport const SECP256K1_JWT_ALG = 'ES256K'\n"]}
|
package/dist/did.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export type ParsedMultikey = {
|
|
|
5
5
|
export declare const parseMultikey: (multikey: string) => ParsedMultikey;
|
|
6
6
|
export declare const formatMultikey: (jwtAlg: string, keyBytes: Uint8Array) => string;
|
|
7
7
|
export declare const parseDidKey: (did: string) => ParsedMultikey;
|
|
8
|
-
export declare
|
|
8
|
+
export declare function formatDidKey(jwtAlg: string, keyBytes: Uint8Array): `did:key:${string}`;
|
|
9
9
|
//# sourceMappingURL=did.d.ts.map
|
package/dist/did.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,UAAU,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,KAAG,cAahD,CAAA;AAED,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EACd,UAAU,UAAU,KACnB,MAYF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,cAGzC,CAAA;AAED,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,UAAU,GACnB,WAAW,MAAM,EAAE,CAErB"}
|
package/dist/did.js
CHANGED
|
@@ -15,25 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
28
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
36
|
+
exports.parseDidKey = exports.formatMultikey = exports.parseMultikey = void 0;
|
|
37
|
+
exports.formatDidKey = formatDidKey;
|
|
30
38
|
const uint8arrays = __importStar(require("uint8arrays"));
|
|
31
39
|
const const_1 = require("./const");
|
|
32
|
-
const plugins_1 =
|
|
40
|
+
const plugins_1 = require("./plugins");
|
|
33
41
|
const utils_1 = require("./utils");
|
|
34
42
|
const parseMultikey = (multikey) => {
|
|
35
43
|
const prefixedBytes = (0, utils_1.extractPrefixedBytes)(multikey);
|
|
36
|
-
const plugin = plugins_1.
|
|
44
|
+
const plugin = plugins_1.plugins.find((p) => (0, utils_1.hasPrefix)(prefixedBytes, p.prefix));
|
|
37
45
|
if (!plugin) {
|
|
38
46
|
throw new Error('Unsupported key type');
|
|
39
47
|
}
|
|
@@ -45,7 +53,7 @@ const parseMultikey = (multikey) => {
|
|
|
45
53
|
};
|
|
46
54
|
exports.parseMultikey = parseMultikey;
|
|
47
55
|
const formatMultikey = (jwtAlg, keyBytes) => {
|
|
48
|
-
const plugin = plugins_1.
|
|
56
|
+
const plugin = plugins_1.plugins.find((p) => p.jwtAlg === jwtAlg);
|
|
49
57
|
if (!plugin) {
|
|
50
58
|
throw new Error('Unsupported key type');
|
|
51
59
|
}
|
|
@@ -61,8 +69,7 @@ const parseDidKey = (did) => {
|
|
|
61
69
|
return (0, exports.parseMultikey)(multikey);
|
|
62
70
|
};
|
|
63
71
|
exports.parseDidKey = parseDidKey;
|
|
64
|
-
|
|
65
|
-
return const_1.DID_KEY_PREFIX
|
|
66
|
-
}
|
|
67
|
-
exports.formatDidKey = formatDidKey;
|
|
72
|
+
function formatDidKey(jwtAlg, keyBytes) {
|
|
73
|
+
return `${const_1.DID_KEY_PREFIX}${(0, exports.formatMultikey)(jwtAlg, keyBytes)}`;
|
|
74
|
+
}
|
|
68
75
|
//# sourceMappingURL=did.js.map
|
package/dist/did.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did.js","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"did.js","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,oCAKC;AApDD,yDAA0C;AAC1C,mCAAiE;AACjE,uCAAmC;AACnC,mCAA0E;AAOnE,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAkB,EAAE;IAChE,MAAM,aAAa,GAAG,IAAA,4BAAoB,EAAC,QAAQ,CAAC,CAAA;IACpD,MAAM,MAAM,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,iBAAS,EAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IACtE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACzC,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,CACtC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAC1C,CAAA;IACD,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AAbY,QAAA,aAAa,iBAazB;AAEM,MAAM,cAAc,GAAG,CAC5B,MAAc,EACd,QAAoB,EACZ,EAAE;IACV,MAAM,MAAM,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;IACvD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACzC,CAAC;IACD,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC;QACvC,MAAM,CAAC,MAAM;QACb,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;KAChC,CAAC,CAAA;IACF,OAAO,CACL,+BAAuB,GAAG,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAC3E,CAAA;AACH,CAAC,CAAA;AAfY,QAAA,cAAc,kBAe1B;AAEM,MAAM,WAAW,GAAG,CAAC,GAAW,EAAkB,EAAE;IACzD,MAAM,QAAQ,GAAG,IAAA,uBAAe,EAAC,GAAG,CAAC,CAAA;IACrC,OAAO,IAAA,qBAAa,EAAC,QAAQ,CAAC,CAAA;AAChC,CAAC,CAAA;AAHY,QAAA,WAAW,eAGvB;AAED,SAAgB,YAAY,CAC1B,MAAc,EACd,QAAoB;IAEpB,OAAO,GAAG,sBAAc,GAAG,IAAA,sBAAc,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAW,CAAA;AACxE,CAAC","sourcesContent":["import * as uint8arrays from 'uint8arrays'\nimport { BASE58_MULTIBASE_PREFIX, DID_KEY_PREFIX } from './const'\nimport { plugins } from './plugins'\nimport { extractMultikey, extractPrefixedBytes, hasPrefix } from './utils'\n\nexport type ParsedMultikey = {\n jwtAlg: string\n keyBytes: Uint8Array\n}\n\nexport const parseMultikey = (multikey: string): ParsedMultikey => {\n const prefixedBytes = extractPrefixedBytes(multikey)\n const plugin = plugins.find((p) => hasPrefix(prefixedBytes, p.prefix))\n if (!plugin) {\n throw new Error('Unsupported key type')\n }\n const keyBytes = plugin.decompressPubkey(\n prefixedBytes.slice(plugin.prefix.length),\n )\n return {\n jwtAlg: plugin.jwtAlg,\n keyBytes,\n }\n}\n\nexport const formatMultikey = (\n jwtAlg: string,\n keyBytes: Uint8Array,\n): string => {\n const plugin = plugins.find((p) => p.jwtAlg === jwtAlg)\n if (!plugin) {\n throw new Error('Unsupported key type')\n }\n const prefixedBytes = uint8arrays.concat([\n plugin.prefix,\n plugin.compressPubkey(keyBytes),\n ])\n return (\n BASE58_MULTIBASE_PREFIX + uint8arrays.toString(prefixedBytes, 'base58btc')\n )\n}\n\nexport const parseDidKey = (did: string): ParsedMultikey => {\n const multikey = extractMultikey(did)\n return parseMultikey(multikey)\n}\n\nexport function formatDidKey(\n jwtAlg: string,\n keyBytes: Uint8Array,\n): `did:key:${string}` {\n return `${DID_KEY_PREFIX}${formatMultikey(jwtAlg, keyBytes)}` as const\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,wCAAqB;AACrB,8CAA2B;AAC3B,2CAAwB;AACxB,wCAAqB;AACrB,0CAAuB;AACvB,2CAAwB;AACxB,0CAAuB;AAEvB,iDAA8B;AAC9B,gDAA6B;AAE7B,sDAAmC;AACnC,qDAAkC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,wCAAqB;AACrB,8CAA2B;AAC3B,2CAAwB;AACxB,wCAAqB;AACrB,0CAAuB;AACvB,2CAAwB;AACxB,0CAAuB;AAEvB,iDAA8B;AAC9B,gDAA6B;AAE7B,sDAAmC;AACnC,qDAAkC","sourcesContent":["export * from './const'\nexport * from './did'\nexport * from './multibase'\nexport * from './random'\nexport * from './sha'\nexport * from './types'\nexport * from './verify'\nexport * from './utils'\n\nexport * from './p256/keypair'\nexport * from './p256/plugin'\n\nexport * from './secp256k1/keypair'\nexport * from './secp256k1/plugin'\n"]}
|
package/dist/multibase.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multibase.d.ts","sourceRoot":"","sources":["../src/multibase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE1D,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"multibase.d.ts","sourceRoot":"","sources":["../src/multibase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE1D,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,KAAG,UAuB7C,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,IAAI,UAAU,EACd,UAAU,kBAAkB,KAC3B,MAqBF,CAAA"}
|
package/dist/multibase.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.bytesToMultibase = exports.multibaseToBytes = void 0;
|
|
27
37
|
const uint8arrays = __importStar(require("uint8arrays"));
|
package/dist/multibase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multibase.js","sourceRoot":"","sources":["../src/multibase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multibase.js","sourceRoot":"","sources":["../src/multibase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA0C;AAGnC,MAAM,gBAAgB,GAAG,CAAC,EAAU,EAAc,EAAE;IACzD,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;IAClB,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACvB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAC9C,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;QACnD,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAC9C,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;QACnD,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;QACjD,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAC9C,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;QACjD,KAAK,GAAG;YACN,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;QACpD;YACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;IACpD,CAAC;AACH,CAAC,CAAA;AAvBY,QAAA,gBAAgB,oBAuB5B;AAEM,MAAM,gBAAgB,GAAG,CAC9B,EAAc,EACd,QAA4B,EACpB,EAAE;IACV,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,aAAa;YAChB,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,QAAQ;YACX,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,aAAa;YAChB,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,WAAW;YACd,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,QAAQ;YACX,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,WAAW;YACd,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD,KAAK,cAAc;YACjB,OAAO,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QACjD;YACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC,CAAA;AAxBY,QAAA,gBAAgB,oBAwB5B","sourcesContent":["import * as uint8arrays from 'uint8arrays'\nimport { SupportedEncodings } from 'uint8arrays/to-string'\n\nexport const multibaseToBytes = (mb: string): Uint8Array => {\n const base = mb[0]\n const key = mb.slice(1)\n switch (base) {\n case 'f':\n return uint8arrays.fromString(key, 'base16')\n case 'F':\n return uint8arrays.fromString(key, 'base16upper')\n case 'b':\n return uint8arrays.fromString(key, 'base32')\n case 'B':\n return uint8arrays.fromString(key, 'base32upper')\n case 'z':\n return uint8arrays.fromString(key, 'base58btc')\n case 'm':\n return uint8arrays.fromString(key, 'base64')\n case 'u':\n return uint8arrays.fromString(key, 'base64url')\n case 'U':\n return uint8arrays.fromString(key, 'base64urlpad')\n default:\n throw new Error(`Unsupported multibase: :${mb}`)\n }\n}\n\nexport const bytesToMultibase = (\n mb: Uint8Array,\n encoding: SupportedEncodings,\n): string => {\n switch (encoding) {\n case 'base16':\n return 'f' + uint8arrays.toString(mb, encoding)\n case 'base16upper':\n return 'F' + uint8arrays.toString(mb, encoding)\n case 'base32':\n return 'b' + uint8arrays.toString(mb, encoding)\n case 'base32upper':\n return 'B' + uint8arrays.toString(mb, encoding)\n case 'base58btc':\n return 'z' + uint8arrays.toString(mb, encoding)\n case 'base64':\n return 'm' + uint8arrays.toString(mb, encoding)\n case 'base64url':\n return 'u' + uint8arrays.toString(mb, encoding)\n case 'base64urlpad':\n return 'U' + uint8arrays.toString(mb, encoding)\n default:\n throw new Error(`Unsupported multibase: :${encoding}`)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/p256/encoding.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/p256/encoding.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAI,aAAa,UAAU,KAAG,UAGxD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU,KAAG,UAMzD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/p256/encoding.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAElC,MAAM,cAAc,GAAG,CAAC,WAAuB,EAAc,EAAE;IACpE,MAAM,KAAK,GAAG,WAAI,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACvD,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B;AAEM,MAAM,gBAAgB,GAAG,CAAC,UAAsB,EAAc,EAAE;IACrE,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,MAAM,KAAK,GAAG,WAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACtD,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,CAAA;AANY,QAAA,gBAAgB,oBAM5B"}
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/p256/encoding.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAElC,MAAM,cAAc,GAAG,CAAC,WAAuB,EAAc,EAAE;IACpE,MAAM,KAAK,GAAG,WAAI,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACvD,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B;AAEM,MAAM,gBAAgB,GAAG,CAAC,UAAsB,EAAc,EAAE;IACrE,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,MAAM,KAAK,GAAG,WAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACtD,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,CAAA;AANY,QAAA,gBAAgB,oBAM5B","sourcesContent":["import { p256 } from '@noble/curves/p256'\n\nexport const compressPubkey = (pubkeyBytes: Uint8Array): Uint8Array => {\n const point = p256.ProjectivePoint.fromHex(pubkeyBytes)\n return point.toRawBytes(true)\n}\n\nexport const decompressPubkey = (compressed: Uint8Array): Uint8Array => {\n if (compressed.length !== 33) {\n throw new Error('Expected 33 byte compress pubkey')\n }\n const point = p256.ProjectivePoint.fromHex(compressed)\n return point.toRawBytes(false)\n}\n"]}
|
package/dist/p256/keypair.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/p256/keypair.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/p256/keypair.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,qBAAa,WAAY,YAAW,OAAO;IAKvC,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IALpB,MAAM,SAAe;IACrB,OAAO,CAAC,SAAS,CAAY;gBAGnB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,OAAO;WAKhB,MAAM,CACjB,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACjC,OAAO,CAAC,WAAW,CAAC;WAMV,MAAM,CACjB,OAAO,EAAE,UAAU,GAAG,MAAM,EAC5B,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACjC,OAAO,CAAC,WAAW,CAAC;IAOvB,cAAc,IAAI,UAAU;IAI5B,YAAY,CAAC,QAAQ,GAAE,kBAAgC,GAAG,MAAM;IAIhE,GAAG,IAAI,MAAM;IAIP,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAO1C,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC;CAMpC"}
|
package/dist/p256/keypair.js
CHANGED
|
@@ -15,20 +15,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.P256Keypair = void 0;
|
|
27
37
|
const p256_1 = require("@noble/curves/p256");
|
|
28
38
|
const sha256_1 = require("@noble/hashes/sha256");
|
|
29
39
|
const uint8arrays_1 = require("uint8arrays");
|
|
30
|
-
const did = __importStar(require("../did"));
|
|
31
40
|
const const_1 = require("../const");
|
|
41
|
+
const did = __importStar(require("../did"));
|
|
32
42
|
class P256Keypair {
|
|
33
43
|
constructor(privateKey, exportable) {
|
|
34
44
|
Object.defineProperty(this, "privateKey", {
|
|
@@ -90,5 +100,4 @@ class P256Keypair {
|
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
exports.P256Keypair = P256Keypair;
|
|
93
|
-
exports.default = P256Keypair;
|
|
94
103
|
//# sourceMappingURL=keypair.js.map
|
package/dist/p256/keypair.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../src/p256/keypair.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../src/p256/keypair.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AACzC,iDAA6C;AAC7C,6CAGoB;AAEpB,oCAAuC;AACvC,4CAA6B;AAO7B,MAAa,WAAW;IAItB,YACU,UAAsB,EACtB,UAAmB;QAD3B;;;;mBAAQ,UAAU;WAAY;QAC9B;;;;mBAAQ,UAAU;WAAS;QAL7B;;;;mBAAS,oBAAY;WAAA;QACb;;;;;WAAqB;QAM3B,IAAI,CAAC,SAAS,GAAG,WAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,IAAkC;QAElC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,CAAA;QACzC,MAAM,OAAO,GAAG,WAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAA;QAC7C,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,OAA4B,EAC5B,IAAkC;QAElC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,CAAA;QACzC,MAAM,YAAY,GAChB,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,wBAAa,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QACvE,OAAO,IAAI,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IAClD,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,YAAY,CAAC,WAA+B,WAAW;QACrD,OAAO,IAAA,sBAAW,EAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IAC9C,CAAC;IAED,GAAG;QACD,OAAO,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACtD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAe;QACxB,MAAM,OAAO,GAAG,MAAM,IAAA,eAAM,EAAC,GAAG,CAAC,CAAA;QACjC,yCAAyC;QACzC,MAAM,GAAG,GAAG,MAAM,WAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACrE,OAAO,GAAG,CAAC,iBAAiB,EAAE,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;QAClD,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF;AAtDD,kCAsDC","sourcesContent":["import { p256 } from '@noble/curves/p256'\nimport { sha256 } from '@noble/hashes/sha256'\nimport {\n fromString as ui8FromString,\n toString as ui8ToString,\n} from 'uint8arrays'\nimport { SupportedEncodings } from 'uint8arrays/to-string'\nimport { P256_JWT_ALG } from '../const'\nimport * as did from '../did'\nimport { Keypair } from '../types'\n\nexport type P256KeypairOptions = {\n exportable: boolean\n}\n\nexport class P256Keypair implements Keypair {\n jwtAlg = P256_JWT_ALG\n private publicKey: Uint8Array\n\n constructor(\n private privateKey: Uint8Array,\n private exportable: boolean,\n ) {\n this.publicKey = p256.getPublicKey(privateKey)\n }\n\n static async create(\n opts?: Partial<P256KeypairOptions>,\n ): Promise<P256Keypair> {\n const { exportable = false } = opts || {}\n const privKey = p256.utils.randomPrivateKey()\n return new P256Keypair(privKey, exportable)\n }\n\n static async import(\n privKey: Uint8Array | string,\n opts?: Partial<P256KeypairOptions>,\n ): Promise<P256Keypair> {\n const { exportable = false } = opts || {}\n const privKeyBytes =\n typeof privKey === 'string' ? ui8FromString(privKey, 'hex') : privKey\n return new P256Keypair(privKeyBytes, exportable)\n }\n\n publicKeyBytes(): Uint8Array {\n return this.publicKey\n }\n\n publicKeyStr(encoding: SupportedEncodings = 'base64pad'): string {\n return ui8ToString(this.publicKey, encoding)\n }\n\n did(): string {\n return did.formatDidKey(this.jwtAlg, this.publicKey)\n }\n\n async sign(msg: Uint8Array): Promise<Uint8Array> {\n const msgHash = await sha256(msg)\n // return raw 64 byte sig not DER-encoded\n const sig = await p256.sign(msgHash, this.privateKey, { lowS: true })\n return sig.toCompactRawBytes()\n }\n\n async export(): Promise<Uint8Array> {\n if (!this.exportable) {\n throw new Error('Private key is not exportable')\n }\n return this.privateKey\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/p256/operations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/p256/operations.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EACX,MAAM,UAAU,EAChB,KAAK,UAAU,EACf,OAAO,aAAa,KACnB,OAAO,CAAC,OAAO,CAOjB,CAAA;AAED,eAAO,MAAM,SAAS,GACpB,WAAW,UAAU,EACrB,MAAM,UAAU,EAChB,KAAK,UAAU,EACf,OAAO,aAAa,KACnB,OAAO,CAAC,OAAO,CAOjB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,UAAU,YAO9C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/p256/operations.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,iDAA6C;AAC7C,6CAAiD;
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/p256/operations.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,iDAA6C;AAC7C,6CAAiD;AACjD,oCAA0C;AAE1C,oCAA2E;AAEpE,MAAM,YAAY,GAAG,KAAK,EAC/B,GAAW,EACX,IAAgB,EAChB,GAAe,EACf,IAAoB,EACF,EAAE;IACpB,MAAM,aAAa,GAAG,IAAA,4BAAoB,EAAC,IAAA,uBAAe,EAAC,GAAG,CAAC,CAAC,CAAA;IAChE,IAAI,CAAC,IAAA,iBAAS,EAAC,aAAa,EAAE,uBAAe,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAA;IAChD,CAAC;IACD,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,uBAAe,CAAC,MAAM,CAAC,CAAA;IAC5D,OAAO,IAAA,iBAAS,EAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;AAC7C,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB;AAEM,MAAM,SAAS,GAAG,KAAK,EAC5B,SAAqB,EACrB,IAAgB,EAChB,GAAe,EACf,IAAoB,EACF,EAAE;IACpB,MAAM,cAAc,GAAG,IAAI,EAAE,iBAAiB,IAAI,KAAK,CAAA;IACvD,MAAM,OAAO,GAAG,MAAM,IAAA,eAAM,EAAC,IAAI,CAAC,CAAA;IAClC,OAAO,WAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE;QAC1C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,iCAAiC;QACjF,IAAI,EAAE,CAAC,cAAc;KACtB,CAAC,CAAA;AACJ,CAAC,CAAA;AAZY,QAAA,SAAS,aAYrB;AAEM,MAAM,eAAe,GAAG,CAAC,GAAe,EAAE,EAAE;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,WAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAC9C,OAAO,IAAA,oBAAS,EAAC,MAAM,CAAC,iBAAiB,EAAE,EAAE,GAAG,CAAC,CAAA;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAPY,QAAA,eAAe,mBAO3B","sourcesContent":["import { p256 } from '@noble/curves/p256'\nimport { sha256 } from '@noble/hashes/sha256'\nimport { equals as ui8equals } from 'uint8arrays'\nimport { P256_DID_PREFIX } from '../const'\nimport { VerifyOptions } from '../types'\nimport { extractMultikey, extractPrefixedBytes, hasPrefix } from '../utils'\n\nexport const verifyDidSig = async (\n did: string,\n data: Uint8Array,\n sig: Uint8Array,\n opts?: VerifyOptions,\n): Promise<boolean> => {\n const prefixedBytes = extractPrefixedBytes(extractMultikey(did))\n if (!hasPrefix(prefixedBytes, P256_DID_PREFIX)) {\n throw new Error(`Not a P-256 did:key: ${did}`)\n }\n const keyBytes = prefixedBytes.slice(P256_DID_PREFIX.length)\n return verifySig(keyBytes, data, sig, opts)\n}\n\nexport const verifySig = async (\n publicKey: Uint8Array,\n data: Uint8Array,\n sig: Uint8Array,\n opts?: VerifyOptions,\n): Promise<boolean> => {\n const allowMalleable = opts?.allowMalleableSig ?? false\n const msgHash = await sha256(data)\n return p256.verify(sig, msgHash, publicKey, {\n format: allowMalleable ? undefined : 'compact', // prevent DER-encoded signatures\n lowS: !allowMalleable,\n })\n}\n\nexport const isCompactFormat = (sig: Uint8Array) => {\n try {\n const parsed = p256.Signature.fromCompact(sig)\n return ui8equals(parsed.toCompactRawBytes(), sig)\n } catch {\n return false\n }\n}\n"]}
|
package/dist/p256/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/p256/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/p256/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAIvC,eAAO,MAAM,UAAU,EAAE,YAOxB,CAAA"}
|
package/dist/p256/plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.p256Plugin = void 0;
|
|
4
|
-
const operations_1 = require("./operations");
|
|
5
|
-
const encoding_1 = require("./encoding");
|
|
6
4
|
const const_1 = require("../const");
|
|
5
|
+
const encoding_1 = require("./encoding");
|
|
6
|
+
const operations_1 = require("./operations");
|
|
7
7
|
exports.p256Plugin = {
|
|
8
8
|
prefix: const_1.P256_DID_PREFIX,
|
|
9
9
|
jwtAlg: const_1.P256_JWT_ALG,
|
|
@@ -11,5 +11,4 @@ exports.p256Plugin = {
|
|
|
11
11
|
compressPubkey: encoding_1.compressPubkey,
|
|
12
12
|
decompressPubkey: encoding_1.decompressPubkey,
|
|
13
13
|
};
|
|
14
|
-
exports.default = exports.p256Plugin;
|
|
15
14
|
//# sourceMappingURL=plugin.js.map
|
package/dist/p256/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/p256/plugin.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/p256/plugin.ts"],"names":[],"mappings":";;;AAAA,oCAAwD;AAExD,yCAA6D;AAC7D,6CAA2C;AAE9B,QAAA,UAAU,GAAiB;IACtC,MAAM,EAAE,uBAAe;IACvB,MAAM,EAAE,oBAAY;IACpB,eAAe,EAAE,yBAAY;IAE7B,cAAc,EAAd,yBAAc;IACd,gBAAgB,EAAhB,2BAAgB;CACjB,CAAA","sourcesContent":["import { P256_DID_PREFIX, P256_JWT_ALG } from '../const'\nimport { DidKeyPlugin } from '../types'\nimport { compressPubkey, decompressPubkey } from './encoding'\nimport { verifyDidSig } from './operations'\n\nexport const p256Plugin: DidKeyPlugin = {\n prefix: P256_DID_PREFIX,\n jwtAlg: P256_JWT_ALG,\n verifySignature: verifyDidSig,\n\n compressPubkey,\n decompressPubkey,\n}\n"]}
|
package/dist/plugins.d.ts
CHANGED
package/dist/plugins.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,kCAAgC,CAAA
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,kCAAgC,CAAA"}
|
package/dist/plugins.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.plugins = void 0;
|
|
7
|
-
const plugin_1 =
|
|
8
|
-
const plugin_2 =
|
|
9
|
-
exports.plugins = [plugin_1.
|
|
10
|
-
exports.default = exports.plugins;
|
|
4
|
+
const plugin_1 = require("./p256/plugin");
|
|
5
|
+
const plugin_2 = require("./secp256k1/plugin");
|
|
6
|
+
exports.plugins = [plugin_1.p256Plugin, plugin_2.secp256k1Plugin];
|
|
11
7
|
//# sourceMappingURL=plugins.js.map
|
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,+CAAoD;AAEvC,QAAA,OAAO,GAAG,CAAC,mBAAU,EAAE,wBAAe,CAAC,CAAA","sourcesContent":["import { p256Plugin } from './p256/plugin'\nimport { secp256k1Plugin } from './secp256k1/plugin'\n\nexport const plugins = [p256Plugin, secp256k1Plugin]\n"]}
|
package/dist/random.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG1D,eAAO,MAAM,WAAW,0BAAoB,CAAA;AAE5C,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAA;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG1D,eAAO,MAAM,WAAW,0BAAoB,CAAA;AAE5C,eAAO,MAAM,SAAS,GACpB,YAAY,MAAM,EAClB,UAAU,kBAAkB,KAC3B,MAGF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,YAAO,KACN,OAAO,CAAC,MAAM,CAMhB,CAAA"}
|
package/dist/random.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.randomIntFromSeed = exports.randomStr = exports.randomBytes = void 0;
|
|
27
37
|
const noble = __importStar(require("@noble/hashes/utils"));
|
package/dist/random.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA4C;AAC5C,yDAA0C;AAE1C,+BAA8B;AAEjB,QAAA,WAAW,GAAG,KAAK,CAAC,WAAW,CAAA;AAErC,MAAM,SAAS,GAAG,CACvB,UAAkB,EAClB,QAA4B,EACpB,EAAE;IACV,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,UAAU,CAAC,CAAA;IACrC,OAAO,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AAC9C,CAAC,CAAA;AANY,QAAA,SAAS,aAMrB;AAEM,MAAM,iBAAiB,GAAG,KAAK,EACpC,IAAY,EACZ,IAAY,EACZ,GAAG,GAAG,CAAC,EACU,EAAE;IACnB,MAAM,IAAI,GAAG,MAAM,IAAA,YAAM,EAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACjD,MAAM,KAAK,GAAG,IAAI,GAAG,GAAG,CAAA;IACxB,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAA;IACjC,OAAO,UAAU,GAAG,GAAG,CAAA;AACzB,CAAC,CAAA;AAVY,QAAA,iBAAiB,qBAU7B","sourcesContent":["import * as noble from '@noble/hashes/utils'\nimport * as uint8arrays from 'uint8arrays'\nimport { SupportedEncodings } from 'uint8arrays/to-string'\nimport { sha256 } from './sha'\n\nexport const randomBytes = noble.randomBytes\n\nexport const randomStr = (\n byteLength: number,\n encoding: SupportedEncodings,\n): string => {\n const bytes = randomBytes(byteLength)\n return uint8arrays.toString(bytes, encoding)\n}\n\nexport const randomIntFromSeed = async (\n seed: string,\n high: number,\n low = 0,\n): Promise<number> => {\n const hash = await sha256(seed)\n const number = Buffer.from(hash).readUintBE(0, 6)\n const range = high - low\n const normalized = number % range\n return normalized + low\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/secp256k1/encoding.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/secp256k1/encoding.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAI,aAAa,UAAU,KAAG,UAGxD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU,KAAG,UAMzD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/secp256k1/encoding.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAEpD,MAAM,cAAc,GAAG,CAAC,WAAuB,EAAc,EAAE;IACpE,MAAM,KAAK,GAAG,qBAAI,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACvD,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B;AAEM,MAAM,gBAAgB,GAAG,CAAC,UAAsB,EAAc,EAAE;IACrE,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,MAAM,KAAK,GAAG,qBAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACtD,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,CAAA;AANY,QAAA,gBAAgB,oBAM5B"}
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/secp256k1/encoding.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAEpD,MAAM,cAAc,GAAG,CAAC,WAAuB,EAAc,EAAE;IACpE,MAAM,KAAK,GAAG,qBAAI,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACvD,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B;AAEM,MAAM,gBAAgB,GAAG,CAAC,UAAsB,EAAc,EAAE;IACrE,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,MAAM,KAAK,GAAG,qBAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACtD,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,CAAA;AANY,QAAA,gBAAgB,oBAM5B","sourcesContent":["import { secp256k1 as k256 } from '@noble/curves/secp256k1'\n\nexport const compressPubkey = (pubkeyBytes: Uint8Array): Uint8Array => {\n const point = k256.ProjectivePoint.fromHex(pubkeyBytes)\n return point.toRawBytes(true)\n}\n\nexport const decompressPubkey = (compressed: Uint8Array): Uint8Array => {\n if (compressed.length !== 33) {\n throw new Error('Expected 33 byte compress pubkey')\n }\n const point = k256.ProjectivePoint.fromHex(compressed)\n return point.toRawBytes(false)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/secp256k1/keypair.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/secp256k1/keypair.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,qBAAa,gBAAiB,YAAW,OAAO;IAK5C,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;IALpB,MAAM,SAAoB;IAC1B,OAAO,CAAC,SAAS,CAAY;gBAGnB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,OAAO;WAKhB,MAAM,CACjB,IAAI,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACtC,OAAO,CAAC,gBAAgB,CAAC;WAMf,MAAM,CACjB,OAAO,EAAE,UAAU,GAAG,MAAM,EAC5B,IAAI,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACtC,OAAO,CAAC,gBAAgB,CAAC;IAO5B,cAAc,IAAI,UAAU;IAI5B,YAAY,CAAC,QAAQ,GAAE,kBAAgC,GAAG,MAAM;IAIhE,GAAG,IAAI,MAAM;IAIP,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAO1C,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC;CAMpC"}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.Secp256k1Keypair = void 0;
|
|
27
37
|
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
@@ -90,5 +100,4 @@ class Secp256k1Keypair {
|
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
exports.Secp256k1Keypair = Secp256k1Keypair;
|
|
93
|
-
exports.default = Secp256k1Keypair;
|
|
94
103
|
//# sourceMappingURL=keypair.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../src/secp256k1/keypair.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keypair.js","sourceRoot":"","sources":["../../src/secp256k1/keypair.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA2D;AAC3D,iDAA6C;AAC7C,6CAGoB;AAEpB,oCAA4C;AAC5C,4CAA6B;AAO7B,MAAa,gBAAgB;IAI3B,YACU,UAAsB,EACtB,UAAmB;QAD3B;;;;mBAAQ,UAAU;WAAY;QAC9B;;;;mBAAQ,UAAU;WAAS;QAL7B;;;;mBAAS,yBAAiB;WAAA;QAClB;;;;;WAAqB;QAM3B,IAAI,CAAC,SAAS,GAAG,qBAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,IAAuC;QAEvC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,CAAA;QACzC,MAAM,OAAO,GAAG,qBAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAA;QAC7C,OAAO,IAAI,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,OAA4B,EAC5B,IAAuC;QAEvC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,CAAA;QACzC,MAAM,YAAY,GAChB,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,wBAAa,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QACvE,OAAO,IAAI,gBAAgB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACvD,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,YAAY,CAAC,WAA+B,WAAW;QACrD,OAAO,IAAA,sBAAW,EAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IAC9C,CAAC;IAED,GAAG;QACD,OAAO,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;IACtD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAe;QACxB,MAAM,OAAO,GAAG,MAAM,IAAA,eAAM,EAAC,GAAG,CAAC,CAAA;QACjC,yCAAyC;QACzC,MAAM,GAAG,GAAG,MAAM,qBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACrE,OAAO,GAAG,CAAC,iBAAiB,EAAE,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;QAClD,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF;AAtDD,4CAsDC","sourcesContent":["import { secp256k1 as k256 } from '@noble/curves/secp256k1'\nimport { sha256 } from '@noble/hashes/sha256'\nimport {\n fromString as ui8FromString,\n toString as ui8ToString,\n} from 'uint8arrays'\nimport { SupportedEncodings } from 'uint8arrays/to-string'\nimport { SECP256K1_JWT_ALG } from '../const'\nimport * as did from '../did'\nimport { Keypair } from '../types'\n\nexport type Secp256k1KeypairOptions = {\n exportable: boolean\n}\n\nexport class Secp256k1Keypair implements Keypair {\n jwtAlg = SECP256K1_JWT_ALG\n private publicKey: Uint8Array\n\n constructor(\n private privateKey: Uint8Array,\n private exportable: boolean,\n ) {\n this.publicKey = k256.getPublicKey(privateKey)\n }\n\n static async create(\n opts?: Partial<Secp256k1KeypairOptions>,\n ): Promise<Secp256k1Keypair> {\n const { exportable = false } = opts || {}\n const privKey = k256.utils.randomPrivateKey()\n return new Secp256k1Keypair(privKey, exportable)\n }\n\n static async import(\n privKey: Uint8Array | string,\n opts?: Partial<Secp256k1KeypairOptions>,\n ): Promise<Secp256k1Keypair> {\n const { exportable = false } = opts || {}\n const privKeyBytes =\n typeof privKey === 'string' ? ui8FromString(privKey, 'hex') : privKey\n return new Secp256k1Keypair(privKeyBytes, exportable)\n }\n\n publicKeyBytes(): Uint8Array {\n return this.publicKey\n }\n\n publicKeyStr(encoding: SupportedEncodings = 'base64pad'): string {\n return ui8ToString(this.publicKey, encoding)\n }\n\n did(): string {\n return did.formatDidKey(this.jwtAlg, this.publicKey)\n }\n\n async sign(msg: Uint8Array): Promise<Uint8Array> {\n const msgHash = await sha256(msg)\n // return raw 64 byte sig not DER-encoded\n const sig = await k256.sign(msgHash, this.privateKey, { lowS: true })\n return sig.toCompactRawBytes()\n }\n\n async export(): Promise<Uint8Array> {\n if (!this.exportable) {\n throw new Error('Private key is not exportable')\n }\n return this.privateKey\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/secp256k1/operations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/secp256k1/operations.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EACX,MAAM,UAAU,EAChB,KAAK,UAAU,EACf,OAAO,aAAa,KACnB,OAAO,CAAC,OAAO,CAOjB,CAAA;AAED,eAAO,MAAM,SAAS,GACpB,WAAW,UAAU,EACrB,MAAM,UAAU,EAChB,KAAK,UAAU,EACf,OAAO,aAAa,KACnB,OAAO,CAAC,OAAO,CAOjB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,UAAU,YAO9C,CAAA"}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.isCompactFormat = exports.verifySig = exports.verifyDidSig = void 0;
|
|
27
37
|
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/secp256k1/operations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/secp256k1/operations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA2D;AAC3D,iDAA6C;AAC7C,iDAAkC;AAClC,oCAA+C;AAE/C,oCAA2E;AAEpE,MAAM,YAAY,GAAG,KAAK,EAC/B,GAAW,EACX,IAAgB,EAChB,GAAe,EACf,IAAoB,EACF,EAAE;IACpB,MAAM,aAAa,GAAG,IAAA,4BAAoB,EAAC,IAAA,uBAAe,EAAC,GAAG,CAAC,CAAC,CAAA;IAChE,IAAI,CAAC,IAAA,iBAAS,EAAC,aAAa,EAAE,4BAAoB,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAA;IACpD,CAAC;IACD,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,4BAAoB,CAAC,MAAM,CAAC,CAAA;IACjE,OAAO,IAAA,iBAAS,EAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;AAC7C,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB;AAEM,MAAM,SAAS,GAAG,KAAK,EAC5B,SAAqB,EACrB,IAAgB,EAChB,GAAe,EACf,IAAoB,EACF,EAAE;IACpB,MAAM,cAAc,GAAG,IAAI,EAAE,iBAAiB,IAAI,KAAK,CAAA;IACvD,MAAM,OAAO,GAAG,MAAM,IAAA,eAAM,EAAC,IAAI,CAAC,CAAA;IAClC,OAAO,qBAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE;QAC1C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,iCAAiC;QACjF,IAAI,EAAE,CAAC,cAAc;KACtB,CAAC,CAAA;AACJ,CAAC,CAAA;AAZY,QAAA,SAAS,aAYrB;AAEM,MAAM,eAAe,GAAG,CAAC,GAAe,EAAE,EAAE;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,qBAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAC9C,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,EAAE,GAAG,CAAC,CAAA;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAPY,QAAA,eAAe,mBAO3B","sourcesContent":["import { secp256k1 as k256 } from '@noble/curves/secp256k1'\nimport { sha256 } from '@noble/hashes/sha256'\nimport * as ui8 from 'uint8arrays'\nimport { SECP256K1_DID_PREFIX } from '../const'\nimport { VerifyOptions } from '../types'\nimport { extractMultikey, extractPrefixedBytes, hasPrefix } from '../utils'\n\nexport const verifyDidSig = async (\n did: string,\n data: Uint8Array,\n sig: Uint8Array,\n opts?: VerifyOptions,\n): Promise<boolean> => {\n const prefixedBytes = extractPrefixedBytes(extractMultikey(did))\n if (!hasPrefix(prefixedBytes, SECP256K1_DID_PREFIX)) {\n throw new Error(`Not a secp256k1 did:key: ${did}`)\n }\n const keyBytes = prefixedBytes.slice(SECP256K1_DID_PREFIX.length)\n return verifySig(keyBytes, data, sig, opts)\n}\n\nexport const verifySig = async (\n publicKey: Uint8Array,\n data: Uint8Array,\n sig: Uint8Array,\n opts?: VerifyOptions,\n): Promise<boolean> => {\n const allowMalleable = opts?.allowMalleableSig ?? false\n const msgHash = await sha256(data)\n return k256.verify(sig, msgHash, publicKey, {\n format: allowMalleable ? undefined : 'compact', // prevent DER-encoded signatures\n lowS: !allowMalleable,\n })\n}\n\nexport const isCompactFormat = (sig: Uint8Array) => {\n try {\n const parsed = k256.Signature.fromCompact(sig)\n return ui8.equals(parsed.toCompactRawBytes(), sig)\n } catch {\n return false\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/secp256k1/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/secp256k1/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAIvC,eAAO,MAAM,eAAe,EAAE,YAO7B,CAAA"}
|
package/dist/secp256k1/plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.secp256k1Plugin = void 0;
|
|
4
|
-
const operations_1 = require("./operations");
|
|
5
|
-
const encoding_1 = require("./encoding");
|
|
6
4
|
const const_1 = require("../const");
|
|
5
|
+
const encoding_1 = require("./encoding");
|
|
6
|
+
const operations_1 = require("./operations");
|
|
7
7
|
exports.secp256k1Plugin = {
|
|
8
8
|
prefix: const_1.SECP256K1_DID_PREFIX,
|
|
9
9
|
jwtAlg: const_1.SECP256K1_JWT_ALG,
|
|
@@ -11,5 +11,4 @@ exports.secp256k1Plugin = {
|
|
|
11
11
|
compressPubkey: encoding_1.compressPubkey,
|
|
12
12
|
decompressPubkey: encoding_1.decompressPubkey,
|
|
13
13
|
};
|
|
14
|
-
exports.default = exports.secp256k1Plugin;
|
|
15
14
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/secp256k1/plugin.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/secp256k1/plugin.ts"],"names":[],"mappings":";;;AAAA,oCAAkE;AAElE,yCAA6D;AAC7D,6CAA2C;AAE9B,QAAA,eAAe,GAAiB;IAC3C,MAAM,EAAE,4BAAoB;IAC5B,MAAM,EAAE,yBAAiB;IACzB,eAAe,EAAE,yBAAY;IAE7B,cAAc,EAAd,yBAAc;IACd,gBAAgB,EAAhB,2BAAgB;CACjB,CAAA","sourcesContent":["import { SECP256K1_DID_PREFIX, SECP256K1_JWT_ALG } from '../const'\nimport { DidKeyPlugin } from '../types'\nimport { compressPubkey, decompressPubkey } from './encoding'\nimport { verifyDidSig } from './operations'\n\nexport const secp256k1Plugin: DidKeyPlugin = {\n prefix: SECP256K1_DID_PREFIX,\n jwtAlg: SECP256K1_JWT_ALG,\n verifySignature: verifyDidSig,\n\n compressPubkey,\n decompressPubkey,\n}\n"]}
|
package/dist/sha.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha.d.ts","sourceRoot":"","sources":["../src/sha.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"sha.d.ts","sourceRoot":"","sources":["../src/sha.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,GACjB,OAAO,UAAU,GAAG,MAAM,KACzB,OAAO,CAAC,UAAU,CAIpB,CAAA;AAGD,eAAO,MAAM,SAAS,GACpB,OAAO,UAAU,GAAG,MAAM,KACzB,OAAO,CAAC,MAAM,CAGhB,CAAA"}
|
package/dist/sha.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.sha256Hex = exports.sha256 = void 0;
|
|
27
37
|
const noble = __importStar(require("@noble/hashes/sha256"));
|
package/dist/sha.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha.js","sourceRoot":"","sources":["../src/sha.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sha.js","sourceRoot":"","sources":["../src/sha.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA6C;AAC7C,yDAA0C;AAE1C,mCAAmC;AACnC,yBAAyB;AAClB,MAAM,MAAM,GAAG,KAAK,EACzB,KAA0B,EACL,EAAE;IACvB,MAAM,KAAK,GACT,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAC3E,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA;AANY,QAAA,MAAM,UAMlB;AAED,yBAAyB;AAClB,MAAM,SAAS,GAAG,KAAK,EAC5B,KAA0B,EACT,EAAE;IACnB,MAAM,IAAI,GAAG,MAAM,IAAA,cAAM,EAAC,KAAK,CAAC,CAAA;IAChC,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAC1C,CAAC,CAAA;AALY,QAAA,SAAS,aAKrB","sourcesContent":["import * as noble from '@noble/hashes/sha256'\nimport * as uint8arrays from 'uint8arrays'\n\n// takes either bytes of utf8 input\n// @TODO this can be sync\nexport const sha256 = async (\n input: Uint8Array | string,\n): Promise<Uint8Array> => {\n const bytes =\n typeof input === 'string' ? uint8arrays.fromString(input, 'utf8') : input\n return noble.sha256(bytes)\n}\n\n// @TODO this can be sync\nexport const sha256Hex = async (\n input: Uint8Array | string,\n): Promise<string> => {\n const hash = await sha256(input)\n return uint8arrays.toString(hash, 'hex')\n}\n"]}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface Signer {\n jwtAlg: string\n sign(msg: Uint8Array): Promise<Uint8Array>\n}\n\nexport interface Didable {\n did(): string\n}\n\nexport interface Keypair extends Signer, Didable {}\n\nexport interface ExportableKeypair extends Keypair {\n export(): Promise<Uint8Array>\n}\n\nexport type DidKeyPlugin = {\n prefix: Uint8Array\n jwtAlg: string\n verifySignature: (\n did: string,\n msg: Uint8Array,\n data: Uint8Array,\n opts?: VerifyOptions,\n ) => Promise<boolean>\n\n compressPubkey: (uncompressed: Uint8Array) => Uint8Array\n decompressPubkey: (compressed: Uint8Array) => Uint8Array\n}\n\nexport type VerifyOptions = {\n allowMalleableSig?: boolean\n}\n"]}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MAK7C,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,UAQvD,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,OAAO,UAAU,EAAE,QAAQ,UAAU,KAAG,OAEjE,CAAA"}
|
package/dist/utils.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.hasPrefix = exports.extractPrefixedBytes = exports.extractMultikey = void 0;
|
|
27
37
|
const uint8arrays = __importStar(require("uint8arrays"));
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA0C;AAC1C,mCAAiE;AAE1D,MAAM,eAAe,GAAG,CAAC,GAAW,EAAU,EAAE;IACrD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,sBAAc,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,sBAAc,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC,CAAA;AALY,QAAA,eAAe,mBAK3B;AAEM,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAc,EAAE;IACnE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,+BAAuB,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,WAAW,CAAC,UAAU,CAC3B,QAAQ,CAAC,KAAK,CAAC,+BAAuB,CAAC,MAAM,CAAC,EAC9C,WAAW,CACZ,CAAA;AACH,CAAC,CAAA;AARY,QAAA,oBAAoB,wBAQhC;AAEM,MAAM,SAAS,GAAG,CAAC,KAAiB,EAAE,MAAkB,EAAW,EAAE;IAC1E,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;AACzE,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB","sourcesContent":["import * as uint8arrays from 'uint8arrays'\nimport { BASE58_MULTIBASE_PREFIX, DID_KEY_PREFIX } from './const'\n\nexport const extractMultikey = (did: string): string => {\n if (!did.startsWith(DID_KEY_PREFIX)) {\n throw new Error(`Incorrect prefix for did:key: ${did}`)\n }\n return did.slice(DID_KEY_PREFIX.length)\n}\n\nexport const extractPrefixedBytes = (multikey: string): Uint8Array => {\n if (!multikey.startsWith(BASE58_MULTIBASE_PREFIX)) {\n throw new Error(`Incorrect prefix for multikey: ${multikey}`)\n }\n return uint8arrays.fromString(\n multikey.slice(BASE58_MULTIBASE_PREFIX.length),\n 'base58btc',\n )\n}\n\nexport const hasPrefix = (bytes: Uint8Array, prefix: Uint8Array): boolean => {\n return uint8arrays.equals(prefix, bytes.subarray(0, prefix.byteLength))\n}\n"]}
|
package/dist/verify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,EACd,MAAM,UAAU,EAChB,KAAK,UAAU,EACf,OAAO,aAAa,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,KACA,OAAO,CAAC,OAAO,CAUjB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,OAAO,aAAa,KACnB,OAAO,CAAC,OAAO,CAIjB,CAAA"}
|
package/dist/verify.js
CHANGED
|
@@ -15,27 +15,34 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
28
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
36
|
exports.verifySignatureUtf8 = exports.verifySignature = void 0;
|
|
30
37
|
const uint8arrays = __importStar(require("uint8arrays"));
|
|
31
38
|
const did_1 = require("./did");
|
|
32
|
-
const plugins_1 =
|
|
39
|
+
const plugins_1 = require("./plugins");
|
|
33
40
|
const verifySignature = (didKey, data, sig, opts) => {
|
|
34
41
|
const parsed = (0, did_1.parseDidKey)(didKey);
|
|
35
42
|
if (opts?.jwtAlg && opts.jwtAlg !== parsed.jwtAlg) {
|
|
36
43
|
throw new Error(`Expected key alg ${opts.jwtAlg}, got ${parsed.jwtAlg}`);
|
|
37
44
|
}
|
|
38
|
-
const plugin = plugins_1.
|
|
45
|
+
const plugin = plugins_1.plugins.find((p) => p.jwtAlg === parsed.jwtAlg);
|
|
39
46
|
if (!plugin) {
|
|
40
47
|
throw new Error(`Unsupported signature alg: ${parsed.jwtAlg}`);
|
|
41
48
|
}
|
package/dist/verify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA0C;AAC1C,+BAAmC;AACnC,uCAAmC;AAG5B,MAAM,eAAe,GAAG,CAC7B,MAAc,EACd,IAAgB,EAChB,GAAe,EACf,IAEC,EACiB,EAAE;IACpB,MAAM,MAAM,GAAG,IAAA,iBAAW,EAAC,MAAM,CAAC,CAAA;IAClC,IAAI,IAAI,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;IAC1E,CAAC;IACD,MAAM,MAAM,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAA;IAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;IAChE,CAAC;IACD,OAAO,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;AACxD,CAAC,CAAA;AAjBY,QAAA,eAAe,mBAiB3B;AAEM,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAAc,EACd,IAAY,EACZ,GAAW,EACX,IAAoB,EACF,EAAE;IACpB,MAAM,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACtD,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACzD,OAAO,IAAA,uBAAe,EAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAC3D,CAAC,CAAA;AATY,QAAA,mBAAmB,uBAS/B","sourcesContent":["import * as uint8arrays from 'uint8arrays'\nimport { parseDidKey } from './did'\nimport { plugins } from './plugins'\nimport { VerifyOptions } from './types'\n\nexport const verifySignature = (\n didKey: string,\n data: Uint8Array,\n sig: Uint8Array,\n opts?: VerifyOptions & {\n jwtAlg?: string\n },\n): Promise<boolean> => {\n const parsed = parseDidKey(didKey)\n if (opts?.jwtAlg && opts.jwtAlg !== parsed.jwtAlg) {\n throw new Error(`Expected key alg ${opts.jwtAlg}, got ${parsed.jwtAlg}`)\n }\n const plugin = plugins.find((p) => p.jwtAlg === parsed.jwtAlg)\n if (!plugin) {\n throw new Error(`Unsupported signature alg: ${parsed.jwtAlg}`)\n }\n return plugin.verifySignature(didKey, data, sig, opts)\n}\n\nexport const verifySignatureUtf8 = async (\n didKey: string,\n data: string,\n sig: string,\n opts?: VerifyOptions,\n): Promise<boolean> => {\n const dataBytes = uint8arrays.fromString(data, 'utf8')\n const sigBytes = uint8arrays.fromString(sig, 'base64url')\n return verifySignature(didKey, dataBytes, sigBytes, opts)\n}\n"]}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/crypto",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Library for cryptographic keys and signing in atproto",
|
|
6
6
|
"keywords": [
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
"main": "dist/index.js",
|
|
17
17
|
"types": "dist/index.d.ts",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18.7.0"
|
|
20
|
+
},
|
|
18
21
|
"dependencies": {
|
|
19
22
|
"@noble/curves": "^1.7.0",
|
|
20
23
|
"@noble/hashes": "^1.6.1",
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"jest": "^28.1.2",
|
|
25
28
|
"typescript": "^5.6.3",
|
|
26
|
-
"@atproto/common": "^0.
|
|
29
|
+
"@atproto/common": "^0.5.2"
|
|
27
30
|
},
|
|
28
31
|
"scripts": {
|
|
29
32
|
"test": "jest ",
|
package/src/did.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as uint8arrays from 'uint8arrays'
|
|
2
|
-
|
|
3
2
|
import { BASE58_MULTIBASE_PREFIX, DID_KEY_PREFIX } from './const'
|
|
4
|
-
import plugins from './plugins'
|
|
3
|
+
import { plugins } from './plugins'
|
|
5
4
|
import { extractMultikey, extractPrefixedBytes, hasPrefix } from './utils'
|
|
6
5
|
|
|
7
6
|
export type ParsedMultikey = {
|
|
@@ -46,6 +45,9 @@ export const parseDidKey = (did: string): ParsedMultikey => {
|
|
|
46
45
|
return parseMultikey(multikey)
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
export
|
|
50
|
-
|
|
48
|
+
export function formatDidKey(
|
|
49
|
+
jwtAlg: string,
|
|
50
|
+
keyBytes: Uint8Array,
|
|
51
|
+
): `did:key:${string}` {
|
|
52
|
+
return `${DID_KEY_PREFIX}${formatMultikey(jwtAlg, keyBytes)}` as const
|
|
51
53
|
}
|
package/src/p256/keypair.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { p256 } from '@noble/curves/p256'
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256'
|
|
3
|
-
import { SupportedEncodings } from 'uint8arrays/to-string'
|
|
4
3
|
import {
|
|
5
4
|
fromString as ui8FromString,
|
|
6
5
|
toString as ui8ToString,
|
|
7
6
|
} from 'uint8arrays'
|
|
8
|
-
|
|
9
|
-
import * as did from '../did'
|
|
7
|
+
import { SupportedEncodings } from 'uint8arrays/to-string'
|
|
10
8
|
import { P256_JWT_ALG } from '../const'
|
|
9
|
+
import * as did from '../did'
|
|
11
10
|
import { Keypair } from '../types'
|
|
12
11
|
|
|
13
12
|
export type P256KeypairOptions = {
|
|
@@ -69,5 +68,3 @@ export class P256Keypair implements Keypair {
|
|
|
69
68
|
return this.privateKey
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
|
|
73
|
-
export default P256Keypair
|
package/src/p256/operations.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { p256 } from '@noble/curves/p256'
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256'
|
|
3
3
|
import { equals as ui8equals } from 'uint8arrays'
|
|
4
|
-
|
|
5
4
|
import { P256_DID_PREFIX } from '../const'
|
|
6
5
|
import { VerifyOptions } from '../types'
|
|
7
6
|
import { extractMultikey, extractPrefixedBytes, hasPrefix } from '../utils'
|
package/src/p256/plugin.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { verifyDidSig } from './operations'
|
|
2
|
-
import { compressPubkey, decompressPubkey } from './encoding'
|
|
3
|
-
|
|
4
|
-
import { DidKeyPlugin } from '../types'
|
|
5
1
|
import { P256_DID_PREFIX, P256_JWT_ALG } from '../const'
|
|
2
|
+
import { DidKeyPlugin } from '../types'
|
|
3
|
+
import { compressPubkey, decompressPubkey } from './encoding'
|
|
4
|
+
import { verifyDidSig } from './operations'
|
|
6
5
|
|
|
7
6
|
export const p256Plugin: DidKeyPlugin = {
|
|
8
7
|
prefix: P256_DID_PREFIX,
|
|
@@ -12,5 +11,3 @@ export const p256Plugin: DidKeyPlugin = {
|
|
|
12
11
|
compressPubkey,
|
|
13
12
|
decompressPubkey,
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
export default p256Plugin
|
package/src/plugins.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import p256Plugin from './p256/plugin'
|
|
2
|
-
import secp256k1Plugin from './secp256k1/plugin'
|
|
1
|
+
import { p256Plugin } from './p256/plugin'
|
|
2
|
+
import { secp256k1Plugin } from './secp256k1/plugin'
|
|
3
3
|
|
|
4
4
|
export const plugins = [p256Plugin, secp256k1Plugin]
|
|
5
|
-
|
|
6
|
-
export default plugins
|
package/src/secp256k1/keypair.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
toString as ui8ToString,
|
|
6
6
|
} from 'uint8arrays'
|
|
7
7
|
import { SupportedEncodings } from 'uint8arrays/to-string'
|
|
8
|
-
|
|
9
8
|
import { SECP256K1_JWT_ALG } from '../const'
|
|
10
9
|
import * as did from '../did'
|
|
11
10
|
import { Keypair } from '../types'
|
|
@@ -69,5 +68,3 @@ export class Secp256k1Keypair implements Keypair {
|
|
|
69
68
|
return this.privateKey
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
|
|
73
|
-
export default Secp256k1Keypair
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { secp256k1 as k256 } from '@noble/curves/secp256k1'
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256'
|
|
3
3
|
import * as ui8 from 'uint8arrays'
|
|
4
|
-
|
|
5
4
|
import { SECP256K1_DID_PREFIX } from '../const'
|
|
6
5
|
import { VerifyOptions } from '../types'
|
|
7
6
|
import { extractMultikey, extractPrefixedBytes, hasPrefix } from '../utils'
|
package/src/secp256k1/plugin.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { verifyDidSig } from './operations'
|
|
2
|
-
import { compressPubkey, decompressPubkey } from './encoding'
|
|
3
|
-
|
|
4
|
-
import { DidKeyPlugin } from '../types'
|
|
5
1
|
import { SECP256K1_DID_PREFIX, SECP256K1_JWT_ALG } from '../const'
|
|
2
|
+
import { DidKeyPlugin } from '../types'
|
|
3
|
+
import { compressPubkey, decompressPubkey } from './encoding'
|
|
4
|
+
import { verifyDidSig } from './operations'
|
|
6
5
|
|
|
7
6
|
export const secp256k1Plugin: DidKeyPlugin = {
|
|
8
7
|
prefix: SECP256K1_DID_PREFIX,
|
|
@@ -12,5 +11,3 @@ export const secp256k1Plugin: DidKeyPlugin = {
|
|
|
12
11
|
compressPubkey,
|
|
13
12
|
decompressPubkey,
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
export default secp256k1Plugin
|
package/src/verify.ts
CHANGED
package/tests/did.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as uint8arrays from 'uint8arrays'
|
|
1
2
|
import { P256Keypair, Secp256k1Keypair } from '../src'
|
|
2
3
|
import * as did from '../src/did'
|
|
3
|
-
import * as uint8arrays from 'uint8arrays'
|
|
4
4
|
|
|
5
5
|
describe('secp256k1 did:key', () => {
|
|
6
6
|
it('derives the correct DID from the privatekey', async () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import P256Keypair from '../src/p256/keypair'
|
|
2
|
-
import Secp256k1Keypair from '../src/secp256k1/keypair'
|
|
3
|
-
import * as secpEncoding from '../src/secp256k1/encoding'
|
|
4
|
-
import * as p256Encoding from '../src/p256/encoding'
|
|
5
1
|
import * as did from '../src/did'
|
|
2
|
+
import * as p256Encoding from '../src/p256/encoding'
|
|
3
|
+
import { P256Keypair } from '../src/p256/keypair'
|
|
4
|
+
import * as secpEncoding from '../src/secp256k1/encoding'
|
|
5
|
+
import { Secp256k1Keypair } from '../src/secp256k1/keypair'
|
|
6
6
|
|
|
7
7
|
describe('public key compression', () => {
|
|
8
8
|
describe('secp256k1', () => {
|
package/tests/keypairs.test.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { randomBytes } from '../src'
|
|
2
|
+
import { P256Keypair } from '../src/p256/keypair'
|
|
3
3
|
import * as p256 from '../src/p256/operations'
|
|
4
|
+
import { Secp256k1Keypair } from '../src/secp256k1/keypair'
|
|
4
5
|
import * as secp from '../src/secp256k1/operations'
|
|
5
|
-
import { randomBytes } from '../src'
|
|
6
6
|
|
|
7
7
|
describe('keypairs', () => {
|
|
8
8
|
describe('secp256k1', () => {
|
package/tests/random.test.ts
CHANGED
|
@@ -10,6 +10,6 @@ describe('randomIntFromSeed()', () => {
|
|
|
10
10
|
}
|
|
11
11
|
const [zero, one] = counts
|
|
12
12
|
expect(zero + one).toEqual(10000)
|
|
13
|
-
expect(Math.max(zero, one) / Math.min(zero, one)).toBeLessThan(1.
|
|
13
|
+
expect(Math.max(zero, one) / Math.min(zero, one)).toBeLessThan(1.1)
|
|
14
14
|
})
|
|
15
15
|
})
|
package/tests/signatures.test.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
/* eslint-disable import/no-deprecated */
|
|
2
|
+
|
|
1
3
|
import fs from 'node:fs'
|
|
2
|
-
import * as uint8arrays from 'uint8arrays'
|
|
3
|
-
import { secp256k1 as nobleK256 } from '@noble/curves/secp256k1'
|
|
4
4
|
import { p256 as nobleP256 } from '@noble/curves/p256'
|
|
5
|
+
import { secp256k1 as nobleK256 } from '@noble/curves/secp256k1'
|
|
6
|
+
import * as uint8arrays from 'uint8arrays'
|
|
5
7
|
import { cborEncode } from '@atproto/common'
|
|
6
|
-
import EcdsaKeypair from '../src/p256/keypair'
|
|
7
|
-
import Secp256k1Keypair from '../src/secp256k1/keypair'
|
|
8
|
-
import * as p256 from '../src/p256/operations'
|
|
9
|
-
import * as secp from '../src/secp256k1/operations'
|
|
10
8
|
import {
|
|
9
|
+
P256_JWT_ALG,
|
|
10
|
+
SECP256K1_JWT_ALG,
|
|
11
11
|
bytesToMultibase,
|
|
12
12
|
multibaseToBytes,
|
|
13
13
|
parseDidKey,
|
|
14
|
-
P256_JWT_ALG,
|
|
15
|
-
SECP256K1_JWT_ALG,
|
|
16
14
|
sha256,
|
|
17
15
|
} from '../src'
|
|
16
|
+
import { P256Keypair } from '../src/p256/keypair'
|
|
17
|
+
import * as p256 from '../src/p256/operations'
|
|
18
|
+
import { Secp256k1Keypair } from '../src/secp256k1/keypair'
|
|
19
|
+
import * as secp from '../src/secp256k1/operations'
|
|
18
20
|
|
|
19
21
|
describe('signatures', () => {
|
|
20
22
|
let vectors: TestVector[]
|
|
@@ -140,7 +142,7 @@ describe('signatures', () => {
|
|
|
140
142
|
// @ts-expect-error
|
|
141
143
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
142
144
|
async function generateTestVectors(): Promise<TestVector[]> {
|
|
143
|
-
const p256Key = await
|
|
145
|
+
const p256Key = await P256Keypair.create({ exportable: true })
|
|
144
146
|
const secpKey = await Secp256k1Keypair.create({ exportable: true })
|
|
145
147
|
const messageBytes = cborEncode({ hello: 'world' })
|
|
146
148
|
const messageBase64 = uint8arrays.toString(messageBytes, 'base64')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/const.ts","./src/did.ts","./src/index.ts","./src/multibase.ts","./src/plugins.ts","./src/random.ts","./src/sha.ts","./src/types.ts","./src/utils.ts","./src/verify.ts","./src/p256/encoding.ts","./src/p256/keypair.ts","./src/p256/operations.ts","./src/p256/plugin.ts","./src/secp256k1/encoding.ts","./src/secp256k1/keypair.ts","./src/secp256k1/operations.ts","./src/secp256k1/plugin.ts"],"version":"5.
|
|
1
|
+
{"root":["./src/const.ts","./src/did.ts","./src/index.ts","./src/multibase.ts","./src/plugins.ts","./src/random.ts","./src/sha.ts","./src/types.ts","./src/utils.ts","./src/verify.ts","./src/p256/encoding.ts","./src/p256/keypair.ts","./src/p256/operations.ts","./src/p256/plugin.ts","./src/secp256k1/encoding.ts","./src/secp256k1/keypair.ts","./src/secp256k1/operations.ts","./src/secp256k1/plugin.ts"],"version":"5.8.2"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./tests/did.test.ts","./tests/key-compression.test.ts","./tests/keypairs.test.ts","./tests/random.test.ts","./tests/signatures.test.ts"],"version":"5.
|
|
1
|
+
{"root":["./tests/did.test.ts","./tests/key-compression.test.ts","./tests/keypairs.test.ts","./tests/random.test.ts","./tests/signatures.test.ts"],"version":"5.8.3"}
|