@twin.org/crypto 0.0.1-next.6 → 0.0.1-next.60

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 (36) hide show
  1. package/dist/cjs/index.cjs +251 -0
  2. package/dist/esm/index.mjs +251 -2
  3. package/dist/types/address/bip44.d.ts +15 -0
  4. package/dist/types/curves/ed25519.d.ts +12 -0
  5. package/dist/types/hashes/blake3.d.ts +44 -0
  6. package/dist/types/hashes/sha3.d.ts +61 -0
  7. package/dist/types/index.d.ts +2 -0
  8. package/docs/changelog.md +155 -1
  9. package/docs/reference/classes/Bech32.md +15 -7
  10. package/docs/reference/classes/Bip32Path.md +17 -9
  11. package/docs/reference/classes/Bip39.md +28 -12
  12. package/docs/reference/classes/Bip44.md +121 -21
  13. package/docs/reference/classes/Blake2b.md +35 -17
  14. package/docs/reference/classes/Blake3.md +137 -0
  15. package/docs/reference/classes/ChaCha20Poly1305.md +18 -8
  16. package/docs/reference/classes/Ed25519.md +65 -9
  17. package/docs/reference/classes/HmacSha1.md +17 -9
  18. package/docs/reference/classes/HmacSha256.md +26 -12
  19. package/docs/reference/classes/HmacSha512.md +38 -16
  20. package/docs/reference/classes/Hotp.md +9 -5
  21. package/docs/reference/classes/PasswordGenerator.md +6 -4
  22. package/docs/reference/classes/PasswordValidator.md +23 -11
  23. package/docs/reference/classes/Pbkdf2.md +27 -11
  24. package/docs/reference/classes/Secp256k1.md +21 -9
  25. package/docs/reference/classes/Sha1.md +11 -7
  26. package/docs/reference/classes/Sha256.md +17 -9
  27. package/docs/reference/classes/Sha3.md +179 -0
  28. package/docs/reference/classes/Sha512.md +23 -11
  29. package/docs/reference/classes/Slip0010.md +27 -11
  30. package/docs/reference/classes/Totp.md +42 -16
  31. package/docs/reference/classes/X25519.md +9 -5
  32. package/docs/reference/classes/Zip215.md +12 -6
  33. package/docs/reference/index.md +2 -0
  34. package/docs/reference/type-aliases/KeyType.md +1 -1
  35. package/locales/en.json +3 -6
  36. package/package.json +12 -12
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Perform a SHA-3 hash on the block.
3
+ */
4
+ export declare class Sha3 {
5
+ /**
6
+ * Sha3 224.
7
+ */
8
+ static readonly SIZE_224: number;
9
+ /**
10
+ * Sha3 256.
11
+ */
12
+ static readonly SIZE_256: number;
13
+ /**
14
+ * Sha3 384.
15
+ */
16
+ static readonly SIZE_384: number;
17
+ /**
18
+ * Sha3 512.
19
+ */
20
+ static readonly SIZE_512: number;
21
+ /**
22
+ * Create a new instance of Sha3.
23
+ * @param bits The number of bits.
24
+ */
25
+ constructor(bits?: number);
26
+ /**
27
+ * Perform Sum 256 on the block.
28
+ * @param block The block to operate on.
29
+ * @returns The sum 256 of the block.
30
+ */
31
+ static sum256(block: Uint8Array): Uint8Array;
32
+ /**
33
+ * Perform Sum 224 on the block.
34
+ * @param block The block to operate on.
35
+ * @returns The sum 224 of the block.
36
+ */
37
+ static sum224(block: Uint8Array): Uint8Array;
38
+ /**
39
+ * Perform Sum 384 on the block.
40
+ * @param block The block to operate on.
41
+ * @returns The sum 384 of the block.
42
+ */
43
+ static sum384(block: Uint8Array): Uint8Array;
44
+ /**
45
+ * Perform Sum 512 on the block.
46
+ * @param block The block to operate on.
47
+ * @returns The sum 512 of the block.
48
+ */
49
+ static sum512(block: Uint8Array): Uint8Array;
50
+ /**
51
+ * Update the hash with the block.
52
+ * @param block The block to update the hash with.
53
+ * @returns The instance for chaining.
54
+ */
55
+ update(block: Uint8Array): Sha3;
56
+ /**
57
+ * Get the digest for the hash.
58
+ * @returns The instance for chaining.
59
+ */
60
+ digest(): Uint8Array;
61
+ }
@@ -6,12 +6,14 @@ export * from "./curves/secp256k1";
6
6
  export * from "./curves/x25519";
7
7
  export * from "./curves/zip215";
8
8
  export * from "./hashes/blake2b";
9
+ export * from "./hashes/blake3";
9
10
  export * from "./hashes/hmacSha1";
10
11
  export * from "./hashes/hmacSha256";
11
12
  export * from "./hashes/hmacSha512";
12
13
  export * from "./hashes/pbkdf2";
13
14
  export * from "./hashes/sha1";
14
15
  export * from "./hashes/sha256";
16
+ export * from "./hashes/sha3";
15
17
  export * from "./hashes/sha512";
16
18
  export * from "./keys/bip32Path";
17
19
  export * from "./keys/bip39";
package/docs/changelog.md CHANGED
@@ -1,5 +1,159 @@
1
1
  # @twin.org/crypto - Changelog
2
2
 
3
- ## 0.0.1-next.6
3
+ ## [0.0.1-next.60](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.59...crypto-v0.0.1-next.60) (2025-06-17)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **crypto:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.0.1-next.59 to 0.0.1-next.60
16
+
17
+ ## [0.0.1-next.59](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.58...crypto-v0.0.1-next.59) (2025-06-17)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **crypto:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/core bumped from 0.0.1-next.58 to 0.0.1-next.59
30
+
31
+ ## [0.0.1-next.58](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.57...crypto-v0.0.1-next.58) (2025-06-13)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **crypto:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/core bumped from 0.0.1-next.57 to 0.0.1-next.58
44
+
45
+ ## [0.0.1-next.57](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.56...crypto-v0.0.1-next.57) (2025-06-10)
46
+
47
+
48
+ ### Features
49
+
50
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/core bumped from 0.0.1-next.56 to 0.0.1-next.57
58
+
59
+ ## [0.0.1-next.56](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.55...crypto-v0.0.1-next.56) (2025-05-08)
60
+
61
+
62
+ ### Miscellaneous Chores
63
+
64
+ * **crypto:** Synchronize repo versions
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/core bumped from 0.0.1-next.55 to 0.0.1-next.56
72
+
73
+ ## [0.0.1-next.55](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.54...crypto-v0.0.1-next.55) (2025-05-07)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **crypto:** Synchronize repo versions
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/core bumped from 0.0.1-next.54 to 0.0.1-next.55
86
+
87
+ ## [0.0.1-next.54](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.53...crypto-v0.0.1-next.54) (2025-05-06)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **crypto:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/core bumped from 0.0.1-next.53 to 0.0.1-next.54
100
+
101
+ ## [0.0.1-next.53](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.52...crypto-v0.0.1-next.53) (2025-05-01)
102
+
103
+
104
+ ### Miscellaneous Chores
105
+
106
+ * **crypto:** Synchronize repo versions
107
+
108
+
109
+ ### Dependencies
110
+
111
+ * The following workspace dependencies were updated
112
+ * dependencies
113
+ * @twin.org/core bumped from 0.0.1-next.52 to 0.0.1-next.53
114
+
115
+ ## [0.0.1-next.52](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.51...crypto-v0.0.1-next.52) (2025-04-17)
116
+
117
+
118
+ ### Features
119
+
120
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
121
+
122
+
123
+ ### Dependencies
124
+
125
+ * The following workspace dependencies were updated
126
+ * dependencies
127
+ * @twin.org/core bumped from 0.0.1-next.51 to 0.0.1-next.52
128
+
129
+ ## [0.0.1-next.51](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.50...crypto-v0.0.1-next.51) (2025-03-27)
130
+
131
+
132
+ ### Miscellaneous Chores
133
+
134
+ * **crypto:** Synchronize repo versions
135
+
136
+
137
+ ### Dependencies
138
+
139
+ * The following workspace dependencies were updated
140
+ * dependencies
141
+ * @twin.org/core bumped from 0.0.1-next.50 to 0.0.1-next.51
142
+
143
+ ## [0.0.1-next.50](https://github.com/twinfoundation/framework/compare/crypto-v0.0.1-next.49...crypto-v0.0.1-next.50) (2025-03-26)
144
+
145
+
146
+ ### Miscellaneous Chores
147
+
148
+ * **crypto:** Synchronize repo versions
149
+
150
+
151
+ ### Dependencies
152
+
153
+ * The following workspace dependencies were updated
154
+ * dependencies
155
+ * @twin.org/core bumped from 0.0.1-next.49 to 0.0.1-next.50
156
+
157
+ ## 0.0.1-next.49
4
158
 
5
159
  - Added: Bip44
@@ -4,13 +4,13 @@ Bech32 encoding and decoding.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Bech32()
7
+ ### Constructor
8
8
 
9
- > **new Bech32**(): [`Bech32`](Bech32.md)
9
+ > **new Bech32**(): `Bech32`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`Bech32`](Bech32.md)
13
+ `Bech32`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,11 +22,15 @@ Encode the buffer.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **humanReadablePart**: `string`
25
+ ##### humanReadablePart
26
+
27
+ `string`
26
28
 
27
29
  The header.
28
30
 
29
- **data**: `Uint8Array`
31
+ ##### data
32
+
33
+ `Uint8Array`
30
34
 
31
35
  The data to encode.
32
36
 
@@ -46,7 +50,9 @@ Decode a bech32 string.
46
50
 
47
51
  #### Parameters
48
52
 
49
- **bech**: `string`
53
+ ##### bech
54
+
55
+ `string`
50
56
 
51
57
  The text to decode.
52
58
 
@@ -78,7 +84,9 @@ Is the input a bech 32 address.
78
84
 
79
85
  #### Parameters
80
86
 
81
- **bech**: `unknown`
87
+ ##### bech
88
+
89
+ `unknown`
82
90
 
83
91
  The value to test.
84
92
 
@@ -4,39 +4,43 @@ Class to help with bip32 paths.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Bip32Path()
7
+ ### Constructor
8
8
 
9
- > **new Bip32Path**(`initialPath`?): [`Bip32Path`](Bip32Path.md)
9
+ > **new Bip32Path**(`initialPath?`): `Bip32Path`
10
10
 
11
11
  Create a new instance of Bip32Path.
12
12
 
13
13
  #### Parameters
14
14
 
15
- **initialPath?**: `string`
15
+ ##### initialPath?
16
+
17
+ `string`
16
18
 
17
19
  Initial path to create.
18
20
 
19
21
  #### Returns
20
22
 
21
- [`Bip32Path`](Bip32Path.md)
23
+ `Bip32Path`
22
24
 
23
25
  ## Methods
24
26
 
25
27
  ### fromPath()
26
28
 
27
- > `static` **fromPath**(`bip32Path`): [`Bip32Path`](Bip32Path.md)
29
+ > `static` **fromPath**(`bip32Path`): `Bip32Path`
28
30
 
29
31
  Construct a new path by cloning an existing one.
30
32
 
31
33
  #### Parameters
32
34
 
33
- **bip32Path**: [`Bip32Path`](Bip32Path.md)
35
+ ##### bip32Path
36
+
37
+ `Bip32Path`
34
38
 
35
39
  The path to clone.
36
40
 
37
41
  #### Returns
38
42
 
39
- [`Bip32Path`](Bip32Path.md)
43
+ `Bip32Path`
40
44
 
41
45
  A new instance of Bip32Path.
42
46
 
@@ -64,7 +68,9 @@ Push a new index on to the path.
64
68
 
65
69
  #### Parameters
66
70
 
67
- **index**: `number`
71
+ ##### index
72
+
73
+ `number`
68
74
 
69
75
  The index to add to the path.
70
76
 
@@ -82,7 +88,9 @@ Push a new hardened index on to the path.
82
88
 
83
89
  #### Parameters
84
90
 
85
- **index**: `number`
91
+ ##### index
92
+
93
+ `number`
86
94
 
87
95
  The index to add to the path.
88
96
 
@@ -4,13 +4,13 @@ Implementation of Bip39 for mnemonic generation.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Bip39()
7
+ ### Constructor
8
8
 
9
- > **new Bip39**(): [`Bip39`](Bip39.md)
9
+ > **new Bip39**(): `Bip39`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`Bip39`](Bip39.md)
13
+ `Bip39`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,11 +22,15 @@ Generate a random mnemonic.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **strength**: `number` = `256`
25
+ ##### strength
26
+
27
+ `number` = `256`
26
28
 
27
29
  The strength of the mnemonic to generate, defaults to 256.
28
30
 
29
- **words**: `string`[] = `wordlist`
31
+ ##### words
32
+
33
+ `string`[] = `wordlist`
30
34
 
31
35
  The wordlist to use, defaults to the English wordlist.
32
36
 
@@ -50,11 +54,15 @@ Generate a mnemonic from the entropy.
50
54
 
51
55
  #### Parameters
52
56
 
53
- **entropy**: `Uint8Array`
57
+ ##### entropy
58
+
59
+ `Uint8Array`
54
60
 
55
61
  The entropy to generate.
56
62
 
57
- **words**: `string`[] = `wordlist`
63
+ ##### words
64
+
65
+ `string`[] = `wordlist`
58
66
 
59
67
  The wordlist to use, defaults to the English wordlist.
60
68
 
@@ -72,17 +80,21 @@ Error if the length of the entropy is not a multiple of 4, or is less than 16 or
72
80
 
73
81
  ### mnemonicToSeed()
74
82
 
75
- > `static` **mnemonicToSeed**(`mnemonic`, `password`?): `Uint8Array`
83
+ > `static` **mnemonicToSeed**(`mnemonic`, `password?`): `Uint8Array`
76
84
 
77
85
  Convert a mnemonic to a seed.
78
86
 
79
87
  #### Parameters
80
88
 
81
- **mnemonic**: `string`
89
+ ##### mnemonic
90
+
91
+ `string`
82
92
 
83
93
  The mnemonic to convert.
84
94
 
85
- **password?**: `string`
95
+ ##### password?
96
+
97
+ `string`
86
98
 
87
99
  The password to apply to the seed generation.
88
100
 
@@ -102,11 +114,15 @@ Convert the mnemonic back to entropy.
102
114
 
103
115
  #### Parameters
104
116
 
105
- **mnemonic**: `string`
117
+ ##### mnemonic
118
+
119
+ `string`
106
120
 
107
121
  The mnemonic to convert.
108
122
 
109
- **words**: `string`[] = `wordlist`
123
+ ##### words
124
+
125
+ `string`[] = `wordlist`
110
126
 
111
127
  The wordlist to use, defaults to the English wordlist.
112
128
 
@@ -4,13 +4,13 @@ Implementation of Bip44 for address generation.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Bip44()
7
+ ### Constructor
8
8
 
9
- > **new Bip44**(): [`Bip44`](Bip44.md)
9
+ > **new Bip44**(): `Bip44`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`Bip44`](Bip44.md)
13
+ `Bip44`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,27 +22,39 @@ Generate a bip44 key pair from the seed and parts.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **seed**: `Uint8Array`
25
+ ##### seed
26
+
27
+ `Uint8Array`
26
28
 
27
29
  The account seed.
28
30
 
29
- **keyType**: [`KeyType`](../type-aliases/KeyType.md)
31
+ ##### keyType
32
+
33
+ [`KeyType`](../type-aliases/KeyType.md)
30
34
 
31
35
  The key type.
32
36
 
33
- **coinType**: `number`
37
+ ##### coinType
38
+
39
+ `number`
34
40
 
35
41
  The coin type.
36
42
 
37
- **accountIndex**: `number`
43
+ ##### accountIndex
44
+
45
+ `number`
38
46
 
39
47
  The account index.
40
48
 
41
- **isInternal**: `boolean`
49
+ ##### isInternal
50
+
51
+ `boolean`
42
52
 
43
53
  Is this an internal address.
44
54
 
45
- **addressIndex**: `number`
55
+ ##### addressIndex
56
+
57
+ `number`
46
58
 
47
59
  The address index.
48
60
 
@@ -74,19 +86,27 @@ Generate a bip44 path based on all its parts.
74
86
 
75
87
  #### Parameters
76
88
 
77
- **coinType**: `number`
89
+ ##### coinType
90
+
91
+ `number`
78
92
 
79
93
  The coin type.
80
94
 
81
- **accountIndex**: `number`
95
+ ##### accountIndex
96
+
97
+ `number`
82
98
 
83
99
  The account index.
84
100
 
85
- **isInternal**: `boolean`
101
+ ##### isInternal
102
+
103
+ `boolean`
86
104
 
87
105
  Is this an internal address.
88
106
 
89
- **addressIndex**: `number`
107
+ ##### addressIndex
108
+
109
+ `number`
90
110
 
91
111
  The address index.
92
112
 
@@ -106,7 +126,9 @@ Create a bip44 base path for the provided coin type.
106
126
 
107
127
  #### Parameters
108
128
 
109
- **coinType**: `number`
129
+ ##### coinType
130
+
131
+ `number`
110
132
 
111
133
  The coin type.
112
134
 
@@ -118,6 +140,70 @@ The bip44 address base path.
118
140
 
119
141
  ***
120
142
 
143
+ ### address()
144
+
145
+ > `static` **address**(`seed`, `keyType`, `coinType`, `accountIndex`, `isInternal`, `addressIndex`): `object`
146
+
147
+ Generate an address from the seed and parts.
148
+
149
+ #### Parameters
150
+
151
+ ##### seed
152
+
153
+ `Uint8Array`
154
+
155
+ The account seed.
156
+
157
+ ##### keyType
158
+
159
+ [`KeyType`](../type-aliases/KeyType.md)
160
+
161
+ The key type.
162
+
163
+ ##### coinType
164
+
165
+ `number`
166
+
167
+ The coin type.
168
+
169
+ ##### accountIndex
170
+
171
+ `number`
172
+
173
+ The account index.
174
+
175
+ ##### isInternal
176
+
177
+ `boolean`
178
+
179
+ Is this an internal address.
180
+
181
+ ##### addressIndex
182
+
183
+ `number`
184
+
185
+ The address index.
186
+
187
+ #### Returns
188
+
189
+ `object`
190
+
191
+ The generated path and the associated keypair.
192
+
193
+ ##### address
194
+
195
+ > **address**: `string`
196
+
197
+ ##### privateKey
198
+
199
+ > **privateKey**: `Uint8Array`
200
+
201
+ ##### publicKey
202
+
203
+ > **publicKey**: `Uint8Array`
204
+
205
+ ***
206
+
121
207
  ### addressBech32()
122
208
 
123
209
  > `static` **addressBech32**(`seed`, `keyType`, `hrp`, `coinType`, `accountIndex`, `isInternal`, `addressIndex`): `object`
@@ -126,31 +212,45 @@ Generate a bech32 address from the seed and parts.
126
212
 
127
213
  #### Parameters
128
214
 
129
- **seed**: `Uint8Array`
215
+ ##### seed
216
+
217
+ `Uint8Array`
130
218
 
131
219
  The account seed.
132
220
 
133
- **keyType**: [`KeyType`](../type-aliases/KeyType.md)
221
+ ##### keyType
222
+
223
+ [`KeyType`](../type-aliases/KeyType.md)
134
224
 
135
225
  The key type.
136
226
 
137
- **hrp**: `string`
227
+ ##### hrp
228
+
229
+ `string`
138
230
 
139
231
  The human readable part of the address.
140
232
 
141
- **coinType**: `number`
233
+ ##### coinType
234
+
235
+ `number`
142
236
 
143
237
  The coin type.
144
238
 
145
- **accountIndex**: `number`
239
+ ##### accountIndex
240
+
241
+ `number`
146
242
 
147
243
  The account index.
148
244
 
149
- **isInternal**: `boolean`
245
+ ##### isInternal
246
+
247
+ `boolean`
150
248
 
151
249
  Is this an internal address.
152
250
 
153
- **addressIndex**: `number`
251
+ ##### addressIndex
252
+
253
+ `number`
154
254
 
155
255
  The address index.
156
256