Skip to content

gautamdhameja/sr25519-dotnet

Repository files navigation

sr25519-dotnet

.Net bindings for SR25519 crypto implemented using P/Invoke on a dll generated by compiling Rust code as cdylib.

The underlying Rust code compiled into dll is from the SR26619 C bindings https://github.com/Warchant/sr25519-crust. The original Rust implementation of SR25519 crypto, on which these bindings are built, is available at w3f/schnorrkel.

Well, yeah, we can call these bindings on bindings. :-)

The current code uses release builds on various platforms from the C bindings compatible with version v0.9.1 of schnorrkel (builds from master https://github.com/Warchant/sr25519-crust/commit/ddbabcd12cbe60a7921e280ad93476faf4d4212a).

Test data used here is the same as that in the C bindings to ensure things are working as expected.

Usage

All SR25519 operations (currently supported) are in the SR25519.cs class. Simply call any of the functions like:

var keys = SR25519.GenerateKeypairFromSeed(
                "8fd6aabb4e4c06826efcf0d0a46b2580ca7bad1b419a49c92b49717b30bc343e");

Check the tests for more examples.

Current State

At the moment, these bindings don't include VRF signing and verification functions.

The native lib dependency is also provided for various platforms in the /native/libs folder:

  • Windows 64-bit (MSVC)
  • MaxOS 64-bit
  • Android (Linux) ARMv8 & x86_64
  • Linux x86_64

To Do

  • Update to latest version of schnorrkel when C bindings are updated.
  • Add bindings for VRF related functions.
  • Automate build process.
  • Publish as a nuget package.