@enbox/crypto 0.0.3 → 0.0.4
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/browser.mjs +1 -1
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/algorithms/aes-ctr.js +1 -1
- package/dist/esm/algorithms/aes-gcm.js +34 -1
- package/dist/esm/algorithms/aes-gcm.js.map +1 -1
- package/dist/esm/algorithms/aes-kw.js +154 -0
- package/dist/esm/algorithms/aes-kw.js.map +1 -0
- package/dist/esm/algorithms/ecdsa.js +110 -1
- package/dist/esm/algorithms/ecdsa.js.map +1 -1
- package/dist/esm/algorithms/eddsa.js +90 -1
- package/dist/esm/algorithms/eddsa.js.map +1 -1
- package/dist/esm/algorithms/hkdf.js +53 -0
- package/dist/esm/algorithms/hkdf.js.map +1 -0
- package/dist/esm/algorithms/pbkdf2.js +55 -0
- package/dist/esm/algorithms/pbkdf2.js.map +1 -0
- package/dist/esm/algorithms/sha-2.js +1 -1
- package/dist/esm/algorithms/x25519.js +125 -0
- package/dist/esm/algorithms/x25519.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/local-key-manager.js +6 -1
- package/dist/esm/local-key-manager.js.map +1 -1
- package/dist/esm/primitives/ecies-secp256k1.js +79 -0
- package/dist/esm/primitives/ecies-secp256k1.js.map +1 -0
- package/dist/esm/primitives/x25519.js +9 -16
- package/dist/esm/primitives/x25519.js.map +1 -1
- package/dist/esm/utils.js +30 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/algorithms/aes-ctr.d.ts +1 -1
- package/dist/types/algorithms/aes-gcm.d.ts +23 -3
- package/dist/types/algorithms/aes-gcm.d.ts.map +1 -1
- package/dist/types/algorithms/aes-kw.d.ts +129 -0
- package/dist/types/algorithms/aes-kw.d.ts.map +1 -0
- package/dist/types/algorithms/ecdsa.d.ts +48 -3
- package/dist/types/algorithms/ecdsa.d.ts.map +1 -1
- package/dist/types/algorithms/eddsa.d.ts +48 -3
- package/dist/types/algorithms/eddsa.d.ts.map +1 -1
- package/dist/types/algorithms/hkdf.d.ts +35 -0
- package/dist/types/algorithms/hkdf.d.ts.map +1 -0
- package/dist/types/algorithms/pbkdf2.d.ts +35 -0
- package/dist/types/algorithms/pbkdf2.d.ts.map +1 -0
- package/dist/types/algorithms/sha-2.d.ts +1 -1
- package/dist/types/algorithms/x25519.d.ts +76 -0
- package/dist/types/algorithms/x25519.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/local-key-manager.d.ts +4 -4
- package/dist/types/local-key-manager.d.ts.map +1 -1
- package/dist/types/primitives/ecies-secp256k1.d.ts +53 -0
- package/dist/types/primitives/ecies-secp256k1.d.ts.map +1 -0
- package/dist/types/primitives/x25519.d.ts +9 -16
- package/dist/types/primitives/x25519.d.ts.map +1 -1
- package/dist/types/types/crypto-api.d.ts +52 -4
- package/dist/types/types/crypto-api.d.ts.map +1 -1
- package/dist/types/types/key-converter.d.ts +37 -15
- package/dist/types/types/key-converter.d.ts.map +1 -1
- package/dist/types/types/key-deriver.d.ts +41 -0
- package/dist/types/types/key-deriver.d.ts.map +1 -1
- package/dist/types/types/key-io.d.ts +37 -0
- package/dist/types/types/key-io.d.ts.map +1 -1
- package/dist/types/types/params-direct.d.ts +17 -0
- package/dist/types/types/params-direct.d.ts.map +1 -1
- package/dist/types/types/params-kms.d.ts +55 -0
- package/dist/types/types/params-kms.d.ts.map +1 -1
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +3 -3
- package/package.json +10 -13
- package/src/algorithms/aes-ctr.ts +1 -1
- package/src/algorithms/aes-gcm.ts +38 -2
- package/src/algorithms/aes-kw.ts +182 -0
- package/src/algorithms/ecdsa.ts +132 -1
- package/src/algorithms/eddsa.ts +108 -1
- package/src/algorithms/hkdf.ts +54 -0
- package/src/algorithms/pbkdf2.ts +57 -0
- package/src/algorithms/sha-2.ts +1 -1
- package/src/algorithms/x25519.ts +153 -0
- package/src/index.ts +5 -0
- package/src/local-key-manager.ts +9 -4
- package/src/primitives/ecies-secp256k1.ts +113 -0
- package/src/primitives/x25519.ts +9 -16
- package/src/types/crypto-api.ts +124 -6
- package/src/types/key-converter.ts +33 -7
- package/src/types/key-deriver.ts +49 -0
- package/src/types/key-io.ts +40 -0
- package/src/types/params-direct.ts +21 -0
- package/src/types/params-kms.ts +67 -0
- package/src/utils.ts +53 -0
- package/dist/browser.js +0 -60
- package/dist/browser.js.map +0 -7
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AsymmetricKeyGenerator } from '../types/key-generator.js';
|
|
2
2
|
import type { Jwk } from '../jose/jwk.js';
|
|
3
3
|
import type { Signer } from '../types/signer.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AsymmetricKeyConverter, KeyConverter } from '../types/key-converter.js';
|
|
5
|
+
import type { BytesToPrivateKeyParams, BytesToPublicKeyParams, ComputePublicKeyParams, GenerateKeyParams, GetPublicKeyParams, PrivateKeyToBytesParams, PublicKeyToBytesParams, SignParams, VerifyParams } from '../types/params-direct.js';
|
|
5
6
|
import { CryptoAlgorithm } from './crypto-algorithm.js';
|
|
6
7
|
/**
|
|
7
8
|
* The `EcdsaGenerateKeyParams` interface defines the algorithm-specific parameters that should be
|
|
@@ -25,9 +26,35 @@ export interface EcdsaGenerateKeyParams extends GenerateKeyParams {
|
|
|
25
26
|
* of signatures.
|
|
26
27
|
*
|
|
27
28
|
* This class is typically accessed through implementations that extend the
|
|
28
|
-
* {@link
|
|
29
|
+
* {@link DsaApi | `DsaApi`} interface.
|
|
29
30
|
*/
|
|
30
|
-
export declare class EcdsaAlgorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<EcdsaGenerateKeyParams, Jwk, GetPublicKeyParams>, Signer<SignParams, VerifyParams> {
|
|
31
|
+
export declare class EcdsaAlgorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<EcdsaGenerateKeyParams, Jwk, GetPublicKeyParams>, KeyConverter, AsymmetricKeyConverter, Signer<SignParams, VerifyParams> {
|
|
32
|
+
/**
|
|
33
|
+
* Converts a private key from a byte array to JWK format, setting the `alg` property based on
|
|
34
|
+
* the algorithm.
|
|
35
|
+
*
|
|
36
|
+
* @param params - The parameters for the private key conversion.
|
|
37
|
+
* @param params.algorithm - The ECDSA algorithm identifier.
|
|
38
|
+
* @param params.privateKeyBytes - The raw private key as a Uint8Array.
|
|
39
|
+
*
|
|
40
|
+
* @returns A Promise that resolves to the private key in JWK format.
|
|
41
|
+
*/
|
|
42
|
+
bytesToPrivateKey({ algorithm, privateKeyBytes }: BytesToPrivateKeyParams & {
|
|
43
|
+
algorithm: 'ES256' | 'ES256K' | 'secp256k1' | 'secp256r1';
|
|
44
|
+
}): Promise<Jwk>;
|
|
45
|
+
/**
|
|
46
|
+
* Converts a public key from a byte array to JWK format, setting the `alg` property based on
|
|
47
|
+
* the algorithm.
|
|
48
|
+
*
|
|
49
|
+
* @param params - The parameters for the public key conversion.
|
|
50
|
+
* @param params.algorithm - The ECDSA algorithm identifier.
|
|
51
|
+
* @param params.publicKeyBytes - The raw public key as a Uint8Array.
|
|
52
|
+
*
|
|
53
|
+
* @returns A Promise that resolves to the public key in JWK format.
|
|
54
|
+
*/
|
|
55
|
+
bytesToPublicKey({ algorithm, publicKeyBytes }: BytesToPublicKeyParams & {
|
|
56
|
+
algorithm: 'ES256' | 'ES256K' | 'secp256k1' | 'secp256r1';
|
|
57
|
+
}): Promise<Jwk>;
|
|
31
58
|
/**
|
|
32
59
|
* Derives the public key in JWK format from a given private key.
|
|
33
60
|
*
|
|
@@ -150,5 +177,23 @@ export declare class EcdsaAlgorithm extends CryptoAlgorithm implements Asymmetri
|
|
|
150
177
|
* @returns A Promise resolving to a boolean indicating whether the signature is valid.
|
|
151
178
|
*/
|
|
152
179
|
verify({ key, signature, data }: VerifyParams): Promise<boolean>;
|
|
180
|
+
/**
|
|
181
|
+
* Converts a private key from JWK format to a byte array.
|
|
182
|
+
*
|
|
183
|
+
* @param params - The parameters for the private key conversion.
|
|
184
|
+
* @param params.privateKey - The private key in JWK format.
|
|
185
|
+
*
|
|
186
|
+
* @returns A Promise that resolves to the private key as a Uint8Array.
|
|
187
|
+
*/
|
|
188
|
+
privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
|
|
189
|
+
/**
|
|
190
|
+
* Converts a public key from JWK format to a byte array.
|
|
191
|
+
*
|
|
192
|
+
* @param params - The parameters for the public key conversion.
|
|
193
|
+
* @param params.publicKey - The public key in JWK format.
|
|
194
|
+
*
|
|
195
|
+
* @returns A Promise that resolves to the public key as a Uint8Array.
|
|
196
|
+
*/
|
|
197
|
+
publicKeyToBytes({ publicKey }: PublicKeyToBytesParams): Promise<Uint8Array>;
|
|
153
198
|
}
|
|
154
199
|
//# sourceMappingURL=ecdsa.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/algorithms/ecdsa.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,YAAY,EACb,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/algorithms/ecdsa.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,GAAG,EA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AaG;IACU,WAAW,CAAC,EAAE,SAAS,EAAE,EACpC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAmBf;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,YAAY,CAAC,EAAE,GAAG,EAAE,EAC/B,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAuBf;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACU,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAC7B,UAAU,GACT,OAAO,CAAC,UAAU,CAAC;IAmBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACU,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAC1C,YAAY,GACX,OAAO,CAAC,OAAO,CAAC;IAmBnB;;;;;;;OAOG;IACU,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAC3C,uBAAuB,GACtB,OAAO,CAAC,UAAU,CAAC;IAiBtB;;;;;;;OAOG;IACU,gBAAgB,CAAC,EAAE,SAAS,EAAE,EACzC,sBAAsB,GACrB,OAAO,CAAC,UAAU,CAAC;CAgBvB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AsymmetricKeyGenerator } from '../types/key-generator.js';
|
|
2
2
|
import type { Jwk } from '../jose/jwk.js';
|
|
3
3
|
import type { Signer } from '../types/signer.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AsymmetricKeyConverter, KeyConverter } from '../types/key-converter.js';
|
|
5
|
+
import type { BytesToPrivateKeyParams, BytesToPublicKeyParams, ComputePublicKeyParams, GenerateKeyParams, GetPublicKeyParams, PrivateKeyToBytesParams, PublicKeyToBytesParams, SignParams, VerifyParams } from '../types/params-direct.js';
|
|
5
6
|
import { CryptoAlgorithm } from './crypto-algorithm.js';
|
|
6
7
|
/**
|
|
7
8
|
* The `EdDsaGenerateKeyParams` interface defines the algorithm-specific parameters that should be
|
|
@@ -22,9 +23,35 @@ export interface EdDsaGenerateKeyParams extends GenerateKeyParams {
|
|
|
22
23
|
* of signatures.
|
|
23
24
|
*
|
|
24
25
|
* This class is typically accessed through implementations that extend the
|
|
25
|
-
* {@link
|
|
26
|
+
* {@link DsaApi | `DsaApi`} interface.
|
|
26
27
|
*/
|
|
27
|
-
export declare class EdDsaAlgorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<EdDsaGenerateKeyParams, Jwk, GetPublicKeyParams>, Signer<SignParams, VerifyParams> {
|
|
28
|
+
export declare class EdDsaAlgorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<EdDsaGenerateKeyParams, Jwk, GetPublicKeyParams>, KeyConverter, AsymmetricKeyConverter, Signer<SignParams, VerifyParams> {
|
|
29
|
+
/**
|
|
30
|
+
* Converts a private key from a byte array to JWK format, setting the `alg` property to
|
|
31
|
+
* `'EdDSA'`.
|
|
32
|
+
*
|
|
33
|
+
* @param params - The parameters for the private key conversion.
|
|
34
|
+
* @param params.algorithm - The EdDSA algorithm identifier (`'Ed25519'`).
|
|
35
|
+
* @param params.privateKeyBytes - The raw private key as a Uint8Array.
|
|
36
|
+
*
|
|
37
|
+
* @returns A Promise that resolves to the private key in JWK format.
|
|
38
|
+
*/
|
|
39
|
+
bytesToPrivateKey({ algorithm, privateKeyBytes }: BytesToPrivateKeyParams & {
|
|
40
|
+
algorithm: 'Ed25519';
|
|
41
|
+
}): Promise<Jwk>;
|
|
42
|
+
/**
|
|
43
|
+
* Converts a public key from a byte array to JWK format, setting the `alg` property to
|
|
44
|
+
* `'EdDSA'`.
|
|
45
|
+
*
|
|
46
|
+
* @param params - The parameters for the public key conversion.
|
|
47
|
+
* @param params.algorithm - The EdDSA algorithm identifier (`'Ed25519'`).
|
|
48
|
+
* @param params.publicKeyBytes - The raw public key as a Uint8Array.
|
|
49
|
+
*
|
|
50
|
+
* @returns A Promise that resolves to the public key in JWK format.
|
|
51
|
+
*/
|
|
52
|
+
bytesToPublicKey({ algorithm, publicKeyBytes }: BytesToPublicKeyParams & {
|
|
53
|
+
algorithm: 'Ed25519';
|
|
54
|
+
}): Promise<Jwk>;
|
|
28
55
|
/**
|
|
29
56
|
* Derives the public key in JWK format from a given private key.
|
|
30
57
|
*
|
|
@@ -147,5 +174,23 @@ export declare class EdDsaAlgorithm extends CryptoAlgorithm implements Asymmetri
|
|
|
147
174
|
* @returns A Promise resolving to a boolean indicating whether the signature is valid.
|
|
148
175
|
*/
|
|
149
176
|
verify({ key, signature, data }: VerifyParams): Promise<boolean>;
|
|
177
|
+
/**
|
|
178
|
+
* Converts a private key from JWK format to a byte array.
|
|
179
|
+
*
|
|
180
|
+
* @param params - The parameters for the private key conversion.
|
|
181
|
+
* @param params.privateKey - The private key in JWK format.
|
|
182
|
+
*
|
|
183
|
+
* @returns A Promise that resolves to the private key as a Uint8Array.
|
|
184
|
+
*/
|
|
185
|
+
privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
|
|
186
|
+
/**
|
|
187
|
+
* Converts a public key from JWK format to a byte array.
|
|
188
|
+
*
|
|
189
|
+
* @param params - The parameters for the public key conversion.
|
|
190
|
+
* @param params.publicKey - The public key in JWK format.
|
|
191
|
+
*
|
|
192
|
+
* @returns A Promise that resolves to the public key as a Uint8Array.
|
|
193
|
+
*/
|
|
194
|
+
publicKeyToBytes({ publicKey }: PublicKeyToBytesParams): Promise<Uint8Array>;
|
|
150
195
|
}
|
|
151
196
|
//# sourceMappingURL=eddsa.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/algorithms/eddsa.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,E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AE,GAChD,OAAO,CAAC,GAAG,CAAC;IAef;;;;;;;;;;;;;;;;;;;OAmBG;IACU,gBAAgB,CAAC,EAAE,GAAG,EAAE,EACnC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAiBf;;;;;;;;;;;;;OAaG;IACG,WAAW,CAAC,EAAE,SAAS,EAAE,EAC7B,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAWf;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,YAAY,CAAC,EAAE,GAAG,EAAE,EAC/B,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAiBf;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACU,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAC7B,UAAU,GACT,OAAO,CAAC,UAAU,CAAC;IAetB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACU,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAC1C,YAAY,GACX,OAAO,CAAC,OAAO,CAAC;IAenB;;;;;;;OAOG;IACU,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAC3C,uBAAuB,GACtB,OAAO,CAAC,UAAU,CAAC;IAatB;;;;;;;OAOG;IACU,gBAAgB,CAAC,EAAE,SAAS,EAAE,EACzC,sBAAsB,GACrB,OAAO,CAAC,UAAU,CAAC;CAYvB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DeriveKeyBytesParams } from '../types/params-direct.js';
|
|
2
|
+
import type { HkdfParams } from '../primitives/hkdf.js';
|
|
3
|
+
import type { KeyBytesDeriver } from '../types/key-deriver.js';
|
|
4
|
+
import { CryptoAlgorithm } from './crypto-algorithm.js';
|
|
5
|
+
/**
|
|
6
|
+
* The `HkdfDeriveKeyBytesParams` interface defines the algorithm-specific parameters that should be
|
|
7
|
+
* passed into the `deriveKeyBytes()` method when using the HKDF algorithm.
|
|
8
|
+
*/
|
|
9
|
+
export interface HkdfDeriveKeyBytesParams extends DeriveKeyBytesParams {
|
|
10
|
+
/** Specifies the algorithm variant for HKDF key derivation.
|
|
11
|
+
* The value determines the hash function that will be used and must be one of the following:
|
|
12
|
+
* - `"HKDF-256"`: HKDF with SHA-256.
|
|
13
|
+
* - `"HKDF-384"`: HKDF with SHA-384.
|
|
14
|
+
* - `"HKDF-512"`: HKDF with SHA-512.
|
|
15
|
+
*/
|
|
16
|
+
algorithm: 'HKDF-256' | 'HKDF-384' | 'HKDF-512';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The `HkdfAlgorithm` class provides a concrete implementation for HKDF key derivation. It wraps
|
|
20
|
+
* the {@link Hkdf} primitive and maps JOSE algorithm names to hash functions.
|
|
21
|
+
*/
|
|
22
|
+
export declare class HkdfAlgorithm extends CryptoAlgorithm implements KeyBytesDeriver<HkdfDeriveKeyBytesParams, Uint8Array> {
|
|
23
|
+
/**
|
|
24
|
+
* Derives a cryptographic byte array using HKDF.
|
|
25
|
+
*
|
|
26
|
+
* @param params - The parameters for the key derivation operation.
|
|
27
|
+
* @param params.algorithm - The HKDF algorithm variant (e.g., `'HKDF-256'`).
|
|
28
|
+
* @param params.baseKeyBytes - The input key material.
|
|
29
|
+
* @param params.length - The desired length of the output in bits.
|
|
30
|
+
*
|
|
31
|
+
* @returns A Promise that resolves to the derived key bytes.
|
|
32
|
+
*/
|
|
33
|
+
deriveKeyBytes({ algorithm, ...params }: HkdfDeriveKeyBytesParams & Omit<HkdfParams, 'hash'>): Promise<Uint8Array>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=hkdf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../../src/algorithms/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IACpE;;;;;OAKG;IACH,SAAS,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;CACjD;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,eACjC,YAAW,eAAe,CAAC,wBAAwB,EAAE,UAAU,CAAC;IAEhE;;;;;;;;;OASG;IACU,cAAc,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,wBAAwB,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC;CAavB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DeriveKeyBytesParams } from '../types/params-direct.js';
|
|
2
|
+
import type { KeyBytesDeriver } from '../types/key-deriver.js';
|
|
3
|
+
import type { Pbkdf2Params } from '../primitives/pbkdf2.js';
|
|
4
|
+
import { CryptoAlgorithm } from './crypto-algorithm.js';
|
|
5
|
+
/**
|
|
6
|
+
* The `Pbkdf2DeriveKeyBytesParams` interface defines the algorithm-specific parameters that
|
|
7
|
+
* should be passed into the `deriveKeyBytes()` method when using the PBKDF2 algorithm.
|
|
8
|
+
*/
|
|
9
|
+
export interface Pbkdf2DeriveKeyBytesParams extends DeriveKeyBytesParams {
|
|
10
|
+
/** Specifies the algorithm variant for PBKDF2 key derivation.
|
|
11
|
+
* The value determines the hash function that will be used and must be one of the following:
|
|
12
|
+
* - `"PBES2-HS256+A128KW"`: PBKDF2 with HMAC SHA-256 and A128KW key wrapping.
|
|
13
|
+
* - `"PBES2-HS384+A192KW"`: PBKDF2 with HMAC SHA-384 and A192KW key wrapping.
|
|
14
|
+
* - `"PBES2-HS512+A256KW"`: PBKDF2 with HMAC SHA-512 and A256KW key wrapping.
|
|
15
|
+
*/
|
|
16
|
+
algorithm: 'PBES2-HS256+A128KW' | 'PBES2-HS384+A192KW' | 'PBES2-HS512+A256KW';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The `Pbkdf2Algorithm` class provides a concrete implementation for PBKDF2 key derivation. It
|
|
20
|
+
* wraps the {@link Pbkdf2} primitive and maps PBES2 JOSE algorithm names to hash functions.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Pbkdf2Algorithm extends CryptoAlgorithm implements KeyBytesDeriver<Pbkdf2DeriveKeyBytesParams, Uint8Array> {
|
|
23
|
+
/**
|
|
24
|
+
* Derives a cryptographic byte array using PBKDF2.
|
|
25
|
+
*
|
|
26
|
+
* @param params - The parameters for the key derivation operation.
|
|
27
|
+
* @param params.algorithm - The PBES2 algorithm variant (e.g., `'PBES2-HS512+A256KW'`).
|
|
28
|
+
* @param params.baseKeyBytes - The password or passphrase as bytes.
|
|
29
|
+
* @param params.length - The desired length of the output in bits.
|
|
30
|
+
*
|
|
31
|
+
* @returns A Promise that resolves to the derived key bytes.
|
|
32
|
+
*/
|
|
33
|
+
deriveKeyBytes({ algorithm, ...params }: Pbkdf2DeriveKeyBytesParams & Omit<Pbkdf2Params, 'hash'>): Promise<Uint8Array>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pbkdf2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../../src/algorithms/pbkdf2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACtE;;;;;OAKG;IACH,SAAS,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;CAC/E;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,eACnC,YAAW,eAAe,CAAC,0BAA0B,EAAE,UAAU,CAAC;IAElE;;;;;;;;;OASG;IACU,cAAc,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,0BAA0B,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GACtD,OAAO,CAAC,UAAU,CAAC;CAgBvB"}
|
|
@@ -18,7 +18,7 @@ export interface Sha2DigestParams extends DigestParams {
|
|
|
18
18
|
* of the hash function and arbitrary data as input and returns the hash digest of the data.
|
|
19
19
|
*
|
|
20
20
|
* This class is typically accessed through implementations that extend the
|
|
21
|
-
* {@link
|
|
21
|
+
* {@link DsaApi | `DsaApi`} interface.
|
|
22
22
|
*/
|
|
23
23
|
export declare class Sha2Algorithm extends CryptoAlgorithm implements Hasher<Sha2DigestParams> {
|
|
24
24
|
/**
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { AsymmetricKeyGenerator } from '../types/key-generator.js';
|
|
2
|
+
import type { Jwk } from '../jose/jwk.js';
|
|
3
|
+
import type { KeyConverter } from '../types/key-converter.js';
|
|
4
|
+
import type { BytesToPrivateKeyParams, ComputePublicKeyParams, GenerateKeyParams, GetPublicKeyParams, PrivateKeyToBytesParams } from '../types/params-direct.js';
|
|
5
|
+
import { CryptoAlgorithm } from './crypto-algorithm.js';
|
|
6
|
+
/**
|
|
7
|
+
* The `X25519GenerateKeyParams` interface defines the algorithm-specific parameters that should be
|
|
8
|
+
* passed into the `generateKey()` method when using the X25519 key agreement algorithm.
|
|
9
|
+
*/
|
|
10
|
+
export interface X25519GenerateKeyParams extends GenerateKeyParams {
|
|
11
|
+
/**
|
|
12
|
+
* A string defining the type of key to generate. The value must be:
|
|
13
|
+
* - `"X25519"`: Elliptic-curve Diffie-Hellman (ECDH) using Curve25519.
|
|
14
|
+
*/
|
|
15
|
+
algorithm: 'X25519';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `X25519Algorithm` class provides a concrete implementation for key generation,
|
|
19
|
+
* public key derivation, and key conversion using the X25519 elliptic curve. X25519 is a
|
|
20
|
+
* key agreement curve (not a signature curve) used for ECDH key exchange in JWE encryption.
|
|
21
|
+
*
|
|
22
|
+
* This class implements the {@link AsymmetricKeyGenerator | `AsymmetricKeyGenerator`} and
|
|
23
|
+
* {@link KeyConverter | `KeyConverter`} interfaces, providing private key generation,
|
|
24
|
+
* public key derivation, and byte/JWK conversion.
|
|
25
|
+
*/
|
|
26
|
+
export declare class X25519Algorithm extends CryptoAlgorithm implements AsymmetricKeyGenerator<X25519GenerateKeyParams, Jwk, GetPublicKeyParams>, KeyConverter {
|
|
27
|
+
/**
|
|
28
|
+
* Converts a raw private key in bytes to its corresponding JWK format.
|
|
29
|
+
*
|
|
30
|
+
* @param params - The parameters for the private key conversion.
|
|
31
|
+
* @param params.algorithm - Must be `'X25519'`.
|
|
32
|
+
* @param params.privateKeyBytes - The raw private key as a Uint8Array.
|
|
33
|
+
*
|
|
34
|
+
* @returns A Promise that resolves to the private key in JWK format.
|
|
35
|
+
*/
|
|
36
|
+
bytesToPrivateKey({ algorithm, privateKeyBytes }: BytesToPrivateKeyParams & {
|
|
37
|
+
algorithm: 'X25519';
|
|
38
|
+
}): Promise<Jwk>;
|
|
39
|
+
/**
|
|
40
|
+
* Derives the public key in JWK format from a given X25519 private key.
|
|
41
|
+
*
|
|
42
|
+
* @param params - The parameters for the public key derivation.
|
|
43
|
+
* @param params.key - The private key in JWK format from which to derive the public key.
|
|
44
|
+
*
|
|
45
|
+
* @returns A Promise that resolves to the derived public key in JWK format.
|
|
46
|
+
*/
|
|
47
|
+
computePublicKey({ key }: ComputePublicKeyParams): Promise<Jwk>;
|
|
48
|
+
/**
|
|
49
|
+
* Generates a new X25519 private key in JWK format.
|
|
50
|
+
*
|
|
51
|
+
* @param params - The parameters for key generation.
|
|
52
|
+
* @param params.algorithm - Must be `'X25519'`.
|
|
53
|
+
*
|
|
54
|
+
* @returns A Promise that resolves to the generated private key in JWK format.
|
|
55
|
+
*/
|
|
56
|
+
generateKey({ algorithm }: X25519GenerateKeyParams): Promise<Jwk>;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves the public key properties from a given X25519 private key in JWK format.
|
|
59
|
+
*
|
|
60
|
+
* @param params - The parameters for retrieving the public key properties.
|
|
61
|
+
* @param params.key - The private key in JWK format.
|
|
62
|
+
*
|
|
63
|
+
* @returns A Promise that resolves to the public key in JWK format.
|
|
64
|
+
*/
|
|
65
|
+
getPublicKey({ key }: GetPublicKeyParams): Promise<Jwk>;
|
|
66
|
+
/**
|
|
67
|
+
* Converts a private key from JWK format to a byte array.
|
|
68
|
+
*
|
|
69
|
+
* @param params - The parameters for the private key conversion.
|
|
70
|
+
* @param params.privateKey - The private key in JWK format.
|
|
71
|
+
*
|
|
72
|
+
* @returns A Promise that resolves to the private key as a Uint8Array.
|
|
73
|
+
*/
|
|
74
|
+
privateKeyToBytes({ privateKey }: PrivateKeyToBytesParams): Promise<Uint8Array>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=x25519.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x25519.d.ts","sourceRoot":"","sources":["../../../src/algorithms/x25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAMxD;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE;;;OAGG;IACH,SAAS,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,eACnC,YAAW,sBAAsB,CAAC,uBAAuB,EAAE,GAAG,EAAE,kBAAkB,CAAC,EACxE,YAAY;IAEvB;;;;;;;;OAQG;IACU,iBAAiB,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,EAC3D,uBAAuB,GAAG;QAAE,SAAS,EAAE,QAAQ,CAAA;KAAE,GAChD,OAAO,CAAC,GAAG,CAAC;IAaf;;;;;;;OAOG;IACU,gBAAgB,CAAC,EAAE,GAAG,EAAE,EACnC,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAef;;;;;;;OAOG;IACG,WAAW,CAAC,EAAE,SAAS,EAAE,EAC7B,uBAAuB,GACtB,OAAO,CAAC,GAAG,CAAC;IAaf;;;;;;;OAOG;IACU,YAAY,CAAC,EAAE,GAAG,EAAE,EAC/B,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAef;;;;;;;OAOG;IACU,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAC3C,uBAAuB,GACtB,OAAO,CAAC,UAAU,CAAC;CAGvB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,10 +3,14 @@ export * from './local-key-manager.js';
|
|
|
3
3
|
export * from './utils.js';
|
|
4
4
|
export * from './algorithms/aes-ctr.js';
|
|
5
5
|
export * from './algorithms/aes-gcm.js';
|
|
6
|
+
export * from './algorithms/aes-kw.js';
|
|
6
7
|
export * from './algorithms/crypto-algorithm.js';
|
|
7
8
|
export * from './algorithms/ecdsa.js';
|
|
8
9
|
export * from './algorithms/eddsa.js';
|
|
10
|
+
export * from './algorithms/hkdf.js';
|
|
11
|
+
export * from './algorithms/pbkdf2.js';
|
|
9
12
|
export * from './algorithms/sha-2.js';
|
|
13
|
+
export * from './algorithms/x25519.js';
|
|
10
14
|
export * from './jose/jwe.js';
|
|
11
15
|
export * from './jose/jwk.js';
|
|
12
16
|
export * from './jose/jws.js';
|
|
@@ -16,6 +20,7 @@ export * from './primitives/aes-ctr.js';
|
|
|
16
20
|
export * from './primitives/aes-gcm.js';
|
|
17
21
|
export * from './primitives/aes-kw.js';
|
|
18
22
|
export * from './primitives/concat-kdf.js';
|
|
23
|
+
export * from './primitives/ecies-secp256k1.js';
|
|
19
24
|
export * from './primitives/ed25519.js';
|
|
20
25
|
export * from './primitives/hkdf.js';
|
|
21
26
|
export * from './primitives/secp256r1.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAE3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAE3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AAEnD,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,2BAA2B,CAAC;AAC/C,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,wBAAwB,CAAC;AAC5C,mBAAmB,0BAA0B,CAAC;AAC9C,mBAAmB,4BAA4B,CAAC;AAChD,mBAAmB,uBAAuB,CAAC;AAC3C,mBAAmB,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { KeyValueStore } from '@enbox/common';
|
|
2
|
-
import type { CryptoApi } from './types/crypto-api.js';
|
|
3
2
|
import type { Jwk } from './jose/jwk.js';
|
|
4
3
|
import type { KeyIdentifier } from './types/identifier.js';
|
|
5
4
|
import type { KeyImporterExporter } from './types/key-io.js';
|
|
5
|
+
import type { KeyManager } from './types/crypto-api.js';
|
|
6
6
|
import type { KmsDigestParams, KmsExportKeyParams, KmsGenerateKeyParams, KmsGetKeyUriParams, KmsGetPublicKeyParams, KmsImportKeyParams, KmsSignParams, KmsVerifyParams } from './types/params-kms.js';
|
|
7
7
|
/**
|
|
8
8
|
* The `LocalKeyManagerParams` interface specifies the parameters for initializing an instance of
|
|
@@ -42,9 +42,9 @@ export interface LocalKeyManagerGenerateKeyParams extends KmsGenerateKeyParams {
|
|
|
42
42
|
* - `"Ed25519"`
|
|
43
43
|
* - `"secp256k1"`
|
|
44
44
|
*/
|
|
45
|
-
algorithm: 'Ed25519' | 'secp256k1' | 'secp256r1';
|
|
45
|
+
algorithm: 'Ed25519' | 'secp256k1' | 'secp256r1' | 'X25519';
|
|
46
46
|
}
|
|
47
|
-
export declare class LocalKeyManager implements
|
|
47
|
+
export declare class LocalKeyManager implements KeyManager, KeyImporterExporter<KmsImportKeyParams, KeyIdentifier, KmsExportKeyParams> {
|
|
48
48
|
/**
|
|
49
49
|
* A private map that stores instances of cryptographic algorithm implementations. Each key in
|
|
50
50
|
* this map is an `AlgorithmConstructor`, and its corresponding value is an instance of a class
|
|
@@ -131,7 +131,7 @@ export declare class LocalKeyManager implements CryptoApi, KeyImporterExporter<K
|
|
|
131
131
|
* @remarks
|
|
132
132
|
* This method generates a {@link https://datatracker.ietf.org/doc/html/rfc3986 | URI}
|
|
133
133
|
* (Uniform Resource Identifier) for the given JWK, which uniquely identifies the key across all
|
|
134
|
-
* `
|
|
134
|
+
* `KeyManager` implementations. The key URI is constructed by appending the
|
|
135
135
|
* {@link https://datatracker.ietf.org/doc/html/rfc7638 | JWK thumbprint} to the prefix
|
|
136
136
|
* `urn:jwk:`. The JWK thumbprint is deterministically computed from the JWK and is consistent
|
|
137
137
|
* regardless of property order or optional property inclusion in the JWK. This ensures that the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-key-manager.d.ts","sourceRoot":"","sources":["../../src/local-key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"local-key-manager.d.ts","sourceRoot":"","sources":["../../src/local-key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA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/B,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAOf;;;;;;;;;;;;;;;OAeG;IACU,WAAW,CAAC,EAAE,SAAS,EAAE,EACpC,gCAAgC,GAC/B,OAAO,CAAC,aAAa,CAAC;IAoBzB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACU,SAAS,CAAC,EAAE,GAAG,EAAE,EAC5B,kBAAkB,GACjB,OAAO,CAAC,aAAa,CAAC;IAUzB;;;;;;;;;;;;;;;OAeG;IACU,YAAY,CAAC,EAAE,MAAM,EAAE,EAClC,qBAAqB,GACpB,OAAO,CAAC,GAAG,CAAC;IAgBf;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,SAAS,CAAC,EAAE,GAAG,EAAE,EAC5B,kBAAkB,GACjB,OAAO,CAAC,aAAa,CAAC;IAkBzB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAChC,aAAa,GACZ,OAAO,CAAC,UAAU,CAAC;IAgBtB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACU,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAC1C,eAAe,GACd,OAAO,CAAC,OAAO,CAAC;IAanB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,YAAY;IAmBpB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;;;;;;;;;;;;OAcG;YACW,aAAa;CAY5B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output of an ECIES-SECP256K1 encryption operation.
|
|
3
|
+
*/
|
|
4
|
+
export type EciesSecp256k1EncryptionOutput = {
|
|
5
|
+
/** The AES-GCM initialization vector. */
|
|
6
|
+
initializationVector: Uint8Array;
|
|
7
|
+
/** The ephemeral secp256k1 public key (compressed, 33 bytes). */
|
|
8
|
+
ephemeralPublicKey: Uint8Array;
|
|
9
|
+
/** The encrypted data. */
|
|
10
|
+
ciphertext: Uint8Array;
|
|
11
|
+
/** The AES-GCM authentication tag (16 bytes). */
|
|
12
|
+
messageAuthenticationCode: Uint8Array;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Input required for ECIES-SECP256K1 decryption.
|
|
16
|
+
*/
|
|
17
|
+
export type EciesSecp256k1EncryptionInput = EciesSecp256k1EncryptionOutput & {
|
|
18
|
+
/** The recipient's secp256k1 private key (raw 32 bytes). */
|
|
19
|
+
privateKey: Uint8Array;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Browser-compatible ECIES (Elliptic Curve Integrated Encryption Scheme) using secp256k1.
|
|
23
|
+
*
|
|
24
|
+
* Wire-format compatible with `eciesjs` v0.4.x configured with
|
|
25
|
+
* `isEphemeralKeyCompressed: true, isHkdfKeyCompressed: false` (the default).
|
|
26
|
+
*
|
|
27
|
+
* Protocol:
|
|
28
|
+
* 1. Generate an ephemeral secp256k1 key pair.
|
|
29
|
+
* 2. ECDH shared secret (uncompressed point).
|
|
30
|
+
* 3. HKDF-SHA-256 key derivation: `hkdf(sha256, ephemeralPubUncompressed || sharedPointUncompressed)`.
|
|
31
|
+
* 4. AES-256-GCM encryption with random 16-byte nonce.
|
|
32
|
+
*
|
|
33
|
+
* All underlying primitives (`@noble/ciphers`, `@noble/curves`, `@noble/hashes`)
|
|
34
|
+
* are pure JavaScript and work in Node, Bun, and browsers.
|
|
35
|
+
*/
|
|
36
|
+
export declare class EciesSecp256k1 {
|
|
37
|
+
/**
|
|
38
|
+
* Encrypt plaintext for a given secp256k1 public key.
|
|
39
|
+
* @param publicKeyBytes - Recipient's public key (compressed 33 bytes or uncompressed 65 bytes).
|
|
40
|
+
* @param plaintext - The data to encrypt.
|
|
41
|
+
*/
|
|
42
|
+
static encrypt(publicKeyBytes: Uint8Array, plaintext: Uint8Array): EciesSecp256k1EncryptionOutput;
|
|
43
|
+
/**
|
|
44
|
+
* Decrypt ciphertext produced by {@link EciesSecp256k1.encrypt}.
|
|
45
|
+
* @param input - The encryption output plus the recipient's private key.
|
|
46
|
+
*/
|
|
47
|
+
static decrypt(input: EciesSecp256k1EncryptionInput): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the ephemeral public key is compressed (always true for this implementation).
|
|
50
|
+
*/
|
|
51
|
+
static get isEphemeralKeyCompressed(): boolean;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ecies-secp256k1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecies-secp256k1.d.ts","sourceRoot":"","sources":["../../../src/primitives/ecies-secp256k1.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,yCAAyC;IACzC,oBAAoB,EAAE,UAAU,CAAC;IACjC,iEAAiE;IACjE,kBAAkB,EAAE,UAAU,CAAC;IAC/B,0BAA0B;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,iDAAiD;IACjD,yBAAyB,EAAE,UAAU,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,8BAA8B,GAAG;IAC3E,4DAA4D;IAC5D,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IACzB;;;;OAIG;WACW,OAAO,CAAC,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,8BAA8B;IAyBxG;;;OAGG;WACW,OAAO,CAAC,KAAK,EAAE,6BAA6B,GAAG,UAAU;IAiBvE;;OAEG;IACH,WAAkB,wBAAwB,IAAI,OAAO,CAEpD;CACF"}
|
|
@@ -238,32 +238,25 @@ export declare class X25519 {
|
|
|
238
238
|
publicKey: Jwk;
|
|
239
239
|
}): Promise<Uint8Array>;
|
|
240
240
|
/**
|
|
241
|
-
* Computes an
|
|
242
|
-
* using
|
|
241
|
+
* Computes an X25519 Elliptic Curve Diffie-Hellman (ECDH) shared secret
|
|
242
|
+
* using X25519 private and public keys in JSON Web Key (JWK) format.
|
|
243
243
|
*
|
|
244
244
|
* @remarks
|
|
245
245
|
* This method facilitates the ECDH key agreement protocol, which is a method of securely
|
|
246
246
|
* deriving a shared secret between two parties based on their private and public keys.
|
|
247
247
|
* It takes the private key of one party (privateKeyA) and the public key of another
|
|
248
|
-
* party (publicKeyB) to compute a shared secret. The shared secret is
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* consists of an x-coordinate and a y-coordinate. With a 256-bit curve like
|
|
255
|
-
* secp256k1, each of these coordinates is 32 bytes (256 bits) long. However,
|
|
256
|
-
* in the ECDH process, it's standard practice to use only the x-coordinate
|
|
257
|
-
* of the shared secret point as the resulting shared key. This is because
|
|
258
|
-
* the y-coordinate does not add to the entropy of the key, and both parties
|
|
259
|
-
* can independently compute the x-coordinate. Consquently, this implementation
|
|
260
|
-
* omits the y-coordinate for simplicity and standard compliance.
|
|
248
|
+
* party (publicKeyB) to compute a shared secret. The shared secret is the raw output
|
|
249
|
+
* of the X25519 function as defined in RFC 7748.
|
|
250
|
+
*
|
|
251
|
+
* Note: Unlike Weierstrass curves (e.g., secp256k1), X25519 is a Montgomery curve
|
|
252
|
+
* where the ECDH output is a single 32-byte scalar value, not an (x, y) point.
|
|
253
|
+
* The result is used directly as the shared secret.
|
|
261
254
|
*
|
|
262
255
|
* @example
|
|
263
256
|
* ```ts
|
|
264
257
|
* const privateKeyA = { ... }; // A Jwk object for party A
|
|
265
258
|
* const publicKeyB = { ... }; // A PublicKeyJwk object for party B
|
|
266
|
-
* const sharedSecret = await
|
|
259
|
+
* const sharedSecret = await X25519.sharedSecret({
|
|
267
260
|
* privateKeyA,
|
|
268
261
|
* publicKeyB
|
|
269
262
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x25519.d.ts","sourceRoot":"","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;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,YAAY,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;QAC5D,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,GAAG,CAAC;KACjB,GAAG,OAAO,CAAC,UAAU,CAAC;CAexB"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { AsymmetricKeyConverter } from './key-converter.js';
|
|
1
2
|
import type { AsymmetricKeyGenerator } from './key-generator.js';
|
|
3
|
+
import type { Cipher } from './cipher.js';
|
|
2
4
|
import type { Hasher } from './hasher.js';
|
|
5
|
+
import type { Jwk } from '../jose/jwk.js';
|
|
3
6
|
import type { KeyIdentifier } from './identifier.js';
|
|
7
|
+
import type { KeyWrapper } from './key-wrapper.js';
|
|
4
8
|
import type { Signer } from './signer.js';
|
|
5
|
-
import type {
|
|
9
|
+
import type { BytesToPrivateKeyParams, BytesToPublicKeyParams, CipherParams, DeriveKeyBytesParams, DeriveKeyFromBytesParams, DigestParams, GenerateKeyParams, GetPublicKeyParams, PrivateKeyToBytesParams, PublicKeyToBytesParams, SignParams, UnwrapKeyParams, VerifyParams, WrapKeyParams } from './params-direct.js';
|
|
10
|
+
import type { KeyBytesDeriver, SimpleKeyDeriver } from './key-deriver.js';
|
|
11
|
+
import type { KmsCipherParams, KmsDigestParams, KmsGenerateKeyParams, KmsGetKeyUriParams, KmsGetPublicKeyParams, KmsSignParams, KmsVerifyParams } from './params-kms.js';
|
|
6
12
|
/**
|
|
7
|
-
* The `
|
|
13
|
+
* The `DsaApi` interface integrates key generation, hashing, and signing functionalities,
|
|
8
14
|
* designed for use with a Key Management System (KMS). It extends `AsymmetricKeyGenerator` for
|
|
9
15
|
* generating asymmetric keys, `Hasher` for hash digest computations, and `Signer` for signing and
|
|
10
16
|
* verifying operations.
|
|
@@ -24,12 +30,54 @@ import type { KmsDigestParams, KmsGenerateKeyParams, KmsGetKeyUriParams, KmsGetP
|
|
|
24
30
|
* identifier (e.g. JWK thumbprint, UUID generated by hosted KMS, etc.).
|
|
25
31
|
* - Must support key generation, hashing, signing, and verifying operations.
|
|
26
32
|
* - May be extended to support other cryptographic operations.
|
|
27
|
-
* - Implementations of the `
|
|
33
|
+
* - Implementations of the `DsaApi` interface can be passed as an argument to the public API
|
|
28
34
|
* methods of Web5 libraries that involve key material (e.g., DID creation, VC signing, arbitrary
|
|
29
35
|
* data signing/verification, etc.).
|
|
30
36
|
*/
|
|
31
|
-
export interface
|
|
37
|
+
export interface DsaApi<GenerateKeyInput = KmsGenerateKeyParams, GenerateKeyOutput = KeyIdentifier, GetPublicKeyInput = KmsGetPublicKeyParams, DigestInput = KmsDigestParams, SignInput = KmsSignParams, VerifyInput = KmsVerifyParams> extends AsymmetricKeyGenerator<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput>, Hasher<DigestInput>, Signer<SignInput, VerifyInput> {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The `CryptoApi` interface extends {@link DsaApi} with encryption, key conversion,
|
|
41
|
+
* key derivation, and key wrapping capabilities.
|
|
42
|
+
*
|
|
43
|
+
* This is the full-featured cryptographic API used by agent-level code that needs direct-key
|
|
44
|
+
* cipher, key conversion, and key derivation operations beyond what the base `DsaApi` provides.
|
|
45
|
+
*/
|
|
46
|
+
export interface CryptoApi<GenerateKeyInput = GenerateKeyParams, GenerateKeyOutput = Jwk, GetPublicKeyInput = GetPublicKeyParams, DigestInput = DigestParams, SignInput = SignParams, VerifyInput = VerifyParams, EncryptInput = CipherParams, DecryptInput = CipherParams, BytesToPublicKeyInput = BytesToPublicKeyParams, PublicKeyToBytesInput = PublicKeyToBytesParams, BytesToPrivateKeyInput = BytesToPrivateKeyParams, PrivateKeyToBytesInput = PrivateKeyToBytesParams, DeriveKeyInput = DeriveKeyFromBytesParams, DeriveKeyOutput = Jwk, DeriveKeyBytesInput = DeriveKeyBytesParams, DeriveKeyBytesOutput = Uint8Array, WrapKeyInput = WrapKeyParams, UnwrapKeyInput = UnwrapKeyParams> extends DsaApi<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput, DigestInput, SignInput, VerifyInput>, Cipher<EncryptInput, DecryptInput>, AsymmetricKeyConverter<BytesToPublicKeyInput, PublicKeyToBytesInput, BytesToPrivateKeyInput, PrivateKeyToBytesInput>, SimpleKeyDeriver<DeriveKeyInput, DeriveKeyOutput>, KeyBytesDeriver<DeriveKeyBytesInput, DeriveKeyBytesOutput>, KeyWrapper<WrapKeyInput, UnwrapKeyInput> {
|
|
47
|
+
}
|
|
48
|
+
/** @deprecated Use {@link CryptoApi} instead. */
|
|
49
|
+
export type ExtendedCryptoApi<GenerateKeyInput = GenerateKeyParams, GenerateKeyOutput = Jwk, GetPublicKeyInput = GetPublicKeyParams, DigestInput = DigestParams, SignInput = SignParams, VerifyInput = VerifyParams, EncryptInput = CipherParams, DecryptInput = CipherParams, BytesToPublicKeyInput = BytesToPublicKeyParams, PublicKeyToBytesInput = PublicKeyToBytesParams, BytesToPrivateKeyInput = BytesToPrivateKeyParams, PrivateKeyToBytesInput = PrivateKeyToBytesParams, DeriveKeyInput = DeriveKeyFromBytesParams, DeriveKeyOutput = Jwk, DeriveKeyBytesInput = DeriveKeyBytesParams, DeriveKeyBytesOutput = Uint8Array, WrapKeyInput = WrapKeyParams, UnwrapKeyInput = UnwrapKeyParams> = CryptoApi<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput, DigestInput, SignInput, VerifyInput, EncryptInput, DecryptInput, BytesToPublicKeyInput, PublicKeyToBytesInput, BytesToPrivateKeyInput, PrivateKeyToBytesInput, DeriveKeyInput, DeriveKeyOutput, DeriveKeyBytesInput, DeriveKeyBytesOutput, WrapKeyInput, UnwrapKeyInput>;
|
|
50
|
+
/**
|
|
51
|
+
* Parameters for configuring a {@link KeyManager} implementation.
|
|
52
|
+
*/
|
|
53
|
+
export interface KeyManagerParams {
|
|
54
|
+
CipherInput?: unknown;
|
|
55
|
+
GenerateKeyInput?: unknown;
|
|
56
|
+
GenerateKeyOutput?: unknown;
|
|
57
|
+
GetPublicKeyInput?: unknown;
|
|
58
|
+
SignInput?: unknown;
|
|
59
|
+
VerifyInput?: unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Default parameter types for {@link KeyManager}, using KMS-oriented types.
|
|
63
|
+
*/
|
|
64
|
+
export interface DefaultKeyManagerParams {
|
|
65
|
+
CipherInput: KmsCipherParams;
|
|
66
|
+
GenerateKeyInput: KmsGenerateKeyParams;
|
|
67
|
+
GenerateKeyOutput: KeyIdentifier;
|
|
68
|
+
GetPublicKeyInput: KmsGetPublicKeyParams;
|
|
69
|
+
SignInput: KmsSignParams;
|
|
70
|
+
VerifyInput: KmsVerifyParams;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The `KeyManager` interface integrates key generation and signing capabilities.
|
|
74
|
+
*
|
|
75
|
+
* Concrete implementations of this interface are intended to be used as a Key Management System
|
|
76
|
+
* (KMS), which is responsible for generating and storing cryptographic keys.
|
|
77
|
+
*/
|
|
78
|
+
export interface KeyManager<T extends KeyManagerParams = DefaultKeyManagerParams> extends DsaApi<T['GenerateKeyInput'], T['GenerateKeyOutput'], T['GetPublicKeyInput'], KmsDigestParams, T['SignInput'], T['VerifyInput']> {
|
|
32
79
|
/**
|
|
80
|
+
* Returns the Key URI for a given JWK.
|
|
33
81
|
*
|
|
34
82
|
* @param params - The parameters for getting the key URI.
|
|
35
83
|
* @param params.key - The key to get the URI for.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-api.d.ts","sourceRoot":"","sources":["../../../src/types/crypto-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE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