@reallyme/crypto 0.3.9 → 0.3.11
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/README.md +10 -11
- package/dist/aead.js +1 -1
- package/dist/aesKw.js +1 -1
- package/dist/algorithms.js +1 -1
- package/dist/argon2id.js +1 -1
- package/dist/bip340Schnorr.js +1 -1
- package/dist/cryptoFacade.d.ts +60 -81
- package/dist/cryptoFacade.js +12 -408
- package/dist/cryptoFacadeAsymmetric.d.ts +20 -0
- package/dist/cryptoFacadeAsymmetric.js +252 -0
- package/dist/cryptoFacadeSymmetric.d.ts +27 -0
- package/dist/cryptoFacadeSymmetric.js +166 -0
- package/dist/digest.js +1 -1
- package/dist/ed25519.d.ts +2 -0
- package/dist/ed25519.js +45 -4
- package/dist/encodeEcdsaDer.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/hkdf.js +1 -1
- package/dist/hmac.d.ts +3 -3
- package/dist/hmac.js +8 -5
- package/dist/hpke.d.ts +1 -1
- package/dist/hpke.js +4 -2
- package/dist/index.js +1 -1
- package/dist/jwaConcatKdf.js +1 -1
- package/dist/jwk.js +46 -11
- package/dist/kmac.js +1 -1
- package/dist/memory.js +1 -1
- package/dist/mlDsa.js +1 -1
- package/dist/mlKem.js +1 -1
- package/dist/operationResponse.js +1 -1
- package/dist/p256Ecdh.js +1 -1
- package/dist/p256Ecdsa.js +1 -1
- package/dist/p384Ecdh.js +1 -1
- package/dist/p384Ecdsa.js +1 -1
- package/dist/p521Ecdh.js +1 -1
- package/dist/p521Ecdsa.js +1 -1
- package/dist/pbkdf2.js +12 -4
- package/dist/proto/generated/reallyme/crypto/v1/crypto_pb.js +1 -1
- package/dist/proto.d.ts +8 -117
- package/dist/proto.js +6 -1085
- package/dist/protoAlgorithms.d.ts +21 -0
- package/dist/protoAlgorithms.js +323 -0
- package/dist/protoErrors.d.ts +27 -0
- package/dist/protoErrors.js +275 -0
- package/dist/protoIdentifiers.d.ts +14 -0
- package/dist/protoIdentifiers.js +112 -0
- package/dist/protoJwk.d.ts +10 -0
- package/dist/protoJwk.js +204 -0
- package/dist/protoValues.d.ts +63 -0
- package/dist/protoValues.js +228 -0
- package/dist/providerCatalog.js +1 -1
- package/dist/rsa.js +1 -1
- package/dist/secp256k1.js +1 -1
- package/dist/slhDsa.js +1 -1
- package/dist/validateBytes.js +1 -1
- package/dist/verifyBundledWasmModule.d.ts +63 -0
- package/dist/verifyBundledWasmModule.js +80 -0
- package/dist/wasm/reallyme_crypto_wasm.d.ts +383 -0
- package/dist/wasm/reallyme_crypto_wasm.js +8 -8
- package/dist/wasm/reallyme_crypto_wasm_bg.wasm +0 -0
- package/dist/wasmModuleTypes.js +1 -1
- package/dist/wasmProvider.d.ts +5 -0
- package/dist/wasmProvider.js +61 -3
- package/dist/x25519.js +1 -1
- package/dist/xWing.js +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 ReallyMe LLC
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
4
|
+
import { create } from "@bufbuild/protobuf";
|
|
5
|
+
import { ReallyMeCryptoError } from "./errors.js";
|
|
6
|
+
import { hpkeSuiteFromProto, hpkeSuiteToProto, kemAlgorithmFromProto, kemAlgorithmToProto, keyAgreementAlgorithmFromProto, keyAgreementAlgorithmToProto, signatureAlgorithmFromProto, signatureAlgorithmToProto, } from "./protoAlgorithms.js";
|
|
7
|
+
import { CryptoAlgorithmIdentifierSchema, MulticodecKeyAlgorithm, } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
|
|
8
|
+
export const signatureAlgorithmIdentifierToProto = (value) => create(CryptoAlgorithmIdentifierSchema, {
|
|
9
|
+
algorithm: { case: "signature", value: signatureAlgorithmToProto(value) },
|
|
10
|
+
});
|
|
11
|
+
export const keyAgreementAlgorithmIdentifierToProto = (value) => create(CryptoAlgorithmIdentifierSchema, {
|
|
12
|
+
algorithm: { case: "keyAgreement", value: keyAgreementAlgorithmToProto(value) },
|
|
13
|
+
});
|
|
14
|
+
export const kemAlgorithmIdentifierToProto = (value) => create(CryptoAlgorithmIdentifierSchema, {
|
|
15
|
+
algorithm: { case: "kem", value: kemAlgorithmToProto(value) },
|
|
16
|
+
});
|
|
17
|
+
export const hpkeSuiteIdentifierToProto = (value) => create(CryptoAlgorithmIdentifierSchema, {
|
|
18
|
+
algorithm: { case: "hpkeSuite", value: hpkeSuiteToProto(value) },
|
|
19
|
+
});
|
|
20
|
+
export const signatureAlgorithmFromIdentifier = (value) => {
|
|
21
|
+
if (value?.algorithm.case !== "signature") {
|
|
22
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
23
|
+
}
|
|
24
|
+
return signatureAlgorithmFromProto(value.algorithm.value);
|
|
25
|
+
};
|
|
26
|
+
export const keyAgreementAlgorithmFromIdentifier = (value) => {
|
|
27
|
+
if (value?.algorithm.case !== "keyAgreement") {
|
|
28
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
29
|
+
}
|
|
30
|
+
return keyAgreementAlgorithmFromProto(value.algorithm.value);
|
|
31
|
+
};
|
|
32
|
+
export const kemAlgorithmFromIdentifier = (value) => {
|
|
33
|
+
if (value?.algorithm.case !== "kem") {
|
|
34
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
35
|
+
}
|
|
36
|
+
return kemAlgorithmFromProto(value.algorithm.value);
|
|
37
|
+
};
|
|
38
|
+
export const hpkeSuiteFromIdentifier = (value) => {
|
|
39
|
+
if (value?.algorithm.case !== "hpkeSuite") {
|
|
40
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
41
|
+
}
|
|
42
|
+
return hpkeSuiteFromProto(value.algorithm.value);
|
|
43
|
+
};
|
|
44
|
+
export const multicodecKeyAlgorithmFromProto = (value) => {
|
|
45
|
+
switch (value) {
|
|
46
|
+
case MulticodecKeyAlgorithm.ED25519_PUB:
|
|
47
|
+
return "ed25519-pub";
|
|
48
|
+
case MulticodecKeyAlgorithm.X25519_PUB:
|
|
49
|
+
return "x25519-pub";
|
|
50
|
+
case MulticodecKeyAlgorithm.SECP256K1_PUB:
|
|
51
|
+
return "secp256k1-pub";
|
|
52
|
+
case MulticodecKeyAlgorithm.P256_PUB:
|
|
53
|
+
return "p256-pub";
|
|
54
|
+
case MulticodecKeyAlgorithm.P384_PUB:
|
|
55
|
+
return "p384-pub";
|
|
56
|
+
case MulticodecKeyAlgorithm.P521_PUB:
|
|
57
|
+
return "p521-pub";
|
|
58
|
+
case MulticodecKeyAlgorithm.ED448_PUB:
|
|
59
|
+
return "ed448-pub";
|
|
60
|
+
case MulticodecKeyAlgorithm.RSA_PUB:
|
|
61
|
+
return "rsa-pub";
|
|
62
|
+
case MulticodecKeyAlgorithm.ML_KEM_512_PUB:
|
|
63
|
+
return "mlkem-512-pub";
|
|
64
|
+
case MulticodecKeyAlgorithm.ML_KEM_768_PUB:
|
|
65
|
+
return "mlkem-768-pub";
|
|
66
|
+
case MulticodecKeyAlgorithm.ML_KEM_1024_PUB:
|
|
67
|
+
return "mlkem-1024-pub";
|
|
68
|
+
case MulticodecKeyAlgorithm.ML_DSA_44_PUB:
|
|
69
|
+
return "mldsa-44-pub";
|
|
70
|
+
case MulticodecKeyAlgorithm.ML_DSA_65_PUB:
|
|
71
|
+
return "mldsa-65-pub";
|
|
72
|
+
case MulticodecKeyAlgorithm.ML_DSA_87_PUB:
|
|
73
|
+
return "mldsa-87-pub";
|
|
74
|
+
default:
|
|
75
|
+
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const multicodecKeyAlgorithmToProto = (value) => {
|
|
79
|
+
switch (value) {
|
|
80
|
+
case "ed25519-pub":
|
|
81
|
+
return MulticodecKeyAlgorithm.ED25519_PUB;
|
|
82
|
+
case "x25519-pub":
|
|
83
|
+
return MulticodecKeyAlgorithm.X25519_PUB;
|
|
84
|
+
case "secp256k1-pub":
|
|
85
|
+
return MulticodecKeyAlgorithm.SECP256K1_PUB;
|
|
86
|
+
case "p256-pub":
|
|
87
|
+
return MulticodecKeyAlgorithm.P256_PUB;
|
|
88
|
+
case "p384-pub":
|
|
89
|
+
return MulticodecKeyAlgorithm.P384_PUB;
|
|
90
|
+
case "p521-pub":
|
|
91
|
+
return MulticodecKeyAlgorithm.P521_PUB;
|
|
92
|
+
case "ed448-pub":
|
|
93
|
+
return MulticodecKeyAlgorithm.ED448_PUB;
|
|
94
|
+
case "rsa-pub":
|
|
95
|
+
return MulticodecKeyAlgorithm.RSA_PUB;
|
|
96
|
+
case "mlkem-512-pub":
|
|
97
|
+
return MulticodecKeyAlgorithm.ML_KEM_512_PUB;
|
|
98
|
+
case "mlkem-768-pub":
|
|
99
|
+
return MulticodecKeyAlgorithm.ML_KEM_768_PUB;
|
|
100
|
+
case "mlkem-1024-pub":
|
|
101
|
+
return MulticodecKeyAlgorithm.ML_KEM_1024_PUB;
|
|
102
|
+
case "mldsa-44-pub":
|
|
103
|
+
return MulticodecKeyAlgorithm.ML_DSA_44_PUB;
|
|
104
|
+
case "mldsa-65-pub":
|
|
105
|
+
return MulticodecKeyAlgorithm.ML_DSA_65_PUB;
|
|
106
|
+
case "mldsa-87-pub":
|
|
107
|
+
return MulticodecKeyAlgorithm.ML_DSA_87_PUB;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
// The largest supported canonical JWK is below 4 KiB. Keeping a full factor of
|
|
111
|
+
// two for future public-key encodings prevents attacker-controlled allocations
|
|
112
|
+
// and guarantees conversion never depends on an engine's argument-count limit.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReallyMeJwkKey, ReallyMeJwksKeySet } from "./jwk.js";
|
|
2
|
+
import type { JsonWebKey, JsonWebKeySet } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
|
|
3
|
+
export declare const jsonWebKeyToProto: (key: ReallyMeJwkKey) => JsonWebKey;
|
|
4
|
+
export declare const jsonWebKeyToProtoBytes: (key: ReallyMeJwkKey) => Uint8Array;
|
|
5
|
+
export declare const jsonWebKeyFromProto: (value: JsonWebKey) => ReallyMeJwkKey;
|
|
6
|
+
export declare const jsonWebKeyFromProtoBytes: (bytes: Uint8Array) => ReallyMeJwkKey;
|
|
7
|
+
export declare const jsonWebKeySetToProto: (keySet: ReallyMeJwksKeySet) => JsonWebKeySet;
|
|
8
|
+
export declare const jsonWebKeySetToProtoBytes: (keySet: ReallyMeJwksKeySet) => Uint8Array;
|
|
9
|
+
export declare const jsonWebKeySetFromProto: (value: JsonWebKeySet) => ReallyMeJwksKeySet;
|
|
10
|
+
export declare const jsonWebKeySetFromProtoBytes: (bytes: Uint8Array) => ReallyMeJwksKeySet;
|
package/dist/protoJwk.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 ReallyMe LLC
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
4
|
+
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
5
|
+
import { ReallyMeCryptoError } from "./errors.js";
|
|
6
|
+
import { MAX_JWKS_KEYS, ReallyMeJwk } from "./jwk.js";
|
|
7
|
+
import { ensureByteArrayAtMost, MAX_CRYPTO_INPUT_LENGTH, } from "./validateBytes.js";
|
|
8
|
+
import { CryptoAlgorithmIdentifierSchema, JsonWebKeySchema, JsonWebKeySetSchema, KemAlgorithm, KeyAgreementAlgorithm, SignatureAlgorithm, } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
|
|
9
|
+
const MAX_JWK_CANONICAL_JCS_LENGTH = 8_192;
|
|
10
|
+
const asciiToBytes = (value) => {
|
|
11
|
+
if (value.length > MAX_JWK_CANONICAL_JCS_LENGTH) {
|
|
12
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
13
|
+
}
|
|
14
|
+
const bytes = new Uint8Array(value.length);
|
|
15
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
16
|
+
const codeUnit = value.charCodeAt(index);
|
|
17
|
+
if (codeUnit > 0x7f) {
|
|
18
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
19
|
+
}
|
|
20
|
+
bytes[index] = codeUnit;
|
|
21
|
+
}
|
|
22
|
+
return bytes;
|
|
23
|
+
};
|
|
24
|
+
const asciiFromBytes = (value) => {
|
|
25
|
+
ensureByteArrayAtMost(value, MAX_JWK_CANONICAL_JCS_LENGTH);
|
|
26
|
+
const characters = [];
|
|
27
|
+
for (const byte of value) {
|
|
28
|
+
if (byte > 0x7f) {
|
|
29
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
30
|
+
}
|
|
31
|
+
characters.push(String.fromCharCode(byte));
|
|
32
|
+
}
|
|
33
|
+
return characters.join("");
|
|
34
|
+
};
|
|
35
|
+
const withJwkProtoBoundaryErrors = (operation) => {
|
|
36
|
+
try {
|
|
37
|
+
return operation();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const signatureJwkAlgorithmToProto = (value) => {
|
|
47
|
+
switch (value) {
|
|
48
|
+
case "Ed25519":
|
|
49
|
+
return SignatureAlgorithm.ED25519;
|
|
50
|
+
case "P-256":
|
|
51
|
+
return SignatureAlgorithm.ECDSA_P256_SHA256;
|
|
52
|
+
case "secp256k1":
|
|
53
|
+
return SignatureAlgorithm.ECDSA_SECP256K1_SHA256;
|
|
54
|
+
case "ML-DSA-44":
|
|
55
|
+
return SignatureAlgorithm.ML_DSA_44;
|
|
56
|
+
case "ML-DSA-65":
|
|
57
|
+
return SignatureAlgorithm.ML_DSA_65;
|
|
58
|
+
case "ML-DSA-87":
|
|
59
|
+
return SignatureAlgorithm.ML_DSA_87;
|
|
60
|
+
case "SLH-DSA-SHA2-128s":
|
|
61
|
+
return SignatureAlgorithm.SLH_DSA_SHA2_128S;
|
|
62
|
+
default:
|
|
63
|
+
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const jwkAlgorithmToProto = (value) => {
|
|
67
|
+
switch (value) {
|
|
68
|
+
case "X25519":
|
|
69
|
+
return create(CryptoAlgorithmIdentifierSchema, {
|
|
70
|
+
algorithm: {
|
|
71
|
+
case: "keyAgreement",
|
|
72
|
+
value: KeyAgreementAlgorithm.X25519,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
case "ML-KEM-512":
|
|
76
|
+
return create(CryptoAlgorithmIdentifierSchema, {
|
|
77
|
+
algorithm: {
|
|
78
|
+
case: "kem",
|
|
79
|
+
value: KemAlgorithm.ML_KEM_512,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
case "ML-KEM-768":
|
|
83
|
+
return create(CryptoAlgorithmIdentifierSchema, {
|
|
84
|
+
algorithm: {
|
|
85
|
+
case: "kem",
|
|
86
|
+
value: KemAlgorithm.ML_KEM_768,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
case "ML-KEM-1024":
|
|
90
|
+
return create(CryptoAlgorithmIdentifierSchema, {
|
|
91
|
+
algorithm: {
|
|
92
|
+
case: "kem",
|
|
93
|
+
value: KemAlgorithm.ML_KEM_1024,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
case "X-Wing-768":
|
|
97
|
+
return create(CryptoAlgorithmIdentifierSchema, {
|
|
98
|
+
algorithm: {
|
|
99
|
+
case: "kem",
|
|
100
|
+
value: KemAlgorithm.X_WING_768,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
default:
|
|
104
|
+
return create(CryptoAlgorithmIdentifierSchema, {
|
|
105
|
+
algorithm: {
|
|
106
|
+
case: "signature",
|
|
107
|
+
value: signatureJwkAlgorithmToProto(value),
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const signatureJwkAlgorithmFromProto = (value) => {
|
|
113
|
+
switch (value) {
|
|
114
|
+
case SignatureAlgorithm.ED25519:
|
|
115
|
+
return "Ed25519";
|
|
116
|
+
case SignatureAlgorithm.ECDSA_P256_SHA256:
|
|
117
|
+
return "P-256";
|
|
118
|
+
case SignatureAlgorithm.ECDSA_SECP256K1_SHA256:
|
|
119
|
+
return "secp256k1";
|
|
120
|
+
case SignatureAlgorithm.ML_DSA_44:
|
|
121
|
+
return "ML-DSA-44";
|
|
122
|
+
case SignatureAlgorithm.ML_DSA_65:
|
|
123
|
+
return "ML-DSA-65";
|
|
124
|
+
case SignatureAlgorithm.ML_DSA_87:
|
|
125
|
+
return "ML-DSA-87";
|
|
126
|
+
case SignatureAlgorithm.SLH_DSA_SHA2_128S:
|
|
127
|
+
return "SLH-DSA-SHA2-128s";
|
|
128
|
+
default:
|
|
129
|
+
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const jwkAlgorithmFromProto = (value) => {
|
|
133
|
+
switch (value.algorithm.case) {
|
|
134
|
+
case "signature":
|
|
135
|
+
return signatureJwkAlgorithmFromProto(value.algorithm.value);
|
|
136
|
+
case "keyAgreement":
|
|
137
|
+
if (value.algorithm.value === KeyAgreementAlgorithm.X25519) {
|
|
138
|
+
return "X25519";
|
|
139
|
+
}
|
|
140
|
+
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
141
|
+
case "kem":
|
|
142
|
+
switch (value.algorithm.value) {
|
|
143
|
+
case KemAlgorithm.ML_KEM_512:
|
|
144
|
+
return "ML-KEM-512";
|
|
145
|
+
case KemAlgorithm.ML_KEM_768:
|
|
146
|
+
return "ML-KEM-768";
|
|
147
|
+
case KemAlgorithm.ML_KEM_1024:
|
|
148
|
+
return "ML-KEM-1024";
|
|
149
|
+
case KemAlgorithm.X_WING_768:
|
|
150
|
+
return "X-Wing-768";
|
|
151
|
+
default:
|
|
152
|
+
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
153
|
+
}
|
|
154
|
+
default:
|
|
155
|
+
throw new ReallyMeCryptoError("unsupported-algorithm");
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
export const jsonWebKeyToProto = (key) => create(JsonWebKeySchema, {
|
|
159
|
+
algorithm: jwkAlgorithmToProto(key.algorithm),
|
|
160
|
+
publicKey: key.publicKey,
|
|
161
|
+
canonicalJcs: asciiToBytes(ReallyMeJwk.toJcs(key.jwk)),
|
|
162
|
+
});
|
|
163
|
+
export const jsonWebKeyToProtoBytes = (key) => toBinary(JsonWebKeySchema, jsonWebKeyToProto(key));
|
|
164
|
+
export const jsonWebKeyFromProto = (value) => withJwkProtoBoundaryErrors(() => {
|
|
165
|
+
// Read each field once so a hostile message proxy cannot change values
|
|
166
|
+
// between validation and construction.
|
|
167
|
+
const algorithmValue = value.algorithm;
|
|
168
|
+
const publicKey = value.publicKey;
|
|
169
|
+
const canonicalJcs = value.canonicalJcs;
|
|
170
|
+
const algorithm = algorithmValue === undefined
|
|
171
|
+
? undefined
|
|
172
|
+
: jwkAlgorithmFromProto(algorithmValue);
|
|
173
|
+
if (algorithm === undefined) {
|
|
174
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
175
|
+
}
|
|
176
|
+
ensureByteArrayAtMost(publicKey, MAX_CRYPTO_INPUT_LENGTH);
|
|
177
|
+
const jwk = ReallyMeJwk.toJwk(algorithm, publicKey);
|
|
178
|
+
if (canonicalJcs.length > 0) {
|
|
179
|
+
const expected = ReallyMeJwk.toJcs(jwk);
|
|
180
|
+
if (asciiFromBytes(canonicalJcs) !== expected) {
|
|
181
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return { algorithm, publicKey, jwk };
|
|
185
|
+
});
|
|
186
|
+
export const jsonWebKeyFromProtoBytes = (bytes) => withJwkProtoBoundaryErrors(() => {
|
|
187
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
188
|
+
return jsonWebKeyFromProto(fromBinary(JsonWebKeySchema, bytes));
|
|
189
|
+
});
|
|
190
|
+
export const jsonWebKeySetToProto = (keySet) => create(JsonWebKeySetSchema, {
|
|
191
|
+
keys: keySet.keys.map((key) => jsonWebKeyToProto(key)),
|
|
192
|
+
});
|
|
193
|
+
export const jsonWebKeySetToProtoBytes = (keySet) => toBinary(JsonWebKeySetSchema, jsonWebKeySetToProto(keySet));
|
|
194
|
+
export const jsonWebKeySetFromProto = (value) => withJwkProtoBoundaryErrors(() => {
|
|
195
|
+
const keys = value.keys;
|
|
196
|
+
if (!Array.isArray(keys) || keys.length > MAX_JWKS_KEYS) {
|
|
197
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
198
|
+
}
|
|
199
|
+
return { keys: keys.map((key) => jsonWebKeyFromProto(key)) };
|
|
200
|
+
});
|
|
201
|
+
export const jsonWebKeySetFromProtoBytes = (bytes) => withJwkProtoBoundaryErrors(() => {
|
|
202
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
203
|
+
return jsonWebKeySetFromProto(fromBinary(JsonWebKeySetSchema, bytes));
|
|
204
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ReallyMeHpkeSuite, ReallyMeKemAlgorithm, ReallyMeKeyAgreementAlgorithm, ReallyMeSignatureAlgorithm } from "./algorithms.js";
|
|
2
|
+
import type { ReallyMeHpkeSealedMessage, ReallyMeKemEncapsulation, ReallyMeKemKeyPair, ReallyMeKeyAgreementKeyPair, ReallyMeSignatureKeyPair } from "./cryptoFacade.js";
|
|
3
|
+
import { ReallyMeCryptoError } from "./errors.js";
|
|
4
|
+
import { CryptoAlgorithmFamily } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
|
|
5
|
+
import type { CryptoAlgorithmIdentifier, CryptoHpkeSealedMessage, CryptoKemEncapsulation, CryptoKeyPair, CryptoProviderCapability, CryptoProviderCapabilitySet, CryptoVerificationResult } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
|
|
6
|
+
export type ReallyMeProviderSupportStatus = "partial" | "provider-aware" | "supported" | "unsupported";
|
|
7
|
+
export type ReallyMeProviderCapability = Readonly<{
|
|
8
|
+
algorithm: CryptoAlgorithmIdentifier;
|
|
9
|
+
family: CryptoAlgorithmFamily;
|
|
10
|
+
providerNames: ReadonlyArray<string>;
|
|
11
|
+
status: ReallyMeProviderSupportStatus;
|
|
12
|
+
usesRust: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
export type ReallyMeSignatureKeyPairProtoValue = Readonly<{
|
|
15
|
+
algorithm: ReallyMeSignatureAlgorithm;
|
|
16
|
+
keyPair: ReallyMeSignatureKeyPair;
|
|
17
|
+
}>;
|
|
18
|
+
export type ReallyMeKeyAgreementKeyPairProtoValue = Readonly<{
|
|
19
|
+
algorithm: ReallyMeKeyAgreementAlgorithm;
|
|
20
|
+
keyPair: ReallyMeKeyAgreementKeyPair;
|
|
21
|
+
}>;
|
|
22
|
+
export type ReallyMeKemKeyPairProtoValue = Readonly<{
|
|
23
|
+
algorithm: ReallyMeKemAlgorithm;
|
|
24
|
+
keyPair: ReallyMeKemKeyPair;
|
|
25
|
+
}>;
|
|
26
|
+
export type ReallyMeKemEncapsulationProtoValue = Readonly<{
|
|
27
|
+
algorithm: ReallyMeKemAlgorithm;
|
|
28
|
+
encapsulation: ReallyMeKemEncapsulation;
|
|
29
|
+
}>;
|
|
30
|
+
export type ReallyMeHpkeSealedMessageProtoValue = Readonly<{
|
|
31
|
+
sealedMessage: ReallyMeHpkeSealedMessage;
|
|
32
|
+
suite: ReallyMeHpkeSuite;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const signatureKeyPairToProto: (algorithm: ReallyMeSignatureAlgorithm, keyPair: ReallyMeSignatureKeyPair) => CryptoKeyPair;
|
|
35
|
+
export declare const signatureKeyPairToProtoBytes: (algorithm: ReallyMeSignatureAlgorithm, keyPair: ReallyMeSignatureKeyPair) => Uint8Array;
|
|
36
|
+
export declare const signatureKeyPairFromProto: (value: CryptoKeyPair) => ReallyMeSignatureKeyPairProtoValue;
|
|
37
|
+
export declare const signatureKeyPairFromProtoBytes: (bytes: Uint8Array) => ReallyMeSignatureKeyPairProtoValue;
|
|
38
|
+
export declare const keyAgreementKeyPairToProto: (algorithm: ReallyMeKeyAgreementAlgorithm, keyPair: ReallyMeKeyAgreementKeyPair) => CryptoKeyPair;
|
|
39
|
+
export declare const keyAgreementKeyPairToProtoBytes: (algorithm: ReallyMeKeyAgreementAlgorithm, keyPair: ReallyMeKeyAgreementKeyPair) => Uint8Array;
|
|
40
|
+
export declare const keyAgreementKeyPairFromProto: (value: CryptoKeyPair) => ReallyMeKeyAgreementKeyPairProtoValue;
|
|
41
|
+
export declare const keyAgreementKeyPairFromProtoBytes: (bytes: Uint8Array) => ReallyMeKeyAgreementKeyPairProtoValue;
|
|
42
|
+
export declare const kemKeyPairToProto: (algorithm: ReallyMeKemAlgorithm, keyPair: ReallyMeKemKeyPair) => CryptoKeyPair;
|
|
43
|
+
export declare const kemKeyPairToProtoBytes: (algorithm: ReallyMeKemAlgorithm, keyPair: ReallyMeKemKeyPair) => Uint8Array;
|
|
44
|
+
export declare const kemKeyPairFromProto: (value: CryptoKeyPair) => ReallyMeKemKeyPairProtoValue;
|
|
45
|
+
export declare const kemKeyPairFromProtoBytes: (bytes: Uint8Array) => ReallyMeKemKeyPairProtoValue;
|
|
46
|
+
export declare const kemEncapsulationToProto: (algorithm: ReallyMeKemAlgorithm, encapsulation: ReallyMeKemEncapsulation) => CryptoKemEncapsulation;
|
|
47
|
+
export declare const kemEncapsulationToProtoBytes: (algorithm: ReallyMeKemAlgorithm, encapsulation: ReallyMeKemEncapsulation) => Uint8Array;
|
|
48
|
+
export declare const kemEncapsulationFromProto: (value: CryptoKemEncapsulation) => ReallyMeKemEncapsulationProtoValue;
|
|
49
|
+
export declare const kemEncapsulationFromProtoBytes: (bytes: Uint8Array) => ReallyMeKemEncapsulationProtoValue;
|
|
50
|
+
export declare const hpkeSealedMessageToProto: (suite: ReallyMeHpkeSuite, sealedMessage: ReallyMeHpkeSealedMessage) => CryptoHpkeSealedMessage;
|
|
51
|
+
export declare const hpkeSealedMessageToProtoBytes: (suite: ReallyMeHpkeSuite, sealedMessage: ReallyMeHpkeSealedMessage) => Uint8Array;
|
|
52
|
+
export declare const hpkeSealedMessageFromProto: (value: CryptoHpkeSealedMessage) => ReallyMeHpkeSealedMessageProtoValue;
|
|
53
|
+
export declare const hpkeSealedMessageFromProtoBytes: (bytes: Uint8Array) => ReallyMeHpkeSealedMessageProtoValue;
|
|
54
|
+
export declare const verificationResultToProto: (algorithm: CryptoAlgorithmIdentifier, valid: boolean) => CryptoVerificationResult;
|
|
55
|
+
export declare const verificationErrorToProto: (algorithm: CryptoAlgorithmIdentifier, error: ReallyMeCryptoError) => CryptoVerificationResult;
|
|
56
|
+
export declare const verificationResultToProtoBytes: (value: CryptoVerificationResult) => Uint8Array;
|
|
57
|
+
export declare const verificationResultFromProtoBytes: (bytes: Uint8Array) => CryptoVerificationResult;
|
|
58
|
+
export declare const providerCapabilityToProto: (value: ReallyMeProviderCapability) => CryptoProviderCapability;
|
|
59
|
+
export declare const providerCapabilityFromProto: (value: CryptoProviderCapability) => ReallyMeProviderCapability;
|
|
60
|
+
export declare const providerCapabilitySetToProto: (values: ReadonlyArray<ReallyMeProviderCapability>) => CryptoProviderCapabilitySet;
|
|
61
|
+
export declare const providerCapabilitySetToProtoBytes: (values: ReadonlyArray<ReallyMeProviderCapability>) => Uint8Array;
|
|
62
|
+
export declare const providerCapabilitySetFromProto: (value: CryptoProviderCapabilitySet) => readonly ReallyMeProviderCapability[];
|
|
63
|
+
export declare const providerCapabilitySetFromProtoBytes: (bytes: Uint8Array) => readonly ReallyMeProviderCapability[];
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 ReallyMe LLC
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
4
|
+
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
|
|
5
|
+
import { ReallyMeCryptoError } from "./errors.js";
|
|
6
|
+
import { ensureByteArrayAtMost, MAX_CRYPTO_INPUT_LENGTH } from "./validateBytes.js";
|
|
7
|
+
import { cryptoErrorToProto } from "./protoErrors.js";
|
|
8
|
+
import { hpkeSuiteFromIdentifier, hpkeSuiteIdentifierToProto, kemAlgorithmFromIdentifier, kemAlgorithmIdentifierToProto, keyAgreementAlgorithmFromIdentifier, keyAgreementAlgorithmIdentifierToProto, signatureAlgorithmFromIdentifier, signatureAlgorithmIdentifierToProto, } from "./protoIdentifiers.js";
|
|
9
|
+
import { CryptoAlgorithmFamily, CryptoHpkeSealedMessageSchema, CryptoKemEncapsulationSchema, CryptoKeyPairSchema, CryptoProviderCapabilitySchema, CryptoProviderCapabilitySetSchema, CryptoProviderSupportStatus, CryptoVerificationResultSchema, CryptoVerificationStatus, } from "./proto/generated/reallyme/crypto/v1/crypto_pb.js";
|
|
10
|
+
const keyPairToProto = (algorithm, keyPair) => create(CryptoKeyPairSchema, {
|
|
11
|
+
algorithm,
|
|
12
|
+
publicKey: keyPair.publicKey,
|
|
13
|
+
secretKey: keyPair.secretKey,
|
|
14
|
+
});
|
|
15
|
+
export const signatureKeyPairToProto = (algorithm, keyPair) => keyPairToProto(signatureAlgorithmIdentifierToProto(algorithm), keyPair);
|
|
16
|
+
export const signatureKeyPairToProtoBytes = (algorithm, keyPair) => toBinary(CryptoKeyPairSchema, signatureKeyPairToProto(algorithm, keyPair));
|
|
17
|
+
export const signatureKeyPairFromProto = (value) => ({
|
|
18
|
+
algorithm: signatureAlgorithmFromIdentifier(value.algorithm),
|
|
19
|
+
keyPair: {
|
|
20
|
+
publicKey: new Uint8Array(value.publicKey),
|
|
21
|
+
secretKey: new Uint8Array(value.secretKey),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
export const signatureKeyPairFromProtoBytes = (bytes) => {
|
|
25
|
+
try {
|
|
26
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
27
|
+
return signatureKeyPairFromProto(fromBinary(CryptoKeyPairSchema, bytes));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const keyAgreementKeyPairToProto = (algorithm, keyPair) => keyPairToProto(keyAgreementAlgorithmIdentifierToProto(algorithm), keyPair);
|
|
37
|
+
export const keyAgreementKeyPairToProtoBytes = (algorithm, keyPair) => toBinary(CryptoKeyPairSchema, keyAgreementKeyPairToProto(algorithm, keyPair));
|
|
38
|
+
export const keyAgreementKeyPairFromProto = (value) => ({
|
|
39
|
+
algorithm: keyAgreementAlgorithmFromIdentifier(value.algorithm),
|
|
40
|
+
keyPair: {
|
|
41
|
+
publicKey: new Uint8Array(value.publicKey),
|
|
42
|
+
secretKey: new Uint8Array(value.secretKey),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
export const keyAgreementKeyPairFromProtoBytes = (bytes) => {
|
|
46
|
+
try {
|
|
47
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
48
|
+
return keyAgreementKeyPairFromProto(fromBinary(CryptoKeyPairSchema, bytes));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export const kemKeyPairToProto = (algorithm, keyPair) => keyPairToProto(kemAlgorithmIdentifierToProto(algorithm), keyPair);
|
|
58
|
+
export const kemKeyPairToProtoBytes = (algorithm, keyPair) => toBinary(CryptoKeyPairSchema, kemKeyPairToProto(algorithm, keyPair));
|
|
59
|
+
export const kemKeyPairFromProto = (value) => ({
|
|
60
|
+
algorithm: kemAlgorithmFromIdentifier(value.algorithm),
|
|
61
|
+
keyPair: {
|
|
62
|
+
publicKey: new Uint8Array(value.publicKey),
|
|
63
|
+
secretKey: new Uint8Array(value.secretKey),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
export const kemKeyPairFromProtoBytes = (bytes) => {
|
|
67
|
+
try {
|
|
68
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
69
|
+
return kemKeyPairFromProto(fromBinary(CryptoKeyPairSchema, bytes));
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const kemEncapsulationToProto = (algorithm, encapsulation) => create(CryptoKemEncapsulationSchema, {
|
|
79
|
+
algorithm: kemAlgorithmIdentifierToProto(algorithm),
|
|
80
|
+
ciphertext: encapsulation.ciphertext,
|
|
81
|
+
sharedSecret: encapsulation.sharedSecret,
|
|
82
|
+
});
|
|
83
|
+
export const kemEncapsulationToProtoBytes = (algorithm, encapsulation) => toBinary(CryptoKemEncapsulationSchema, kemEncapsulationToProto(algorithm, encapsulation));
|
|
84
|
+
export const kemEncapsulationFromProto = (value) => ({
|
|
85
|
+
algorithm: kemAlgorithmFromIdentifier(value.algorithm),
|
|
86
|
+
encapsulation: {
|
|
87
|
+
ciphertext: new Uint8Array(value.ciphertext),
|
|
88
|
+
sharedSecret: new Uint8Array(value.sharedSecret),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
export const kemEncapsulationFromProtoBytes = (bytes) => {
|
|
92
|
+
try {
|
|
93
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
94
|
+
return kemEncapsulationFromProto(fromBinary(CryptoKemEncapsulationSchema, bytes));
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export const hpkeSealedMessageToProto = (suite, sealedMessage) => create(CryptoHpkeSealedMessageSchema, {
|
|
104
|
+
algorithm: hpkeSuiteIdentifierToProto(suite),
|
|
105
|
+
encapsulatedKey: sealedMessage.encapsulatedKey,
|
|
106
|
+
ciphertext: sealedMessage.ciphertext,
|
|
107
|
+
});
|
|
108
|
+
export const hpkeSealedMessageToProtoBytes = (suite, sealedMessage) => toBinary(CryptoHpkeSealedMessageSchema, hpkeSealedMessageToProto(suite, sealedMessage));
|
|
109
|
+
export const hpkeSealedMessageFromProto = (value) => ({
|
|
110
|
+
suite: hpkeSuiteFromIdentifier(value.algorithm),
|
|
111
|
+
sealedMessage: {
|
|
112
|
+
encapsulatedKey: new Uint8Array(value.encapsulatedKey),
|
|
113
|
+
ciphertext: new Uint8Array(value.ciphertext),
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
export const hpkeSealedMessageFromProtoBytes = (bytes) => {
|
|
117
|
+
try {
|
|
118
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
119
|
+
return hpkeSealedMessageFromProto(fromBinary(CryptoHpkeSealedMessageSchema, bytes));
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export const verificationResultToProto = (algorithm, valid) => create(CryptoVerificationResultSchema, {
|
|
129
|
+
algorithm,
|
|
130
|
+
status: valid ? CryptoVerificationStatus.VALID : CryptoVerificationStatus.INVALID,
|
|
131
|
+
});
|
|
132
|
+
export const verificationErrorToProto = (algorithm, error) => create(CryptoVerificationResultSchema, {
|
|
133
|
+
algorithm,
|
|
134
|
+
status: CryptoVerificationStatus.ERROR,
|
|
135
|
+
error: cryptoErrorToProto(error),
|
|
136
|
+
});
|
|
137
|
+
export const verificationResultToProtoBytes = (value) => toBinary(CryptoVerificationResultSchema, value);
|
|
138
|
+
export const verificationResultFromProtoBytes = (bytes) => {
|
|
139
|
+
try {
|
|
140
|
+
ensureByteArrayAtMost(bytes, MAX_CRYPTO_INPUT_LENGTH);
|
|
141
|
+
const value = fromBinary(CryptoVerificationResultSchema, bytes);
|
|
142
|
+
if (value.algorithm?.algorithm.case === undefined) {
|
|
143
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
144
|
+
}
|
|
145
|
+
// Require an explicit outcome, and prevent a success or invalid result
|
|
146
|
+
// from masking a structured processing error.
|
|
147
|
+
switch (value.status) {
|
|
148
|
+
case CryptoVerificationStatus.VALID:
|
|
149
|
+
case CryptoVerificationStatus.INVALID:
|
|
150
|
+
if (value.error !== undefined) {
|
|
151
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
case CryptoVerificationStatus.ERROR:
|
|
155
|
+
if (value.error?.error.case === undefined) {
|
|
156
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const providerSupportStatusToProto = (value) => {
|
|
169
|
+
switch (value) {
|
|
170
|
+
case "partial":
|
|
171
|
+
return CryptoProviderSupportStatus.PARTIAL;
|
|
172
|
+
case "provider-aware":
|
|
173
|
+
return CryptoProviderSupportStatus.PROVIDER_AWARE;
|
|
174
|
+
case "supported":
|
|
175
|
+
return CryptoProviderSupportStatus.SUPPORTED;
|
|
176
|
+
case "unsupported":
|
|
177
|
+
return CryptoProviderSupportStatus.UNSUPPORTED;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const providerSupportStatusFromProto = (value) => {
|
|
181
|
+
switch (value) {
|
|
182
|
+
case CryptoProviderSupportStatus.PARTIAL:
|
|
183
|
+
return "partial";
|
|
184
|
+
case CryptoProviderSupportStatus.PROVIDER_AWARE:
|
|
185
|
+
return "provider-aware";
|
|
186
|
+
case CryptoProviderSupportStatus.SUPPORTED:
|
|
187
|
+
return "supported";
|
|
188
|
+
case CryptoProviderSupportStatus.UNSUPPORTED:
|
|
189
|
+
return "unsupported";
|
|
190
|
+
default:
|
|
191
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
export const providerCapabilityToProto = (value) => create(CryptoProviderCapabilitySchema, {
|
|
195
|
+
algorithm: value.algorithm,
|
|
196
|
+
family: value.family,
|
|
197
|
+
providerNames: [...value.providerNames],
|
|
198
|
+
status: providerSupportStatusToProto(value.status),
|
|
199
|
+
usesRust: value.usesRust,
|
|
200
|
+
});
|
|
201
|
+
export const providerCapabilityFromProto = (value) => {
|
|
202
|
+
if (value.algorithm === undefined || value.family === CryptoAlgorithmFamily.UNSPECIFIED) {
|
|
203
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
algorithm: value.algorithm,
|
|
207
|
+
family: value.family,
|
|
208
|
+
providerNames: [...value.providerNames],
|
|
209
|
+
status: providerSupportStatusFromProto(value.status),
|
|
210
|
+
usesRust: value.usesRust,
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
export const providerCapabilitySetToProto = (values) => create(CryptoProviderCapabilitySetSchema, {
|
|
214
|
+
capabilities: values.map((value) => providerCapabilityToProto(value)),
|
|
215
|
+
});
|
|
216
|
+
export const providerCapabilitySetToProtoBytes = (values) => toBinary(CryptoProviderCapabilitySetSchema, providerCapabilitySetToProto(values));
|
|
217
|
+
export const providerCapabilitySetFromProto = (value) => value.capabilities.map((capability) => providerCapabilityFromProto(capability));
|
|
218
|
+
export const providerCapabilitySetFromProtoBytes = (bytes) => {
|
|
219
|
+
try {
|
|
220
|
+
return providerCapabilitySetFromProto(fromBinary(CryptoProviderCapabilitySetSchema, bytes));
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error instanceof ReallyMeCryptoError) {
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
throw new ReallyMeCryptoError("invalid-input");
|
|
227
|
+
}
|
|
228
|
+
};
|
package/dist/providerCatalog.js
CHANGED
package/dist/rsa.js
CHANGED
package/dist/secp256k1.js
CHANGED
package/dist/slhDsa.js
CHANGED
package/dist/validateBytes.js
CHANGED