ZkpSharp 1.4.0
dotnet add package ZkpSharp --version 1.4.0
NuGet\Install-Package ZkpSharp -Version 1.4.0
<PackageReference Include="ZkpSharp" Version="1.4.0" />
<PackageVersion Include="ZkpSharp" Version="1.4.0" />
<PackageReference Include="ZkpSharp" />
paket add ZkpSharp --version 1.4.0
#r "nuget: ZkpSharp, 1.4.0"
#:package ZkpSharp@1.4.0
#addin nuget:?package=ZkpSharp&version=1.4.0
#tool nuget:?package=ZkpSharp&version=1.4.0
ZkpSharp
A .NET library for Zero-Knowledge Proofs with Stellar Soroban blockchain integration. Prove facts about private data (age, balance, membership, range, time conditions) without revealing the data itself.
Features
Privacy proofs (HMAC-based commitment schemes) -- fast, lightweight:
- Proof of Age, Balance, Membership, Range, Time Condition
- HMAC-SHA256 with cryptographic salt
True zero-knowledge proofs (Bulletproofs) -- mathematically sound:
- ZK range, age, and balance proofs using Pedersen commitments
- Compact serialization for storage and transmission
Stellar blockchain integration:
- Soroban SDK 25 with BLS12-381 cryptography
- On-chain verification via
InvokeHostFunctionOp SorobanTransactionBuilderfor XDR construction
Installation
dotnet add package ZkpSharp
Quick start
using ZkpSharp.Core;
using ZkpSharp.Security;
var proofProvider = new ProofProvider("your-base64-encoded-32-byte-key");
var zkp = new Zkp(proofProvider);
// Prove age >= 18 without revealing birthdate
var (proof, salt) = zkp.ProveAge(new DateTime(1995, 3, 15));
bool valid = zkp.VerifyAge(proof, new DateTime(1995, 3, 15), salt);
// Prove sufficient balance without revealing actual amount
var (bProof, bSalt) = zkp.ProveBalance(1000.0, 500.0);
bool bValid = zkp.VerifyBalance(bProof, 500.0, bSalt, 1000.0);
For Bulletproofs (true ZKP):
using ZkpSharp.Security;
var zkProvider = new BulletproofsProvider();
var (proof, commitment) = zkProvider.ProveRange(value: 42, min: 0, max: 100);
bool valid = zkProvider.VerifyRange(proof, commitment, min: 0, max: 100);
See QUICKSTART.md for a complete walkthrough including Stellar integration.
API
Zkp -- HMAC-based privacy proofs
| Method | Description |
|---|---|
ProveAge(DateTime dateOfBirth) |
Prove age >= 18 (configurable) |
VerifyAge(string proof, DateTime dateOfBirth, string salt) |
Verify age proof |
ProveBalance(double balance, double requestedAmount) |
Prove balance >= requested |
VerifyBalance(string proof, double requestedAmount, string salt, double balance) |
Verify balance proof |
ProveMembership(string value, string[] validValues) |
Prove value is in set |
VerifyMembership(string proof, string value, string salt, string[] validValues) |
Verify membership proof |
ProveRange(double value, double minValue, double maxValue) |
Prove value is in range |
VerifyRange(string proof, double minValue, double maxValue, double value, string salt) |
Verify range proof |
ProveTimeCondition(DateTime eventDate, DateTime conditionDate) |
Prove event after date |
VerifyTimeCondition(string proof, DateTime eventDate, DateTime conditionDate, string salt) |
Verify time proof |
All Prove* methods return (string Proof, string Salt). Salts are generated automatically and must be stored alongside proofs.
BulletproofsProvider -- True zero-knowledge proofs
| Method | Description |
|---|---|
ProveRange(long value, long min, long max) |
ZK range proof |
VerifyRange(byte[] proof, byte[] commitment, long min, long max) |
Verify ZK range proof |
ProveAge(DateTime birthDate, int minAge) |
ZK age proof |
VerifyAge(byte[] proof, byte[] commitment, int minAge) |
Verify ZK age proof |
ProveBalance(long balance, long requiredAmount) |
ZK balance proof |
VerifyBalance(byte[] proof, byte[] commitment, long requiredAmount) |
Verify ZK balance proof |
SerializeProof(byte[] proof, byte[] commitment) |
Serialize for storage |
DeserializeProof(string serialized) |
Deserialize proof |
Prove* methods return (byte[] proof, byte[] commitment).
StellarBlockchain -- On-chain verification
var blockchain = new StellarBlockchain(
serverUrl: "https://horizon-testnet.stellar.org",
sorobanRpcUrl: "https://soroban-testnet.stellar.org",
hmacKey: hmacKey
);
bool result = await blockchain.VerifyBalanceProof(contractId, proof, balance, required, salt);
SorobanTransactionBuilder -- Manual transaction construction
var builder = new SorobanTransactionBuilder(Network.Test());
// HMAC proof verification
string xdr = builder.BuildVerifyProofTransaction(contractId, proof, data, salt, hmacKey);
// ZK proof verification
string zkXdr = builder.BuildVerifyZkRangeProofTransaction(contractId, proof, commitment, min, max);
string ageXdr = builder.BuildVerifyZkAgeProofTransaction(contractId, proof, commitment, minAge);
string balXdr = builder.BuildVerifyZkBalanceProofTransaction(contractId, proof, commitment, required);
Soroban contract
The Rust smart contract (contracts/stellar/contracts/proof-balance/) exposes the following functions:
| Function | Description |
|---|---|
verify_proof |
HMAC-SHA256 proof verification |
verify_balance_proof |
Balance proof with numeric comparison |
verify_batch |
Batch verification of multiple proofs |
verify_zk_range_proof |
BLS12-381 ZK range verification |
verify_zk_age_proof |
ZK age verification |
verify_zk_balance_proof |
ZK balance verification |
See contracts/stellar/README.md for contract details and contracts/stellar/DEPLOYMENT.md for deployment instructions.
Architecture
Application
|
+-- Zkp (HMAC proofs)
+-- BulletproofsProvider (ZK proofs)
|
+-- StellarBlockchain
+-- SorobanTransactionBuilder --> XDR
+-- SorobanRpcClient --> Soroban RPC --> ZkpVerifier Contract
Security
- Key management: Use environment variables for development. Use Azure Key Vault, AWS Secrets Manager, or HashiCorp Vault in production.
- Salts: Never reuse. ZkpSharp generates cryptographically secure random salts automatically.
- Contract verification: Always verify deployed contract code matches source.
- Transaction fees: Soroban transactions require XLM.
Documentation
| Document | Description |
|---|---|
| QUICKSTART.md | Step-by-step setup and usage guide |
| DEPLOYMENT.md | Soroban contract deployment |
| STELLAR_REALITY_CHECK.md | Capabilities and limitations |
| INTEGRATION_STATUS.md | Feature status and migration guide |
| CHANGELOG.md | Version history |
Contributing
- Fork the repository
- Create a branch (
git checkout -b feature/your-feature) - Run tests (
dotnet test) - Submit a pull request
License
MIT License. See LICENSE for details.
Contact
| 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 was computed. 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
- stellar-dotnet-sdk (>= 14.0.1)
- stellar-dotnet-sdk-xdr (>= 14.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.4.0: True ZKP via Bulletproofs-style proofs (IZkProofProvider, BulletproofsProvider), Soroban SDK 25 with BLS12-381, SorobanTransactionBuilder for XDR construction, ZK range/age/balance verification on-chain, comprehensive test coverage with 64+ tests.