-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_type.ts
77 lines (74 loc) · 2 KB
/
key_type.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import * as keysEntitiesProto from "../../bridge/proto/keys_entities";
/**
* Represents the type of cryptographic key.
*/
export enum KeyType {
/**
* Represents the elliptic curve key type P-256k.
*/
EcP256k,
/**
* Represents the RSA key type with a 2048-bit modulus.
*/
Rsa2048,
/**
* Represents the RSA key type with a 3072-bit modulus.
*/
Rsa3072,
/**
* Represents the RSA key type with a 4096-bit modulus.
*/
Rsa4096,
/**
* Represents the AES key type with a 128-bit key length.
*/
Aes128,
/**
* Represents the AES key type with a 256-bit key length.
*/
Aes256,
/**
* Represents the Baby JubJub key type, elliptic curve defined over the large prime subgroup of BN128.
*/
Bjj
}
export namespace KeyType {
export function toProto(type: KeyType): keysEntitiesProto.KeyType {
switch (type) {
case KeyType.EcP256k:
return keysEntitiesProto.KeyType.EcP256k;
case KeyType.Rsa2048:
return keysEntitiesProto.KeyType.Rsa2048;
case KeyType.Rsa3072:
return keysEntitiesProto.KeyType.Rsa3072;
case KeyType.Rsa4096:
return keysEntitiesProto.KeyType.Rsa4096;
case KeyType.Aes128:
return keysEntitiesProto.KeyType.Aes128;
case KeyType.Aes256:
return keysEntitiesProto.KeyType.Aes256;
case KeyType.Bjj:
return keysEntitiesProto.KeyType.Bjj;
}
}
export function fromProto(
type: keysEntitiesProto.KeyType | undefined
): KeyType {
switch (type) {
case keysEntitiesProto.KeyType.Rsa2048:
return KeyType.Rsa2048;
case keysEntitiesProto.KeyType.Rsa3072:
return KeyType.Rsa3072;
case keysEntitiesProto.KeyType.Rsa4096:
return KeyType.Rsa4096;
case keysEntitiesProto.KeyType.Aes128:
return KeyType.Aes128;
case keysEntitiesProto.KeyType.Aes256:
return KeyType.Aes256;
case keysEntitiesProto.KeyType.Bjj:
return KeyType.Bjj;
default:
return KeyType.EcP256k;
}
}
}