File tree 5 files changed +17
-2
lines changed
5 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ export class Bip32PrivateKey {
71
71
* - 32 bytes: Ed25519 curve scalar from which few bits have been tweaked according to ED25519-BIP32
72
72
* - 32 bytes: Ed25519 binary blob used as IV for signing
73
73
*
74
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
75
+ *
74
76
* @param entropy Random stream of bytes generated from a BIP39 seed phrase.
75
77
* @param password The second factor authentication password for the mnemonic phrase.
76
78
* @returns The secret extended key.
@@ -123,6 +125,8 @@ export class Bip32PrivateKey {
123
125
* This is why deriving the private key should not fail while deriving
124
126
* the public key may fail (if the derivation index is invalid).
125
127
*
128
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
129
+ *
126
130
* @param derivationIndices The derivation indices.
127
131
* @returns The child BIP-32 key.
128
132
*/
@@ -144,6 +148,8 @@ export class Bip32PrivateKey {
144
148
/**
145
149
* Computes the BIP-32 public key from this BIP-32 private key.
146
150
*
151
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
152
+ *
147
153
* @returns the public key.
148
154
*/
149
155
toPublic ( ) : Bip32PublicKey {
Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ export class Bip32PublicKey {
53
53
/**
54
54
* Given a set of indices, this function computes the corresponding child extended key.
55
55
*
56
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
57
+ *
56
58
* @param derivationIndices The list of derivation indices.
57
59
* @returns The child extended private key.
58
60
*/
@@ -76,7 +78,7 @@ export class Bip32PublicKey {
76
78
return Bip32PublicKeyHex ( Buffer . from ( this . #key) . toString ( 'hex' ) ) ;
77
79
}
78
80
79
- /** Gets the blake2 hash of the key. */
81
+ /** Gets the blake2 hash of the key. NOTE: You must call `Crypto.ready()` at least once before calling this function. */
80
82
hash ( ) : Bip32PublicKeyHashHex {
81
83
const hash = sodium . crypto_generichash ( BIP32_PUBLIC_KEY_HASH_LENGTH , this . #key) ;
82
84
return Bip32PublicKeyHashHex ( Buffer . from ( hash ) . toString ( 'hex' ) ) ;
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ export class Ed25519PrivateKey {
78
78
/**
79
79
* Computes the raw public key from this raw private key.
80
80
*
81
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
82
+ *
81
83
* @returns the public key.
82
84
*/
83
85
toPublic ( ) : Ed25519PublicKey {
@@ -91,6 +93,8 @@ export class Ed25519PrivateKey {
91
93
/**
92
94
* Generates an Ed25519 signature.
93
95
*
96
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
97
+ *
94
98
* @param message The message to be signed.
95
99
* @returns The Ed25519 digital signature.
96
100
*/
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ export class Ed25519PublicKey {
26
26
* Verifies that the passed-in signature was generated with a private key that matches
27
27
* the given public key.
28
28
*
29
+ * NOTE: You must call `Crypto.ready()` at least once before calling this function.
30
+ *
29
31
* @param signature The signature bytes to be verified.
30
32
* @param message The original message the signature was computed from.
31
33
* @returns true if the signature is valid; otherwise; false.
@@ -57,7 +59,7 @@ export class Ed25519PublicKey {
57
59
return Ed25519PublicKey . fromBytes ( Buffer . from ( keyMaterial , 'hex' ) ) ;
58
60
}
59
61
60
- /** Gets the blake2 hash of the key material. */
62
+ /** Gets the blake2 hash of the key material. NOTE: You must call `Crypto.ready()` at least once before calling this function. */
61
63
hash ( ) : Ed25519KeyHash {
62
64
const hash = sodium . crypto_generichash ( ED25519_PUBLIC_KEY_HASH_LENGTH , this . #keyMaterial) ;
63
65
return Ed25519KeyHash . fromBytes ( hash ) ;
Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ export * from './strategies';
9
9
export * from './hexTypes' ;
10
10
export * from './types' ;
11
11
12
+ /** This function must be called before any other function in this module. it is safe to call this function multiple times. */
12
13
export const ready = async ( ) : Promise < void > => await sodium . ready ;
You can’t perform that action at this time.
0 commit comments