@twin.org/crypto 0.0.3-next.21 → 0.0.3-next.23
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/README.md +1 -11
- package/docs/changelog.md +39 -1
- package/docs/examples.md +130 -1
- package/docs/reference/classes/Bech32.md +4 -4
- package/docs/reference/classes/Bip32Path.md +6 -6
- package/docs/reference/classes/Bip39.md +16 -16
- package/docs/reference/classes/Bip44.md +6 -6
- package/docs/reference/classes/Blake2b.md +9 -9
- package/docs/reference/classes/Blake3.md +7 -7
- package/docs/reference/classes/ChaCha20Poly1305.md +3 -3
- package/docs/reference/classes/Ed25519.md +8 -8
- package/docs/reference/classes/HmacSha1.md +4 -4
- package/docs/reference/classes/HmacSha256.md +9 -9
- package/docs/reference/classes/HmacSha512.md +13 -13
- package/docs/reference/classes/Hotp.md +2 -2
- package/docs/reference/classes/IntegrityHelper.md +3 -3
- package/docs/reference/classes/PasswordGenerator.md +5 -5
- package/docs/reference/classes/PasswordValidator.md +5 -5
- package/docs/reference/classes/Pbkdf2.md +3 -3
- package/docs/reference/classes/PemHelper.md +5 -5
- package/docs/reference/classes/Secp256k1.md +6 -6
- package/docs/reference/classes/Sha1.md +4 -4
- package/docs/reference/classes/Sha256.md +9 -9
- package/docs/reference/classes/Sha3.md +13 -13
- package/docs/reference/classes/Sha512.md +13 -13
- package/docs/reference/classes/Slip0010.md +11 -11
- package/docs/reference/classes/Totp.md +12 -12
- package/docs/reference/classes/X25519.md +3 -3
- package/docs/reference/classes/Zip215.md +2 -2
- package/docs/reference/variables/IntegrityAlgorithm.md +3 -3
- package/docs/reference/variables/KeyType.md +2 -2
- package/package.json +6 -6
|
@@ -6,13 +6,13 @@ Perform a SHA-512 hash on the block.
|
|
|
6
6
|
|
|
7
7
|
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new Sha512**(`bits
|
|
9
|
+
> **new Sha512**(`bits?`): `Sha512`
|
|
10
10
|
|
|
11
11
|
Create a new instance of Sha512.
|
|
12
12
|
|
|
13
13
|
#### Parameters
|
|
14
14
|
|
|
15
|
-
##### bits
|
|
15
|
+
##### bits?
|
|
16
16
|
|
|
17
17
|
`number` = `Sha512.SIZE_512`
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ The number of bits.
|
|
|
24
24
|
|
|
25
25
|
## Properties
|
|
26
26
|
|
|
27
|
-
### SIZE\_224
|
|
27
|
+
### SIZE\_224 {#size_224}
|
|
28
28
|
|
|
29
29
|
> `static` **SIZE\_224**: `number` = `224`
|
|
30
30
|
|
|
@@ -32,7 +32,7 @@ Sha512 224.
|
|
|
32
32
|
|
|
33
33
|
***
|
|
34
34
|
|
|
35
|
-
### SIZE\_256
|
|
35
|
+
### SIZE\_256 {#size_256}
|
|
36
36
|
|
|
37
37
|
> `static` **SIZE\_256**: `number` = `256`
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ Sha512 256.
|
|
|
40
40
|
|
|
41
41
|
***
|
|
42
42
|
|
|
43
|
-
### SIZE\_384
|
|
43
|
+
### SIZE\_384 {#size_384}
|
|
44
44
|
|
|
45
45
|
> `static` **SIZE\_384**: `number` = `384`
|
|
46
46
|
|
|
@@ -48,7 +48,7 @@ Sha512 384.
|
|
|
48
48
|
|
|
49
49
|
***
|
|
50
50
|
|
|
51
|
-
### SIZE\_512
|
|
51
|
+
### SIZE\_512 {#size_512}
|
|
52
52
|
|
|
53
53
|
> `static` **SIZE\_512**: `number` = `512`
|
|
54
54
|
|
|
@@ -56,7 +56,7 @@ Sha512 512.
|
|
|
56
56
|
|
|
57
57
|
***
|
|
58
58
|
|
|
59
|
-
### CLASS\_NAME
|
|
59
|
+
### CLASS\_NAME {#class_name}
|
|
60
60
|
|
|
61
61
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
62
62
|
|
|
@@ -64,7 +64,7 @@ Runtime name for the class.
|
|
|
64
64
|
|
|
65
65
|
## Methods
|
|
66
66
|
|
|
67
|
-
### sum512()
|
|
67
|
+
### sum512() {#sum512}
|
|
68
68
|
|
|
69
69
|
> `static` **sum512**(`block`): `Uint8Array`
|
|
70
70
|
|
|
@@ -86,7 +86,7 @@ The sum 512 of the block.
|
|
|
86
86
|
|
|
87
87
|
***
|
|
88
88
|
|
|
89
|
-
### sum384()
|
|
89
|
+
### sum384() {#sum384}
|
|
90
90
|
|
|
91
91
|
> `static` **sum384**(`block`): `Uint8Array`
|
|
92
92
|
|
|
@@ -108,7 +108,7 @@ The sum 384 of the block.
|
|
|
108
108
|
|
|
109
109
|
***
|
|
110
110
|
|
|
111
|
-
### sum256()
|
|
111
|
+
### sum256() {#sum256}
|
|
112
112
|
|
|
113
113
|
> `static` **sum256**(`block`): `Uint8Array`
|
|
114
114
|
|
|
@@ -130,7 +130,7 @@ The sum 256 of the block.
|
|
|
130
130
|
|
|
131
131
|
***
|
|
132
132
|
|
|
133
|
-
### sum224()
|
|
133
|
+
### sum224() {#sum224}
|
|
134
134
|
|
|
135
135
|
> `static` **sum224**(`block`): `Uint8Array`
|
|
136
136
|
|
|
@@ -152,7 +152,7 @@ The sum 224 of the block.
|
|
|
152
152
|
|
|
153
153
|
***
|
|
154
154
|
|
|
155
|
-
### update()
|
|
155
|
+
### update() {#update}
|
|
156
156
|
|
|
157
157
|
> **update**(`block`): `Sha512`
|
|
158
158
|
|
|
@@ -174,7 +174,7 @@ The instance for chaining.
|
|
|
174
174
|
|
|
175
175
|
***
|
|
176
176
|
|
|
177
|
-
### digest()
|
|
177
|
+
### digest() {#digest}
|
|
178
178
|
|
|
179
179
|
> **digest**(): `Uint8Array`
|
|
180
180
|
|
|
@@ -15,7 +15,7 @@ https://github.com/satoshilabs/slips/blob/master/slip-0010.md.
|
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
18
|
-
### CLASS\_NAME
|
|
18
|
+
### CLASS\_NAME {#class_name}
|
|
19
19
|
|
|
20
20
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
21
21
|
|
|
@@ -23,9 +23,9 @@ Runtime name for the class.
|
|
|
23
23
|
|
|
24
24
|
## Methods
|
|
25
25
|
|
|
26
|
-
### getMasterKeyFromSeed()
|
|
26
|
+
### getMasterKeyFromSeed() {#getmasterkeyfromseed}
|
|
27
27
|
|
|
28
|
-
> `static` **getMasterKeyFromSeed**(`seed`, `keyType
|
|
28
|
+
> `static` **getMasterKeyFromSeed**(`seed`, `keyType?`): `object`
|
|
29
29
|
|
|
30
30
|
Get the master key from the seed.
|
|
31
31
|
|
|
@@ -37,7 +37,7 @@ Get the master key from the seed.
|
|
|
37
37
|
|
|
38
38
|
The seed to generate the master key from.
|
|
39
39
|
|
|
40
|
-
##### keyType
|
|
40
|
+
##### keyType?
|
|
41
41
|
|
|
42
42
|
[`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
|
|
43
43
|
|
|
@@ -63,9 +63,9 @@ If the seed is invalid.
|
|
|
63
63
|
|
|
64
64
|
***
|
|
65
65
|
|
|
66
|
-
### derivePath()
|
|
66
|
+
### derivePath() {#derivepath}
|
|
67
67
|
|
|
68
|
-
> `static` **derivePath**(`seed`, `path`, `keyType
|
|
68
|
+
> `static` **derivePath**(`seed`, `path`, `keyType?`): `object`
|
|
69
69
|
|
|
70
70
|
Derive a key from the path.
|
|
71
71
|
|
|
@@ -83,7 +83,7 @@ The seed.
|
|
|
83
83
|
|
|
84
84
|
The path.
|
|
85
85
|
|
|
86
|
-
##### keyType
|
|
86
|
+
##### keyType?
|
|
87
87
|
|
|
88
88
|
[`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
|
|
89
89
|
|
|
@@ -105,9 +105,9 @@ The key and chain code.
|
|
|
105
105
|
|
|
106
106
|
***
|
|
107
107
|
|
|
108
|
-
### getPublicKey()
|
|
108
|
+
### getPublicKey() {#getpublickey}
|
|
109
109
|
|
|
110
|
-
> `static` **getPublicKey**(`privateKey`, `keyType
|
|
110
|
+
> `static` **getPublicKey**(`privateKey`, `keyType?`, `withZeroByte?`): `Uint8Array`
|
|
111
111
|
|
|
112
112
|
Get the public key from the private key.
|
|
113
113
|
|
|
@@ -119,13 +119,13 @@ Get the public key from the private key.
|
|
|
119
119
|
|
|
120
120
|
The private key.
|
|
121
121
|
|
|
122
|
-
##### keyType
|
|
122
|
+
##### keyType?
|
|
123
123
|
|
|
124
124
|
[`KeyType`](../type-aliases/KeyType.md) = `KeyType.Ed25519`
|
|
125
125
|
|
|
126
126
|
The key type.
|
|
127
127
|
|
|
128
|
-
##### withZeroByte
|
|
128
|
+
##### withZeroByte?
|
|
129
129
|
|
|
130
130
|
`boolean` = `true`
|
|
131
131
|
|
|
@@ -15,9 +15,9 @@ Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .
|
|
|
15
15
|
|
|
16
16
|
## Methods
|
|
17
17
|
|
|
18
|
-
### generate()
|
|
18
|
+
### generate() {#generate}
|
|
19
19
|
|
|
20
|
-
> `static` **generate**(`key`, `interval
|
|
20
|
+
> `static` **generate**(`key`, `interval?`, `timestamp?`): `string`
|
|
21
21
|
|
|
22
22
|
Generate a time based One Time Password.
|
|
23
23
|
|
|
@@ -29,13 +29,13 @@ Generate a time based One Time Password.
|
|
|
29
29
|
|
|
30
30
|
Key for the one time password.
|
|
31
31
|
|
|
32
|
-
##### interval
|
|
32
|
+
##### interval?
|
|
33
33
|
|
|
34
34
|
`number` = `30`
|
|
35
35
|
|
|
36
36
|
The time step of the counter.
|
|
37
37
|
|
|
38
|
-
##### timestamp
|
|
38
|
+
##### timestamp?
|
|
39
39
|
|
|
40
40
|
`number` = `...`
|
|
41
41
|
|
|
@@ -49,9 +49,9 @@ The one time password.
|
|
|
49
49
|
|
|
50
50
|
***
|
|
51
51
|
|
|
52
|
-
### verify()
|
|
52
|
+
### verify() {#verify}
|
|
53
53
|
|
|
54
|
-
> `static` **verify**(`token`, `key`, `window
|
|
54
|
+
> `static` **verify**(`token`, `key`, `window?`, `interval?`, `timestamp?`): `number` \| `undefined`
|
|
55
55
|
|
|
56
56
|
Check a One Time Password based on a timer.
|
|
57
57
|
|
|
@@ -70,19 +70,19 @@ Passcode to validate.
|
|
|
70
70
|
Key for the one time password. This should be unique and secret for
|
|
71
71
|
every user as it is the seed used to calculate the HMAC.
|
|
72
72
|
|
|
73
|
-
##### window
|
|
73
|
+
##### window?
|
|
74
74
|
|
|
75
75
|
`number` = `2`
|
|
76
76
|
|
|
77
77
|
The allowable margin for the counter.
|
|
78
78
|
|
|
79
|
-
##### interval
|
|
79
|
+
##### interval?
|
|
80
80
|
|
|
81
81
|
`number` = `30`
|
|
82
82
|
|
|
83
83
|
The time step of the counter.
|
|
84
84
|
|
|
85
|
-
##### timestamp
|
|
85
|
+
##### timestamp?
|
|
86
86
|
|
|
87
87
|
`number` = `...`
|
|
88
88
|
|
|
@@ -96,7 +96,7 @@ Undefined if failure, delta on success
|
|
|
96
96
|
|
|
97
97
|
***
|
|
98
98
|
|
|
99
|
-
### generateSecret()
|
|
99
|
+
### generateSecret() {#generatesecret}
|
|
100
100
|
|
|
101
101
|
> `static` **generateSecret**(`length`): `string`
|
|
102
102
|
|
|
@@ -118,7 +118,7 @@ The secret encoded as base32.
|
|
|
118
118
|
|
|
119
119
|
***
|
|
120
120
|
|
|
121
|
-
### secretToBytes()
|
|
121
|
+
### secretToBytes() {#secrettobytes}
|
|
122
122
|
|
|
123
123
|
> `static` **secretToBytes**(`secretBase32`): `Uint8Array`
|
|
124
124
|
|
|
@@ -140,7 +140,7 @@ The bytes of the secret.
|
|
|
140
140
|
|
|
141
141
|
***
|
|
142
142
|
|
|
143
|
-
### generateAuthUrl()
|
|
143
|
+
### generateAuthUrl() {#generateauthurl}
|
|
144
144
|
|
|
145
145
|
> `static` **generateAuthUrl**(`issuer`, `label`, `secretBase32`): `string`
|
|
146
146
|
|
|
@@ -14,7 +14,7 @@ Implementation of X25519.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### CLASS\_NAME
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
18
|
|
|
19
19
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Runtime name for the class.
|
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
25
|
-
### convertPrivateKeyToX25519()
|
|
25
|
+
### convertPrivateKeyToX25519() {#convertprivatekeytox25519}
|
|
26
26
|
|
|
27
27
|
> `static` **convertPrivateKeyToX25519**(`ed25519PrivateKey`): `Uint8Array`
|
|
28
28
|
|
|
@@ -44,7 +44,7 @@ The x25519 private key.
|
|
|
44
44
|
|
|
45
45
|
***
|
|
46
46
|
|
|
47
|
-
### convertPublicKeyToX25519()
|
|
47
|
+
### convertPublicKeyToX25519() {#convertpublickeytox25519}
|
|
48
48
|
|
|
49
49
|
> `static` **convertPublicKeyToX25519**(`ed25519PublicKey`): `Uint8Array`
|
|
50
50
|
|
|
@@ -14,7 +14,7 @@ Implementation of Zip215.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### CLASS\_NAME
|
|
17
|
+
### CLASS\_NAME {#class_name}
|
|
18
18
|
|
|
19
19
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ Runtime name for the class.
|
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
25
|
-
### verify()
|
|
25
|
+
### verify() {#verify}
|
|
26
26
|
|
|
27
27
|
> `static` **verify**(`publicKey`, `block`, `sig`): `boolean`
|
|
28
28
|
|
|
@@ -6,19 +6,19 @@ The names of the integrity algorithms.
|
|
|
6
6
|
|
|
7
7
|
## Type Declaration
|
|
8
8
|
|
|
9
|
-
### Sha256
|
|
9
|
+
### Sha256 {#sha256}
|
|
10
10
|
|
|
11
11
|
> `readonly` **Sha256**: `"sha256"` = `"sha256"`
|
|
12
12
|
|
|
13
13
|
Sha256.
|
|
14
14
|
|
|
15
|
-
### Sha384
|
|
15
|
+
### Sha384 {#sha384}
|
|
16
16
|
|
|
17
17
|
> `readonly` **Sha384**: `"sha384"` = `"sha384"`
|
|
18
18
|
|
|
19
19
|
Sha384.
|
|
20
20
|
|
|
21
|
-
### Sha512
|
|
21
|
+
### Sha512 {#sha512}
|
|
22
22
|
|
|
23
23
|
> `readonly` **Sha512**: `"sha512"` = `"sha512"`
|
|
24
24
|
|
|
@@ -6,13 +6,13 @@ The names of the key types.
|
|
|
6
6
|
|
|
7
7
|
## Type Declaration
|
|
8
8
|
|
|
9
|
-
### Ed25519
|
|
9
|
+
### Ed25519 {#ed25519}
|
|
10
10
|
|
|
11
11
|
> `readonly` **Ed25519**: `0` = `0`
|
|
12
12
|
|
|
13
13
|
Ed25519.
|
|
14
14
|
|
|
15
|
-
### Secp256k1
|
|
15
|
+
### Secp256k1 {#secp256k1}
|
|
16
16
|
|
|
17
17
|
> `readonly` **Secp256k1**: `1` = `1`
|
|
18
18
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.23",
|
|
4
|
+
"description": "Helper methods and classes which implement cryptographic functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/framework.git",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@noble/ciphers": "2.
|
|
17
|
+
"@noble/ciphers": "2.1.1",
|
|
18
18
|
"@noble/curves": "2.0.1",
|
|
19
19
|
"@noble/hashes": "2.0.1",
|
|
20
20
|
"@scure/base": "2.0.0",
|
|
21
21
|
"@scure/bip32": "2.0.1",
|
|
22
22
|
"@scure/bip39": "2.0.1",
|
|
23
|
-
"@twin.org/core": "0.0.3-next.
|
|
24
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
23
|
+
"@twin.org/core": "0.0.3-next.23",
|
|
24
|
+
"@twin.org/nameof": "0.0.3-next.23",
|
|
25
25
|
"crypto-browserify": "3.12.1",
|
|
26
|
-
"micro-key-producer": "0.8.
|
|
26
|
+
"micro-key-producer": "0.8.5"
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/es/index.js",
|
|
29
29
|
"types": "./dist/types/index.d.ts",
|