Krysalis 0.1.0

dotnet add package Krysalis --version 0.1.0
                    
NuGet\Install-Package Krysalis -Version 0.1.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="Krysalis" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Krysalis" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Krysalis" />
                    
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 Krysalis --version 0.1.0
                    
#r "nuget: Krysalis, 0.1.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 Krysalis@0.1.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=Krysalis&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Krysalis&version=0.1.0
                    
Install as a Cake Tool

krysalis-csharp

CI

C# / .NET bindings for krysalis — a general-purpose end-to-end encryption library. Seal and open arbitrary data (blobs, files, database records, API payloads) with a single, composable API.

Built with P/Invoke (LibraryImport) over the krysalis C ABI. Targets .NET 8+.


Prerequisites

  • .NET 8 SDK or later
  • The compiled libkrysalis native library (see Setup)

Setup

Download pre-built native library

bash scripts/setup-native.sh          # downloads v0.1.0 by default
KRYSALIS_VERSION=v0.2.0 bash scripts/setup-native.sh  # specific version

The script downloads libkrysalis.so (Linux) or libkrysalis.dylib (macOS) from the krysalis releases into native/.

Build from source

If no release is available for your platform:

git clone https://github.com/Pirand92/krysalis.git krysalis-src
cargo build -p krysalis-ffi --release --manifest-path krysalis-src/Cargo.toml
mkdir -p native && cp krysalis-src/target/release/libkrysalis.so native/

Quick start

using Krysalis;

// Generate a key pair — always dispose to zero the secret key
using var kp = EncryptionKeyPair.Generate();

// Encrypt
byte[] plaintext = System.Text.Encoding.UTF8.GetBytes("hello, world");
byte[] sealed    = BlobContext.Seal(plaintext, kp.PublicKey);

// Decrypt
byte[] recovered = BlobContext.Open(sealed, kp.SecretKey);
Console.WriteLine(System.Text.Encoding.UTF8.GetString(recovered)); // hello, world

Multi-recipient encryption

using var alice = EncryptionKeyPair.Generate();
using var bob   = EncryptionKeyPair.Generate();

var recipients = new[] { alice.PublicKey.ToArray(), bob.PublicKey.ToArray() };
byte[] multi   = BlobContext.SealForMany("group secret"u8.ToArray(), recipients);

// Both can decrypt independently
byte[] a = BlobContext.OpenMulti(multi, alice.SecretKey);
byte[] b = BlobContext.OpenMulti(multi, bob.SecretKey);

API Reference

EncryptionKeyPairIDisposable

Member Description
EncryptionKeyPair.Generate() Generate a new X25519 key pair
ReadOnlySpan<byte> PublicKey 32-byte public key (safe to share)
ReadOnlySpan<byte> SecretKey 32-byte secret key — throws ObjectDisposedException after Dispose()
byte[] Fingerprint() SHA-256 fingerprint of the public key
void Dispose() Zeros the secret key from managed memory

BlobContext — static API

Method Description
Seal(plaintext, recipientPublicKey) Encrypt for one recipient
Open(sealedBytes, secretKey) Decrypt
SealForMany(plaintext, recipientKeys[]) Encrypt for N recipients (KEM+DEM)
OpenMulti(multiSealedBytes, secretKey) Decrypt a multi-recipient blob

All methods throw KrysalisException on cryptographic failure. Open and OpenMulti zero the secret-key copy in a finally block.


Development

# 1. Get the native library
bash scripts/setup-native.sh

# 2. Run all tests
dotnet test Krysalis.sln

# 3. Build the library
dotnet build Krysalis/Krysalis.csproj -c Release

Tests are in Krysalis.Tests/BlobContextTests.cs.


License

Licensed under either of MIT or Apache 2.0, at your option.

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

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
0.1.0 53 6/6/2026