hd-wallet-wasm 2.0.32 → 2.1.0

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 CHANGED
@@ -7,7 +7,7 @@ canonical EPM attestations.
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm install hd-wallet-wasm@2.0.32
10
+ npm install hd-wallet-wasm@2.1.0
11
11
  ```
12
12
 
13
13
  Use the package through a standards-compliant ESM bundler or from an installed
@@ -44,8 +44,17 @@ const seed = wallet.mnemonic.toSeed(phrase, 'optional passphrase');
44
44
  const master = wallet.hdkey.fromSeed(seed);
45
45
  const child = master.derivePath("m/44'/0'/0'/0/0");
46
46
 
47
- const digest = wallet.utils.sha256(new TextEncoder().encode('example'));
48
- const signature = wallet.curves.secp256k1.sign(digest, child.privateKey());
47
+ // sign()/verify() hash the message themselves (SHA-256; SHA-384 for P-384):
48
+ // pass the message, never a hash of it.
49
+ const message = new TextEncoder().encode('example');
50
+ const signature = wallet.curves.secp256k1.sign(message, child.privateKey());
51
+ const valid = wallet.curves.secp256k1.verify(message, signature, child.publicKey());
52
+
53
+ // signRecoverable()/recover() take a 32-byte hash you computed, used as given.
54
+ const { signature: rs, recoveryId } = wallet.curves.secp256k1.signRecoverable(
55
+ wallet.utils.keccak256(message),
56
+ child.privateKey(),
57
+ );
49
58
 
50
59
  wallet.utils.secureWipe(seed);
51
60
  child.wipe();
@@ -116,6 +125,14 @@ const valid = verifyEPMSignature(wallet, epm, publicKey, {
116
125
  });
117
126
  ```
118
127
 
128
+ A secp256k1 EPM signature (`{ curve: 'secp256k1' }`) is DER-encoded ECDSA over
129
+ SHA-256 of the canonical content, hashed once, as the SDS EPM annex and SDN's
130
+ Go and C++ verifiers require. Bitcoin chain proofs sign the Bitcoin
131
+ signed-message hash and Ethereum chain proofs the EIP-191 `personal_sign` hash,
132
+ each as a 65-byte compact recoverable signature; `verifyChainProof` recovers the
133
+ key from that protocol hash. Signatures from 2.0.x, which hashed twice, do not
134
+ verify.
135
+
119
136
  The dedicated attestation subpath and root package expose the same declaration
120
137
  surface for these helpers.
121
138
 
Binary file