Modern .NET9 library implementing common cryptographic standards used by various cryptocurrencies like BIP32/SLIP10, BIP39 and BIP44.
The intention of this library is to provide minimal no boilerplate implemenations of these cryptographic primitives while maintaining the best possible performance using the latest language features.
The base package is always required.
Installing a curve package will provide a singleton instance of that specific curve to be used in SLIP10 derivations.
Requires the secp256k1 c library in the same directory as your binary to work.
Consider building it from source or installing the Secp256k1.Native
package which bundles it for you.
Uses NSec behind the scenes for curve math which is also MIT licensed.
Converts mnemonic words to the seed used for deriving private keys.
Note
Only supports the english wordlist.
byte[] seed = BIP39.MnemonicToSeed("[mnemonics]");
//Or using spans
Span<byte> seed = stackalloc byte[256];
BIP39.TryMnemonicToSeed(seed, "[mnemonics]")
Takes the seed calculated using BIP39 and derives the master private key and child keys using BIP44 derivation paths.
(byte[] key, byte[] chainCode) = Slip10.DerivePath(
Secp256k1.Instance,
seed,
"m/44'/60'/0'/0/0"
);
//Or using spans
Span<byte> key = stackalloc byte[32];
Span<byte> chainCode = stackalloc byte[32];
Span<uint> path = stackalloc uint[5];
BIP44.Ethereum(path);
Slip10.TryDerivePath(
Secp256k1.Instance,
seed,
key,
chainCode,
path
);
Defines the format for derivation paths used for Bitcoin and a lot of other chains following the same spec.
This library defines helper methods to construct these paths to be used for BIP32 derivation.
string path = BIP44.Ethereum(5);
// ^ "m/44'/60'/0'/0/5"
// Or using spans
Span<uint> path = stackalloc uint[5];
BIP44.Ethereum(path, 5);