Qubic.Crypto 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Qubic.Crypto --version 1.0.0
                    
NuGet\Install-Package Qubic.Crypto -Version 1.0.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="Qubic.Crypto" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Qubic.Crypto" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Qubic.Crypto" />
                    
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 Qubic.Crypto --version 1.0.0
                    
#r "nuget: Qubic.Crypto, 1.0.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 Qubic.Crypto@1.0.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=Qubic.Crypto&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Qubic.Crypto&version=1.0.0
                    
Install as a Cake Tool

Qubic.Crypto

A pure C#/.NET implementation of cryptographic primitives for the Qubic protocol. Zero external dependencies - runs on any .NET 8.0 platform.

Features

  • K12 (KangarooTwelve) - Fast hash function based on Keccak-p[1600,12]
  • FourQ - High-performance elliptic curve over Fp2
  • SchnorrQ - Digital signatures using FourQ and K12
  • ECDH - Elliptic Curve Diffie-Hellman key exchange
  • Identity - Qubic identity (60-char base-26) encoding/decoding with checksum

Installation

No external NuGet packages required. Just reference the project:

dotnet add reference path/to/Qubic.Crypto.csproj

Quick Start

using Qubic.Crypto;

var crypt = new QubicCrypt();

// From a 55-character lowercase seed (a-z)
var seed = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabc";

// Get keys
var publicKey = crypt.GetPublicKey(seed);
var privateKey = crypt.GetPrivateKey(seed);

// Get Qubic identity (60-char string like "ABCD...WXYZ")
var identity = crypt.GetIdentityFromPublicKey(publicKey);

// Sign a message (returns message + 64-byte signature)
var message = new byte[] { 0x01, 0x02, 0x03 };
var signedMessage = crypt.Sign(seed, message);

// Verify signature
bool isValid = crypt.Verify(publicKey, signedMessage);

// ECDH shared key
var sharedKey = crypt.GetSharedKey(seed, otherPublicKey);

// K12 hashing
var hash = crypt.KangarooTwelve(data, outputLength: 32);

API Reference

IQubicCrypt Interface

Method Description
KangarooTwelve(data, outputLen) K12 hash with configurable output length
KangarooTwelve64To32(data) K12 hash of 64 bytes to 32 bytes
GetPrivateKey(seed) Get 32-byte private key from 55-char seed
GetPublicKey(seed) Get 32-byte public key from 55-char seed
GetIdentityFromPublicKey(pubKey) Convert public key to 60-char identity
GetPublicKeyFromIdentity(identity) Convert identity back to public key
GetSharedKey(seed, pubKey) ECDH shared key derivation
Sign(seed, message) Sign message, returns message + signature
Verify(pubKey, signedMessage) Verify signature (last 64 bytes)
Verify(pubKey, message, signature) Verify with separate signature
GetHumanReadableBytes(data) Convert bytes to shifted hex (a-p) used e.g. for tx ids
ShiftedHexToBytes(hex) Convert shifted hex back to bytes

Low-Level SchnorrQ API

using Qubic.Crypto;

// From 55-char seed to 32-byte subSeed
var subSeed = SchnorrQ.GetSubSeedFromSeed(seed);

// Generate keys from subSeed
var privateKey = SchnorrQ.GeneratePrivateKey(subSeed);
var publicKey = SchnorrQ.GeneratePublicKey(subSeed);

// Sign a 32-byte digest
var signature = SchnorrQ.Sign(subSeed, publicKey, digest);

// Verify
bool valid = SchnorrQ.Verify(publicKey, digest, signature);

// Sign full message (hashes internally)
var sig = SchnorrQ.SignMessage(subSeed, publicKey, message);
bool valid = SchnorrQ.VerifyMessage(publicKey, message, sig);

Direct K12 Hashing

using Qubic.Crypto;

var hash = K12.Hash(data, outputLength: 32);
var hash64 = K12.Hash(data, outputLength: 64);

Project Structure

Qubic.Crypto/
├── K12.cs              # KangarooTwelve hash implementation
├── SchnorrQ.cs         # SchnorrQ signature scheme
├── IQubicCrypt.cs      # Interface definition
├── QubicCrypt.cs       # Full implementation
└── FourQ/
    ├── Fp.cs           # Prime field (p = 2^127 - 1)
    ├── Fp2.cs          # Quadratic extension field
    ├── Point.cs        # Curve point operations
    ├── Codec.cs        # Point encoding/decoding
    └── ScalarField.cs  # Scalar arithmetic (mod N)

Technical Details

K12 (KangarooTwelve)

  • Keccak-p[1600,12] permutation (12 rounds)
  • Rate: 168 bytes, Capacity: 256 bits
  • Domain separator: 0x07
  • Compatible with noble/hashes implementation

FourQ Curve

  • Twisted Edwards curve over Fp2 where p = 2^127 - 1 (Mersenne prime)
  • Curve equation: -x² + y² = 1 + d·x²·y²
  • ~128-bit security level
  • Curve order N = 0x29CBC14E5E0A72F05397829CBC14E5DFBD004DFE0F79992FB2540EC7768CE7

Qubic Identity Format

  • 60 characters using A-Z (base-26)
  • First 56 chars: encoded public key (4 chunks × 14 chars)
  • Last 4 chars: K12 checksum (18 bits encoded)

Security Warning

This is a pure managed C# implementation optimized for portability, not for side-channel resistance. Do not use signing operations in environments where timing attacks are a concern.

Building & Testing

dotnet build
dotnet test

All 74 tests pass, including:

  • Real Qubic network signature verification
  • Identity round-trip conversion
  • ECDH shared key derivation

Platform Support

Runs on any platform supporting .NET 8.0:

  • Windows (x64, ARM64)
  • Linux (x64, ARM64)
  • macOS (x64, ARM64)

No native dependencies or platform-specific code.

References

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Qubic.Crypto:

Package Downloads
Qubic.Core

Core domain models and abstractions for the Qubic network

Qubic.Services

High-level services for Qubic applications: backend abstraction, tick monitoring, label service, wallet storage, transaction tracking, and more.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.2 249 6/13/2026
1.5.1 231 5/27/2026
1.5.0 160 5/17/2026
1.4.0 258 3/2/2026
1.3.5 644 2/28/2026
1.3.3 182 2/21/2026
1.3.1 267 2/21/2026
1.3.0 147 2/17/2026
1.2.0 124 2/16/2026
1.1.1 331 2/12/2026
1.1.0 254 1/28/2026
1.0.0 136 1/16/2026