You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When deriving many soft children of the same parent (e.g. scanning wallet addresses m/44'/60'/0'/0/{i}), wrap the parent in a Bip32Parent. It computes the parent public key once and reuses it for every child, instead of one EC multiplication per child — about 10x faster for secp256k1:
varaccount=newBip32Key();Secp256K1HdKey.Instance.DerivePath("m/44'/60'/0'/0",seed,refaccount);varparent=newBip32Parent(inaccount,Secp256K1HdKey.Instance);varchild=newBip32Key();for(vari=0u;i<1000u;i++){parent.Derive(KeyPathElement.Soft(i),refchild);// EC point multiplication happens once, not 1000 times// use child.Key / child.ChainCode}
Hardened indices work too (they simply take the regular path, since no public key is involved).
Method
Count
Mean
Ratio
Allocated
CachedParentDerive
100
142.6 us
0.10
-
PlainDerive
100
1,424.7 us
1.00
-
Benchmarks
AMD Ryzen Threadripper 7980X 64-Cores 2.18GHz, 1 CPU, 128 logical and 64 physical cores (lower values is better)