@twin.org/crypto 0.0.1-next.3 → 0.0.1-next.31

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 (34) hide show
  1. package/dist/cjs/index.cjs +218 -0
  2. package/dist/esm/index.mjs +217 -1
  3. package/dist/types/address/bip44.d.ts +15 -0
  4. package/dist/types/hashes/blake3.d.ts +44 -0
  5. package/dist/types/hashes/sha3.d.ts +61 -0
  6. package/dist/types/index.d.ts +2 -0
  7. package/docs/changelog.md +1 -1
  8. package/docs/reference/classes/Bech32.md +12 -4
  9. package/docs/reference/classes/Bip32Path.md +12 -4
  10. package/docs/reference/classes/Bip39.md +24 -8
  11. package/docs/reference/classes/Bip44.md +118 -18
  12. package/docs/reference/classes/Blake2b.md +27 -9
  13. package/docs/reference/classes/Blake3.md +137 -0
  14. package/docs/reference/classes/ChaCha20Poly1305.md +15 -5
  15. package/docs/reference/classes/Ed25519.md +18 -6
  16. package/docs/reference/classes/HmacSha1.md +12 -4
  17. package/docs/reference/classes/HmacSha256.md +21 -7
  18. package/docs/reference/classes/HmacSha512.md +33 -11
  19. package/docs/reference/classes/Hotp.md +6 -2
  20. package/docs/reference/classes/PasswordGenerator.md +3 -1
  21. package/docs/reference/classes/PasswordValidator.md +19 -7
  22. package/docs/reference/classes/Pbkdf2.md +24 -8
  23. package/docs/reference/classes/Secp256k1.md +18 -6
  24. package/docs/reference/classes/Sha1.md +6 -2
  25. package/docs/reference/classes/Sha256.md +12 -4
  26. package/docs/reference/classes/Sha3.md +179 -0
  27. package/docs/reference/classes/Sha512.md +18 -6
  28. package/docs/reference/classes/Slip0010.md +24 -8
  29. package/docs/reference/classes/Totp.md +39 -13
  30. package/docs/reference/classes/X25519.md +6 -2
  31. package/docs/reference/classes/Zip215.md +9 -3
  32. package/docs/reference/index.md +2 -0
  33. package/locales/en.json +3 -6
  34. package/package.json +12 -38
@@ -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');
@@ -590,6 +592,24 @@ class Bip44 {
590
592
  static basePath(coinType) {
591
593
  return `m/44'/${coinType}'`;
592
594
  }
595
+ /**
596
+ * Generate an address from the seed and parts.
597
+ * @param seed The account seed.
598
+ * @param keyType The key type.
599
+ * @param coinType The coin type.
600
+ * @param accountIndex The account index.
601
+ * @param isInternal Is this an internal address.
602
+ * @param addressIndex The address index.
603
+ * @returns The generated path and the associated keypair.
604
+ */
605
+ static address(seed, keyType, coinType, accountIndex, isInternal, addressIndex) {
606
+ const keyPair = Bip44.keyPair(seed, keyType, coinType, accountIndex, isInternal, addressIndex);
607
+ const addressData = Blake2b.sum256(keyPair.publicKey);
608
+ return {
609
+ address: core.Converter.bytesToHex(addressData, true),
610
+ ...keyPair
611
+ };
612
+ }
593
613
  /**
594
614
  * Generate a bech32 address from the seed and parts.
595
615
  * @param seed The account seed.
@@ -727,6 +747,81 @@ class Zip215 {
727
747
  }
728
748
  }
729
749
 
750
+ // Copyright 2024 IOTA Stiftung.
751
+ // SPDX-License-Identifier: Apache-2.0.
752
+ /**
753
+ * Class to help with Blake3 Signature scheme.
754
+ */
755
+ class Blake3 {
756
+ /**
757
+ * Blake3 256.
758
+ */
759
+ static SIZE_256 = 32;
760
+ /**
761
+ * Blake3 512.
762
+ */
763
+ static SIZE_512 = 64;
764
+ /**
765
+ * Runtime name for the class.
766
+ * @internal
767
+ */
768
+ static _CLASS_NAME = "Blake3";
769
+ /**
770
+ * The instance of the hash.
771
+ * @internal
772
+ */
773
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
774
+ _instance;
775
+ /**
776
+ * Create a new instance of Blake3.
777
+ * @param outputLength The output length.
778
+ * @param key Optional key for the hash.
779
+ */
780
+ constructor(outputLength, key) {
781
+ this._instance = blake3.blake3.create({
782
+ dkLen: outputLength,
783
+ key
784
+ });
785
+ }
786
+ /**
787
+ * Perform Sum 256 on the block.
788
+ * @param block The block to operate on.
789
+ * @param key Optional key for the hash.
790
+ * @returns The sum 256 of the block.
791
+ */
792
+ static sum256(block, key) {
793
+ core.Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
794
+ return new Blake3(Blake3.SIZE_256, key).update(block).digest();
795
+ }
796
+ /**
797
+ * Perform Sum 512 on the block.
798
+ * @param block The block to operate on.
799
+ * @param key Optional key for the hash.
800
+ * @returns The sum 512 of the block.
801
+ */
802
+ static sum512(block, key) {
803
+ core.Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
804
+ return new Blake3(Blake3.SIZE_512, key).update(block).digest();
805
+ }
806
+ /**
807
+ * Update the hash with the block.
808
+ * @param block The block to update the hash with.
809
+ * @returns The instance for chaining.
810
+ */
811
+ update(block) {
812
+ core.Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
813
+ this._instance.update(block);
814
+ return this;
815
+ }
816
+ /**
817
+ * Get the digest for the hash.
818
+ * @returns The instance for chaining.
819
+ */
820
+ digest() {
821
+ return this._instance.digest();
822
+ }
823
+ }
824
+
730
825
  // Copyright 2024 IOTA Stiftung.
731
826
  // SPDX-License-Identifier: Apache-2.0.
732
827
  /**
@@ -1160,6 +1255,127 @@ class Sha256 {
1160
1255
  }
1161
1256
  }
1162
1257
 
1258
+ // Copyright 2024 IOTA Stiftung.
1259
+ // SPDX-License-Identifier: Apache-2.0.
1260
+ // eslint-disable-next-line camelcase
1261
+ /**
1262
+ * Perform a SHA-3 hash on the block.
1263
+ */
1264
+ class Sha3 {
1265
+ /**
1266
+ * Sha3 224.
1267
+ */
1268
+ static SIZE_224 = 224;
1269
+ /**
1270
+ * Sha3 256.
1271
+ */
1272
+ static SIZE_256 = 256;
1273
+ /**
1274
+ * Sha3 384.
1275
+ */
1276
+ static SIZE_384 = 384;
1277
+ /**
1278
+ * Sha3 512.
1279
+ */
1280
+ static SIZE_512 = 512;
1281
+ /**
1282
+ * Runtime name for the class.
1283
+ * @internal
1284
+ */
1285
+ static _CLASS_NAME = "Sha3";
1286
+ /**
1287
+ * The instance of the hash.
1288
+ * @internal
1289
+ */
1290
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1291
+ _instance;
1292
+ /**
1293
+ * Create a new instance of Sha3.
1294
+ * @param bits The number of bits.
1295
+ */
1296
+ constructor(bits = Sha3.SIZE_256) {
1297
+ if (bits !== Sha3.SIZE_224 &&
1298
+ bits !== Sha3.SIZE_256 &&
1299
+ bits !== Sha3.SIZE_384 &&
1300
+ bits !== Sha3.SIZE_512) {
1301
+ throw new core.GeneralError(Sha3._CLASS_NAME, "bitSize", { bitSize: bits });
1302
+ }
1303
+ if (bits === Sha3.SIZE_224) {
1304
+ // eslint-disable-next-line camelcase
1305
+ this._instance = sha3.sha3_224.create();
1306
+ }
1307
+ else if (bits === Sha3.SIZE_256) {
1308
+ // eslint-disable-next-line camelcase
1309
+ this._instance = sha3.sha3_256.create();
1310
+ }
1311
+ else if (bits === Sha3.SIZE_384) {
1312
+ // eslint-disable-next-line camelcase
1313
+ this._instance = sha3.sha3_384.create();
1314
+ }
1315
+ else {
1316
+ // eslint-disable-next-line camelcase
1317
+ this._instance = sha3.sha3_512.create();
1318
+ }
1319
+ }
1320
+ /**
1321
+ * Perform Sum 256 on the block.
1322
+ * @param block The block to operate on.
1323
+ * @returns The sum 256 of the block.
1324
+ */
1325
+ static sum256(block) {
1326
+ const b2b = new Sha3(Sha3.SIZE_256);
1327
+ b2b.update(block);
1328
+ return b2b.digest();
1329
+ }
1330
+ /**
1331
+ * Perform Sum 224 on the block.
1332
+ * @param block The block to operate on.
1333
+ * @returns The sum 224 of the block.
1334
+ */
1335
+ static sum224(block) {
1336
+ const b2b = new Sha3(Sha3.SIZE_224);
1337
+ b2b.update(block);
1338
+ return b2b.digest();
1339
+ }
1340
+ /**
1341
+ * Perform Sum 384 on the block.
1342
+ * @param block The block to operate on.
1343
+ * @returns The sum 384 of the block.
1344
+ */
1345
+ static sum384(block) {
1346
+ const b2b = new Sha3(Sha3.SIZE_384);
1347
+ b2b.update(block);
1348
+ return b2b.digest();
1349
+ }
1350
+ /**
1351
+ * Perform Sum 512 on the block.
1352
+ * @param block The block to operate on.
1353
+ * @returns The sum 512 of the block.
1354
+ */
1355
+ static sum512(block) {
1356
+ const b2b = new Sha3(Sha3.SIZE_512);
1357
+ b2b.update(block);
1358
+ return b2b.digest();
1359
+ }
1360
+ /**
1361
+ * Update the hash with the block.
1362
+ * @param block The block to update the hash with.
1363
+ * @returns The instance for chaining.
1364
+ */
1365
+ update(block) {
1366
+ core.Guards.uint8Array(Sha3._CLASS_NAME, "block", block);
1367
+ this._instance.update(block);
1368
+ return this;
1369
+ }
1370
+ /**
1371
+ * Get the digest for the hash.
1372
+ * @returns The instance for chaining.
1373
+ */
1374
+ digest() {
1375
+ return this._instance.digest();
1376
+ }
1377
+ }
1378
+
1163
1379
  // Copyright 2024 IOTA Stiftung.
1164
1380
  // SPDX-License-Identifier: Apache-2.0.
1165
1381
  /* eslint-disable camelcase */
@@ -1552,6 +1768,7 @@ exports.Bip32Path = Bip32Path;
1552
1768
  exports.Bip39 = Bip39;
1553
1769
  exports.Bip44 = Bip44;
1554
1770
  exports.Blake2b = Blake2b;
1771
+ exports.Blake3 = Blake3;
1555
1772
  exports.ChaCha20Poly1305 = ChaCha20Poly1305;
1556
1773
  exports.Ed25519 = Ed25519;
1557
1774
  exports.HmacSha1 = HmacSha1;
@@ -1565,6 +1782,7 @@ exports.Pbkdf2 = Pbkdf2;
1565
1782
  exports.Secp256k1 = Secp256k1;
1566
1783
  exports.Sha1 = Sha1;
1567
1784
  exports.Sha256 = Sha256;
1785
+ exports.Sha3 = Sha3;
1568
1786
  exports.Sha512 = Sha512;
1569
1787
  exports.Slip0010 = Slip0010;
1570
1788
  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';
@@ -568,6 +570,24 @@ class Bip44 {
568
570
  static basePath(coinType) {
569
571
  return `m/44'/${coinType}'`;
570
572
  }
573
+ /**
574
+ * Generate an address from the seed and parts.
575
+ * @param seed The account seed.
576
+ * @param keyType The key type.
577
+ * @param coinType The coin type.
578
+ * @param accountIndex The account index.
579
+ * @param isInternal Is this an internal address.
580
+ * @param addressIndex The address index.
581
+ * @returns The generated path and the associated keypair.
582
+ */
583
+ static address(seed, keyType, coinType, accountIndex, isInternal, addressIndex) {
584
+ const keyPair = Bip44.keyPair(seed, keyType, coinType, accountIndex, isInternal, addressIndex);
585
+ const addressData = Blake2b.sum256(keyPair.publicKey);
586
+ return {
587
+ address: Converter.bytesToHex(addressData, true),
588
+ ...keyPair
589
+ };
590
+ }
571
591
  /**
572
592
  * Generate a bech32 address from the seed and parts.
573
593
  * @param seed The account seed.
@@ -705,6 +725,81 @@ class Zip215 {
705
725
  }
706
726
  }
707
727
 
728
+ // Copyright 2024 IOTA Stiftung.
729
+ // SPDX-License-Identifier: Apache-2.0.
730
+ /**
731
+ * Class to help with Blake3 Signature scheme.
732
+ */
733
+ class Blake3 {
734
+ /**
735
+ * Blake3 256.
736
+ */
737
+ static SIZE_256 = 32;
738
+ /**
739
+ * Blake3 512.
740
+ */
741
+ static SIZE_512 = 64;
742
+ /**
743
+ * Runtime name for the class.
744
+ * @internal
745
+ */
746
+ static _CLASS_NAME = "Blake3";
747
+ /**
748
+ * The instance of the hash.
749
+ * @internal
750
+ */
751
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
752
+ _instance;
753
+ /**
754
+ * Create a new instance of Blake3.
755
+ * @param outputLength The output length.
756
+ * @param key Optional key for the hash.
757
+ */
758
+ constructor(outputLength, key) {
759
+ this._instance = blake3.create({
760
+ dkLen: outputLength,
761
+ key
762
+ });
763
+ }
764
+ /**
765
+ * Perform Sum 256 on the block.
766
+ * @param block The block to operate on.
767
+ * @param key Optional key for the hash.
768
+ * @returns The sum 256 of the block.
769
+ */
770
+ static sum256(block, key) {
771
+ Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
772
+ return new Blake3(Blake3.SIZE_256, key).update(block).digest();
773
+ }
774
+ /**
775
+ * Perform Sum 512 on the block.
776
+ * @param block The block to operate on.
777
+ * @param key Optional key for the hash.
778
+ * @returns The sum 512 of the block.
779
+ */
780
+ static sum512(block, key) {
781
+ Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
782
+ return new Blake3(Blake3.SIZE_512, key).update(block).digest();
783
+ }
784
+ /**
785
+ * Update the hash with the block.
786
+ * @param block The block to update the hash with.
787
+ * @returns The instance for chaining.
788
+ */
789
+ update(block) {
790
+ Guards.uint8Array(Blake3._CLASS_NAME, "block", block);
791
+ this._instance.update(block);
792
+ return this;
793
+ }
794
+ /**
795
+ * Get the digest for the hash.
796
+ * @returns The instance for chaining.
797
+ */
798
+ digest() {
799
+ return this._instance.digest();
800
+ }
801
+ }
802
+
708
803
  // Copyright 2024 IOTA Stiftung.
709
804
  // SPDX-License-Identifier: Apache-2.0.
710
805
  /**
@@ -1138,6 +1233,127 @@ class Sha256 {
1138
1233
  }
1139
1234
  }
1140
1235
 
1236
+ // Copyright 2024 IOTA Stiftung.
1237
+ // SPDX-License-Identifier: Apache-2.0.
1238
+ // eslint-disable-next-line camelcase
1239
+ /**
1240
+ * Perform a SHA-3 hash on the block.
1241
+ */
1242
+ class Sha3 {
1243
+ /**
1244
+ * Sha3 224.
1245
+ */
1246
+ static SIZE_224 = 224;
1247
+ /**
1248
+ * Sha3 256.
1249
+ */
1250
+ static SIZE_256 = 256;
1251
+ /**
1252
+ * Sha3 384.
1253
+ */
1254
+ static SIZE_384 = 384;
1255
+ /**
1256
+ * Sha3 512.
1257
+ */
1258
+ static SIZE_512 = 512;
1259
+ /**
1260
+ * Runtime name for the class.
1261
+ * @internal
1262
+ */
1263
+ static _CLASS_NAME = "Sha3";
1264
+ /**
1265
+ * The instance of the hash.
1266
+ * @internal
1267
+ */
1268
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1269
+ _instance;
1270
+ /**
1271
+ * Create a new instance of Sha3.
1272
+ * @param bits The number of bits.
1273
+ */
1274
+ constructor(bits = Sha3.SIZE_256) {
1275
+ if (bits !== Sha3.SIZE_224 &&
1276
+ bits !== Sha3.SIZE_256 &&
1277
+ bits !== Sha3.SIZE_384 &&
1278
+ bits !== Sha3.SIZE_512) {
1279
+ throw new GeneralError(Sha3._CLASS_NAME, "bitSize", { bitSize: bits });
1280
+ }
1281
+ if (bits === Sha3.SIZE_224) {
1282
+ // eslint-disable-next-line camelcase
1283
+ this._instance = sha3_224.create();
1284
+ }
1285
+ else if (bits === Sha3.SIZE_256) {
1286
+ // eslint-disable-next-line camelcase
1287
+ this._instance = sha3_256.create();
1288
+ }
1289
+ else if (bits === Sha3.SIZE_384) {
1290
+ // eslint-disable-next-line camelcase
1291
+ this._instance = sha3_384.create();
1292
+ }
1293
+ else {
1294
+ // eslint-disable-next-line camelcase
1295
+ this._instance = sha3_512.create();
1296
+ }
1297
+ }
1298
+ /**
1299
+ * Perform Sum 256 on the block.
1300
+ * @param block The block to operate on.
1301
+ * @returns The sum 256 of the block.
1302
+ */
1303
+ static sum256(block) {
1304
+ const b2b = new Sha3(Sha3.SIZE_256);
1305
+ b2b.update(block);
1306
+ return b2b.digest();
1307
+ }
1308
+ /**
1309
+ * Perform Sum 224 on the block.
1310
+ * @param block The block to operate on.
1311
+ * @returns The sum 224 of the block.
1312
+ */
1313
+ static sum224(block) {
1314
+ const b2b = new Sha3(Sha3.SIZE_224);
1315
+ b2b.update(block);
1316
+ return b2b.digest();
1317
+ }
1318
+ /**
1319
+ * Perform Sum 384 on the block.
1320
+ * @param block The block to operate on.
1321
+ * @returns The sum 384 of the block.
1322
+ */
1323
+ static sum384(block) {
1324
+ const b2b = new Sha3(Sha3.SIZE_384);
1325
+ b2b.update(block);
1326
+ return b2b.digest();
1327
+ }
1328
+ /**
1329
+ * Perform Sum 512 on the block.
1330
+ * @param block The block to operate on.
1331
+ * @returns The sum 512 of the block.
1332
+ */
1333
+ static sum512(block) {
1334
+ const b2b = new Sha3(Sha3.SIZE_512);
1335
+ b2b.update(block);
1336
+ return b2b.digest();
1337
+ }
1338
+ /**
1339
+ * Update the hash with the block.
1340
+ * @param block The block to update the hash with.
1341
+ * @returns The instance for chaining.
1342
+ */
1343
+ update(block) {
1344
+ Guards.uint8Array(Sha3._CLASS_NAME, "block", block);
1345
+ this._instance.update(block);
1346
+ return this;
1347
+ }
1348
+ /**
1349
+ * Get the digest for the hash.
1350
+ * @returns The instance for chaining.
1351
+ */
1352
+ digest() {
1353
+ return this._instance.digest();
1354
+ }
1355
+ }
1356
+
1141
1357
  // Copyright 2024 IOTA Stiftung.
1142
1358
  // SPDX-License-Identifier: Apache-2.0.
1143
1359
  /* eslint-disable camelcase */
@@ -1525,4 +1741,4 @@ class PasswordValidator {
1525
1741
  }
1526
1742
  }
1527
1743
 
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 };
1744
+ 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 };
@@ -34,6 +34,21 @@ export declare class Bip44 {
34
34
  * @returns The bip44 address base path.
35
35
  */
36
36
  static basePath(coinType: number): string;
37
+ /**
38
+ * Generate an address from the seed and parts.
39
+ * @param seed The account seed.
40
+ * @param keyType The key type.
41
+ * @param coinType The coin type.
42
+ * @param accountIndex The account index.
43
+ * @param isInternal Is this an internal address.
44
+ * @param addressIndex The address index.
45
+ * @returns The generated path and the associated keypair.
46
+ */
47
+ static address(seed: Uint8Array, keyType: KeyType, coinType: number, accountIndex: number, isInternal: boolean, addressIndex: number): {
48
+ address: string;
49
+ privateKey: Uint8Array;
50
+ publicKey: Uint8Array;
51
+ };
37
52
  /**
38
53
  * Generate a bech32 address from the seed and parts.
39
54
  * @param seed The account seed.
@@ -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.3
3
+ ## 0.0.1-next.31
4
4
 
5
5
  - Added: Bip44
@@ -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