@twin.org/crypto 0.0.1-next.9 → 0.0.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 (31) hide show
  1. package/dist/cjs/index.cjs +51 -0
  2. package/dist/esm/index.mjs +52 -1
  3. package/dist/types/address/bip44.d.ts +15 -0
  4. package/dist/types/curves/ed25519.d.ts +12 -0
  5. package/docs/changelog.md +331 -1
  6. package/docs/reference/classes/Bech32.md +15 -7
  7. package/docs/reference/classes/Bip32Path.md +17 -9
  8. package/docs/reference/classes/Bip39.md +28 -12
  9. package/docs/reference/classes/Bip44.md +121 -21
  10. package/docs/reference/classes/Blake2b.md +35 -17
  11. package/docs/reference/classes/Blake3.md +28 -14
  12. package/docs/reference/classes/ChaCha20Poly1305.md +18 -8
  13. package/docs/reference/classes/Ed25519.md +65 -9
  14. package/docs/reference/classes/HmacSha1.md +17 -9
  15. package/docs/reference/classes/HmacSha256.md +26 -12
  16. package/docs/reference/classes/HmacSha512.md +38 -16
  17. package/docs/reference/classes/Hotp.md +9 -5
  18. package/docs/reference/classes/PasswordGenerator.md +6 -4
  19. package/docs/reference/classes/PasswordValidator.md +23 -11
  20. package/docs/reference/classes/Pbkdf2.md +27 -11
  21. package/docs/reference/classes/Secp256k1.md +21 -9
  22. package/docs/reference/classes/Sha1.md +11 -7
  23. package/docs/reference/classes/Sha256.md +17 -9
  24. package/docs/reference/classes/Sha3.md +23 -11
  25. package/docs/reference/classes/Sha512.md +23 -11
  26. package/docs/reference/classes/Slip0010.md +27 -11
  27. package/docs/reference/classes/Totp.md +42 -16
  28. package/docs/reference/classes/X25519.md +9 -5
  29. package/docs/reference/classes/Zip215.md +12 -6
  30. package/docs/reference/type-aliases/KeyType.md +1 -1
  31. package/package.json +13 -13
@@ -4,15 +4,15 @@ Perform a SHA-1 hash on the block.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Sha1()
7
+ ### Constructor
8
8
 
9
- > **new Sha1**(): [`Sha1`](Sha1.md)
9
+ > **new Sha1**(): `Sha1`
10
10
 
11
11
  Create a new instance of Sha1.
12
12
 
13
13
  #### Returns
14
14
 
15
- [`Sha1`](Sha1.md)
15
+ `Sha1`
16
16
 
17
17
  ## Methods
18
18
 
@@ -24,7 +24,9 @@ Perform Sum on the block.
24
24
 
25
25
  #### Parameters
26
26
 
27
- **block**: `Uint8Array`
27
+ ##### block
28
+
29
+ `Uint8Array`
28
30
 
29
31
  The block to operate on.
30
32
 
@@ -38,19 +40,21 @@ The sum of the block.
38
40
 
39
41
  ### update()
40
42
 
41
- > **update**(`block`): [`Sha1`](Sha1.md)
43
+ > **update**(`block`): `Sha1`
42
44
 
43
45
  Update the hash with the block.
44
46
 
45
47
  #### Parameters
46
48
 
47
- **block**: `Uint8Array`
49
+ ##### block
50
+
51
+ `Uint8Array`
48
52
 
49
53
  The block to update the hash with.
50
54
 
51
55
  #### Returns
52
56
 
53
- [`Sha1`](Sha1.md)
57
+ `Sha1`
54
58
 
55
59
  The instance for chaining.
56
60
 
@@ -4,21 +4,23 @@ Perform a SHA-256 hash on the block.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Sha256()
7
+ ### Constructor
8
8
 
9
- > **new Sha256**(`bits`): [`Sha256`](Sha256.md)
9
+ > **new Sha256**(`bits`): `Sha256`
10
10
 
11
11
  Create a new instance of Sha256.
12
12
 
13
13
  #### Parameters
14
14
 
15
- **bits**: `number` = `Sha256.SIZE_256`
15
+ ##### bits
16
+
17
+ `number` = `Sha256.SIZE_256`
16
18
 
17
19
  The number of bits.
18
20
 
19
21
  #### Returns
20
22
 
21
- [`Sha256`](Sha256.md)
23
+ `Sha256`
22
24
 
23
25
  ## Properties
24
26
 
@@ -46,7 +48,9 @@ Perform Sum 256 on the block.
46
48
 
47
49
  #### Parameters
48
50
 
49
- **block**: `Uint8Array`
51
+ ##### block
52
+
53
+ `Uint8Array`
50
54
 
51
55
  The block to operate on.
52
56
 
@@ -66,7 +70,9 @@ Perform Sum 224 on the block.
66
70
 
67
71
  #### Parameters
68
72
 
69
- **block**: `Uint8Array`
73
+ ##### block
74
+
75
+ `Uint8Array`
70
76
 
71
77
  The block to operate on.
72
78
 
@@ -80,19 +86,21 @@ The sum 224 of the block.
80
86
 
81
87
  ### update()
82
88
 
83
- > **update**(`block`): [`Sha256`](Sha256.md)
89
+ > **update**(`block`): `Sha256`
84
90
 
85
91
  Update the hash with the block.
86
92
 
87
93
  #### Parameters
88
94
 
89
- **block**: `Uint8Array`
95
+ ##### block
96
+
97
+ `Uint8Array`
90
98
 
91
99
  The block to update the hash with.
92
100
 
93
101
  #### Returns
94
102
 
95
- [`Sha256`](Sha256.md)
103
+ `Sha256`
96
104
 
97
105
  The instance for chaining.
98
106
 
@@ -4,21 +4,23 @@ Perform a SHA-3 hash on the block.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Sha3()
7
+ ### Constructor
8
8
 
9
- > **new Sha3**(`bits`): [`Sha3`](Sha3.md)
9
+ > **new Sha3**(`bits`): `Sha3`
10
10
 
11
11
  Create a new instance of Sha3.
12
12
 
13
13
  #### Parameters
14
14
 
15
- **bits**: `number` = `Sha3.SIZE_256`
15
+ ##### bits
16
+
17
+ `number` = `Sha3.SIZE_256`
16
18
 
17
19
  The number of bits.
18
20
 
19
21
  #### Returns
20
22
 
21
- [`Sha3`](Sha3.md)
23
+ `Sha3`
22
24
 
23
25
  ## Properties
24
26
 
@@ -62,7 +64,9 @@ Perform Sum 256 on the block.
62
64
 
63
65
  #### Parameters
64
66
 
65
- **block**: `Uint8Array`
67
+ ##### block
68
+
69
+ `Uint8Array`
66
70
 
67
71
  The block to operate on.
68
72
 
@@ -82,7 +86,9 @@ Perform Sum 224 on the block.
82
86
 
83
87
  #### Parameters
84
88
 
85
- **block**: `Uint8Array`
89
+ ##### block
90
+
91
+ `Uint8Array`
86
92
 
87
93
  The block to operate on.
88
94
 
@@ -102,7 +108,9 @@ Perform Sum 384 on the block.
102
108
 
103
109
  #### Parameters
104
110
 
105
- **block**: `Uint8Array`
111
+ ##### block
112
+
113
+ `Uint8Array`
106
114
 
107
115
  The block to operate on.
108
116
 
@@ -122,7 +130,9 @@ Perform Sum 512 on the block.
122
130
 
123
131
  #### Parameters
124
132
 
125
- **block**: `Uint8Array`
133
+ ##### block
134
+
135
+ `Uint8Array`
126
136
 
127
137
  The block to operate on.
128
138
 
@@ -136,19 +146,21 @@ The sum 512 of the block.
136
146
 
137
147
  ### update()
138
148
 
139
- > **update**(`block`): [`Sha3`](Sha3.md)
149
+ > **update**(`block`): `Sha3`
140
150
 
141
151
  Update the hash with the block.
142
152
 
143
153
  #### Parameters
144
154
 
145
- **block**: `Uint8Array`
155
+ ##### block
156
+
157
+ `Uint8Array`
146
158
 
147
159
  The block to update the hash with.
148
160
 
149
161
  #### Returns
150
162
 
151
- [`Sha3`](Sha3.md)
163
+ `Sha3`
152
164
 
153
165
  The instance for chaining.
154
166
 
@@ -4,21 +4,23 @@ Perform a SHA-512 hash on the block.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Sha512()
7
+ ### Constructor
8
8
 
9
- > **new Sha512**(`bits`): [`Sha512`](Sha512.md)
9
+ > **new Sha512**(`bits`): `Sha512`
10
10
 
11
11
  Create a new instance of Sha512.
12
12
 
13
13
  #### Parameters
14
14
 
15
- **bits**: `number` = `Sha512.SIZE_512`
15
+ ##### bits
16
+
17
+ `number` = `Sha512.SIZE_512`
16
18
 
17
19
  The number of bits.
18
20
 
19
21
  #### Returns
20
22
 
21
- [`Sha512`](Sha512.md)
23
+ `Sha512`
22
24
 
23
25
  ## Properties
24
26
 
@@ -62,7 +64,9 @@ Perform Sum 512 on the block.
62
64
 
63
65
  #### Parameters
64
66
 
65
- **block**: `Uint8Array`
67
+ ##### block
68
+
69
+ `Uint8Array`
66
70
 
67
71
  The block to operate on.
68
72
 
@@ -82,7 +86,9 @@ Perform Sum 384 on the block.
82
86
 
83
87
  #### Parameters
84
88
 
85
- **block**: `Uint8Array`
89
+ ##### block
90
+
91
+ `Uint8Array`
86
92
 
87
93
  The block to operate on.
88
94
 
@@ -102,7 +108,9 @@ Perform Sum 256 on the block.
102
108
 
103
109
  #### Parameters
104
110
 
105
- **block**: `Uint8Array`
111
+ ##### block
112
+
113
+ `Uint8Array`
106
114
 
107
115
  The block to operate on.
108
116
 
@@ -122,7 +130,9 @@ Perform Sum 224 on the block.
122
130
 
123
131
  #### Parameters
124
132
 
125
- **block**: `Uint8Array`
133
+ ##### block
134
+
135
+ `Uint8Array`
126
136
 
127
137
  The block to operate on.
128
138
 
@@ -136,19 +146,21 @@ The sum 224 of the block.
136
146
 
137
147
  ### update()
138
148
 
139
- > **update**(`block`): [`Sha512`](Sha512.md)
149
+ > **update**(`block`): `Sha512`
140
150
 
141
151
  Update the hash with the block.
142
152
 
143
153
  #### Parameters
144
154
 
145
- **block**: `Uint8Array`
155
+ ##### block
156
+
157
+ `Uint8Array`
146
158
 
147
159
  The block to update the hash with.
148
160
 
149
161
  #### Returns
150
162
 
151
- [`Sha512`](Sha512.md)
163
+ `Sha512`
152
164
 
153
165
  The instance for chaining.
154
166
 
@@ -5,13 +5,13 @@ https://github.com/satoshilabs/slips/blob/master/slip-0010.md.
5
5
 
6
6
  ## Constructors
7
7
 
8
- ### new Slip0010()
8
+ ### Constructor
9
9
 
10
- > **new Slip0010**(): [`Slip0010`](Slip0010.md)
10
+ > **new Slip0010**(): `Slip0010`
11
11
 
12
12
  #### Returns
13
13
 
14
- [`Slip0010`](Slip0010.md)
14
+ `Slip0010`
15
15
 
16
16
  ## Methods
17
17
 
@@ -23,11 +23,15 @@ Get the master key from the seed.
23
23
 
24
24
  #### Parameters
25
25
 
26
- **seed**: `Uint8Array`
26
+ ##### seed
27
+
28
+ `Uint8Array`
27
29
 
28
30
  The seed to generate the master key from.
29
31
 
30
- **keyType**: [`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
32
+ ##### keyType
33
+
34
+ [`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
31
35
 
32
36
  The key type.
33
37
 
@@ -59,15 +63,21 @@ Derive a key from the path.
59
63
 
60
64
  #### Parameters
61
65
 
62
- **seed**: `Uint8Array`
66
+ ##### seed
67
+
68
+ `Uint8Array`
63
69
 
64
70
  The seed.
65
71
 
66
- **path**: [`Bip32Path`](Bip32Path.md)
72
+ ##### path
73
+
74
+ [`Bip32Path`](Bip32Path.md)
67
75
 
68
76
  The path.
69
77
 
70
- **keyType**: [`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
78
+ ##### keyType
79
+
80
+ [`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
71
81
 
72
82
  The key type.
73
83
 
@@ -95,15 +105,21 @@ Get the public key from the private key.
95
105
 
96
106
  #### Parameters
97
107
 
98
- **privateKey**: `Uint8Array`
108
+ ##### privateKey
109
+
110
+ `Uint8Array`
99
111
 
100
112
  The private key.
101
113
 
102
- **keyType**: [`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
114
+ ##### keyType
115
+
116
+ [`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
103
117
 
104
118
  The key type.
105
119
 
106
- **withZeroByte**: `boolean` = `true`
120
+ ##### withZeroByte
121
+
122
+ `boolean` = `true`
107
123
 
108
124
  Include a zero bute prefix.
109
125
 
@@ -5,13 +5,13 @@ Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .
5
5
 
6
6
  ## Constructors
7
7
 
8
- ### new Totp()
8
+ ### Constructor
9
9
 
10
- > **new Totp**(): [`Totp`](Totp.md)
10
+ > **new Totp**(): `Totp`
11
11
 
12
12
  #### Returns
13
13
 
14
- [`Totp`](Totp.md)
14
+ `Totp`
15
15
 
16
16
  ## Methods
17
17
 
@@ -23,15 +23,21 @@ Generate a time based One Time Password.
23
23
 
24
24
  #### Parameters
25
25
 
26
- **key**: `Uint8Array`
26
+ ##### key
27
+
28
+ `Uint8Array`
27
29
 
28
30
  Key for the one time password.
29
31
 
30
- **interval**: `number` = `30`
32
+ ##### interval
33
+
34
+ `number` = `30`
31
35
 
32
36
  The time step of the counter.
33
37
 
34
- **timestamp**: `number` = `...`
38
+ ##### timestamp
39
+
40
+ `number` = `...`
35
41
 
36
42
  The timestamp.
37
43
 
@@ -51,24 +57,34 @@ Check a One Time Password based on a timer.
51
57
 
52
58
  #### Parameters
53
59
 
54
- **token**: `string`
60
+ ##### token
61
+
62
+ `string`
55
63
 
56
64
  Passcode to validate.
57
65
 
58
- **key**: `Uint8Array`
66
+ ##### key
67
+
68
+ `Uint8Array`
59
69
 
60
70
  Key for the one time password. This should be unique and secret for
61
71
  every user as it is the seed used to calculate the HMAC.
62
72
 
63
- **window**: `number` = `2`
73
+ ##### window
74
+
75
+ `number` = `2`
64
76
 
65
77
  The allowable margin for the counter.
66
78
 
67
- **interval**: `number` = `30`
79
+ ##### interval
80
+
81
+ `number` = `30`
68
82
 
69
83
  The time step of the counter.
70
84
 
71
- **timestamp**: `number` = `...`
85
+ ##### timestamp
86
+
87
+ `number` = `...`
72
88
 
73
89
  The timestamp now.
74
90
 
@@ -88,7 +104,9 @@ Generate a secret.
88
104
 
89
105
  #### Parameters
90
106
 
91
- **length**: `number`
107
+ ##### length
108
+
109
+ `number`
92
110
 
93
111
  The length of the secret to generate.
94
112
 
@@ -108,7 +126,9 @@ Convert the secret back to bytes.
108
126
 
109
127
  #### Parameters
110
128
 
111
- **secretBase32**: `string`
129
+ ##### secretBase32
130
+
131
+ `string`
112
132
 
113
133
  The secret encoded as base32.
114
134
 
@@ -129,15 +149,21 @@ See https://github.com/google/google-authenticator/wiki/Key-Uri-Format .
129
149
 
130
150
  #### Parameters
131
151
 
132
- **issuer**: `string`
152
+ ##### issuer
153
+
154
+ `string`
133
155
 
134
156
  The issuer of the totp.
135
157
 
136
- **label**: `string`
158
+ ##### label
159
+
160
+ `string`
137
161
 
138
162
  The label that will show in auth apps.
139
163
 
140
- **secretBase32**: `string`
164
+ ##### secretBase32
165
+
166
+ `string`
141
167
 
142
168
  The secret as base 32.
143
169
 
@@ -4,13 +4,13 @@ Implementation of X25519.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new X25519()
7
+ ### Constructor
8
8
 
9
- > **new X25519**(): [`X25519`](X25519.md)
9
+ > **new X25519**(): `X25519`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`X25519`](X25519.md)
13
+ `X25519`
14
14
 
15
15
  ## Methods
16
16
 
@@ -22,7 +22,9 @@ Convert Ed25519 private key to X25519 private key.
22
22
 
23
23
  #### Parameters
24
24
 
25
- **ed25519PrivateKey**: `Uint8Array`
25
+ ##### ed25519PrivateKey
26
+
27
+ `Uint8Array`
26
28
 
27
29
  The ed25519 private key to convert.
28
30
 
@@ -42,7 +44,9 @@ Convert Ed25519 public key to X25519 public key.
42
44
 
43
45
  #### Parameters
44
46
 
45
- **ed25519PublicKey**: `Uint8Array`
47
+ ##### ed25519PublicKey
48
+
49
+ `Uint8Array`
46
50
 
47
51
  The ed25519 public key to convert.
48
52
 
@@ -4,13 +4,13 @@ Implementation of Zip215.
4
4
 
5
5
  ## Constructors
6
6
 
7
- ### new Zip215()
7
+ ### Constructor
8
8
 
9
- > **new Zip215**(): [`Zip215`](Zip215.md)
9
+ > **new Zip215**(): `Zip215`
10
10
 
11
11
  #### Returns
12
12
 
13
- [`Zip215`](Zip215.md)
13
+ `Zip215`
14
14
 
15
15
  ## Methods
16
16
 
@@ -24,15 +24,21 @@ for use in consensus-critical contexts.
24
24
 
25
25
  #### Parameters
26
26
 
27
- **publicKey**: `Uint8Array`
27
+ ##### publicKey
28
+
29
+ `Uint8Array`
28
30
 
29
31
  The public key for the block.
30
32
 
31
- **block**: `Uint8Array`
33
+ ##### block
34
+
35
+ `Uint8Array`
32
36
 
33
37
  The block content to validate.
34
38
 
35
- **sig**: `Uint8Array`
39
+ ##### sig
40
+
41
+ `Uint8Array`
36
42
 
37
43
  The signature to verify.
38
44
 
@@ -1,5 +1,5 @@
1
1
  # Type Alias: KeyType
2
2
 
3
- > **KeyType**: *typeof* [`KeyType`](../variables/KeyType.md)\[keyof *typeof* [`KeyType`](../variables/KeyType.md)\]
3
+ > **KeyType** = *typeof* [`KeyType`](../variables/KeyType.md)\[keyof *typeof* [`KeyType`](../variables/KeyType.md)\]
4
4
 
5
5
  Key types.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/crypto",
3
- "version": "0.0.1-next.9",
3
+ "version": "0.0.1",
4
4
  "description": "Contains helper methods and classes which implement cryptographic functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,26 +14,26 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@noble/ciphers": "1.0.0",
18
- "@noble/curves": "1.6.0",
19
- "@noble/hashes": "1.5.0",
20
- "@scure/base": "1.1.9",
21
- "@scure/bip32": "1.5.0",
22
- "@scure/bip39": "1.4.0",
23
- "@twin.org/core": "0.0.1-next.9",
24
- "@twin.org/nameof": "next",
25
- "micro-key-producer": "0.7.0"
17
+ "@noble/ciphers": "1.3.0",
18
+ "@noble/curves": "1.9.2",
19
+ "@noble/hashes": "1.8.0",
20
+ "@scure/base": "1.2.6",
21
+ "@scure/bip32": "1.7.0",
22
+ "@scure/bip39": "1.6.0",
23
+ "@twin.org/core": "^0.0.1",
24
+ "@twin.org/nameof": "^0.0.1",
25
+ "micro-key-producer": "0.7.6"
26
26
  },
27
27
  "main": "./dist/cjs/index.cjs",
28
28
  "module": "./dist/esm/index.mjs",
29
29
  "types": "./dist/types/index.d.ts",
30
30
  "exports": {
31
31
  ".": {
32
+ "types": "./dist/types/index.d.ts",
32
33
  "require": "./dist/cjs/index.cjs",
33
- "import": "./dist/esm/index.mjs",
34
- "types": "./dist/types/index.d.ts"
34
+ "import": "./dist/esm/index.mjs"
35
35
  },
36
- "./locales": "./locales"
36
+ "./locales/*.json": "./locales/*.json"
37
37
  },
38
38
  "files": [
39
39
  "dist/cjs",