@cmts-dev/carmentis-sdk-core 1.4.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/carmentis-sdk-core.cjs +3 -3
- package/dist/carmentis-sdk-core.d.ts +26 -0
- package/dist/carmentis-sdk-core.d.ts.map +1 -1
- package/dist/carmentis-sdk-core.js +4905 -3635
- package/dist/crypto/CryptoSchemeFactory.d.ts.map +1 -1
- package/dist/crypto/encoder/signature/dckf/DckfSignatureDecoder.d.ts +1 -0
- package/dist/crypto/encoder/signature/dckf/DckfSignatureDecoder.d.ts.map +1 -1
- package/dist/crypto/encoder/signature/dckf/DckfSignatureEncoder.d.ts.map +1 -1
- package/dist/crypto/signature/SignatureSchemeId.d.ts +2 -1
- package/dist/crypto/signature/SignatureSchemeId.d.ts.map +1 -1
- package/dist/crypto/signature/jwk/JwkBinaryEncoder.d.ts +27 -0
- package/dist/crypto/signature/jwk/JwkBinaryEncoder.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkPrivateSignatureKey.d.ts +122 -0
- package/dist/crypto/signature/jwk/JwkPrivateSignatureKey.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkPublicSignatureKey.d.ts +100 -0
- package/dist/crypto/signature/jwk/JwkPublicSignatureKey.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkSignatureAlgorithm.d.ts +159 -0
- package/dist/crypto/signature/jwk/JwkSignatureAlgorithm.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkSignatureBackend.d.ts +56 -0
- package/dist/crypto/signature/jwk/JwkSignatureBackend.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkSignatureScheme.d.ts +60 -0
- package/dist/crypto/signature/jwk/JwkSignatureScheme.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/webcrypto.d.ts +12 -0
- package/dist/crypto/signature/jwk/webcrypto.d.ts.map +1 -0
- package/dist/crypto/signature/secp256k1/Secp256k1PrivateSignatureKey.d.ts.map +1 -1
- package/dist/crypto/signature/signer/binary/BinaryEncoder.d.ts +6 -0
- package/dist/crypto/signature/signer/binary/BinaryEncoder.d.ts.map +1 -0
- package/dist/crypto/signature/signer/binary/BinaryEndoding.d.ts +9 -0
- package/dist/crypto/signature/signer/binary/BinaryEndoding.d.ts.map +1 -0
- package/dist/crypto/signature/signer/binary/BinarySigner.d.ts +8 -0
- package/dist/crypto/signature/signer/binary/BinarySigner.d.ts.map +1 -0
- package/dist/crypto/signature/signer/binary/BinaryVerifier.d.ts +8 -0
- package/dist/crypto/signature/signer/binary/BinaryVerifier.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signature.d.ts +47 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signature.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signer.d.ts +23 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signer.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalizationMethod.d.ts +11 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalizationMethod.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonEncoder.d.ts +5 -0
- package/dist/crypto/signature/signer/json/JsonEncoder.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignature.d.ts +9 -0
- package/dist/crypto/signature/signer/json/JsonSignature.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignatureParser.d.ts +10 -0
- package/dist/crypto/signature/signer/json/JsonSignatureParser.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignatureUtils.d.ts +9 -0
- package/dist/crypto/signature/signer/json/JsonSignatureUtils.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignatureVerifier.d.ts +12 -0
- package/dist/crypto/signature/signer/json/JsonSignatureVerifier.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JwsSignature.d.ts +27 -0
- package/dist/crypto/signature/signer/json/JwsSignature.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JwsSigner.d.ts +15 -0
- package/dist/crypto/signature/signer/json/JwsSigner.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/SignatureVerificationUtils.d.ts +10 -0
- package/dist/crypto/signature/signer/json/SignatureVerificationUtils.d.ts.map +1 -0
- package/dist/tags/CertificateTagHandler.d.ts +8 -0
- package/dist/tags/CertificateTagHandler.d.ts.map +1 -0
- package/dist/type/JsonSignatureSchemas.d.ts +99 -0
- package/dist/type/JsonSignatureSchemas.d.ts.map +1 -0
- package/dist/type/Resolver.d.ts +2 -0
- package/dist/type/Resolver.d.ts.map +1 -1
- package/dist/type/tags/CertificateTag.d.ts +6 -0
- package/dist/type/tags/CertificateTag.d.ts.map +1 -0
- package/dist/type/tags/SignatureTag.d.ts +27 -0
- package/dist/type/tags/SignatureTag.d.ts.map +1 -0
- package/package.json +8 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoSchemeFactory.d.ts","sourceRoot":"","sources":["../../src/crypto/CryptoSchemeFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,2BAA2B,EAC9B,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EAAC,iBAAiB,EAAE,yBAAyB,EAA0B,MAAM,uBAAuB,CAAC;AAG5G,OAAO,EAAC,kCAAkC,EAAC,MAAM,0CAA0C,CAAC;AAC5F,OAAO,EAAC,qBAAqB,EAAC,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,0CAA0C,EAAC,MAAM,kDAAkD,CAAC;AAC5G,OAAO,EACH,4BAA4B,EAC5B,2BAA2B,EAC9B,MAAM,uEAAuE,CAAC;AAI/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC,eAAe,EAA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ements ISignatureDecodeHandler {
|
|
|
6
6
|
static getAcceptedSchemeTags(): string[][];
|
|
7
7
|
isAcceptingPublicKeyDecodingRequest(encodedPublicKey: string): Promise<boolean>;
|
|
8
8
|
isAcceptingPrivateKeyDecodingRequest(encodedPrivateKey: string): Promise<boolean>;
|
|
9
|
+
private didJwkToJwk;
|
|
9
10
|
decodePublicKey(encodedPublicKey: string): Promise<PublicSignatureKey>;
|
|
10
11
|
decodePrivateKey(encodedPrivateKey: string): Promise<PrivateSignatureKey>;
|
|
11
12
|
private getKeyParts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DckfSignatureDecoder.d.ts","sourceRoot":"","sources":["../../../../../src/crypto/encoder/signature/dckf/DckfSignatureDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"DckfSignatureDecoder.d.ts","sourceRoot":"","sources":["../../../../../src/crypto/encoder/signature/dckf/DckfSignatureDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AA4BzE,qBAAa,oBAAqB,YAAW,uBAAuB;IAChE,SAAS,CAAC,YAAY,iGAAsC;IAE5D,MAAM,CAAC,qBAAqB;IAStB,mCAAmC,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ/E,oCAAoC,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMvF,OAAO,CAAC,WAAW;IAeb,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqCtE,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgC/E,OAAO,CAAC,WAAW;CAmCtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DckfSignatureEncoder.d.ts","sourceRoot":"","sources":["../../../../../src/crypto/encoder/signature/dckf/DckfSignatureEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"DckfSignatureEncoder.d.ts","sourceRoot":"","sources":["../../../../../src/crypto/encoder/signature/dckf/DckfSignatureEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAqBzE,qBAAa,oBAAqB,YAAW,wBAAwB;IACjE,SAAS,CAAC,YAAY,iGAAsC;IAEtD,mCAAmC,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpF,oCAAoC,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvF,eAAe,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/D,gBAAgB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;YAc1D,mBAAmB;YAInB,oBAAoB;IAOlC,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,uBAAuB;CAelC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureSchemeId.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/SignatureSchemeId.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,oBAAY,iBAAiB;IACzB,SAAS,IAAI;IACb,SAAS,IAAI;IACb,cAAc,IAAI;IAClB,OAAO,IAAI;
|
|
1
|
+
{"version":3,"file":"SignatureSchemeId.d.ts","sourceRoot":"","sources":["../../../src/crypto/signature/SignatureSchemeId.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,oBAAY,iBAAiB;IACzB,SAAS,IAAI;IACb,SAAS,IAAI;IACb,cAAc,IAAI;IAClB,OAAO,IAAI;IACX,GAAG,IAAI;CACV"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SignatureJwk } from './JwkSignatureAlgorithm';
|
|
2
|
+
/**
|
|
3
|
+
* Serialises a JWK as CBOR, with its members in lexicographic order.
|
|
4
|
+
*
|
|
5
|
+
* Ordering the members is what makes the encoding canonical: a given key always yields
|
|
6
|
+
* the same bytes, whichever order the JWK it was imported from listed its members in.
|
|
7
|
+
* Feeding this a JWK reduced by {@link extractPublicJwk} or {@link extractPrivateJwk} —
|
|
8
|
+
* which are already ordered — additionally guarantees that two JWKs modelling the same
|
|
9
|
+
* key yield the same bytes, since neither can carry a stray `kid` or `x5c` any more.
|
|
10
|
+
*
|
|
11
|
+
* @param {SignatureJwk} jwk - The JWK to serialise.
|
|
12
|
+
* @return {Uint8Array} The CBOR encoding of the JWK.
|
|
13
|
+
*/
|
|
14
|
+
export declare function encodeSignatureJwk(jwk: SignatureJwk): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Reads back a JWK serialised by {@link encodeSignatureJwk}.
|
|
17
|
+
*
|
|
18
|
+
* The decoded JWK is returned as-is; it is the importer that validates it, so that a
|
|
19
|
+
* payload holding a well-formed but unsupported JWK fails with the same diagnostic as
|
|
20
|
+
* the same JWK passed to `fromJwk` directly.
|
|
21
|
+
*
|
|
22
|
+
* @param {Uint8Array} bytes - The CBOR encoding of a JWK.
|
|
23
|
+
* @return {SignatureJwk} The decoded JWK.
|
|
24
|
+
* @throws {Error} If the payload is not CBOR, or does not hold a map.
|
|
25
|
+
*/
|
|
26
|
+
export declare function decodeSignatureJwk(bytes: Uint8Array): SignatureJwk;
|
|
27
|
+
//# sourceMappingURL=JwkBinaryEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwkBinaryEncoder.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/JwkBinaryEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAiB,MAAM,yBAAyB,CAAC;AAuBrE;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,UAAU,CAIhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAYlE"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { BasePrivateSignatureKey } from '../BasePrivateSignatureKey';
|
|
2
|
+
import { JwkSignatureAlgorithmName, SignatureJwk } from './JwkSignatureAlgorithm';
|
|
3
|
+
import { JwkSignatureScheme } from './JwkSignatureScheme';
|
|
4
|
+
import { JwkGenerationOptions } from './JwkSignatureBackend';
|
|
5
|
+
import { JwkPublicSignatureKey } from './JwkPublicSignatureKey';
|
|
6
|
+
/**
|
|
7
|
+
* Private signature key backed by a JWK (RFC 7517).
|
|
8
|
+
*
|
|
9
|
+
* The key type and, where needed, the `alg` and `crv` members determine the primitive:
|
|
10
|
+
* EC (ES256/ES384/ES512/ES256K), OKP (Ed25519/Ed448), RSA (RS256/RS384/RS512,
|
|
11
|
+
* PS256/PS384/PS512) and AKP (ML-DSA-44/65/87) are all supported. Signing follows JOSE
|
|
12
|
+
* semantics: the message is signed as-is, without the SHA-256 pre-hash the native
|
|
13
|
+
* Carmentis signature keys apply, so the signatures interoperate with any JOSE library.
|
|
14
|
+
*
|
|
15
|
+
* The class behaves identically in Node.js and in browsers. It uses the Web Crypto API
|
|
16
|
+
* for the algorithms both platforms implement natively, and the `@noble/*` packages for
|
|
17
|
+
* the ones they do not (secp256k1, Ed25519, ML-DSA).
|
|
18
|
+
*/
|
|
19
|
+
export declare class JwkPrivateSignatureKey extends BasePrivateSignatureKey {
|
|
20
|
+
private readonly algorithm;
|
|
21
|
+
private readonly privateJwk;
|
|
22
|
+
private readonly publicJwk;
|
|
23
|
+
private readonly signer;
|
|
24
|
+
private readonly scheme;
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Generates a fresh key pair and wraps its private half.
|
|
28
|
+
*
|
|
29
|
+
* @param {JwkSignatureAlgorithmName} alg - The JOSE algorithm to generate a key for.
|
|
30
|
+
* @param {JwkGenerationOptions} options - Algorithm-specific options, such as the RSA modulus size.
|
|
31
|
+
* @return {Promise<JwkPrivateSignatureKey>} The generated private key.
|
|
32
|
+
*/
|
|
33
|
+
static gen(alg?: JwkSignatureAlgorithmName, options?: JwkGenerationOptions): Promise<JwkPrivateSignatureKey>;
|
|
34
|
+
/**
|
|
35
|
+
* Imports a private signature key from a JWK.
|
|
36
|
+
*
|
|
37
|
+
* Any JWK is accepted, whatever it carries beyond the key itself. Only the members
|
|
38
|
+
* that model the key are retained; see {@link extractPrivateJwk} for what that means
|
|
39
|
+
* and for the list of what is dropped.
|
|
40
|
+
*
|
|
41
|
+
* @param {SignatureJwk} jwk - The private JWK to import.
|
|
42
|
+
* @return {Promise<JwkPrivateSignatureKey>} The imported private key.
|
|
43
|
+
* @throws {Error} If the JWK is malformed, carries no private material, or denotes an
|
|
44
|
+
* unsupported algorithm.
|
|
45
|
+
*/
|
|
46
|
+
static fromJwk(jwk: SignatureJwk): Promise<JwkPrivateSignatureKey>;
|
|
47
|
+
/**
|
|
48
|
+
* Imports a private signature key from the bytes {@link getPrivateKeyAsBytes} returns.
|
|
49
|
+
*
|
|
50
|
+
* @param {Uint8Array} bytes - The CBOR encoding of a private JWK.
|
|
51
|
+
* @return {Promise<JwkPrivateSignatureKey>} The imported private key.
|
|
52
|
+
* @throws {Error} If the payload is not CBOR, or does not hold a supported private JWK.
|
|
53
|
+
*/
|
|
54
|
+
static fromBytes(bytes: Uint8Array): Promise<JwkPrivateSignatureKey>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the JOSE `alg` identifier of the key.
|
|
57
|
+
*
|
|
58
|
+
* @return {JwkSignatureAlgorithmName} The JOSE algorithm identifier.
|
|
59
|
+
*/
|
|
60
|
+
getAlgorithm(): JwkSignatureAlgorithmName;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the canonical private JWK of the key.
|
|
63
|
+
*
|
|
64
|
+
* The JWK holds the members that model the key and nothing else, ordered
|
|
65
|
+
* lexicographically, so that two keys imported from different JWKs of the same
|
|
66
|
+
* cryptographic key expose the exact same JWK here.
|
|
67
|
+
*
|
|
68
|
+
* @return {SignatureJwk} A copy of the canonical private JWK.
|
|
69
|
+
*/
|
|
70
|
+
getPrivateJwk(): SignatureJwk;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the canonical public JWK of the key, stripped of every private component.
|
|
73
|
+
*
|
|
74
|
+
* @return {SignatureJwk} A copy of the canonical public JWK.
|
|
75
|
+
*/
|
|
76
|
+
getPublicJwk(): SignatureJwk;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the binary form of the private key: the CBOR encoding of its canonical
|
|
79
|
+
* private JWK, members ordered lexicographically.
|
|
80
|
+
*
|
|
81
|
+
* The JWK is serialised rather than the bare key material because the material alone
|
|
82
|
+
* does not say which primitive it belongs to, and because an RSA private key is a set
|
|
83
|
+
* of integers that no single scalar stands for. Encoding the JWK keeps the bytes
|
|
84
|
+
* self-describing, and keeps them round-trippable through {@link fromBytes}.
|
|
85
|
+
*
|
|
86
|
+
* @return {Uint8Array} The CBOR-encoded private JWK.
|
|
87
|
+
*/
|
|
88
|
+
getPrivateKeyAsBytes(): Uint8Array;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the bare private key material, outside of any JWK framing.
|
|
91
|
+
*
|
|
92
|
+
* The encoding depends on the key type: the private scalar `d` for `EC` and `OKP`,
|
|
93
|
+
* the `priv` seed for `AKP`, and the PKCS#8 (RFC 5208 `PrivateKeyInfo`) DER encoding
|
|
94
|
+
* for `RSA`, whose private key is a set of integers rather than a single scalar.
|
|
95
|
+
*
|
|
96
|
+
* Unlike {@link getPrivateKeyAsBytes}, these bytes carry no indication of the
|
|
97
|
+
* algorithm they belong to, so they cannot be imported back on their own.
|
|
98
|
+
*
|
|
99
|
+
* @return {Uint8Array} The raw private key.
|
|
100
|
+
*/
|
|
101
|
+
getRawPrivateKeyBytes(): Uint8Array;
|
|
102
|
+
/**
|
|
103
|
+
* Returns the public half of the key pair.
|
|
104
|
+
*
|
|
105
|
+
* @return {Promise<JwkPublicSignatureKey>} The matching public key.
|
|
106
|
+
*/
|
|
107
|
+
getPublicKey(): Promise<JwkPublicSignatureKey>;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the signature scheme of the key.
|
|
110
|
+
*
|
|
111
|
+
* @return {JwkSignatureScheme} The signature scheme.
|
|
112
|
+
*/
|
|
113
|
+
getScheme(): JwkSignatureScheme;
|
|
114
|
+
/**
|
|
115
|
+
* Produces a detached signature over `data`.
|
|
116
|
+
*
|
|
117
|
+
* @param {Uint8Array} data - The message to sign, signed as-is.
|
|
118
|
+
* @return {Promise<Uint8Array>} The detached signature.
|
|
119
|
+
*/
|
|
120
|
+
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=JwkPrivateSignatureKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwkPrivateSignatureKey.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/JwkPrivateSignatureKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAIH,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asePublicSignatureKey } from '../BasePublicSignatureKey';
|
|
2
|
+
import { JwkSignatureAlgorithmName, SignatureJwk } from './JwkSignatureAlgorithm';
|
|
3
|
+
import { JwkSignatureScheme } from './JwkSignatureScheme';
|
|
4
|
+
/**
|
|
5
|
+
* Public signature key backed by a JWK (RFC 7517).
|
|
6
|
+
*
|
|
7
|
+
* The key type and, where needed, the `alg` and `crv` members determine the primitive:
|
|
8
|
+
* EC (ES256/ES384/ES512/ES256K), OKP (Ed25519/Ed448), RSA (RS256/RS384/RS512,
|
|
9
|
+
* PS256/PS384/PS512) and AKP (ML-DSA-44/65/87) are all supported. Verification follows
|
|
10
|
+
* JOSE semantics: the message is verified as-is, without the SHA-256 pre-hash the native
|
|
11
|
+
* Carmentis signature keys apply.
|
|
12
|
+
*
|
|
13
|
+
* The class behaves identically in Node.js and in browsers. It uses the Web Crypto API
|
|
14
|
+
* for the algorithms both platforms implement natively, and the `@noble/*` packages for
|
|
15
|
+
* the ones they do not (secp256k1, Ed25519, ML-DSA).
|
|
16
|
+
*/
|
|
17
|
+
export declare class JwkPublicSignatureKey extends BasePublicSignatureKey {
|
|
18
|
+
private readonly algorithm;
|
|
19
|
+
private readonly publicJwk;
|
|
20
|
+
private readonly verifier;
|
|
21
|
+
private readonly scheme;
|
|
22
|
+
private constructor();
|
|
23
|
+
/**
|
|
24
|
+
* Imports a public signature key from a JWK.
|
|
25
|
+
*
|
|
26
|
+
* Any JWK is accepted, whatever it carries beyond the key itself. Only the members
|
|
27
|
+
* that model the key are retained; see {@link extractPublicJwk} for what that means
|
|
28
|
+
* and for the list of what is dropped. A private JWK is accepted as well: only its
|
|
29
|
+
* public members are retained.
|
|
30
|
+
*
|
|
31
|
+
* @param {SignatureJwk} jwk - The JWK to import.
|
|
32
|
+
* @return {Promise<JwkPublicSignatureKey>} The imported public key.
|
|
33
|
+
* @throws {Error} If the JWK is malformed or denotes an unsupported algorithm.
|
|
34
|
+
*/
|
|
35
|
+
static fromJwk(jwk: SignatureJwk): Promise<JwkPublicSignatureKey>;
|
|
36
|
+
/**
|
|
37
|
+
* Imports a public signature key from the bytes {@link getPublicKeyAsBytes} returns.
|
|
38
|
+
*
|
|
39
|
+
* @param {Uint8Array} bytes - The CBOR encoding of a public JWK.
|
|
40
|
+
* @return {Promise<JwkPublicSignatureKey>} The imported public key.
|
|
41
|
+
* @throws {Error} If the payload is not CBOR, or does not hold a supported JWK.
|
|
42
|
+
*/
|
|
43
|
+
static fromBytes(bytes: Uint8Array): Promise<JwkPublicSignatureKey>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the JOSE `alg` identifier of the key.
|
|
46
|
+
*
|
|
47
|
+
* @return {JwkSignatureAlgorithmName} The JOSE algorithm identifier.
|
|
48
|
+
*/
|
|
49
|
+
getAlgorithm(): JwkSignatureAlgorithmName;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the canonical public JWK of the key.
|
|
52
|
+
*
|
|
53
|
+
* The JWK holds the members that model the key and nothing else, ordered
|
|
54
|
+
* lexicographically, so that two keys imported from different JWKs of the same
|
|
55
|
+
* cryptographic key expose the exact same JWK here.
|
|
56
|
+
*
|
|
57
|
+
* @return {SignatureJwk} A copy of the canonical public JWK.
|
|
58
|
+
*/
|
|
59
|
+
getPublicJwk(): SignatureJwk;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the binary form of the public key: the CBOR encoding of its canonical
|
|
62
|
+
* public JWK, members ordered lexicographically.
|
|
63
|
+
*
|
|
64
|
+
* The JWK is serialised rather than the bare key material because the material alone
|
|
65
|
+
* does not say which primitive it belongs to — `x` is a 32-byte string for both an
|
|
66
|
+
* Ed25519 and a P-256 key. Encoding the JWK keeps the bytes self-describing, and
|
|
67
|
+
* keeps them round-trippable through {@link fromBytes}.
|
|
68
|
+
*
|
|
69
|
+
* @return {Promise<Uint8Array>} The CBOR-encoded public JWK.
|
|
70
|
+
*/
|
|
71
|
+
getPublicKeyAsBytes(): Promise<Uint8Array>;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the bare public key material, outside of any JWK framing.
|
|
74
|
+
*
|
|
75
|
+
* The encoding depends on the key type: the uncompressed point for `EC`, the
|
|
76
|
+
* public key itself for `OKP` and `AKP`, and the SPKI (RFC 5280
|
|
77
|
+
* `SubjectPublicKeyInfo`) DER encoding for `RSA`, which has no shorter raw form.
|
|
78
|
+
*
|
|
79
|
+
* Unlike {@link getPublicKeyAsBytes}, these bytes carry no indication of the
|
|
80
|
+
* algorithm they belong to, so they cannot be imported back on their own.
|
|
81
|
+
*
|
|
82
|
+
* @return {Uint8Array} The raw public key.
|
|
83
|
+
*/
|
|
84
|
+
getRawPublicKeyBytes(): Uint8Array;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the signature scheme of the key.
|
|
87
|
+
*
|
|
88
|
+
* @return {JwkSignatureScheme} The signature scheme.
|
|
89
|
+
*/
|
|
90
|
+
getScheme(): JwkSignatureScheme;
|
|
91
|
+
/**
|
|
92
|
+
* Verifies a detached signature over `data`.
|
|
93
|
+
*
|
|
94
|
+
* @param {Uint8Array} data - The signed message, verified as-is.
|
|
95
|
+
* @param {Uint8Array} signature - The detached signature.
|
|
96
|
+
* @return {Promise<boolean>} Whether the signature is valid.
|
|
97
|
+
*/
|
|
98
|
+
verify(data: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=JwkPublicSignatureKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwkPublicSignatureKey.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/JwkPublicSignatureKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAGH,yBAAyB,EAEzB,YAAY,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAIxD;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAsB,SAAQ,sBAAsB;IAEzD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJ3B,OAAO;IASP;;;;;;;;;;;OAWG;WACU,OAAO,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAYvE;;;;;;OAMG;WACU,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIzE;;;;OAIG;IACH,YAAY,IAAI,yBAAyB;IAIzC;;;;;;;;OAQG;IACH,YAAY,IAAI,YAAY;IAI5B;;;;;;;;;;OAUG;IACG,mBAAmB,IAAI,OAAO,CAAC,UAAU,CAAC;IAIhD;;;;;;;;;;;OAWG;IACH,oBAAoB,IAAI,UAAU;IAIlC;;;;OAIG;IACH,SAAS,IAAI,kBAAkB;IAI/B;;;;;;OAMG;IACG,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;CAQ1E"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWK (RFC 7517) signature algorithm resolution and canonicalisation.
|
|
3
|
+
*
|
|
4
|
+
* A JWK does not carry an explicit description of the primitive to use: it has to be
|
|
5
|
+
* derived from the `kty` member, completed by `crv` for elliptic-curve families and by
|
|
6
|
+
* `alg` for RSA and ML-DSA. This module centralises that derivation so that
|
|
7
|
+
* {@link JwkPrivateSignatureKey} and {@link JwkPublicSignatureKey} agree on it.
|
|
8
|
+
*
|
|
9
|
+
* It also reduces an incoming JWK to its canonical form: the lexicographically ordered
|
|
10
|
+
* set of members that are strictly necessary to model the key. Any other member is
|
|
11
|
+
* accepted on import and then dropped, so that two JWKs describing the same key always
|
|
12
|
+
* produce the same canonical form and, in turn, the same serialised bytes.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Key types that can carry a signature key.
|
|
16
|
+
*
|
|
17
|
+
* - `EC` : elliptic curve, RFC 7518 (ES256/ES384/ES512) and RFC 8812 (ES256K).
|
|
18
|
+
* - `OKP` : octet key pair, RFC 8037 (Ed25519, Ed448).
|
|
19
|
+
* - `RSA` : RFC 7518 (RS256/RS384/RS512, PS256/PS384/PS512).
|
|
20
|
+
* - `AKP` : algorithm key pair, RFC 9836 (ML-DSA-44/65/87).
|
|
21
|
+
*/
|
|
22
|
+
export type JwkSignatureKeyType = "EC" | "OKP" | "RSA" | "AKP";
|
|
23
|
+
/** JOSE `alg` identifiers supported by the JWK signature keys. */
|
|
24
|
+
export type JwkSignatureAlgorithmName = "ES256" | "ES384" | "ES512" | "ES256K" | "Ed25519" | "Ed448" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ML-DSA-44" | "ML-DSA-65" | "ML-DSA-87";
|
|
25
|
+
/**
|
|
26
|
+
* Implementation actually performing sign/verify for a given algorithm.
|
|
27
|
+
*
|
|
28
|
+
* `webcrypto` is used for everything every browser and every supported Node.js version
|
|
29
|
+
* implements natively. The remaining algorithms are delegated to the `@noble/*` packages
|
|
30
|
+
* already bundled with the SDK, because their Web Crypto counterparts are either absent
|
|
31
|
+
* (secp256k1) or still experimental and unavailable in browsers (ML-DSA).
|
|
32
|
+
*/
|
|
33
|
+
export type JwkSignatureBackend = "webcrypto" | "ed25519" | "secp256k1" | "ml-dsa";
|
|
34
|
+
/**
|
|
35
|
+
* A JWK that may hold signature key material.
|
|
36
|
+
*
|
|
37
|
+
* Extends the DOM `JsonWebKey` with the AKP members of RFC 9836, which the standard
|
|
38
|
+
* library type does not know about, and with the certificate members of RFC 7517.
|
|
39
|
+
*
|
|
40
|
+
* The members beyond the key material itself are declared for the sake of the JWKs
|
|
41
|
+
* handed to {@link extractPublicJwk} and {@link extractPrivateJwk}, which tolerate them
|
|
42
|
+
* on input; none of them survives into the canonical form those functions return.
|
|
43
|
+
*/
|
|
44
|
+
export interface SignatureJwk extends JsonWebKey {
|
|
45
|
+
/** Key identifier (RFC 7517 §4.5). */
|
|
46
|
+
kid?: string;
|
|
47
|
+
/** AKP public key, base64url-encoded (RFC 9836). */
|
|
48
|
+
pub?: string;
|
|
49
|
+
/** AKP private key seed, base64url-encoded (RFC 9836). */
|
|
50
|
+
priv?: string;
|
|
51
|
+
/** Certificate usage (RFC 7517 §4.6). */
|
|
52
|
+
x5u?: string;
|
|
53
|
+
/** Certificate chain (RFC 7517 §4.7). */
|
|
54
|
+
x5c?: string[];
|
|
55
|
+
/** Certificate SHA-1 Thumbprint (RFC 7517 §4.8). */
|
|
56
|
+
x5t?: string;
|
|
57
|
+
/** Certificate SHA-256 Thumbprint (RFC 7517 §4.9). */
|
|
58
|
+
"x5t#S256"?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fully resolved description of the signature primitive denoted by a JWK.
|
|
62
|
+
*/
|
|
63
|
+
export interface JwkSignatureAlgorithm {
|
|
64
|
+
/** Canonical JOSE `alg` identifier. */
|
|
65
|
+
readonly alg: JwkSignatureAlgorithmName;
|
|
66
|
+
/** Key type the algorithm applies to. */
|
|
67
|
+
readonly kty: JwkSignatureKeyType;
|
|
68
|
+
/** Curve name, for `EC` and `OKP` keys only. */
|
|
69
|
+
readonly crv?: string;
|
|
70
|
+
/** Implementation performing sign/verify. */
|
|
71
|
+
readonly backend: JwkSignatureBackend;
|
|
72
|
+
/** Parameters for `SubtleCrypto.importKey`; only set when `backend` is `webcrypto`. */
|
|
73
|
+
readonly keyAlgorithm?: EcKeyImportParams | RsaHashedImportParams | Algorithm;
|
|
74
|
+
/** Parameters for `SubtleCrypto.sign`/`verify`; only set when `backend` is `webcrypto`. */
|
|
75
|
+
readonly signAlgorithm?: EcdsaParams | RsaPssParams | Algorithm;
|
|
76
|
+
/**
|
|
77
|
+
* Size in bytes of the private scalar or seed the key is built from,
|
|
78
|
+
* or `undefined` for algorithms that have none (RSA).
|
|
79
|
+
*/
|
|
80
|
+
readonly seedSize?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Size in bytes of a detached signature, or `undefined` when it depends on the
|
|
83
|
+
* key size rather than on the algorithm (RSA, where it equals the modulus size).
|
|
84
|
+
*/
|
|
85
|
+
readonly signatureSize?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolves the signature primitive denoted by a JWK.
|
|
89
|
+
*
|
|
90
|
+
* Only the members that define the primitive are looked at. The ones that merely
|
|
91
|
+
* describe the key handle the JWK came from — `use`, `key_ops` and `ext` — are ignored,
|
|
92
|
+
* including when they contradict a signing usage: this class hierarchy is the caller's
|
|
93
|
+
* statement of intent, and a JWK is accepted whatever its declared usage.
|
|
94
|
+
*
|
|
95
|
+
* @param {SignatureJwk} jwk - The JWK to inspect. It may be either a public or a private key.
|
|
96
|
+
* @return {JwkSignatureAlgorithm} The resolved algorithm description.
|
|
97
|
+
* @throws {Error} If the JWK is malformed, is not a signature key, or uses an unsupported algorithm.
|
|
98
|
+
*/
|
|
99
|
+
export declare function resolveJwkSignatureAlgorithm(jwk: SignatureJwk): JwkSignatureAlgorithm;
|
|
100
|
+
/**
|
|
101
|
+
* Resolves a signature primitive from its JOSE `alg` identifier, without a key.
|
|
102
|
+
*
|
|
103
|
+
* @param {JwkSignatureAlgorithmName} alg - The JOSE algorithm identifier.
|
|
104
|
+
* @return {JwkSignatureAlgorithm} The resolved algorithm description.
|
|
105
|
+
* @throws {Error} If the algorithm is not supported.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolveJwkSignatureAlgorithmByName(alg: JwkSignatureAlgorithmName): JwkSignatureAlgorithm;
|
|
108
|
+
/**
|
|
109
|
+
* Reduces a JWK to the canonical public form of the key it holds.
|
|
110
|
+
*
|
|
111
|
+
* The result carries `kty`, the public members of that key type, and `alg` only where
|
|
112
|
+
* {@link ALG_DEPENDENT_KEY_TYPES} says the key material does not already imply the
|
|
113
|
+
* primitive. Everything else the JWK may have arrived with is dropped: the private
|
|
114
|
+
* members, and the members that describe the JWK rather than the key — `use`, `key_ops`,
|
|
115
|
+
* `ext`, `kid`, `x5u`, `x5c`, `x5t`, `x5t#S256` and anything unrecognised.
|
|
116
|
+
*
|
|
117
|
+
* The extraction works on an allow-list rather than by deleting known private members,
|
|
118
|
+
* so that a private RSA JWK cannot leak `p`, `q`, `dp`, `dq`, `qi` or `oth` into the
|
|
119
|
+
* public key, and so that a member added by a future JWK revision cannot slip through.
|
|
120
|
+
*
|
|
121
|
+
* @param {SignatureJwk} jwk - The JWK to derive the public key from.
|
|
122
|
+
* @param {JwkSignatureAlgorithm} algorithm - The algorithm resolved from that JWK.
|
|
123
|
+
* @return {SignatureJwk} The canonical public JWK, with its members ordered.
|
|
124
|
+
* @throws {Error} If a public member required by the key type is missing.
|
|
125
|
+
*/
|
|
126
|
+
export declare function extractPublicJwk(jwk: SignatureJwk, algorithm: JwkSignatureAlgorithm): SignatureJwk;
|
|
127
|
+
/**
|
|
128
|
+
* Reduces a JWK to the canonical private form of the key it holds.
|
|
129
|
+
*
|
|
130
|
+
* The result is {@link extractPublicJwk} completed by the private members of the key
|
|
131
|
+
* type; the same members are dropped, on the same allow-list basis.
|
|
132
|
+
*
|
|
133
|
+
* @param {SignatureJwk} jwk - The private JWK.
|
|
134
|
+
* @param {JwkSignatureAlgorithm} algorithm - The algorithm resolved from that JWK.
|
|
135
|
+
* @return {SignatureJwk} The canonical private JWK, with its members ordered.
|
|
136
|
+
* @throws {Error} If a member required to sign is missing.
|
|
137
|
+
*/
|
|
138
|
+
export declare function extractPrivateJwk(jwk: SignatureJwk, algorithm: JwkSignatureAlgorithm): SignatureJwk;
|
|
139
|
+
/**
|
|
140
|
+
* Returns a copy of a JWK whose members are ordered lexicographically.
|
|
141
|
+
*
|
|
142
|
+
* Both JSON and CBOR serialise object members in insertion order, so ordering them is
|
|
143
|
+
* what turns the canonical form into a canonical byte string: two JWKs holding the same
|
|
144
|
+
* members serialise identically no matter which order they were written in.
|
|
145
|
+
*
|
|
146
|
+
* @param {SignatureJwk | Record<string, unknown>} jwk - The JWK to order.
|
|
147
|
+
* @return {SignatureJwk} A copy of the JWK, with its members in lexicographic order.
|
|
148
|
+
*/
|
|
149
|
+
export declare function sortJwkMembers(jwk: SignatureJwk | Record<string, unknown>): SignatureJwk;
|
|
150
|
+
/**
|
|
151
|
+
* Reads a mandatory string member of a JWK.
|
|
152
|
+
*
|
|
153
|
+
* @param {SignatureJwk} jwk - The JWK to read from.
|
|
154
|
+
* @param {string} member - Name of the member.
|
|
155
|
+
* @return {string} The member value.
|
|
156
|
+
* @throws {Error} If the member is missing or is not a string.
|
|
157
|
+
*/
|
|
158
|
+
export declare function requireJwkMember(jwk: SignatureJwk, member: string): string;
|
|
159
|
+
//# sourceMappingURL=JwkSignatureAlgorithm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwkSignatureAlgorithm.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/JwkSignatureAlgorithm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE/D,kEAAkE;AAClE,MAAM,MAAM,yBAAyB,GAC/B,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GACtC,SAAS,GAAG,OAAO,GACnB,OAAO,GAAG,OAAO,GAAG,OAAO,GAC3B,OAAO,GAAG,OAAO,GAAG,OAAO,GAC3B,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC5C,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDA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AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,qBAAqB,GAAG,YAAY,CAenG;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAMxF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI1E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { JwkSignatureAlgorithm, JwkSignatureAlgorithmName, SignatureJwk } from './JwkSignatureAlgorithm';
|
|
2
|
+
/** Signing half of a JWK key pair. */
|
|
3
|
+
export interface JwkSigner {
|
|
4
|
+
/** Bare private key material; see {@link JwkPrivateSignatureKey.getRawPrivateKeyBytes}. */
|
|
5
|
+
readonly privateKeyBytes: Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* Produces a detached signature over `data`.
|
|
8
|
+
*
|
|
9
|
+
* @param {Uint8Array} data - The message to sign. It is signed as-is, following JOSE semantics.
|
|
10
|
+
* @return {Promise<Uint8Array>} The detached signature.
|
|
11
|
+
*/
|
|
12
|
+
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
13
|
+
}
|
|
14
|
+
/** Verifying half of a JWK key pair. */
|
|
15
|
+
export interface JwkVerifier {
|
|
16
|
+
/** Bare public key material; see {@link JwkPublicSignatureKey.getRawPublicKeyBytes}. */
|
|
17
|
+
readonly publicKeyBytes: Uint8Array;
|
|
18
|
+
/**
|
|
19
|
+
* Checks a detached signature over `data`.
|
|
20
|
+
*
|
|
21
|
+
* @param {Uint8Array} data - The signed message.
|
|
22
|
+
* @param {Uint8Array} signature - The detached signature.
|
|
23
|
+
* @return {Promise<boolean>} Whether the signature is valid.
|
|
24
|
+
*/
|
|
25
|
+
verify(data: Uint8Array, signature: Uint8Array): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
/** Options accepted when generating a fresh signature JWK. */
|
|
28
|
+
export interface JwkGenerationOptions {
|
|
29
|
+
/** Modulus size in bits, for RSA keys only. Defaults to 2048. */
|
|
30
|
+
modulusLength?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builds the signer of a private JWK.
|
|
34
|
+
*
|
|
35
|
+
* @param {JwkSignatureAlgorithm} algorithm - The algorithm resolved from the JWK.
|
|
36
|
+
* @param {SignatureJwk} privateJwk - The sanitised private JWK.
|
|
37
|
+
* @return {Promise<JwkSigner>} The signer bound to that key.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createJwkSigner(algorithm: JwkSignatureAlgorithm, privateJwk: SignatureJwk): Promise<JwkSigner>;
|
|
40
|
+
/**
|
|
41
|
+
* Builds the verifier of a public JWK.
|
|
42
|
+
*
|
|
43
|
+
* @param {JwkSignatureAlgorithm} algorithm - The algorithm resolved from the JWK.
|
|
44
|
+
* @param {SignatureJwk} publicJwk - The sanitised public JWK.
|
|
45
|
+
* @return {Promise<JwkVerifier>} The verifier bound to that key.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createJwkVerifier(algorithm: JwkSignatureAlgorithm, publicJwk: SignatureJwk): Promise<JwkVerifier>;
|
|
48
|
+
/**
|
|
49
|
+
* Generates a fresh private JWK for the given JOSE algorithm.
|
|
50
|
+
*
|
|
51
|
+
* @param {JwkSignatureAlgorithmName} alg - The JOSE algorithm identifier.
|
|
52
|
+
* @param {JwkGenerationOptions} options - Algorithm-specific generation options.
|
|
53
|
+
* @return {Promise<SignatureJwk>} The generated private JWK.
|
|
54
|
+
*/
|
|
55
|
+
export declare function generateSignatureJwk(alg: JwkSignatureAlgorithmName, options?: JwkGenerationOptions): Promise<SignatureJwk>;
|
|
56
|
+
//# sourceMappingURL=JwkSignatureBackend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwkSignatureBackend.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/JwkSignatureBackend.ts"],"names":[],"mappings":"AAmBA,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAGzB,YAAY,EACf,MAAM,yBAAyB,CAAC;AAkBjC,sCAAsC;AACtC,MAAM,WAAW,SAAS;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC;IAErC;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/C;AAED,wCAAwC;AACxC,MAAM,WAAW,WAAW;IACxB,wFAAwF;IACxF,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;IAEpC;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrE;AAED,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACjC,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACjC,SAAS,EAAE,qBAAqB,EAChC,UAAU,EAAE,YAAY,GACzB,OAAO,CAAC,SAAS,CAAC,CAapB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,qBAAqB,EAChC,SAAS,EAAE,YAAY,GACxB,OAAO,CAAC,WAAW,CAAC,CAatB;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACtC,GAAG,EAAE,yBAAyB,EAC9B,OAAO,GAAE,oBAAyB,GACnC,OAAO,CAAC,YAAY,CAAC,CA+CvB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SignatureScheme } from '../SignatureScheme';
|
|
2
|
+
import { SignatureSchemeId } from '../SignatureSchemeId';
|
|
3
|
+
import { JwkSignatureAlgorithm, JwkSignatureAlgorithmName, SignatureJwk } from './JwkSignatureAlgorithm';
|
|
4
|
+
/**
|
|
5
|
+
* {@link SignatureScheme} describing the primitive denoted by a JWK.
|
|
6
|
+
*
|
|
7
|
+
* The instance is bound to a specific key because RSA signature sizes depend on the
|
|
8
|
+
* modulus rather than on the algorithm alone.
|
|
9
|
+
*/
|
|
10
|
+
export declare class JwkSignatureScheme implements SignatureScheme {
|
|
11
|
+
private readonly algorithm;
|
|
12
|
+
private readonly signatureSize;
|
|
13
|
+
/**
|
|
14
|
+
* Builds the scheme of a given key.
|
|
15
|
+
*
|
|
16
|
+
* @param {JwkSignatureAlgorithm} algorithm - The algorithm resolved from the JWK.
|
|
17
|
+
* @param {SignatureJwk} jwk - The JWK the scheme describes; must expose its public members.
|
|
18
|
+
* @return {JwkSignatureScheme} The signature scheme of that key.
|
|
19
|
+
*/
|
|
20
|
+
static forJwk(algorithm: JwkSignatureAlgorithm, jwk: SignatureJwk): JwkSignatureScheme;
|
|
21
|
+
constructor(algorithm: JwkSignatureAlgorithm, signatureSize: number);
|
|
22
|
+
/**
|
|
23
|
+
* Returns the full description of the resolved signature primitive.
|
|
24
|
+
*
|
|
25
|
+
* @return {JwkSignatureAlgorithm} The algorithm description.
|
|
26
|
+
*/
|
|
27
|
+
getAlgorithm(): JwkSignatureAlgorithm;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the JOSE `alg` identifier of the scheme.
|
|
30
|
+
*
|
|
31
|
+
* @return {JwkSignatureAlgorithmName} The JOSE algorithm identifier.
|
|
32
|
+
*/
|
|
33
|
+
getAlgorithmName(): JwkSignatureAlgorithmName;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the Carmentis identifier of the scheme.
|
|
36
|
+
*
|
|
37
|
+
* Most JOSE algorithms have no Carmentis counterpart, and those that look like one
|
|
38
|
+
* are not always compatible with it; see {@link SIGNATURE_SCHEME_IDS}. Such keys can
|
|
39
|
+
* still sign and verify — they simply cannot be used where a scheme identifier has
|
|
40
|
+
* to be recorded, such as on-chain signatures.
|
|
41
|
+
*
|
|
42
|
+
* @return {SignatureSchemeId} The Carmentis signature scheme identifier.
|
|
43
|
+
* @throws {Error} If the algorithm has no equivalent Carmentis scheme.
|
|
44
|
+
*/
|
|
45
|
+
getSignatureSchemeId(): SignatureSchemeId;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the size in bytes of a detached signature produced by this key.
|
|
48
|
+
*
|
|
49
|
+
* @return {number} The signature size in bytes.
|
|
50
|
+
*/
|
|
51
|
+
getSignatureSize(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the size in bytes of the seed the key is derived from.
|
|
54
|
+
*
|
|
55
|
+
* @return {number} The seed size in bytes.
|
|
56
|
+
* @throws {Error} If the algorithm is not seed-based, which is the case of RSA.
|
|
57
|
+
*/
|
|
58
|
+
expectedSeedSize(): number;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=JwkSignatureScheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JwkSignatureScheme.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/JwkSignatureScheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAEzB,YAAY,EACf,MAAM,yBAAyB,CAAC;AAmBjC;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAelD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAflC;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,qBAAqB,EAAE,GAAG,EAAE,YAAY,GAAG,kBAAkB;gBAOjE,SAAS,EAAE,qBAAqB,EAChC,aAAa,EAAE,MAAM;IAI1C;;;;OAIG;IACH,YAAY,IAAI,qBAAqB;IAIrC;;;;OAIG;IACH,gBAAgB,IAAI,yBAAyB;IAI7C;;;;;;;;;;OAUG;IACH,oBAAoB,IAAI,iBAAiB;IAezC;;;;OAIG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;;;OAKG;IACH,gBAAgB,IAAI,MAAM;CAM7B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the Web Crypto `SubtleCrypto` implementation of the current runtime.
|
|
3
|
+
*
|
|
4
|
+
* The lookup is deliberately lazy: resolving `globalThis.crypto.subtle` at module
|
|
5
|
+
* scope would throw while merely importing the module on runtimes where Web Crypto
|
|
6
|
+
* is not exposed globally (Node.js < 19, browsers in an insecure context).
|
|
7
|
+
*
|
|
8
|
+
* @return {SubtleCrypto} The `SubtleCrypto` instance of the current runtime.
|
|
9
|
+
* @throws {Error} If the runtime does not expose the Web Crypto API.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSubtle(): SubtleCrypto;
|
|
12
|
+
//# sourceMappingURL=webcrypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webcrypto.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/jwk/webcrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,SAAS,IAAI,YAAY,CAUxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Secp256k1PrivateSignatureKey.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/secp256k1/Secp256k1PrivateSignatureKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,
|
|
1
|
+
{"version":3,"file":"Secp256k1PrivateSignatureKey.d.ts","sourceRoot":"","sources":["../../../../src/crypto/signature/secp256k1/Secp256k1PrivateSignatureKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAA0C,MAAM,kBAAkB,CAAC;AACrG,OAAO,EAAC,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAGnD;;;;;;;;GAQG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACzD,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,OAAO;IAIvC,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,MAAM;IAI5E;;;;;OAKG;IACH,MAAM,CAAC,GAAG,IAAI,4BAA4B;IAI1C;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU;IAI7B,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKjD,oBAAoB,IAAI,UAAU;IAK5B,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAKjD,SAAS,IAAI,eAAe;CAG/B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BinaryEncoding } from './BinaryEndoding';
|
|
2
|
+
export declare class BinaryEncoder {
|
|
3
|
+
static decode(message: string, encoding: BinaryEncoding): Uint8Array;
|
|
4
|
+
static encode(message: Uint8Array, encoding: BinaryEncoding): string;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=BinaryEncoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryEncoder.d.ts","sourceRoot":"","sources":["../../../../../src/crypto/signature/signer/binary/BinaryEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,qBAAa,aAAa;IACtB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,UAAU;IAQpE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc;CAO9D"}
|