Torann 0.1.1

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

Torann

Torann is a C# implementation of the Noise Protocol Framework (revision 34). There is no libsodium and no native binary. The package targets net9.0 and runs on iOS and Android.

The name is Irish for noise (and thunder).

This code is not production ready. It has not been independently audited. Development used Fable 5 and Grok 4.6.

What it implements

Handshake patterns: NN, NK, KK, XX, IK, with psk0–pskN modifiers. Other patterns (N, X, K, deferred variants, 448) are rejected by Protocol.Parse.

  • DH: 25519 (X25519 via Bouncy Castle's managed implementation)
  • Ciphers: ChaChaPoly, AESGCM. AES-GCM uses System.Security.Cryptography (OS-backed). ChaChaPoly uses the OS where it exists and Bouncy Castle where it does not (e.g. Android API < 28)
  • Hashes: SHA256, SHA512

Correctness is checked against the cacophony reference vectors (public domain / Unlicense). Every vector whose protocol Torann supports is run; the rest (448, BLAKE2, one-way and deferred patterns) are skipped. RFC 7748 X25519 vectors are in tests/Torann.Tests.

Usage

using Torann;

var protocol = Protocol.Parse("Noise_XX_25519_ChaChaPoly_SHA256");
using var staticKey = protocol.GenerateKeyPair();   // persist PrivateKey for reuse

using var handshake = protocol.CreateHandshake(initiator: true, s: staticKey);

var message = new byte[Protocol.MaxMessageLength];  // 65535
var (length, _, _) = handshake.WriteMessage(payload: default, message);
// send message[..length]; read the peer's reply with handshake.ReadMessage(...)
// the final handshake message returns a Transport:
// var (_, handshakeHash, transport) = handshake.ReadMessage(...);
// transport.WriteMessage(...) / transport.ReadMessage(...) for application data

XX is the first-contact pattern (static keys are exchanged and proven during the handshake). IK and KK skip that exchange when the initiator already knows the responder's static public key.

CreateHandshake takes an optional prologue (bound into the transcript) and optional 32-byte PSKs, one per pskN modifier.

Dispose HandshakeState, Transport, and KeyPair. Encrypt or decrypt after dispose throws ObjectDisposedException. It does not fail open to plaintext.

A decrypt or DH error during the handshake is terminal. Discard the HandshakeState. Do not pin RemoteStaticPublicKey unless the handshake returned a Transport.

Transport encrypt/decrypt is serialized internally. A lost write still desynchronizes nonces (Noise uses a strict counter). Abort the session on decrypt failure. RekeySend / RekeyReceive implement Noise §11.3.

Crypto

AEAD and hashes use OS-validated implementations (CryptoKit on Apple platforms, Conscrypt/OpenSSL on Android/Linux, CNG on Windows) when the platform supplies them.

X25519 and the ChaChaPoly fallback are managed Bouncy Castle. Managed code offers weaker constant-time and memory-hygiene guarantees than libsodium. The ChaChaPoly fallback key (Android API < 28) is GC-lifetime: Bouncy Castle's KeyParameter clones on construct and on GetKey(), and has no public wipe API.

This library has not been independently audited.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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.

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.3.1 96 10/11/2026
0.2.0 149 8/29/2026
0.1.1 132 8/23/2026

0.1.1: corrected README; SourceLink, deterministic build, and symbol package (.snupkg). No API changes.