@twin.org/crypto 0.0.1-next.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.
- package/LICENSE +201 -0
- package/README.md +31 -0
- package/dist/cjs/index.cjs +1572 -0
- package/dist/esm/index.mjs +1528 -0
- package/dist/types/address/bech32.d.ts +28 -0
- package/dist/types/address/bip44.d.ts +53 -0
- package/dist/types/ciphers/chaCha20Poly1305.d.ts +24 -0
- package/dist/types/curves/ed25519.d.ts +37 -0
- package/dist/types/curves/secp256k1.d.ts +37 -0
- package/dist/types/curves/x25519.d.ts +18 -0
- package/dist/types/curves/zip215.d.ts +15 -0
- package/dist/types/hashes/blake2b.d.ts +55 -0
- package/dist/types/hashes/hmacSha1.d.ts +28 -0
- package/dist/types/hashes/hmacSha256.d.ts +44 -0
- package/dist/types/hashes/hmacSha512.d.ts +66 -0
- package/dist/types/hashes/pbkdf2.d.ts +23 -0
- package/dist/types/hashes/sha1.d.ts +26 -0
- package/dist/types/hashes/sha256.d.ts +41 -0
- package/dist/types/hashes/sha512.d.ts +61 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/keys/bip32Path.d.ts +40 -0
- package/dist/types/keys/bip39.d.ts +36 -0
- package/dist/types/keys/slip0010.d.ts +38 -0
- package/dist/types/models/keyType.d.ts +17 -0
- package/dist/types/otp/hotp.d.ts +14 -0
- package/dist/types/otp/totp.d.ts +46 -0
- package/dist/types/passwords/passwordGenerator.d.ts +11 -0
- package/dist/types/passwords/passwordValidator.d.ts +22 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/Bech32.md +89 -0
- package/docs/reference/classes/Bip32Path.md +117 -0
- package/docs/reference/classes/Bip39.md +121 -0
- package/docs/reference/classes/Bip44.md +173 -0
- package/docs/reference/classes/Blake2b.md +155 -0
- package/docs/reference/classes/ChaCha20Poly1305.md +69 -0
- package/docs/reference/classes/Ed25519.md +113 -0
- package/docs/reference/classes/HmacSha1.md +79 -0
- package/docs/reference/classes/HmacSha256.md +123 -0
- package/docs/reference/classes/HmacSha512.md +187 -0
- package/docs/reference/classes/Hotp.md +39 -0
- package/docs/reference/classes/PasswordGenerator.md +33 -0
- package/docs/reference/classes/PasswordValidator.md +56 -0
- package/docs/reference/classes/Pbkdf2.md +77 -0
- package/docs/reference/classes/Secp256k1.md +113 -0
- package/docs/reference/classes/Sha1.md +69 -0
- package/docs/reference/classes/Sha256.md +111 -0
- package/docs/reference/classes/Sha512.md +167 -0
- package/docs/reference/classes/Slip0010.md +114 -0
- package/docs/reference/classes/Totp.md +148 -0
- package/docs/reference/classes/X25519.md +57 -0
- package/docs/reference/classes/Zip215.md +43 -0
- package/docs/reference/index.md +34 -0
- package/docs/reference/type-aliases/KeyType.md +5 -0
- package/docs/reference/variables/KeyType.md +19 -0
- package/locales/en.json +71 -0
- package/package.json +71 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bech32 encoding and decoding.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Bech32 {
|
|
5
|
+
/**
|
|
6
|
+
* Encode the buffer.
|
|
7
|
+
* @param humanReadablePart The header.
|
|
8
|
+
* @param data The data to encode.
|
|
9
|
+
* @returns The encoded data.
|
|
10
|
+
*/
|
|
11
|
+
static encode(humanReadablePart: string, data: Uint8Array): string;
|
|
12
|
+
/**
|
|
13
|
+
* Decode a bech32 string.
|
|
14
|
+
* @param bech The text to decode.
|
|
15
|
+
* @returns The decoded data or undefined if it could not be decoded.
|
|
16
|
+
* @throws An error if the decoding fails.
|
|
17
|
+
*/
|
|
18
|
+
static decode(bech: string): {
|
|
19
|
+
humanReadablePart: string;
|
|
20
|
+
data: Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Is the input a bech 32 address.
|
|
24
|
+
* @param bech The value to test.
|
|
25
|
+
* @returns True if this is potentially a match.
|
|
26
|
+
*/
|
|
27
|
+
static isBech32(bech: unknown): bech is string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Bip32Path } from "../keys/bip32Path";
|
|
2
|
+
import { KeyType } from "../models/keyType";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation of Bip44 for address generation.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Bip44 {
|
|
7
|
+
/**
|
|
8
|
+
* Generate a bip44 key pair from the seed and parts.
|
|
9
|
+
* @param seed The account seed.
|
|
10
|
+
* @param keyType The key type.
|
|
11
|
+
* @param coinType The coin type.
|
|
12
|
+
* @param accountIndex The account index.
|
|
13
|
+
* @param isInternal Is this an internal address.
|
|
14
|
+
* @param addressIndex The address index.
|
|
15
|
+
* @returns The key pair.
|
|
16
|
+
* @throws Error if the address type is not supported.
|
|
17
|
+
*/
|
|
18
|
+
static keyPair(seed: Uint8Array, keyType: KeyType, coinType: number, accountIndex: number, isInternal: boolean, addressIndex: number): {
|
|
19
|
+
privateKey: Uint8Array;
|
|
20
|
+
publicKey: Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Generate a bip44 path based on all its parts.
|
|
24
|
+
* @param coinType The coin type.
|
|
25
|
+
* @param accountIndex The account index.
|
|
26
|
+
* @param isInternal Is this an internal address.
|
|
27
|
+
* @param addressIndex The address index.
|
|
28
|
+
* @returns The generated path.
|
|
29
|
+
*/
|
|
30
|
+
static path(coinType: number, accountIndex: number, isInternal: boolean, addressIndex: number): Bip32Path;
|
|
31
|
+
/**
|
|
32
|
+
* Create a bip44 base path for the provided coin type.
|
|
33
|
+
* @param coinType The coin type.
|
|
34
|
+
* @returns The bip44 address base path.
|
|
35
|
+
*/
|
|
36
|
+
static basePath(coinType: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a bech32 address from the seed and parts.
|
|
39
|
+
* @param seed The account seed.
|
|
40
|
+
* @param keyType The key type.
|
|
41
|
+
* @param hrp The human readable part of the address.
|
|
42
|
+
* @param coinType The coin type.
|
|
43
|
+
* @param accountIndex The account index.
|
|
44
|
+
* @param isInternal Is this an internal address.
|
|
45
|
+
* @param addressIndex The address index.
|
|
46
|
+
* @returns The generated path and the associated keypair.
|
|
47
|
+
*/
|
|
48
|
+
static addressBech32(seed: Uint8Array, keyType: KeyType, hrp: string, coinType: number, accountIndex: number, isInternal: boolean, addressIndex: number): {
|
|
49
|
+
address: string;
|
|
50
|
+
privateKey: Uint8Array;
|
|
51
|
+
publicKey: Uint8Array;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of the ChaCha20Poly1305 cipher.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ChaCha20Poly1305 {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new instance of ChaCha20Poly1305.
|
|
7
|
+
* @param key The key.
|
|
8
|
+
* @param nonce The nonce.
|
|
9
|
+
* @param aad The additional authenticated data.
|
|
10
|
+
*/
|
|
11
|
+
constructor(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array);
|
|
12
|
+
/**
|
|
13
|
+
* Encrypt the block.
|
|
14
|
+
* @param block The block to encrypt.
|
|
15
|
+
* @returns The block encrypted.
|
|
16
|
+
*/
|
|
17
|
+
encrypt(block: Uint8Array): Uint8Array;
|
|
18
|
+
/**
|
|
19
|
+
* Decrypt the block.
|
|
20
|
+
* @param block The block to decrypt.
|
|
21
|
+
* @returns The block decrypted.
|
|
22
|
+
*/
|
|
23
|
+
decrypt(block: Uint8Array): Uint8Array;
|
|
24
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of Ed25519.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Ed25519 {
|
|
5
|
+
/**
|
|
6
|
+
* Private Key Size is the size, in bytes, of private keys as used in this package.
|
|
7
|
+
*/
|
|
8
|
+
static PRIVATE_KEY_SIZE: number;
|
|
9
|
+
/**
|
|
10
|
+
* Public Key Size is the size, in bytes, of public keys as used in this package.
|
|
11
|
+
*/
|
|
12
|
+
static PUBLIC_KEY_SIZE: number;
|
|
13
|
+
/**
|
|
14
|
+
* Public returns the PublicKey corresponding to private.
|
|
15
|
+
* @param privateKey The private key to get the corresponding public key.
|
|
16
|
+
* @returns The public key.
|
|
17
|
+
* @throws Error if the private key is not the correct length.
|
|
18
|
+
*/
|
|
19
|
+
static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
|
|
20
|
+
/**
|
|
21
|
+
* Sign the block with privateKey and returns a signature.
|
|
22
|
+
* @param privateKey The private key.
|
|
23
|
+
* @param block The block to sign.
|
|
24
|
+
* @returns The signature.
|
|
25
|
+
* @throws Error if the private key is not the correct length.
|
|
26
|
+
*/
|
|
27
|
+
static sign(privateKey: Uint8Array, block: Uint8Array): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Verify reports whether sig is a valid signature of block by publicKey.
|
|
30
|
+
* @param publicKey The public key to verify the signature.
|
|
31
|
+
* @param block The block for the signature.
|
|
32
|
+
* @param signature The signature.
|
|
33
|
+
* @returns True if the signature matches.
|
|
34
|
+
* @throws Error if the public key is not the correct length.
|
|
35
|
+
*/
|
|
36
|
+
static verify(publicKey: Uint8Array, block: Uint8Array, signature: Uint8Array): boolean;
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of secp256k1.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Secp256k1 {
|
|
5
|
+
/**
|
|
6
|
+
* Private Key Size is the size, in bytes, of private keys as used in this package.
|
|
7
|
+
*/
|
|
8
|
+
static PRIVATE_KEY_SIZE: number;
|
|
9
|
+
/**
|
|
10
|
+
* Public Key Size is the size, in bytes, of public keys as used in this package.
|
|
11
|
+
*/
|
|
12
|
+
static PUBLIC_KEY_SIZE: number;
|
|
13
|
+
/**
|
|
14
|
+
* Public returns the PublicKey corresponding to private.
|
|
15
|
+
* @param privateKey The private key to get the corresponding public key.
|
|
16
|
+
* @returns The public key.
|
|
17
|
+
* @throws Error if the private key is not the correct length.
|
|
18
|
+
*/
|
|
19
|
+
static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
|
|
20
|
+
/**
|
|
21
|
+
* Sign the block with privateKey and returns a signature.
|
|
22
|
+
* @param privateKey The private key.
|
|
23
|
+
* @param block The block to sign.
|
|
24
|
+
* @returns The signature.
|
|
25
|
+
* @throws Error if the private key is not the correct length.
|
|
26
|
+
*/
|
|
27
|
+
static sign(privateKey: Uint8Array, block: Uint8Array): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Verify reports whether sig is a valid signature of block by publicKey.
|
|
30
|
+
* @param publicKey The public key to verify the signature.
|
|
31
|
+
* @param block The block for the signature.
|
|
32
|
+
* @param signature The signature.
|
|
33
|
+
* @returns True if the signature matches.
|
|
34
|
+
* @throws Error if the public key is not the correct length.
|
|
35
|
+
*/
|
|
36
|
+
static verify(publicKey: Uint8Array, block: Uint8Array, signature: Uint8Array): boolean;
|
|
37
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of X25519.
|
|
3
|
+
*/
|
|
4
|
+
export declare class X25519 {
|
|
5
|
+
/**
|
|
6
|
+
* Convert Ed25519 private key to X25519 private key.
|
|
7
|
+
* @param ed25519PrivateKey The ed25519 private key to convert.
|
|
8
|
+
* @returns The x25519 private key.
|
|
9
|
+
*/
|
|
10
|
+
static convertPrivateKeyToX25519(ed25519PrivateKey: Uint8Array): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* Convert Ed25519 public key to X25519 public key.
|
|
13
|
+
* @param ed25519PublicKey The ed25519 public key to convert.
|
|
14
|
+
* @returns The x25519 public key.
|
|
15
|
+
* @throws GeneralError On invalid public key.
|
|
16
|
+
*/
|
|
17
|
+
static convertPublicKeyToX25519(ed25519PublicKey: Uint8Array): Uint8Array;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of Zip215.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Zip215 {
|
|
5
|
+
/**
|
|
6
|
+
* Verify reports whether sig is a valid signature of block by
|
|
7
|
+
* publicKey, using precisely-specified validation criteria (ZIP 215) suitable
|
|
8
|
+
* for use in consensus-critical contexts.
|
|
9
|
+
* @param publicKey The public key for the block.
|
|
10
|
+
* @param block The block content to validate.
|
|
11
|
+
* @param sig The signature to verify.
|
|
12
|
+
* @returns True if the signature is valid.
|
|
13
|
+
*/
|
|
14
|
+
static verify(publicKey: Uint8Array, block: Uint8Array, sig: Uint8Array): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to help with Blake2B Signature scheme.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Blake2b {
|
|
5
|
+
/**
|
|
6
|
+
* Blake2b 160.
|
|
7
|
+
*/
|
|
8
|
+
static SIZE_160: number;
|
|
9
|
+
/**
|
|
10
|
+
* Blake2b 256.
|
|
11
|
+
*/
|
|
12
|
+
static SIZE_256: number;
|
|
13
|
+
/**
|
|
14
|
+
* Blake2b 512.
|
|
15
|
+
*/
|
|
16
|
+
static SIZE_512: number;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of Blake2b.
|
|
19
|
+
* @param outputLength The output length.
|
|
20
|
+
* @param key Optional key for the hash.
|
|
21
|
+
*/
|
|
22
|
+
constructor(outputLength: number, key?: Uint8Array);
|
|
23
|
+
/**
|
|
24
|
+
* Perform Sum 160 on the block.
|
|
25
|
+
* @param block The block to operate on.
|
|
26
|
+
* @param key Optional key for the hash.
|
|
27
|
+
* @returns The sum 160 of the block.
|
|
28
|
+
*/
|
|
29
|
+
static sum160(block: Uint8Array, key?: Uint8Array): Uint8Array;
|
|
30
|
+
/**
|
|
31
|
+
* Perform Sum 256 on the block.
|
|
32
|
+
* @param block The block to operate on.
|
|
33
|
+
* @param key Optional key for the hash.
|
|
34
|
+
* @returns The sum 256 of the block.
|
|
35
|
+
*/
|
|
36
|
+
static sum256(block: Uint8Array, key?: Uint8Array): Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
* Perform Sum 512 on the block.
|
|
39
|
+
* @param block The block to operate on.
|
|
40
|
+
* @param key Optional key for the hash.
|
|
41
|
+
* @returns The sum 512 of the block.
|
|
42
|
+
*/
|
|
43
|
+
static sum512(block: Uint8Array, key?: Uint8Array): Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Update the hash with the block.
|
|
46
|
+
* @param block The block to update the hash with.
|
|
47
|
+
* @returns The instance for chaining.
|
|
48
|
+
*/
|
|
49
|
+
update(block: Uint8Array): Blake2b;
|
|
50
|
+
/**
|
|
51
|
+
* Get the digest for the hash.
|
|
52
|
+
* @returns The instance for chaining.
|
|
53
|
+
*/
|
|
54
|
+
digest(): Uint8Array;
|
|
55
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to help with HmacSha1 scheme.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HmacSha1 {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new instance of HmacSha1.
|
|
7
|
+
* @param key The key for the hmac.
|
|
8
|
+
*/
|
|
9
|
+
constructor(key: Uint8Array);
|
|
10
|
+
/**
|
|
11
|
+
* Perform Sum on the block.
|
|
12
|
+
* @param key The key for the hmac.
|
|
13
|
+
* @param block The block to operate on.
|
|
14
|
+
* @returns The sum of the block.
|
|
15
|
+
*/
|
|
16
|
+
static sum(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Update the hash with the block.
|
|
19
|
+
* @param block The block to update the hash with.
|
|
20
|
+
* @returns The instance for chaining.
|
|
21
|
+
*/
|
|
22
|
+
update(block: Uint8Array): HmacSha1;
|
|
23
|
+
/**
|
|
24
|
+
* Get the digest for the hash.
|
|
25
|
+
* @returns The instance for chaining.
|
|
26
|
+
*/
|
|
27
|
+
digest(): Uint8Array;
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to help with HmacSha256 scheme.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HmacSha256 {
|
|
5
|
+
/**
|
|
6
|
+
* Sha256 256.
|
|
7
|
+
*/
|
|
8
|
+
static readonly SIZE_256: number;
|
|
9
|
+
/**
|
|
10
|
+
* Sha256 224.
|
|
11
|
+
*/
|
|
12
|
+
static readonly SIZE_224: number;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new instance of HmacSha256.
|
|
15
|
+
* @param key The key for the hmac.
|
|
16
|
+
* @param bits The number of bits.
|
|
17
|
+
*/
|
|
18
|
+
constructor(key: Uint8Array, bits?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Perform Sum 224 on the block.
|
|
21
|
+
* @param key The key for the hmac.
|
|
22
|
+
* @param block The block to operate on.
|
|
23
|
+
* @returns The sum 224 of the block.
|
|
24
|
+
*/
|
|
25
|
+
static sum224(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* Perform Sum 256 on the block.
|
|
28
|
+
* @param key The key for the hmac.
|
|
29
|
+
* @param block The block to operate on.
|
|
30
|
+
* @returns The sum 256 of the block.
|
|
31
|
+
*/
|
|
32
|
+
static sum256(key: Uint8Array, block: 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): HmacSha256;
|
|
39
|
+
/**
|
|
40
|
+
* Get the digest for the hash.
|
|
41
|
+
* @returns The instance for chaining.
|
|
42
|
+
*/
|
|
43
|
+
digest(): Uint8Array;
|
|
44
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to help with HmacSha512 scheme.
|
|
3
|
+
*/
|
|
4
|
+
export declare class HmacSha512 {
|
|
5
|
+
/**
|
|
6
|
+
* Sha512 224.
|
|
7
|
+
*/
|
|
8
|
+
static SIZE_224: number;
|
|
9
|
+
/**
|
|
10
|
+
* Sha512 256.
|
|
11
|
+
*/
|
|
12
|
+
static SIZE_256: number;
|
|
13
|
+
/**
|
|
14
|
+
* Sha512 384.
|
|
15
|
+
*/
|
|
16
|
+
static SIZE_384: number;
|
|
17
|
+
/**
|
|
18
|
+
* Sha512 512.
|
|
19
|
+
*/
|
|
20
|
+
static SIZE_512: number;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new instance of HmacSha512.
|
|
23
|
+
* @param key The key for the hmac.
|
|
24
|
+
* @param bits The number of bits.
|
|
25
|
+
*/
|
|
26
|
+
constructor(key: Uint8Array, bits?: number);
|
|
27
|
+
/**
|
|
28
|
+
* Perform Sum 512 on the block.
|
|
29
|
+
* @param key The key for the hmac.
|
|
30
|
+
* @param block The block to operate on.
|
|
31
|
+
* @returns The sum 512 of the block.
|
|
32
|
+
*/
|
|
33
|
+
static sum512(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
34
|
+
/**
|
|
35
|
+
* Perform Sum 384 on the block.
|
|
36
|
+
* @param key The key for the hmac.
|
|
37
|
+
* @param block The block to operate on.
|
|
38
|
+
* @returns The sum 384 of the block.
|
|
39
|
+
*/
|
|
40
|
+
static sum384(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Perform Sum 256 on the block.
|
|
43
|
+
* @param key The key for the hmac.
|
|
44
|
+
* @param block The block to operate on.
|
|
45
|
+
* @returns The sum 256 of the block.
|
|
46
|
+
*/
|
|
47
|
+
static sum256(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Perform Sum 224 on the block.
|
|
50
|
+
* @param key The key for the hmac.
|
|
51
|
+
* @param block The block to operate on.
|
|
52
|
+
* @returns The sum 224 of the block.
|
|
53
|
+
*/
|
|
54
|
+
static sum224(key: Uint8Array, block: Uint8Array): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* Update the hash with the block.
|
|
57
|
+
* @param block The block to update the hash with.
|
|
58
|
+
* @returns The instance for chaining.
|
|
59
|
+
*/
|
|
60
|
+
update(block: Uint8Array): HmacSha512;
|
|
61
|
+
/**
|
|
62
|
+
* Get the digest for the hash.
|
|
63
|
+
* @returns The instance for chaining.
|
|
64
|
+
*/
|
|
65
|
+
digest(): Uint8Array;
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of the password based key derivation function 2.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Pbkdf2 {
|
|
5
|
+
/**
|
|
6
|
+
* Derive a key from the parameters using Sha256.
|
|
7
|
+
* @param password The password to derive the key from.
|
|
8
|
+
* @param salt The salt for the derivation.
|
|
9
|
+
* @param iterations Number of iterations to perform.
|
|
10
|
+
* @param keyLength The length of the key to derive.
|
|
11
|
+
* @returns The derived key.
|
|
12
|
+
*/
|
|
13
|
+
static sha256(password: Uint8Array, salt: Uint8Array, iterations: number, keyLength: number): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* Derive a key from the parameters using Sha512.
|
|
16
|
+
* @param password The password to derive the key from.
|
|
17
|
+
* @param salt The salt for the derivation.
|
|
18
|
+
* @param iterations Number of iterations to perform.
|
|
19
|
+
* @param keyLength The length of the key to derive.
|
|
20
|
+
* @returns The derived key.
|
|
21
|
+
*/
|
|
22
|
+
static sha512(password: Uint8Array, salt: Uint8Array, iterations: number, keyLength: number): Uint8Array;
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perform a SHA-1 hash on the block.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Sha1 {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new instance of Sha1.
|
|
7
|
+
*/
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Perform Sum on the block.
|
|
11
|
+
* @param block The block to operate on.
|
|
12
|
+
* @returns The sum of the block.
|
|
13
|
+
*/
|
|
14
|
+
static sum(block: Uint8Array): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Update the hash with the block.
|
|
17
|
+
* @param block The block to update the hash with.
|
|
18
|
+
* @returns The instance for chaining.
|
|
19
|
+
*/
|
|
20
|
+
update(block: Uint8Array): Sha1;
|
|
21
|
+
/**
|
|
22
|
+
* Get the digest for the hash.
|
|
23
|
+
* @returns The instance for chaining.
|
|
24
|
+
*/
|
|
25
|
+
digest(): Uint8Array;
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perform a SHA-256 hash on the block.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Sha256 {
|
|
5
|
+
/**
|
|
6
|
+
* Sha256 256.
|
|
7
|
+
*/
|
|
8
|
+
static readonly SIZE_256: number;
|
|
9
|
+
/**
|
|
10
|
+
* Sha256 224.
|
|
11
|
+
*/
|
|
12
|
+
static readonly SIZE_224: number;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new instance of Sha256.
|
|
15
|
+
* @param bits The number of bits.
|
|
16
|
+
*/
|
|
17
|
+
constructor(bits?: number);
|
|
18
|
+
/**
|
|
19
|
+
* Perform Sum 256 on the block.
|
|
20
|
+
* @param block The block to operate on.
|
|
21
|
+
* @returns The sum 256 of the block.
|
|
22
|
+
*/
|
|
23
|
+
static sum256(block: Uint8Array): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Perform Sum 224 on the block.
|
|
26
|
+
* @param block The block to operate on.
|
|
27
|
+
* @returns The sum 224 of the block.
|
|
28
|
+
*/
|
|
29
|
+
static sum224(block: Uint8Array): Uint8Array;
|
|
30
|
+
/**
|
|
31
|
+
* Update the hash with the block.
|
|
32
|
+
* @param block The block to update the hash with.
|
|
33
|
+
* @returns The instance for chaining.
|
|
34
|
+
*/
|
|
35
|
+
update(block: Uint8Array): Sha256;
|
|
36
|
+
/**
|
|
37
|
+
* Get the digest for the hash.
|
|
38
|
+
* @returns The instance for chaining.
|
|
39
|
+
*/
|
|
40
|
+
digest(): Uint8Array;
|
|
41
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Perform a SHA-512 hash on the block.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Sha512 {
|
|
5
|
+
/**
|
|
6
|
+
* Sha512 224.
|
|
7
|
+
*/
|
|
8
|
+
static SIZE_224: number;
|
|
9
|
+
/**
|
|
10
|
+
* Sha512 256.
|
|
11
|
+
*/
|
|
12
|
+
static SIZE_256: number;
|
|
13
|
+
/**
|
|
14
|
+
* Sha512 384.
|
|
15
|
+
*/
|
|
16
|
+
static SIZE_384: number;
|
|
17
|
+
/**
|
|
18
|
+
* Sha512 512.
|
|
19
|
+
*/
|
|
20
|
+
static SIZE_512: number;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new instance of Sha512.
|
|
23
|
+
* @param bits The number of bits.
|
|
24
|
+
*/
|
|
25
|
+
constructor(bits?: number);
|
|
26
|
+
/**
|
|
27
|
+
* Perform Sum 512 on the block.
|
|
28
|
+
* @param block The block to operate on.
|
|
29
|
+
* @returns The sum 512 of the block.
|
|
30
|
+
*/
|
|
31
|
+
static sum512(block: Uint8Array): Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* Perform Sum 384 on the block.
|
|
34
|
+
* @param block The block to operate on.
|
|
35
|
+
* @returns The sum 384 of the block.
|
|
36
|
+
*/
|
|
37
|
+
static sum384(block: Uint8Array): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* Perform Sum 256 on the block.
|
|
40
|
+
* @param block The block to operate on.
|
|
41
|
+
* @returns The sum 256 of the block.
|
|
42
|
+
*/
|
|
43
|
+
static sum256(block: Uint8Array): Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Perform Sum 224 on the block.
|
|
46
|
+
* @param block The block to operate on.
|
|
47
|
+
* @returns The sum 224 of the block.
|
|
48
|
+
*/
|
|
49
|
+
static sum224(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): Sha512;
|
|
56
|
+
/**
|
|
57
|
+
* Get the digest for the hash.
|
|
58
|
+
* @returns The instance for chaining.
|
|
59
|
+
*/
|
|
60
|
+
digest(): Uint8Array;
|
|
61
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./address/bech32";
|
|
2
|
+
export * from "./address/bip44";
|
|
3
|
+
export * from "./ciphers/chaCha20Poly1305";
|
|
4
|
+
export * from "./curves/ed25519";
|
|
5
|
+
export * from "./curves/secp256k1";
|
|
6
|
+
export * from "./curves/x25519";
|
|
7
|
+
export * from "./curves/zip215";
|
|
8
|
+
export * from "./hashes/blake2b";
|
|
9
|
+
export * from "./hashes/hmacSha1";
|
|
10
|
+
export * from "./hashes/hmacSha256";
|
|
11
|
+
export * from "./hashes/hmacSha512";
|
|
12
|
+
export * from "./hashes/pbkdf2";
|
|
13
|
+
export * from "./hashes/sha1";
|
|
14
|
+
export * from "./hashes/sha256";
|
|
15
|
+
export * from "./hashes/sha512";
|
|
16
|
+
export * from "./keys/bip32Path";
|
|
17
|
+
export * from "./keys/bip39";
|
|
18
|
+
export * from "./keys/slip0010";
|
|
19
|
+
export * from "./models/keyType";
|
|
20
|
+
export * from "./otp/hotp";
|
|
21
|
+
export * from "./otp/totp";
|
|
22
|
+
export * from "./passwords/passwordGenerator";
|
|
23
|
+
export * from "./passwords/passwordValidator";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to help with bip32 paths.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Bip32Path {
|
|
5
|
+
/**
|
|
6
|
+
* Create a new instance of Bip32Path.
|
|
7
|
+
* @param initialPath Initial path to create.
|
|
8
|
+
*/
|
|
9
|
+
constructor(initialPath?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Construct a new path by cloning an existing one.
|
|
12
|
+
* @param bip32Path The path to clone.
|
|
13
|
+
* @returns A new instance of Bip32Path.
|
|
14
|
+
*/
|
|
15
|
+
static fromPath(bip32Path: Bip32Path): Bip32Path;
|
|
16
|
+
/**
|
|
17
|
+
* Converts the path to a string.
|
|
18
|
+
* @returns The path as a string.
|
|
19
|
+
*/
|
|
20
|
+
toString(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Push a new index on to the path.
|
|
23
|
+
* @param index The index to add to the path.
|
|
24
|
+
*/
|
|
25
|
+
push(index: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Push a new hardened index on to the path.
|
|
28
|
+
* @param index The index to add to the path.
|
|
29
|
+
*/
|
|
30
|
+
pushHardened(index: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Pop an index from the path.
|
|
33
|
+
*/
|
|
34
|
+
pop(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get the segments.
|
|
37
|
+
* @returns The segments as numbers.
|
|
38
|
+
*/
|
|
39
|
+
numberSegments(): number[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation of Bip39 for mnemonic generation.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Bip39 {
|
|
5
|
+
/**
|
|
6
|
+
* Generate a random mnemonic.
|
|
7
|
+
* @param strength The strength of the mnemonic to generate, defaults to 256.
|
|
8
|
+
* @param words The wordlist to use, defaults to the English wordlist.
|
|
9
|
+
* @returns The random mnemonic.
|
|
10
|
+
* @throws Error if the length is not a multiple of 32.
|
|
11
|
+
*/
|
|
12
|
+
static randomMnemonic(strength?: number, words?: string[]): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a mnemonic from the entropy.
|
|
15
|
+
* @param entropy The entropy to generate.
|
|
16
|
+
* @param words The wordlist to use, defaults to the English wordlist.
|
|
17
|
+
* @returns The mnemonic.
|
|
18
|
+
* @throws Error if the length of the entropy is not a multiple of 4, or is less than 16 or greater than 32.
|
|
19
|
+
*/
|
|
20
|
+
static entropyToMnemonic(entropy: Uint8Array, words?: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a mnemonic to a seed.
|
|
23
|
+
* @param mnemonic The mnemonic to convert.
|
|
24
|
+
* @param password The password to apply to the seed generation.
|
|
25
|
+
* @returns The seed.
|
|
26
|
+
*/
|
|
27
|
+
static mnemonicToSeed(mnemonic: string, password?: string): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Convert the mnemonic back to entropy.
|
|
30
|
+
* @param mnemonic The mnemonic to convert.
|
|
31
|
+
* @param words The wordlist to use, defaults to the English wordlist.
|
|
32
|
+
* @returns The entropy.
|
|
33
|
+
* @throws Error if the number of words is not a multiple of 3.
|
|
34
|
+
*/
|
|
35
|
+
static mnemonicToEntropy(mnemonic: string, words?: string[]): Uint8Array;
|
|
36
|
+
}
|