@twin.org/crypto 0.0.1-next.7 → 0.0.1-next.9

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.
@@ -8,11 +8,13 @@ var blake2b = require('@noble/hashes/blake2b');
8
8
  var bip32 = require('@scure/bip32');
9
9
  var slip10_js = require('micro-key-producer/slip10.js');
10
10
  var chacha = require('@noble/ciphers/chacha');
11
+ var blake3 = require('@noble/hashes/blake3');
11
12
  var hmac = require('@noble/hashes/hmac');
12
13
  var sha1 = require('@noble/hashes/sha1');
13
14
  var sha256 = require('@noble/hashes/sha256');
14
15
  var sha512 = require('@noble/hashes/sha512');
15
16
  var pbkdf2 = require('@noble/hashes/pbkdf2');
17
+ var sha3 = require('@noble/hashes/sha3');
16
18
  var bip39 = require('@scure/bip39');
17
19
  var english = require('@scure/bip39/wordlists/english');
18
20
  var otp = require('micro-key-producer/otp.js');
@@ -727,6 +729,81 @@ class Zip215 {
727
729
  }
728
730
  }
729
731
 
732
+ // Copyright 2024 IOTA Stiftung.
733
+ // SPDX-License-Identifier: Apache-2.0.
734
+ /**
735
+ * Class to help with Blake3 Signature scheme.
736
+ */
737
+ class Blake3 {
738
+ /**
739
+ * Blake3 256.
740
+ */
741
+ static SIZE_256 = 32;
742
+ /**
743
+ * Blake3 512.
744
+ */
745
+ static SIZE_512 = 64;
746
+ /**
747
+ * Runtime name for the class.
748
+ * @internal
749
+ */
750
+ static _CLASS_NAME = "Blake3";
751
+ /**
752
+ * The instance of the hash.
753
+ * @internal
754
+ */
755
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
756
+ _instance;
757
+ /**
758
+ * Create a new instance of Blake3.
759
+ * @param outputLength The output length.
760
+ * @param key Optional key for the hash.
761
+ */
762
+ constructor(outputLength, key) {
763
+ this._instance = blake3.blake3.create({
764
+ dkLen: outputLength,
765
+ key
766
+ });
767
+ }
768
+ /**
769
+ * Perform Sum 256 on the block.
770
+ * @param block The block to operate on.
771
+ * @param key Optional key for the hash.
772
+ * @returns The sum 256 of the block.
773
+ */
774
+ static sum256(block, key) {
775
+ core.Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
776
+ return new Blake3(Blake3.SIZE_256, key).update(block).digest();
777
+ }
778
+ /**
779
+ * Perform Sum 512 on the block.
780
+ * @param block The block to operate on.
781
+ * @param key Optional key for the hash.
782
+ * @returns The sum 512 of the block.
783
+ */
784
+ static sum512(block, key) {
785
+ core.Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
786
+ return new Blake3(Blake3.SIZE_512, key).update(block).digest();
787
+ }
788
+ /**
789
+ * Update the hash with the block.
790
+ * @param block The block to update the hash with.
791
+ * @returns The instance for chaining.
792
+ */
793
+ update(block) {
794
+ core.Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
795
+ this._instance.update(block);
796
+ return this;
797
+ }
798
+ /**
799
+ * Get the digest for the hash.
800
+ * @returns The instance for chaining.
801
+ */
802
+ digest() {
803
+ return this._instance.digest();
804
+ }
805
+ }
806
+
730
807
  // Copyright 2024 IOTA Stiftung.
731
808
  // SPDX-License-Identifier: Apache-2.0.
732
809
  /**
@@ -1160,6 +1237,127 @@ class Sha256 {
1160
1237
  }
1161
1238
  }
1162
1239
 
1240
+ // Copyright 2024 IOTA Stiftung.
1241
+ // SPDX-License-Identifier: Apache-2.0.
1242
+ // eslint-disable-next-line camelcase
1243
+ /**
1244
+ * Perform a SHA-3 hash on the block.
1245
+ */
1246
+ class Sha3 {
1247
+ /**
1248
+ * Sha3 224.
1249
+ */
1250
+ static SIZE_224 = 224;
1251
+ /**
1252
+ * Sha3 256.
1253
+ */
1254
+ static SIZE_256 = 256;
1255
+ /**
1256
+ * Sha3 384.
1257
+ */
1258
+ static SIZE_384 = 384;
1259
+ /**
1260
+ * Sha3 512.
1261
+ */
1262
+ static SIZE_512 = 512;
1263
+ /**
1264
+ * Runtime name for the class.
1265
+ * @internal
1266
+ */
1267
+ static _CLASS_NAME = "Sha3";
1268
+ /**
1269
+ * The instance of the hash.
1270
+ * @internal
1271
+ */
1272
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1273
+ _instance;
1274
+ /**
1275
+ * Create a new instance of Sha3.
1276
+ * @param bits The number of bits.
1277
+ */
1278
+ constructor(bits = Sha3.SIZE_256) {
1279
+ if (bits !== Sha3.SIZE_224 &&
1280
+ bits !== Sha3.SIZE_256 &&
1281
+ bits !== Sha3.SIZE_384 &&
1282
+ bits !== Sha3.SIZE_512) {
1283
+ throw new core.GeneralError(Sha3._CLASS_NAME, "bitSize", { bitSize: bits });
1284
+ }
1285
+ if (bits === Sha3.SIZE_224) {
1286
+ // eslint-disable-next-line camelcase
1287
+ this._instance = sha3.sha3_224.create();
1288
+ }
1289
+ else if (bits === Sha3.SIZE_256) {
1290
+ // eslint-disable-next-line camelcase
1291
+ this._instance = sha3.sha3_256.create();
1292
+ }
1293
+ else if (bits === Sha3.SIZE_384) {
1294
+ // eslint-disable-next-line camelcase
1295
+ this._instance = sha3.sha3_384.create();
1296
+ }
1297
+ else {
1298
+ // eslint-disable-next-line camelcase
1299
+ this._instance = sha3.sha3_512.create();
1300
+ }
1301
+ }
1302
+ /**
1303
+ * Perform Sum 256 on the block.
1304
+ * @param block The block to operate on.
1305
+ * @returns The sum 256 of the block.
1306
+ */
1307
+ static sum256(block) {
1308
+ const b2b = new Sha3(Sha3.SIZE_256);
1309
+ b2b.update(block);
1310
+ return b2b.digest();
1311
+ }
1312
+ /**
1313
+ * Perform Sum 224 on the block.
1314
+ * @param block The block to operate on.
1315
+ * @returns The sum 224 of the block.
1316
+ */
1317
+ static sum224(block) {
1318
+ const b2b = new Sha3(Sha3.SIZE_224);
1319
+ b2b.update(block);
1320
+ return b2b.digest();
1321
+ }
1322
+ /**
1323
+ * Perform Sum 384 on the block.
1324
+ * @param block The block to operate on.
1325
+ * @returns The sum 384 of the block.
1326
+ */
1327
+ static sum384(block) {
1328
+ const b2b = new Sha3(Sha3.SIZE_384);
1329
+ b2b.update(block);
1330
+ return b2b.digest();
1331
+ }
1332
+ /**
1333
+ * Perform Sum 512 on the block.
1334
+ * @param block The block to operate on.
1335
+ * @returns The sum 512 of the block.
1336
+ */
1337
+ static sum512(block) {
1338
+ const b2b = new Sha3(Sha3.SIZE_512);
1339
+ b2b.update(block);
1340
+ return b2b.digest();
1341
+ }
1342
+ /**
1343
+ * Update the hash with the block.
1344
+ * @param block The block to update the hash with.
1345
+ * @returns The instance for chaining.
1346
+ */
1347
+ update(block) {
1348
+ core.Guards.uint8Array(Sha3._CLASS_NAME, "block", block);
1349
+ this._instance.update(block);
1350
+ return this;
1351
+ }
1352
+ /**
1353
+ * Get the digest for the hash.
1354
+ * @returns The instance for chaining.
1355
+ */
1356
+ digest() {
1357
+ return this._instance.digest();
1358
+ }
1359
+ }
1360
+
1163
1361
  // Copyright 2024 IOTA Stiftung.
1164
1362
  // SPDX-License-Identifier: Apache-2.0.
1165
1363
  /* eslint-disable camelcase */
@@ -1552,6 +1750,7 @@ exports.Bip32Path = Bip32Path;
1552
1750
  exports.Bip39 = Bip39;
1553
1751
  exports.Bip44 = Bip44;
1554
1752
  exports.Blake2b = Blake2b;
1753
+ exports.Blake3 = Blake3;
1555
1754
  exports.ChaCha20Poly1305 = ChaCha20Poly1305;
1556
1755
  exports.Ed25519 = Ed25519;
1557
1756
  exports.HmacSha1 = HmacSha1;
@@ -1565,6 +1764,7 @@ exports.Pbkdf2 = Pbkdf2;
1565
1764
  exports.Secp256k1 = Secp256k1;
1566
1765
  exports.Sha1 = Sha1;
1567
1766
  exports.Sha256 = Sha256;
1767
+ exports.Sha3 = Sha3;
1568
1768
  exports.Sha512 = Sha512;
1569
1769
  exports.Slip0010 = Slip0010;
1570
1770
  exports.Totp = Totp;
@@ -6,11 +6,13 @@ import { blake2b } from '@noble/hashes/blake2b';
6
6
  import { HDKey as HDKey$1 } from '@scure/bip32';
7
7
  import { HDKey } from 'micro-key-producer/slip10.js';
8
8
  import { chacha20poly1305 } from '@noble/ciphers/chacha';
9
+ import { blake3 } from '@noble/hashes/blake3';
9
10
  import { hmac } from '@noble/hashes/hmac';
10
11
  import { sha1 } from '@noble/hashes/sha1';
11
12
  import { sha256, sha224 } from '@noble/hashes/sha256';
12
13
  import { sha512_224, sha512_256, sha384, sha512 } from '@noble/hashes/sha512';
13
14
  import { pbkdf2 } from '@noble/hashes/pbkdf2';
15
+ import { sha3_224, sha3_256, sha3_384, sha3_512 } from '@noble/hashes/sha3';
14
16
  import * as bip39 from '@scure/bip39';
15
17
  import { wordlist } from '@scure/bip39/wordlists/english';
16
18
  import * as otp from 'micro-key-producer/otp.js';
@@ -705,6 +707,81 @@ class Zip215 {
705
707
  }
706
708
  }
707
709
 
710
+ // Copyright 2024 IOTA Stiftung.
711
+ // SPDX-License-Identifier: Apache-2.0.
712
+ /**
713
+ * Class to help with Blake3 Signature scheme.
714
+ */
715
+ class Blake3 {
716
+ /**
717
+ * Blake3 256.
718
+ */
719
+ static SIZE_256 = 32;
720
+ /**
721
+ * Blake3 512.
722
+ */
723
+ static SIZE_512 = 64;
724
+ /**
725
+ * Runtime name for the class.
726
+ * @internal
727
+ */
728
+ static _CLASS_NAME = "Blake3";
729
+ /**
730
+ * The instance of the hash.
731
+ * @internal
732
+ */
733
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
734
+ _instance;
735
+ /**
736
+ * Create a new instance of Blake3.
737
+ * @param outputLength The output length.
738
+ * @param key Optional key for the hash.
739
+ */
740
+ constructor(outputLength, key) {
741
+ this._instance = blake3.create({
742
+ dkLen: outputLength,
743
+ key
744
+ });
745
+ }
746
+ /**
747
+ * Perform Sum 256 on the block.
748
+ * @param block The block to operate on.
749
+ * @param key Optional key for the hash.
750
+ * @returns The sum 256 of the block.
751
+ */
752
+ static sum256(block, key) {
753
+ Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
754
+ return new Blake3(Blake3.SIZE_256, key).update(block).digest();
755
+ }
756
+ /**
757
+ * Perform Sum 512 on the block.
758
+ * @param block The block to operate on.
759
+ * @param key Optional key for the hash.
760
+ * @returns The sum 512 of the block.
761
+ */
762
+ static sum512(block, key) {
763
+ Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
764
+ return new Blake3(Blake3.SIZE_512, key).update(block).digest();
765
+ }
766
+ /**
767
+ * Update the hash with the block.
768
+ * @param block The block to update the hash with.
769
+ * @returns The instance for chaining.
770
+ */
771
+ update(block) {
772
+ Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
773
+ this._instance.update(block);
774
+ return this;
775
+ }
776
+ /**
777
+ * Get the digest for the hash.
778
+ * @returns The instance for chaining.
779
+ */
780
+ digest() {
781
+ return this._instance.digest();
782
+ }
783
+ }
784
+
708
785
  // Copyright 2024 IOTA Stiftung.
709
786
  // SPDX-License-Identifier: Apache-2.0.
710
787
  /**
@@ -1138,6 +1215,127 @@ class Sha256 {
1138
1215
  }
1139
1216
  }
1140
1217
 
1218
+ // Copyright 2024 IOTA Stiftung.
1219
+ // SPDX-License-Identifier: Apache-2.0.
1220
+ // eslint-disable-next-line camelcase
1221
+ /**
1222
+ * Perform a SHA-3 hash on the block.
1223
+ */
1224
+ class Sha3 {
1225
+ /**
1226
+ * Sha3 224.
1227
+ */
1228
+ static SIZE_224 = 224;
1229
+ /**
1230
+ * Sha3 256.
1231
+ */
1232
+ static SIZE_256 = 256;
1233
+ /**
1234
+ * Sha3 384.
1235
+ */
1236
+ static SIZE_384 = 384;
1237
+ /**
1238
+ * Sha3 512.
1239
+ */
1240
+ static SIZE_512 = 512;
1241
+ /**
1242
+ * Runtime name for the class.
1243
+ * @internal
1244
+ */
1245
+ static _CLASS_NAME = "Sha3";
1246
+ /**
1247
+ * The instance of the hash.
1248
+ * @internal
1249
+ */
1250
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1251
+ _instance;
1252
+ /**
1253
+ * Create a new instance of Sha3.
1254
+ * @param bits The number of bits.
1255
+ */
1256
+ constructor(bits = Sha3.SIZE_256) {
1257
+ if (bits !== Sha3.SIZE_224 &&
1258
+ bits !== Sha3.SIZE_256 &&
1259
+ bits !== Sha3.SIZE_384 &&
1260
+ bits !== Sha3.SIZE_512) {
1261
+ throw new GeneralError(Sha3._CLASS_NAME, "bitSize", { bitSize: bits });
1262
+ }
1263
+ if (bits === Sha3.SIZE_224) {
1264
+ // eslint-disable-next-line camelcase
1265
+ this._instance = sha3_224.create();
1266
+ }
1267
+ else if (bits === Sha3.SIZE_256) {
1268
+ // eslint-disable-next-line camelcase
1269
+ this._instance = sha3_256.create();
1270
+ }
1271
+ else if (bits === Sha3.SIZE_384) {
1272
+ // eslint-disable-next-line camelcase
1273
+ this._instance = sha3_384.create();
1274
+ }
1275
+ else {
1276
+ // eslint-disable-next-line camelcase
1277
+ this._instance = sha3_512.create();
1278
+ }
1279
+ }
1280
+ /**
1281
+ * Perform Sum 256 on the block.
1282
+ * @param block The block to operate on.
1283
+ * @returns The sum 256 of the block.
1284
+ */
1285
+ static sum256(block) {
1286
+ const b2b = new Sha3(Sha3.SIZE_256);
1287
+ b2b.update(block);
1288
+ return b2b.digest();
1289
+ }
1290
+ /**
1291
+ * Perform Sum 224 on the block.
1292
+ * @param block The block to operate on.
1293
+ * @returns The sum 224 of the block.
1294
+ */
1295
+ static sum224(block) {
1296
+ const b2b = new Sha3(Sha3.SIZE_224);
1297
+ b2b.update(block);
1298
+ return b2b.digest();
1299
+ }
1300
+ /**
1301
+ * Perform Sum 384 on the block.
1302
+ * @param block The block to operate on.
1303
+ * @returns The sum 384 of the block.
1304
+ */
1305
+ static sum384(block) {
1306
+ const b2b = new Sha3(Sha3.SIZE_384);
1307
+ b2b.update(block);
1308
+ return b2b.digest();
1309
+ }
1310
+ /**
1311
+ * Perform Sum 512 on the block.
1312
+ * @param block The block to operate on.
1313
+ * @returns The sum 512 of the block.
1314
+ */
1315
+ static sum512(block) {
1316
+ const b2b = new Sha3(Sha3.SIZE_512);
1317
+ b2b.update(block);
1318
+ return b2b.digest();
1319
+ }
1320
+ /**
1321
+ * Update the hash with the block.
1322
+ * @param block The block to update the hash with.
1323
+ * @returns The instance for chaining.
1324
+ */
1325
+ update(block) {
1326
+ Guards.uint8Array(Sha3._CLASS_NAME, "block", block);
1327
+ this._instance.update(block);
1328
+ return this;
1329
+ }
1330
+ /**
1331
+ * Get the digest for the hash.
1332
+ * @returns The instance for chaining.
1333
+ */
1334
+ digest() {
1335
+ return this._instance.digest();
1336
+ }
1337
+ }
1338
+
1141
1339
  // Copyright 2024 IOTA Stiftung.
1142
1340
  // SPDX-License-Identifier: Apache-2.0.
1143
1341
  /* eslint-disable camelcase */
@@ -1525,4 +1723,4 @@ class PasswordValidator {
1525
1723
  }
1526
1724
  }
1527
1725
 
1528
- export { Bech32, Bip32Path, Bip39, Bip44, Blake2b, ChaCha20Poly1305, Ed25519, HmacSha1, HmacSha256, HmacSha512, Hotp, KeyType, PasswordGenerator, PasswordValidator, Pbkdf2, Secp256k1, Sha1, Sha256, Sha512, Slip0010, Totp, X25519, Zip215 };
1726
+ export { Bech32, Bip32Path, Bip39, Bip44, Blake2b, Blake3, ChaCha20Poly1305, Ed25519, HmacSha1, HmacSha256, HmacSha512, Hotp, KeyType, PasswordGenerator, PasswordValidator, Pbkdf2, Secp256k1, Sha1, Sha256, Sha3, Sha512, Slip0010, Totp, X25519, Zip215 };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Class to help with Blake3 Signature scheme.
3
+ */
4
+ export declare class Blake3 {
5
+ /**
6
+ * Blake3 256.
7
+ */
8
+ static SIZE_256: number;
9
+ /**
10
+ * Blake3 512.
11
+ */
12
+ static SIZE_512: number;
13
+ /**
14
+ * Create a new instance of Blake3.
15
+ * @param outputLength The output length.
16
+ * @param key Optional key for the hash.
17
+ */
18
+ constructor(outputLength: number, key?: Uint8Array);
19
+ /**
20
+ * Perform Sum 256 on the block.
21
+ * @param block The block to operate on.
22
+ * @param key Optional key for the hash.
23
+ * @returns The sum 256 of the block.
24
+ */
25
+ static sum256(block: Uint8Array, key?: Uint8Array): Uint8Array;
26
+ /**
27
+ * Perform Sum 512 on the block.
28
+ * @param block The block to operate on.
29
+ * @param key Optional key for the hash.
30
+ * @returns The sum 512 of the block.
31
+ */
32
+ static sum512(block: Uint8Array, key?: Uint8Array): Uint8Array;
33
+ /**
34
+ * Update the hash with the block.
35
+ * @param block The block to update the hash with.
36
+ * @returns The instance for chaining.
37
+ */
38
+ update(block: Uint8Array): Blake3;
39
+ /**
40
+ * Get the digest for the hash.
41
+ * @returns The instance for chaining.
42
+ */
43
+ digest(): Uint8Array;
44
+ }
@@ -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,5 @@
1
1
  # @twin.org/crypto - Changelog
2
2
 
3
- ## 0.0.1-next.7
3
+ ## 0.0.1-next.9
4
4
 
5
5
  - Added: Bip44
@@ -0,0 +1,123 @@
1
+ # Class: Blake3
2
+
3
+ Class to help with Blake3 Signature scheme.
4
+
5
+ ## Constructors
6
+
7
+ ### new Blake3()
8
+
9
+ > **new Blake3**(`outputLength`, `key`?): [`Blake3`](Blake3.md)
10
+
11
+ Create a new instance of Blake3.
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
+ [`Blake3`](Blake3.md)
26
+
27
+ ## Properties
28
+
29
+ ### SIZE\_256
30
+
31
+ > `static` **SIZE\_256**: `number` = `32`
32
+
33
+ Blake3 256.
34
+
35
+ ***
36
+
37
+ ### SIZE\_512
38
+
39
+ > `static` **SIZE\_512**: `number` = `64`
40
+
41
+ Blake3 512.
42
+
43
+ ## Methods
44
+
45
+ ### sum256()
46
+
47
+ > `static` **sum256**(`block`, `key`?): `Uint8Array`
48
+
49
+ Perform Sum 256 on the block.
50
+
51
+ #### Parameters
52
+
53
+ • **block**: `Uint8Array`
54
+
55
+ The block to operate on.
56
+
57
+ • **key?**: `Uint8Array`
58
+
59
+ Optional key for the hash.
60
+
61
+ #### Returns
62
+
63
+ `Uint8Array`
64
+
65
+ The sum 256 of the block.
66
+
67
+ ***
68
+
69
+ ### sum512()
70
+
71
+ > `static` **sum512**(`block`, `key`?): `Uint8Array`
72
+
73
+ Perform Sum 512 on the block.
74
+
75
+ #### Parameters
76
+
77
+ • **block**: `Uint8Array`
78
+
79
+ The block to operate on.
80
+
81
+ • **key?**: `Uint8Array`
82
+
83
+ Optional key for the hash.
84
+
85
+ #### Returns
86
+
87
+ `Uint8Array`
88
+
89
+ The sum 512 of the block.
90
+
91
+ ***
92
+
93
+ ### update()
94
+
95
+ > **update**(`block`): [`Blake3`](Blake3.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
+ [`Blake3`](Blake3.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,167 @@
1
+ # Class: Sha3
2
+
3
+ Perform a SHA-3 hash on the block.
4
+
5
+ ## Constructors
6
+
7
+ ### new Sha3()
8
+
9
+ > **new Sha3**(`bits`): [`Sha3`](Sha3.md)
10
+
11
+ Create a new instance of Sha3.
12
+
13
+ #### Parameters
14
+
15
+ • **bits**: `number` = `Sha3.SIZE_256`
16
+
17
+ The number of bits.
18
+
19
+ #### Returns
20
+
21
+ [`Sha3`](Sha3.md)
22
+
23
+ ## Properties
24
+
25
+ ### SIZE\_224
26
+
27
+ > `readonly` `static` **SIZE\_224**: `number` = `224`
28
+
29
+ Sha3 224.
30
+
31
+ ***
32
+
33
+ ### SIZE\_256
34
+
35
+ > `readonly` `static` **SIZE\_256**: `number` = `256`
36
+
37
+ Sha3 256.
38
+
39
+ ***
40
+
41
+ ### SIZE\_384
42
+
43
+ > `readonly` `static` **SIZE\_384**: `number` = `384`
44
+
45
+ Sha3 384.
46
+
47
+ ***
48
+
49
+ ### SIZE\_512
50
+
51
+ > `readonly` `static` **SIZE\_512**: `number` = `512`
52
+
53
+ Sha3 512.
54
+
55
+ ## Methods
56
+
57
+ ### sum256()
58
+
59
+ > `static` **sum256**(`block`): `Uint8Array`
60
+
61
+ Perform Sum 256 on the block.
62
+
63
+ #### Parameters
64
+
65
+ • **block**: `Uint8Array`
66
+
67
+ The block to operate on.
68
+
69
+ #### Returns
70
+
71
+ `Uint8Array`
72
+
73
+ The sum 256 of the block.
74
+
75
+ ***
76
+
77
+ ### sum224()
78
+
79
+ > `static` **sum224**(`block`): `Uint8Array`
80
+
81
+ Perform Sum 224 on the block.
82
+
83
+ #### Parameters
84
+
85
+ • **block**: `Uint8Array`
86
+
87
+ The block to operate on.
88
+
89
+ #### Returns
90
+
91
+ `Uint8Array`
92
+
93
+ The sum 224 of the block.
94
+
95
+ ***
96
+
97
+ ### sum384()
98
+
99
+ > `static` **sum384**(`block`): `Uint8Array`
100
+
101
+ Perform Sum 384 on the block.
102
+
103
+ #### Parameters
104
+
105
+ • **block**: `Uint8Array`
106
+
107
+ The block to operate on.
108
+
109
+ #### Returns
110
+
111
+ `Uint8Array`
112
+
113
+ The sum 384 of the block.
114
+
115
+ ***
116
+
117
+ ### sum512()
118
+
119
+ > `static` **sum512**(`block`): `Uint8Array`
120
+
121
+ Perform Sum 512 on the block.
122
+
123
+ #### Parameters
124
+
125
+ • **block**: `Uint8Array`
126
+
127
+ The block to operate on.
128
+
129
+ #### Returns
130
+
131
+ `Uint8Array`
132
+
133
+ The sum 512 of the block.
134
+
135
+ ***
136
+
137
+ ### update()
138
+
139
+ > **update**(`block`): [`Sha3`](Sha3.md)
140
+
141
+ Update the hash with the block.
142
+
143
+ #### Parameters
144
+
145
+ • **block**: `Uint8Array`
146
+
147
+ The block to update the hash with.
148
+
149
+ #### Returns
150
+
151
+ [`Sha3`](Sha3.md)
152
+
153
+ The instance for chaining.
154
+
155
+ ***
156
+
157
+ ### digest()
158
+
159
+ > **digest**(): `Uint8Array`
160
+
161
+ Get the digest for the hash.
162
+
163
+ #### Returns
164
+
165
+ `Uint8Array`
166
+
167
+ The instance for chaining.
@@ -10,12 +10,14 @@
10
10
  - [X25519](classes/X25519.md)
11
11
  - [Zip215](classes/Zip215.md)
12
12
  - [Blake2b](classes/Blake2b.md)
13
+ - [Blake3](classes/Blake3.md)
13
14
  - [HmacSha1](classes/HmacSha1.md)
14
15
  - [HmacSha256](classes/HmacSha256.md)
15
16
  - [HmacSha512](classes/HmacSha512.md)
16
17
  - [Pbkdf2](classes/Pbkdf2.md)
17
18
  - [Sha1](classes/Sha1.md)
18
19
  - [Sha256](classes/Sha256.md)
20
+ - [Sha3](classes/Sha3.md)
19
21
  - [Sha512](classes/Sha512.md)
20
22
  - [Bip32Path](classes/Bip32Path.md)
21
23
  - [Bip39](classes/Bip39.md)
package/locales/en.json CHANGED
@@ -31,18 +31,15 @@
31
31
  "sha256": {
32
32
  "bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
33
33
  },
34
+ "sha3": {
35
+ "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
36
+ },
34
37
  "hmacSha256": {
35
38
  "bitSize": "Only 224 or 256 bits are supported, it is \"{bitSize}\""
36
39
  },
37
40
  "hmacSha512": {
38
41
  "bitSize": "Only 224, 256, 384 or 512 bits are supported, it is \"{bitSize}\""
39
42
  },
40
- "base32": {
41
- "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
42
- },
43
- "base64": {
44
- "length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
45
- },
46
43
  "bech32": {
47
44
  "decodeFailed": "The address contains decoding failed for address \"{bech32}\"",
48
45
  "invalidChecksum": "The address contains an invalid checksum in address, \"{bech32}\"",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/crypto",
3
- "version": "0.0.1-next.7",
3
+ "version": "0.0.1-next.9",
4
4
  "description": "Contains helper methods and classes which implement cryptographic functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "@scure/base": "1.1.9",
21
21
  "@scure/bip32": "1.5.0",
22
22
  "@scure/bip39": "1.4.0",
23
- "@twin.org/core": "0.0.1-next.7",
23
+ "@twin.org/core": "0.0.1-next.9",
24
24
  "@twin.org/nameof": "next",
25
25
  "micro-key-producer": "0.7.0"
26
26
  },