Giter Site home page Giter Site logo

kzorin52 / nbip32fast Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 64 KB

High perfomance, SIMD-accelerated BIP-32 HD key derivation library for .NET 8

License: MIT License

C# 100.00%
bip32 bip32ed25519 bip32key ecdsa-key-pair ed25519 hdkey hdwallet secp256k1 performance nistp256

nbip32fast's Introduction

NuGet NuGet NuGet NuGet

NBip32Fast

High perfomance BIP-32 HD key derivation library for .NET 8

Usage

Basic

var secp256k1Key = Secp256K1.Secp256K1HdKey.Instance.DerivePath("m/44'/0'/0'/0/0", seed).Key;
var nistP256Key = NistP256.NistP256HdKey.Instance.DerivePath("m/44'/0'/0'/0/0", seed).Key;
var ed25519Key = Ed25519.Ed25519HdKey.Instance.DerivePath("m/44'/0'/0'/0'/0'", seed).Key;

Optimised

var master = Ed25519.Ed25519HdKey.Instance.DerivePath("m/44'/888'/0'/0'", seed);
var accounts = new List<byte[]>();

for (var i = 0u; i < 5u; i++)
{
    accounts.Add(Ed25519.Ed25519HdKey.Instance.GetPublic(Ed25519.Ed25519HdKey.Instance.Derive(master, new KeyPathElement(i, true)).Key));
}

Benchmarks

Intel Core i9-14900K, 1 CPU, 32 logical and 24 physical cores

SecP256K1

Method Mean Error StdDev Gen0 Gen1 Allocated
NBip39FastKey 37.91 us 0.112 us 0.105 us 0.0610 - 2.04 KB
NBitcoinKey 448.31 us 1.104 us 1.033 us 0.4883 - 9.38 KB
NetezosKey 619.23 us 4.850 us 4.537 us 168.9453 0.9766 3112.87 KB

Ed25519

Method Mean Error StdDev Gen0 Allocated
NBip32FastKey 4.572 us 0.0104 us 0.0097 us 0.0839 1.59 KB
NetezosKey 5.796 us 0.0257 us 0.0241 us 0.3204 5.95 KB
P3HdKey 6.173 us 0.0103 us 0.0126 us 0.3357 6.28 KB

NistP256

Method Mean Error StdDev Gen0 Gen1 Allocated
NBip39FastKey 161.6 us 0.19 us 0.17 us - - 1.93 KB
NetezosKey 1,429.4 us 10.00 us 8.86 us 373.0469 1.9531 6888.66 KB

Benchmark code

TODOs

  • Ed25519 soft derivation scheme (used in Cardano)
  • KeyPathTree for efficient computing (for multiple keypath merging and index depth)
  • HDKey refactoring with public key lazy addition
  • Secp256K1 public key without Span<byte> to byte[] conversion
    • All providers ReadOnlySpan<byte> public keys
  • More testing

nbip32fast's People

Contributors

kzorin52 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.