@twin.org/crypto 0.0.1-next.1

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.
Files changed (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +31 -0
  3. package/dist/cjs/index.cjs +1572 -0
  4. package/dist/esm/index.mjs +1528 -0
  5. package/dist/types/address/bech32.d.ts +28 -0
  6. package/dist/types/address/bip44.d.ts +53 -0
  7. package/dist/types/ciphers/chaCha20Poly1305.d.ts +24 -0
  8. package/dist/types/curves/ed25519.d.ts +37 -0
  9. package/dist/types/curves/secp256k1.d.ts +37 -0
  10. package/dist/types/curves/x25519.d.ts +18 -0
  11. package/dist/types/curves/zip215.d.ts +15 -0
  12. package/dist/types/hashes/blake2b.d.ts +55 -0
  13. package/dist/types/hashes/hmacSha1.d.ts +28 -0
  14. package/dist/types/hashes/hmacSha256.d.ts +44 -0
  15. package/dist/types/hashes/hmacSha512.d.ts +66 -0
  16. package/dist/types/hashes/pbkdf2.d.ts +23 -0
  17. package/dist/types/hashes/sha1.d.ts +26 -0
  18. package/dist/types/hashes/sha256.d.ts +41 -0
  19. package/dist/types/hashes/sha512.d.ts +61 -0
  20. package/dist/types/index.d.ts +23 -0
  21. package/dist/types/keys/bip32Path.d.ts +40 -0
  22. package/dist/types/keys/bip39.d.ts +36 -0
  23. package/dist/types/keys/slip0010.d.ts +38 -0
  24. package/dist/types/models/keyType.d.ts +17 -0
  25. package/dist/types/otp/hotp.d.ts +14 -0
  26. package/dist/types/otp/totp.d.ts +46 -0
  27. package/dist/types/passwords/passwordGenerator.d.ts +11 -0
  28. package/dist/types/passwords/passwordValidator.d.ts +22 -0
  29. package/docs/changelog.md +5 -0
  30. package/docs/examples.md +1 -0
  31. package/docs/reference/classes/Bech32.md +89 -0
  32. package/docs/reference/classes/Bip32Path.md +117 -0
  33. package/docs/reference/classes/Bip39.md +121 -0
  34. package/docs/reference/classes/Bip44.md +173 -0
  35. package/docs/reference/classes/Blake2b.md +155 -0
  36. package/docs/reference/classes/ChaCha20Poly1305.md +69 -0
  37. package/docs/reference/classes/Ed25519.md +113 -0
  38. package/docs/reference/classes/HmacSha1.md +79 -0
  39. package/docs/reference/classes/HmacSha256.md +123 -0
  40. package/docs/reference/classes/HmacSha512.md +187 -0
  41. package/docs/reference/classes/Hotp.md +39 -0
  42. package/docs/reference/classes/PasswordGenerator.md +33 -0
  43. package/docs/reference/classes/PasswordValidator.md +56 -0
  44. package/docs/reference/classes/Pbkdf2.md +77 -0
  45. package/docs/reference/classes/Secp256k1.md +113 -0
  46. package/docs/reference/classes/Sha1.md +69 -0
  47. package/docs/reference/classes/Sha256.md +111 -0
  48. package/docs/reference/classes/Sha512.md +167 -0
  49. package/docs/reference/classes/Slip0010.md +114 -0
  50. package/docs/reference/classes/Totp.md +148 -0
  51. package/docs/reference/classes/X25519.md +57 -0
  52. package/docs/reference/classes/Zip215.md +43 -0
  53. package/docs/reference/index.md +34 -0
  54. package/docs/reference/type-aliases/KeyType.md +5 -0
  55. package/docs/reference/variables/KeyType.md +19 -0
  56. package/locales/en.json +71 -0
  57. package/package.json +71 -0
@@ -0,0 +1,155 @@
1
+ # Class: Blake2b
2
+
3
+ Class to help with Blake2B Signature scheme.
4
+
5
+ ## Constructors
6
+
7
+ ### new Blake2b()
8
+
9
+ > **new Blake2b**(`outputLength`, `key`?): [`Blake2b`](Blake2b.md)
10
+
11
+ Create a new instance of Blake2b.
12
+
13
+ #### Parameters
14
+
15
+ • **outputLength**: `number`
16
+
17
+ The output length.
18
+
19
+ • **key?**: `Uint8Array`
20
+
21
+ Optional key for the hash.
22
+
23
+ #### Returns
24
+
25
+ [`Blake2b`](Blake2b.md)
26
+
27
+ ## Properties
28
+
29
+ ### SIZE\_160
30
+
31
+ > `static` **SIZE\_160**: `number` = `20`
32
+
33
+ Blake2b 160.
34
+
35
+ ***
36
+
37
+ ### SIZE\_256
38
+
39
+ > `static` **SIZE\_256**: `number` = `32`
40
+
41
+ Blake2b 256.
42
+
43
+ ***
44
+
45
+ ### SIZE\_512
46
+
47
+ > `static` **SIZE\_512**: `number` = `64`
48
+
49
+ Blake2b 512.
50
+
51
+ ## Methods
52
+
53
+ ### sum160()
54
+
55
+ > `static` **sum160**(`block`, `key`?): `Uint8Array`
56
+
57
+ Perform Sum 160 on the block.
58
+
59
+ #### Parameters
60
+
61
+ • **block**: `Uint8Array`
62
+
63
+ The block to operate on.
64
+
65
+ • **key?**: `Uint8Array`
66
+
67
+ Optional key for the hash.
68
+
69
+ #### Returns
70
+
71
+ `Uint8Array`
72
+
73
+ The sum 160 of the block.
74
+
75
+ ***
76
+
77
+ ### sum256()
78
+
79
+ > `static` **sum256**(`block`, `key`?): `Uint8Array`
80
+
81
+ Perform Sum 256 on the block.
82
+
83
+ #### Parameters
84
+
85
+ • **block**: `Uint8Array`
86
+
87
+ The block to operate on.
88
+
89
+ • **key?**: `Uint8Array`
90
+
91
+ Optional key for the hash.
92
+
93
+ #### Returns
94
+
95
+ `Uint8Array`
96
+
97
+ The sum 256 of the block.
98
+
99
+ ***
100
+
101
+ ### sum512()
102
+
103
+ > `static` **sum512**(`block`, `key`?): `Uint8Array`
104
+
105
+ Perform Sum 512 on the block.
106
+
107
+ #### Parameters
108
+
109
+ • **block**: `Uint8Array`
110
+
111
+ The block to operate on.
112
+
113
+ • **key?**: `Uint8Array`
114
+
115
+ Optional key for the hash.
116
+
117
+ #### Returns
118
+
119
+ `Uint8Array`
120
+
121
+ The sum 512 of the block.
122
+
123
+ ***
124
+
125
+ ### update()
126
+
127
+ > **update**(`block`): [`Blake2b`](Blake2b.md)
128
+
129
+ Update the hash with the block.
130
+
131
+ #### Parameters
132
+
133
+ • **block**: `Uint8Array`
134
+
135
+ The block to update the hash with.
136
+
137
+ #### Returns
138
+
139
+ [`Blake2b`](Blake2b.md)
140
+
141
+ The instance for chaining.
142
+
143
+ ***
144
+
145
+ ### digest()
146
+
147
+ > **digest**(): `Uint8Array`
148
+
149
+ Get the digest for the hash.
150
+
151
+ #### Returns
152
+
153
+ `Uint8Array`
154
+
155
+ The instance for chaining.
@@ -0,0 +1,69 @@
1
+ # Class: ChaCha20Poly1305
2
+
3
+ Implementation of the ChaCha20Poly1305 cipher.
4
+
5
+ ## Constructors
6
+
7
+ ### new ChaCha20Poly1305()
8
+
9
+ > **new ChaCha20Poly1305**(`key`, `nonce`, `aad`?): [`ChaCha20Poly1305`](ChaCha20Poly1305.md)
10
+
11
+ Create a new instance of ChaCha20Poly1305.
12
+
13
+ #### Parameters
14
+
15
+ • **key**: `Uint8Array`
16
+
17
+ The key.
18
+
19
+ • **nonce**: `Uint8Array`
20
+
21
+ The nonce.
22
+
23
+ • **aad?**: `Uint8Array`
24
+
25
+ The additional authenticated data.
26
+
27
+ #### Returns
28
+
29
+ [`ChaCha20Poly1305`](ChaCha20Poly1305.md)
30
+
31
+ ## Methods
32
+
33
+ ### encrypt()
34
+
35
+ > **encrypt**(`block`): `Uint8Array`
36
+
37
+ Encrypt the block.
38
+
39
+ #### Parameters
40
+
41
+ • **block**: `Uint8Array`
42
+
43
+ The block to encrypt.
44
+
45
+ #### Returns
46
+
47
+ `Uint8Array`
48
+
49
+ The block encrypted.
50
+
51
+ ***
52
+
53
+ ### decrypt()
54
+
55
+ > **decrypt**(`block`): `Uint8Array`
56
+
57
+ Decrypt the block.
58
+
59
+ #### Parameters
60
+
61
+ • **block**: `Uint8Array`
62
+
63
+ The block to decrypt.
64
+
65
+ #### Returns
66
+
67
+ `Uint8Array`
68
+
69
+ The block decrypted.
@@ -0,0 +1,113 @@
1
+ # Class: Ed25519
2
+
3
+ Implementation of Ed25519.
4
+
5
+ ## Constructors
6
+
7
+ ### new Ed25519()
8
+
9
+ > **new Ed25519**(): [`Ed25519`](Ed25519.md)
10
+
11
+ #### Returns
12
+
13
+ [`Ed25519`](Ed25519.md)
14
+
15
+ ## Properties
16
+
17
+ ### PRIVATE\_KEY\_SIZE
18
+
19
+ > `static` **PRIVATE\_KEY\_SIZE**: `number` = `32`
20
+
21
+ Private Key Size is the size, in bytes, of private keys as used in this package.
22
+
23
+ ***
24
+
25
+ ### PUBLIC\_KEY\_SIZE
26
+
27
+ > `static` **PUBLIC\_KEY\_SIZE**: `number` = `32`
28
+
29
+ Public Key Size is the size, in bytes, of public keys as used in this package.
30
+
31
+ ## Methods
32
+
33
+ ### publicKeyFromPrivateKey()
34
+
35
+ > `static` **publicKeyFromPrivateKey**(`privateKey`): `Uint8Array`
36
+
37
+ Public returns the PublicKey corresponding to private.
38
+
39
+ #### Parameters
40
+
41
+ • **privateKey**: `Uint8Array`
42
+
43
+ The private key to get the corresponding public key.
44
+
45
+ #### Returns
46
+
47
+ `Uint8Array`
48
+
49
+ The public key.
50
+
51
+ #### Throws
52
+
53
+ Error if the private key is not the correct length.
54
+
55
+ ***
56
+
57
+ ### sign()
58
+
59
+ > `static` **sign**(`privateKey`, `block`): `Uint8Array`
60
+
61
+ Sign the block with privateKey and returns a signature.
62
+
63
+ #### Parameters
64
+
65
+ • **privateKey**: `Uint8Array`
66
+
67
+ The private key.
68
+
69
+ • **block**: `Uint8Array`
70
+
71
+ The block to sign.
72
+
73
+ #### Returns
74
+
75
+ `Uint8Array`
76
+
77
+ The signature.
78
+
79
+ #### Throws
80
+
81
+ Error if the private key is not the correct length.
82
+
83
+ ***
84
+
85
+ ### verify()
86
+
87
+ > `static` **verify**(`publicKey`, `block`, `signature`): `boolean`
88
+
89
+ Verify reports whether sig is a valid signature of block by publicKey.
90
+
91
+ #### Parameters
92
+
93
+ • **publicKey**: `Uint8Array`
94
+
95
+ The public key to verify the signature.
96
+
97
+ • **block**: `Uint8Array`
98
+
99
+ The block for the signature.
100
+
101
+ • **signature**: `Uint8Array`
102
+
103
+ The signature.
104
+
105
+ #### Returns
106
+
107
+ `boolean`
108
+
109
+ True if the signature matches.
110
+
111
+ #### Throws
112
+
113
+ Error if the public key is not the correct length.
@@ -0,0 +1,79 @@
1
+ # Class: HmacSha1
2
+
3
+ Class to help with HmacSha1 scheme.
4
+
5
+ ## Constructors
6
+
7
+ ### new HmacSha1()
8
+
9
+ > **new HmacSha1**(`key`): [`HmacSha1`](HmacSha1.md)
10
+
11
+ Create a new instance of HmacSha1.
12
+
13
+ #### Parameters
14
+
15
+ • **key**: `Uint8Array`
16
+
17
+ The key for the hmac.
18
+
19
+ #### Returns
20
+
21
+ [`HmacSha1`](HmacSha1.md)
22
+
23
+ ## Methods
24
+
25
+ ### sum()
26
+
27
+ > `static` **sum**(`key`, `block`): `Uint8Array`
28
+
29
+ Perform Sum on the block.
30
+
31
+ #### Parameters
32
+
33
+ • **key**: `Uint8Array`
34
+
35
+ The key for the hmac.
36
+
37
+ • **block**: `Uint8Array`
38
+
39
+ The block to operate on.
40
+
41
+ #### Returns
42
+
43
+ `Uint8Array`
44
+
45
+ The sum of the block.
46
+
47
+ ***
48
+
49
+ ### update()
50
+
51
+ > **update**(`block`): [`HmacSha1`](HmacSha1.md)
52
+
53
+ Update the hash with the block.
54
+
55
+ #### Parameters
56
+
57
+ • **block**: `Uint8Array`
58
+
59
+ The block to update the hash with.
60
+
61
+ #### Returns
62
+
63
+ [`HmacSha1`](HmacSha1.md)
64
+
65
+ The instance for chaining.
66
+
67
+ ***
68
+
69
+ ### digest()
70
+
71
+ > **digest**(): `Uint8Array`
72
+
73
+ Get the digest for the hash.
74
+
75
+ #### Returns
76
+
77
+ `Uint8Array`
78
+
79
+ The instance for chaining.
@@ -0,0 +1,123 @@
1
+ # Class: HmacSha256
2
+
3
+ Class to help with HmacSha256 scheme.
4
+
5
+ ## Constructors
6
+
7
+ ### new HmacSha256()
8
+
9
+ > **new HmacSha256**(`key`, `bits`): [`HmacSha256`](HmacSha256.md)
10
+
11
+ Create a new instance of HmacSha256.
12
+
13
+ #### Parameters
14
+
15
+ • **key**: `Uint8Array`
16
+
17
+ The key for the hmac.
18
+
19
+ • **bits**: `number` = `HmacSha256.SIZE_256`
20
+
21
+ The number of bits.
22
+
23
+ #### Returns
24
+
25
+ [`HmacSha256`](HmacSha256.md)
26
+
27
+ ## Properties
28
+
29
+ ### SIZE\_256
30
+
31
+ > `readonly` `static` **SIZE\_256**: `number` = `256`
32
+
33
+ Sha256 256.
34
+
35
+ ***
36
+
37
+ ### SIZE\_224
38
+
39
+ > `readonly` `static` **SIZE\_224**: `number` = `224`
40
+
41
+ Sha256 224.
42
+
43
+ ## Methods
44
+
45
+ ### sum224()
46
+
47
+ > `static` **sum224**(`key`, `block`): `Uint8Array`
48
+
49
+ Perform Sum 224 on the block.
50
+
51
+ #### Parameters
52
+
53
+ • **key**: `Uint8Array`
54
+
55
+ The key for the hmac.
56
+
57
+ • **block**: `Uint8Array`
58
+
59
+ The block to operate on.
60
+
61
+ #### Returns
62
+
63
+ `Uint8Array`
64
+
65
+ The sum 224 of the block.
66
+
67
+ ***
68
+
69
+ ### sum256()
70
+
71
+ > `static` **sum256**(`key`, `block`): `Uint8Array`
72
+
73
+ Perform Sum 256 on the block.
74
+
75
+ #### Parameters
76
+
77
+ • **key**: `Uint8Array`
78
+
79
+ The key for the hmac.
80
+
81
+ • **block**: `Uint8Array`
82
+
83
+ The block to operate on.
84
+
85
+ #### Returns
86
+
87
+ `Uint8Array`
88
+
89
+ The sum 256 of the block.
90
+
91
+ ***
92
+
93
+ ### update()
94
+
95
+ > **update**(`block`): [`HmacSha256`](HmacSha256.md)
96
+
97
+ Update the hash with the block.
98
+
99
+ #### Parameters
100
+
101
+ • **block**: `Uint8Array`
102
+
103
+ The block to update the hash with.
104
+
105
+ #### Returns
106
+
107
+ [`HmacSha256`](HmacSha256.md)
108
+
109
+ The instance for chaining.
110
+
111
+ ***
112
+
113
+ ### digest()
114
+
115
+ > **digest**(): `Uint8Array`
116
+
117
+ Get the digest for the hash.
118
+
119
+ #### Returns
120
+
121
+ `Uint8Array`
122
+
123
+ The instance for chaining.
@@ -0,0 +1,187 @@
1
+ # Class: HmacSha512
2
+
3
+ Class to help with HmacSha512 scheme.
4
+
5
+ ## Constructors
6
+
7
+ ### new HmacSha512()
8
+
9
+ > **new HmacSha512**(`key`, `bits`): [`HmacSha512`](HmacSha512.md)
10
+
11
+ Create a new instance of HmacSha512.
12
+
13
+ #### Parameters
14
+
15
+ • **key**: `Uint8Array`
16
+
17
+ The key for the hmac.
18
+
19
+ • **bits**: `number` = `HmacSha512.SIZE_512`
20
+
21
+ The number of bits.
22
+
23
+ #### Returns
24
+
25
+ [`HmacSha512`](HmacSha512.md)
26
+
27
+ ## Properties
28
+
29
+ ### SIZE\_224
30
+
31
+ > `static` **SIZE\_224**: `number` = `224`
32
+
33
+ Sha512 224.
34
+
35
+ ***
36
+
37
+ ### SIZE\_256
38
+
39
+ > `static` **SIZE\_256**: `number` = `256`
40
+
41
+ Sha512 256.
42
+
43
+ ***
44
+
45
+ ### SIZE\_384
46
+
47
+ > `static` **SIZE\_384**: `number` = `384`
48
+
49
+ Sha512 384.
50
+
51
+ ***
52
+
53
+ ### SIZE\_512
54
+
55
+ > `static` **SIZE\_512**: `number` = `512`
56
+
57
+ Sha512 512.
58
+
59
+ ## Methods
60
+
61
+ ### sum512()
62
+
63
+ > `static` **sum512**(`key`, `block`): `Uint8Array`
64
+
65
+ Perform Sum 512 on the block.
66
+
67
+ #### Parameters
68
+
69
+ • **key**: `Uint8Array`
70
+
71
+ The key for the hmac.
72
+
73
+ • **block**: `Uint8Array`
74
+
75
+ The block to operate on.
76
+
77
+ #### Returns
78
+
79
+ `Uint8Array`
80
+
81
+ The sum 512 of the block.
82
+
83
+ ***
84
+
85
+ ### sum384()
86
+
87
+ > `static` **sum384**(`key`, `block`): `Uint8Array`
88
+
89
+ Perform Sum 384 on the block.
90
+
91
+ #### Parameters
92
+
93
+ • **key**: `Uint8Array`
94
+
95
+ The key for the hmac.
96
+
97
+ • **block**: `Uint8Array`
98
+
99
+ The block to operate on.
100
+
101
+ #### Returns
102
+
103
+ `Uint8Array`
104
+
105
+ The sum 384 of the block.
106
+
107
+ ***
108
+
109
+ ### sum256()
110
+
111
+ > `static` **sum256**(`key`, `block`): `Uint8Array`
112
+
113
+ Perform Sum 256 on the block.
114
+
115
+ #### Parameters
116
+
117
+ • **key**: `Uint8Array`
118
+
119
+ The key for the hmac.
120
+
121
+ • **block**: `Uint8Array`
122
+
123
+ The block to operate on.
124
+
125
+ #### Returns
126
+
127
+ `Uint8Array`
128
+
129
+ The sum 256 of the block.
130
+
131
+ ***
132
+
133
+ ### sum224()
134
+
135
+ > `static` **sum224**(`key`, `block`): `Uint8Array`
136
+
137
+ Perform Sum 224 on the block.
138
+
139
+ #### Parameters
140
+
141
+ • **key**: `Uint8Array`
142
+
143
+ The key for the hmac.
144
+
145
+ • **block**: `Uint8Array`
146
+
147
+ The block to operate on.
148
+
149
+ #### Returns
150
+
151
+ `Uint8Array`
152
+
153
+ The sum 224 of the block.
154
+
155
+ ***
156
+
157
+ ### update()
158
+
159
+ > **update**(`block`): [`HmacSha512`](HmacSha512.md)
160
+
161
+ Update the hash with the block.
162
+
163
+ #### Parameters
164
+
165
+ • **block**: `Uint8Array`
166
+
167
+ The block to update the hash with.
168
+
169
+ #### Returns
170
+
171
+ [`HmacSha512`](HmacSha512.md)
172
+
173
+ The instance for chaining.
174
+
175
+ ***
176
+
177
+ ### digest()
178
+
179
+ > **digest**(): `Uint8Array`
180
+
181
+ Get the digest for the hash.
182
+
183
+ #### Returns
184
+
185
+ `Uint8Array`
186
+
187
+ The instance for chaining.