Ufsecp 3.60.0
dotnet add package Ufsecp --version 3.60.0
NuGet\Install-Package Ufsecp -Version 3.60.0
<PackageReference Include="Ufsecp" Version="3.60.0" />
<PackageVersion Include="Ufsecp" Version="3.60.0" />
<PackageReference Include="Ufsecp" />
paket add Ufsecp --version 3.60.0
#r "nuget: Ufsecp, 3.60.0"
#:package Ufsecp@3.60.0
#addin nuget:?package=Ufsecp&version=3.60.0
#tool nuget:?package=Ufsecp&version=3.60.0
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.
Features
- ECDSA -- sign, verify, recover, DER serialization (RFC 6979)
- Schnorr -- BIP-340 sign/verify
- ECDH -- shared secret derivation
- BIP-32 -- HD key derivation
- Taproot -- BIP-341 output key tweaking
- Addresses -- P2PKH, P2WPKH, P2TR
- WIF -- encode/decode
- Hashing -- SHA-256, HASH160, tagged hash
- Key tweaking -- negate, add, multiply
- Ethereum -- Keccak-256, EIP-55 addresses, EIP-155 sign, ecrecover
- BIP-39 -- mnemonic generation, validation, seed derivation
- Multi-coin wallet -- 7-coin address dispatch (BTC/LTC/DOGE/DASH/ETH/BCH/TRX)
- Batch verification -- ECDSA + Schnorr batch verify with invalid identification
- MuSig2 -- BIP-327 multi-signatures (key agg, nonce gen, partial sign, aggregate)
- FROST -- threshold signatures (keygen, sign, aggregate, verify)
- Adaptor signatures -- Schnorr + ECDSA adaptor pre-sign, adapt, extract
- Pedersen commitments -- commit, verify, sum balance, switch commitments
- ZK proofs -- knowledge proof, DLEQ proof, Bulletproof range proof
- Multi-scalar multiplication -- Shamir's trick, MSM
- Pubkey arithmetic -- add, negate, combine N keys
- SHA-512 -- full SHA-512 hash
- Message signing -- BIP-137 Bitcoin message sign/verify
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)}");
Local Smoke Validation
bash libs/UltrafastSecp256k1/scripts/validate_bindings.sh
This runs the current C#, Java, and Swift smoke suites against the local build tree on a prepared developer machine.
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.
Performance Tuning
When building the native library from source, you can tune scalar multiplication (k*P) performance via the GLV window width:
cmake -S . -B build -DSECP256K1_GLV_WINDOW_WIDTH=6
| Window | Default On | Tradeoff |
|---|---|---|
| w=4 | ESP32, WASM | Smaller tables, more point additions |
| w=5 | x86-64, ARM64, RISC-V | Balanced (default) |
| w=6 | -- | Larger tables, fewer additions |
See docs/PERFORMANCE_GUIDE.md for detailed benchmarks and per-platform tuning advice.
Supported Platforms
| Platform | Runtime |
|---|---|
| Windows x64 | ufsecp.dll |
| Linux x64 | libufsecp.so |
| Linux ARM64 | libufsecp.so |
| macOS ARM64 | libufsecp.dylib |
License
MIT
Links
| Product | Versions 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. |
-
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.60.0 | 0 | 4/4/2026 |
| 3.50.0 | 104 | 3/28/2026 |
| 3.22.0 | 96 | 3/10/2026 |
| 3.21.1 | 85 | 3/9/2026 |
| 3.21.0 | 84 | 3/8/2026 |
| 3.20.1 | 84 | 3/8/2026 |
| 3.19.0 | 85 | 3/4/2026 |
| 3.15.3 | 89 | 3/1/2026 |
| 3.15.2 | 90 | 3/1/2026 |
| 3.14.0 | 85 | 2/24/2026 |
| 3.13.1 | 84 | 2/24/2026 |
| 3.13.0 | 85 | 2/24/2026 |
| 3.12.3 | 86 | 2/24/2026 |
| 3.12.2 | 89 | 2/24/2026 |
| 3.12.1 | 83 | 2/23/2026 |
| 3.12.0 | 80 | 2/23/2026 |
| 3.11.0 | 87 | 2/23/2026 |
| 3.10.0 | 91 | 2/21/2026 |
| 3.4.0 | 80 | 3/23/2026 |
| 3.3.0 | 80 | 3/20/2026 |