Commit 9751c3a
committed
ckd: reduce IL modulo N before range check
Restore pre-v3.0.0 behavior of applying ilNum.Mod(N) before the range
check in DeriveChildKey. Required for non-hardened CKD to work on
Edwards curves where N ≈ 2^252 and ~94%% of raw 256-bit HMAC outputs
exceed N.
v3.0.0 made the check strict, matching BIP-32 spec, which mandates
retrying with the next index when IL >= N. This library does not
implement retry (non-hardened Ed25519 CKD is non-standard anyway per
SLIP-0010), so the strict check would make EdDSA CKD effectively
unusable.
Trade-off: introduces a modular bias of ~2^-4 on derived child public
keys. Bias is washed out on private shares by the uniform parent share
so does not enable key recovery or forgery. Preserves address
compatibility with production wallets derived under prior library
versions.
Tests verified:
- crypto/ckd: PASS (BIP-32 test vectors for secp256k1)
- eddsa/signing TestE2EConcurrentWithHDDerive: PASS
- ecdsa/signing TestE2EWithHDKeyDerivation: PASS1 parent 2f5ab80 commit 9751c3a
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
230 | 240 | | |
231 | 241 | | |
232 | 242 | | |
| |||
0 commit comments