@twin.org/crypto 0.0.1-next.17 → 0.0.1-next.19
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/docs/changelog.md +1 -1
- package/docs/reference/classes/Bech32.md +12 -4
- package/docs/reference/classes/Bip32Path.md +12 -4
- package/docs/reference/classes/Bip39.md +24 -8
- package/docs/reference/classes/Bip44.md +54 -18
- package/docs/reference/classes/Blake2b.md +27 -9
- package/docs/reference/classes/Blake3.md +21 -7
- package/docs/reference/classes/ChaCha20Poly1305.md +15 -5
- package/docs/reference/classes/Ed25519.md +18 -6
- package/docs/reference/classes/HmacSha1.md +12 -4
- package/docs/reference/classes/HmacSha256.md +21 -7
- package/docs/reference/classes/HmacSha512.md +33 -11
- package/docs/reference/classes/Hotp.md +6 -2
- package/docs/reference/classes/PasswordGenerator.md +3 -1
- package/docs/reference/classes/PasswordValidator.md +19 -7
- package/docs/reference/classes/Pbkdf2.md +24 -8
- package/docs/reference/classes/Secp256k1.md +18 -6
- package/docs/reference/classes/Sha1.md +6 -2
- package/docs/reference/classes/Sha256.md +12 -4
- package/docs/reference/classes/Sha3.md +18 -6
- package/docs/reference/classes/Sha512.md +18 -6
- package/docs/reference/classes/Slip0010.md +24 -8
- package/docs/reference/classes/Totp.md +39 -13
- package/docs/reference/classes/X25519.md +6 -2
- package/docs/reference/classes/Zip215.md +9 -3
- package/package.json +2 -2
package/docs/changelog.md
CHANGED
|
@@ -22,11 +22,15 @@ Encode the buffer.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### humanReadablePart
|
|
26
|
+
|
|
27
|
+
`string`
|
|
26
28
|
|
|
27
29
|
The header.
|
|
28
30
|
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
87
|
+
##### bech
|
|
88
|
+
|
|
89
|
+
`unknown`
|
|
82
90
|
|
|
83
91
|
The value to test.
|
|
84
92
|
|
|
@@ -12,7 +12,9 @@ Create a new instance of Bip32Path.
|
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### initialPath?
|
|
16
|
+
|
|
17
|
+
`string`
|
|
16
18
|
|
|
17
19
|
Initial path to create.
|
|
18
20
|
|
|
@@ -30,7 +32,9 @@ Construct a new path by cloning an existing one.
|
|
|
30
32
|
|
|
31
33
|
#### Parameters
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
##### bip32Path
|
|
36
|
+
|
|
37
|
+
[`Bip32Path`](Bip32Path.md)
|
|
34
38
|
|
|
35
39
|
The path to clone.
|
|
36
40
|
|
|
@@ -64,7 +68,9 @@ Push a new index on to the path.
|
|
|
64
68
|
|
|
65
69
|
#### Parameters
|
|
66
70
|
|
|
67
|
-
|
|
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
|
-
|
|
91
|
+
##### index
|
|
92
|
+
|
|
93
|
+
`number`
|
|
86
94
|
|
|
87
95
|
The index to add to the path.
|
|
88
96
|
|
|
@@ -22,11 +22,15 @@ Generate a random mnemonic.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### strength
|
|
26
|
+
|
|
27
|
+
`number` = `256`
|
|
26
28
|
|
|
27
29
|
The strength of the mnemonic to generate, defaults to 256.
|
|
28
30
|
|
|
29
|
-
|
|
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
|
-
|
|
57
|
+
##### entropy
|
|
58
|
+
|
|
59
|
+
`Uint8Array`
|
|
54
60
|
|
|
55
61
|
The entropy to generate.
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### words
|
|
64
|
+
|
|
65
|
+
`string`[] = `wordlist`
|
|
58
66
|
|
|
59
67
|
The wordlist to use, defaults to the English wordlist.
|
|
60
68
|
|
|
@@ -78,11 +86,15 @@ Convert a mnemonic to a seed.
|
|
|
78
86
|
|
|
79
87
|
#### Parameters
|
|
80
88
|
|
|
81
|
-
|
|
89
|
+
##### mnemonic
|
|
90
|
+
|
|
91
|
+
`string`
|
|
82
92
|
|
|
83
93
|
The mnemonic to convert.
|
|
84
94
|
|
|
85
|
-
|
|
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
|
-
|
|
117
|
+
##### mnemonic
|
|
118
|
+
|
|
119
|
+
`string`
|
|
106
120
|
|
|
107
121
|
The mnemonic to convert.
|
|
108
122
|
|
|
109
|
-
|
|
123
|
+
##### words
|
|
124
|
+
|
|
125
|
+
`string`[] = `wordlist`
|
|
110
126
|
|
|
111
127
|
The wordlist to use, defaults to the English wordlist.
|
|
112
128
|
|
|
@@ -22,27 +22,39 @@ Generate a bip44 key pair from the seed and parts.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### seed
|
|
26
|
+
|
|
27
|
+
`Uint8Array`
|
|
26
28
|
|
|
27
29
|
The account seed.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### keyType
|
|
32
|
+
|
|
33
|
+
[`KeyType`](../type-aliases/KeyType.md)
|
|
30
34
|
|
|
31
35
|
The key type.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### coinType
|
|
38
|
+
|
|
39
|
+
`number`
|
|
34
40
|
|
|
35
41
|
The coin type.
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
##### accountIndex
|
|
44
|
+
|
|
45
|
+
`number`
|
|
38
46
|
|
|
39
47
|
The account index.
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
##### isInternal
|
|
50
|
+
|
|
51
|
+
`boolean`
|
|
42
52
|
|
|
43
53
|
Is this an internal address.
|
|
44
54
|
|
|
45
|
-
|
|
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
|
-
|
|
89
|
+
##### coinType
|
|
90
|
+
|
|
91
|
+
`number`
|
|
78
92
|
|
|
79
93
|
The coin type.
|
|
80
94
|
|
|
81
|
-
|
|
95
|
+
##### accountIndex
|
|
96
|
+
|
|
97
|
+
`number`
|
|
82
98
|
|
|
83
99
|
The account index.
|
|
84
100
|
|
|
85
|
-
|
|
101
|
+
##### isInternal
|
|
102
|
+
|
|
103
|
+
`boolean`
|
|
86
104
|
|
|
87
105
|
Is this an internal address.
|
|
88
106
|
|
|
89
|
-
|
|
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
|
-
|
|
129
|
+
##### coinType
|
|
130
|
+
|
|
131
|
+
`number`
|
|
110
132
|
|
|
111
133
|
The coin type.
|
|
112
134
|
|
|
@@ -126,31 +148,45 @@ Generate a bech32 address from the seed and parts.
|
|
|
126
148
|
|
|
127
149
|
#### Parameters
|
|
128
150
|
|
|
129
|
-
|
|
151
|
+
##### seed
|
|
152
|
+
|
|
153
|
+
`Uint8Array`
|
|
130
154
|
|
|
131
155
|
The account seed.
|
|
132
156
|
|
|
133
|
-
|
|
157
|
+
##### keyType
|
|
158
|
+
|
|
159
|
+
[`KeyType`](../type-aliases/KeyType.md)
|
|
134
160
|
|
|
135
161
|
The key type.
|
|
136
162
|
|
|
137
|
-
|
|
163
|
+
##### hrp
|
|
164
|
+
|
|
165
|
+
`string`
|
|
138
166
|
|
|
139
167
|
The human readable part of the address.
|
|
140
168
|
|
|
141
|
-
|
|
169
|
+
##### coinType
|
|
170
|
+
|
|
171
|
+
`number`
|
|
142
172
|
|
|
143
173
|
The coin type.
|
|
144
174
|
|
|
145
|
-
|
|
175
|
+
##### accountIndex
|
|
176
|
+
|
|
177
|
+
`number`
|
|
146
178
|
|
|
147
179
|
The account index.
|
|
148
180
|
|
|
149
|
-
|
|
181
|
+
##### isInternal
|
|
182
|
+
|
|
183
|
+
`boolean`
|
|
150
184
|
|
|
151
185
|
Is this an internal address.
|
|
152
186
|
|
|
153
|
-
|
|
187
|
+
##### addressIndex
|
|
188
|
+
|
|
189
|
+
`number`
|
|
154
190
|
|
|
155
191
|
The address index.
|
|
156
192
|
|
|
@@ -12,11 +12,15 @@ Create a new instance of Blake2b.
|
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### outputLength
|
|
16
|
+
|
|
17
|
+
`number`
|
|
16
18
|
|
|
17
19
|
The output length.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
##### key?
|
|
22
|
+
|
|
23
|
+
`Uint8Array`
|
|
20
24
|
|
|
21
25
|
Optional key for the hash.
|
|
22
26
|
|
|
@@ -58,11 +62,15 @@ Perform Sum 160 on the block.
|
|
|
58
62
|
|
|
59
63
|
#### Parameters
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
##### block
|
|
66
|
+
|
|
67
|
+
`Uint8Array`
|
|
62
68
|
|
|
63
69
|
The block to operate on.
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
##### key?
|
|
72
|
+
|
|
73
|
+
`Uint8Array`
|
|
66
74
|
|
|
67
75
|
Optional key for the hash.
|
|
68
76
|
|
|
@@ -82,11 +90,15 @@ Perform Sum 256 on the block.
|
|
|
82
90
|
|
|
83
91
|
#### Parameters
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
##### block
|
|
94
|
+
|
|
95
|
+
`Uint8Array`
|
|
86
96
|
|
|
87
97
|
The block to operate on.
|
|
88
98
|
|
|
89
|
-
|
|
99
|
+
##### key?
|
|
100
|
+
|
|
101
|
+
`Uint8Array`
|
|
90
102
|
|
|
91
103
|
Optional key for the hash.
|
|
92
104
|
|
|
@@ -106,11 +118,15 @@ Perform Sum 512 on the block.
|
|
|
106
118
|
|
|
107
119
|
#### Parameters
|
|
108
120
|
|
|
109
|
-
|
|
121
|
+
##### block
|
|
122
|
+
|
|
123
|
+
`Uint8Array`
|
|
110
124
|
|
|
111
125
|
The block to operate on.
|
|
112
126
|
|
|
113
|
-
|
|
127
|
+
##### key?
|
|
128
|
+
|
|
129
|
+
`Uint8Array`
|
|
114
130
|
|
|
115
131
|
Optional key for the hash.
|
|
116
132
|
|
|
@@ -130,7 +146,9 @@ Update the hash with the block.
|
|
|
130
146
|
|
|
131
147
|
#### Parameters
|
|
132
148
|
|
|
133
|
-
|
|
149
|
+
##### block
|
|
150
|
+
|
|
151
|
+
`Uint8Array`
|
|
134
152
|
|
|
135
153
|
The block to update the hash with.
|
|
136
154
|
|
|
@@ -12,11 +12,15 @@ Create a new instance of Blake3.
|
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### outputLength
|
|
16
|
+
|
|
17
|
+
`number`
|
|
16
18
|
|
|
17
19
|
The output length.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
##### key?
|
|
22
|
+
|
|
23
|
+
`Uint8Array`
|
|
20
24
|
|
|
21
25
|
Optional key for the hash.
|
|
22
26
|
|
|
@@ -50,11 +54,15 @@ Perform Sum 256 on the block.
|
|
|
50
54
|
|
|
51
55
|
#### Parameters
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
##### block
|
|
58
|
+
|
|
59
|
+
`Uint8Array`
|
|
54
60
|
|
|
55
61
|
The block to operate on.
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### key?
|
|
64
|
+
|
|
65
|
+
`Uint8Array`
|
|
58
66
|
|
|
59
67
|
Optional key for the hash.
|
|
60
68
|
|
|
@@ -74,11 +82,15 @@ Perform Sum 512 on the block.
|
|
|
74
82
|
|
|
75
83
|
#### Parameters
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
##### block
|
|
86
|
+
|
|
87
|
+
`Uint8Array`
|
|
78
88
|
|
|
79
89
|
The block to operate on.
|
|
80
90
|
|
|
81
|
-
|
|
91
|
+
##### key?
|
|
92
|
+
|
|
93
|
+
`Uint8Array`
|
|
82
94
|
|
|
83
95
|
Optional key for the hash.
|
|
84
96
|
|
|
@@ -98,7 +110,9 @@ Update the hash with the block.
|
|
|
98
110
|
|
|
99
111
|
#### Parameters
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
##### block
|
|
114
|
+
|
|
115
|
+
`Uint8Array`
|
|
102
116
|
|
|
103
117
|
The block to update the hash with.
|
|
104
118
|
|
|
@@ -12,15 +12,21 @@ Create a new instance of ChaCha20Poly1305.
|
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### key
|
|
16
|
+
|
|
17
|
+
`Uint8Array`
|
|
16
18
|
|
|
17
19
|
The key.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
##### nonce
|
|
22
|
+
|
|
23
|
+
`Uint8Array`
|
|
20
24
|
|
|
21
25
|
The nonce.
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
##### aad?
|
|
28
|
+
|
|
29
|
+
`Uint8Array`
|
|
24
30
|
|
|
25
31
|
The additional authenticated data.
|
|
26
32
|
|
|
@@ -38,7 +44,9 @@ Encrypt the block.
|
|
|
38
44
|
|
|
39
45
|
#### Parameters
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
##### block
|
|
48
|
+
|
|
49
|
+
`Uint8Array`
|
|
42
50
|
|
|
43
51
|
The block to encrypt.
|
|
44
52
|
|
|
@@ -58,7 +66,9 @@ Decrypt the block.
|
|
|
58
66
|
|
|
59
67
|
#### Parameters
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
##### block
|
|
70
|
+
|
|
71
|
+
`Uint8Array`
|
|
62
72
|
|
|
63
73
|
The block to decrypt.
|
|
64
74
|
|
|
@@ -38,7 +38,9 @@ Public returns the PublicKey corresponding to private.
|
|
|
38
38
|
|
|
39
39
|
#### Parameters
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
##### privateKey
|
|
42
|
+
|
|
43
|
+
`Uint8Array`
|
|
42
44
|
|
|
43
45
|
The private key to get the corresponding public key.
|
|
44
46
|
|
|
@@ -62,11 +64,15 @@ Sign the block with privateKey and returns a signature.
|
|
|
62
64
|
|
|
63
65
|
#### Parameters
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
##### privateKey
|
|
68
|
+
|
|
69
|
+
`Uint8Array`
|
|
66
70
|
|
|
67
71
|
The private key.
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
##### block
|
|
74
|
+
|
|
75
|
+
`Uint8Array`
|
|
70
76
|
|
|
71
77
|
The block to sign.
|
|
72
78
|
|
|
@@ -90,15 +96,21 @@ Verify reports whether sig is a valid signature of block by publicKey.
|
|
|
90
96
|
|
|
91
97
|
#### Parameters
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
##### publicKey
|
|
100
|
+
|
|
101
|
+
`Uint8Array`
|
|
94
102
|
|
|
95
103
|
The public key to verify the signature.
|
|
96
104
|
|
|
97
|
-
|
|
105
|
+
##### block
|
|
106
|
+
|
|
107
|
+
`Uint8Array`
|
|
98
108
|
|
|
99
109
|
The block for the signature.
|
|
100
110
|
|
|
101
|
-
|
|
111
|
+
##### signature
|
|
112
|
+
|
|
113
|
+
`Uint8Array`
|
|
102
114
|
|
|
103
115
|
The signature.
|
|
104
116
|
|
|
@@ -12,7 +12,9 @@ Create a new instance of HmacSha1.
|
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### key
|
|
16
|
+
|
|
17
|
+
`Uint8Array`
|
|
16
18
|
|
|
17
19
|
The key for the hmac.
|
|
18
20
|
|
|
@@ -30,11 +32,15 @@ Perform Sum on the block.
|
|
|
30
32
|
|
|
31
33
|
#### Parameters
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
##### key
|
|
36
|
+
|
|
37
|
+
`Uint8Array`
|
|
34
38
|
|
|
35
39
|
The key for the hmac.
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
##### block
|
|
42
|
+
|
|
43
|
+
`Uint8Array`
|
|
38
44
|
|
|
39
45
|
The block to operate on.
|
|
40
46
|
|
|
@@ -54,7 +60,9 @@ Update the hash with the block.
|
|
|
54
60
|
|
|
55
61
|
#### Parameters
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### block
|
|
64
|
+
|
|
65
|
+
`Uint8Array`
|
|
58
66
|
|
|
59
67
|
The block to update the hash with.
|
|
60
68
|
|
|
@@ -12,11 +12,15 @@ Create a new instance of HmacSha256.
|
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
##### key
|
|
16
|
+
|
|
17
|
+
`Uint8Array`
|
|
16
18
|
|
|
17
19
|
The key for the hmac.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
##### bits
|
|
22
|
+
|
|
23
|
+
`number` = `HmacSha256.SIZE_256`
|
|
20
24
|
|
|
21
25
|
The number of bits.
|
|
22
26
|
|
|
@@ -50,11 +54,15 @@ Perform Sum 224 on the block.
|
|
|
50
54
|
|
|
51
55
|
#### Parameters
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
##### key
|
|
58
|
+
|
|
59
|
+
`Uint8Array`
|
|
54
60
|
|
|
55
61
|
The key for the hmac.
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### block
|
|
64
|
+
|
|
65
|
+
`Uint8Array`
|
|
58
66
|
|
|
59
67
|
The block to operate on.
|
|
60
68
|
|
|
@@ -74,11 +82,15 @@ Perform Sum 256 on the block.
|
|
|
74
82
|
|
|
75
83
|
#### Parameters
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
##### key
|
|
86
|
+
|
|
87
|
+
`Uint8Array`
|
|
78
88
|
|
|
79
89
|
The key for the hmac.
|
|
80
90
|
|
|
81
|
-
|
|
91
|
+
##### block
|
|
92
|
+
|
|
93
|
+
`Uint8Array`
|
|
82
94
|
|
|
83
95
|
The block to operate on.
|
|
84
96
|
|
|
@@ -98,7 +110,9 @@ Update the hash with the block.
|
|
|
98
110
|
|
|
99
111
|
#### Parameters
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
##### block
|
|
114
|
+
|
|
115
|
+
`Uint8Array`
|
|
102
116
|
|
|
103
117
|
The block to update the hash with.
|
|
104
118
|
|