-
Notifications
You must be signed in to change notification settings - Fork 9
/
dhkemPrimitives.ts
42 lines (31 loc) · 972 Bytes
/
dhkemPrimitives.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// The key usages for KEM.
export const KEM_USAGES: KeyUsage[] = ["deriveBits"];
// b"dkp_prk"
export const LABEL_DKP_PRK: Uint8Array = new Uint8Array([
100,
107,
112,
95,
112,
114,
107,
]);
// b"sk"
export const LABEL_SK: Uint8Array = new Uint8Array([115, 107]);
export interface DhkemPrimitives {
serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;
deserializePublicKey(key: ArrayBuffer): Promise<CryptoKey>;
serializePrivateKey(key: CryptoKey): Promise<ArrayBuffer>;
deserializePrivateKey(key: ArrayBuffer): Promise<CryptoKey>;
importKey(
format: "raw" | "jwk",
key: ArrayBuffer | JsonWebKey,
isPublic: boolean,
): Promise<CryptoKey>;
generateKeyPair(): Promise<CryptoKeyPair>;
deriveKeyPair(ikm: ArrayBuffer): Promise<CryptoKeyPair>;
// DHKEM-specific function.
derivePublicKey(key: CryptoKey): Promise<CryptoKey>;
// DHKEM-specific function.
dh(sk: CryptoKey, pk: CryptoKey): Promise<ArrayBuffer>;
}