Ufsecp 3.19.0

dotnet add package Ufsecp --version 3.19.0
                    
NuGet\Install-Package Ufsecp -Version 3.19.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ufsecp" Version="3.19.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ufsecp" Version="3.19.0" />
                    
Directory.Packages.props
<PackageReference Include="Ufsecp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ufsecp --version 3.19.0
                    
#r "nuget: Ufsecp, 3.19.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ufsecp@3.19.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ufsecp&version=3.19.0
                    
Install as a Cake Addin
#tool nuget:?package=Ufsecp&version=3.19.0
                    
Install as a Cake Tool

Ufsecp

C# P/Invoke bindings for UltrafastSecp256k1 -- high-performance secp256k1 elliptic curve cryptography.

Bundles native runtimes for Windows x64, Linux x64, Linux ARM64, and macOS ARM64. The native library is auto-copied to your build output -- no manual setup required.

Install

dotnet add package Ufsecp

Quick Start

using Ultrafast.Ufsecp;
using System.Security.Cryptography;

using var ctx = new Ufsecp();

// Generate key pair
byte[] privkey = RandomNumberGenerator.GetBytes(32);
byte[] pubkey = ctx.PubkeyCreate(privkey);

Console.WriteLine($"Version: {Ufsecp.VersionString}");
Console.WriteLine($"Pubkey:  {Convert.ToHexString(pubkey)}");

ECDSA Sign & Verify

byte[] msgHash = Ufsecp.Sha256("hello world"u8.ToArray());

// Sign (RFC 6979 deterministic nonce, low-S normalized)
byte[] sig = ctx.EcdsaSign(msgHash, privkey);

// Verify
bool valid = ctx.EcdsaVerify(msgHash, sig, pubkey);

// DER encode/decode
byte[] der = ctx.EcdsaSigToDer(sig);
byte[] compact = ctx.EcdsaSigFromDer(der);

ECDSA Recovery

var (recSig, recId) = ctx.EcdsaSignRecoverable(msgHash, privkey);
byte[] recovered = ctx.EcdsaRecover(msgHash, recSig, recId);

Schnorr (BIP-340)

byte[] xOnlyPub = ctx.PubkeyXonly(privkey);
byte[] auxRand = RandomNumberGenerator.GetBytes(32);

byte[] schnorrSig = ctx.SchnorrSign(msgHash, privkey, auxRand);
bool ok = ctx.SchnorrVerify(msgHash, schnorrSig, xOnlyPub);

ECDH

byte[] otherPriv = RandomNumberGenerator.GetBytes(32);
byte[] otherPub = ctx.PubkeyCreate(otherPriv);

byte[] shared = ctx.Ecdh(privkey, otherPub);        // SHA-256 of compressed point
byte[] xonly  = ctx.EcdhXonly(privkey, otherPub);    // SHA-256 of x-coordinate
byte[] raw    = ctx.EcdhRaw(privkey, otherPub);      // raw 32-byte x-coordinate

Bitcoin Addresses

string p2pkh  = ctx.AddrP2PKH(pubkey);                           // 1...
string p2wpkh = ctx.AddrP2WPKH(pubkey);                          // bc1q...
string p2tr   = ctx.AddrP2TR(xOnlyPub);                          // bc1p...
string test   = ctx.AddrP2WPKH(pubkey, Network.Testnet);         // tb1q...

BIP-32 HD Derivation

byte[] seed = RandomNumberGenerator.GetBytes(64);
byte[] master = ctx.Bip32Master(seed);
byte[] child = ctx.Bip32DerivePath(master, "m/44'/0'/0'/0/0");
byte[] childPriv = ctx.Bip32Privkey(child);
byte[] childPub = ctx.Bip32Pubkey(child);

WIF

string wif = ctx.WifEncode(privkey, compressed: true, Network.Mainnet);
var decoded = ctx.WifDecode(wif);
// decoded.Privkey, decoded.Compressed, decoded.Network

Taproot (BIP-341)

var (outputKeyX, parity) = ctx.TaprootOutputKey(xOnlyPub);
byte[] tweakedPriv = ctx.TaprootTweakSeckey(privkey);
bool tapValid = ctx.TaprootVerify(outputKeyX, parity, xOnlyPub);

Hashing

byte[] sha = Ufsecp.Sha256(data);                    // SHA-256 (SHA-NI accelerated)
byte[] h160 = Ufsecp.Hash160(data);                   // RIPEMD160(SHA256(data))
byte[] tagged = Ufsecp.TaggedHash("BIP0340/aux", data); // BIP-340 tagged hash

API Coverage (45+ functions)

Keys, ECDSA (sign/verify/recover/DER), Schnorr BIP-340, ECDH (compressed/xonly/raw), SHA-256, HASH160, Tagged Hash, BIP-32 HD, Taproot (BIP-341), Bitcoin Addresses (P2PKH/P2WPKH/P2TR), WIF, Key Tweaking.

Architecture Note

The C ABI layer uses the fast (variable-time) implementation for maximum throughput. A constant-time (CT) layer with identical mathematical operations is available via the C++ headers for applications requiring timing-attack resistance.

Supported Platforms

Platform Runtime
Windows x64 ufsecp.dll
Linux x64 libufsecp.so
Linux ARM64 libufsecp.so
macOS ARM64 libufsecp.dylib

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.19.0 0 3/4/2026
3.15.3 42 3/1/2026
3.15.2 44 3/1/2026
3.14.0 82 2/24/2026
3.13.1 80 2/24/2026
3.13.0 75 2/24/2026
3.12.3 79 2/24/2026
3.12.2 83 2/24/2026
3.12.1 79 2/23/2026
3.12.0 76 2/23/2026
3.11.0 84 2/23/2026
3.10.0 83 2/21/2026