Torann 0.3.1

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

Torann for .NET

Torann is a C# implementation of the Noise Protocol Framework, revision 34. The package contains managed code only, with no native binary such as libsodium or OpenSSL, so it runs wherever .NET runs, including iOS and Android. It targets net9.0. The repository README at https://github.com/stonygrey/torann explains Noise, describes how the API is used, and lists the other Torann packages, which share the same API.

Functions

The Diffie-Hellman functions are 25519 and 448, which are X25519 and X448 through Bouncy Castle's managed code. The ciphers are ChaChaPoly and AESGCM. AES-GCM comes from System.Security.Cryptography, which is backed by the operating system. ChaCha20-Poly1305 comes from the operating system where it exists and from Bouncy Castle on Android below API 28. The hashes are SHA256, SHA512, BLAKE2s, and BLAKE2b. The two BLAKE2 hashes come from Bouncy Castle and use the HMAC construction the specification requires, not BLAKE2's own keyed mode.

Installation

dotnet add package Torann

Usage

using Torann;

var protocol = NoiseProtocol.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[NoiseProtocol.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

The C# API follows .NET conventions where they differ from the other packages. WriteMessage and ReadMessage write into a buffer the caller supplies and return the number of bytes written, and the handshake versions return a tuple with the handshake hash and the transport, which are null until the final message. The local static key pair is the s argument of CreateHandshake, and the pre-shared keys are any IEnumerable<byte[]>. The six error categories map to .NET exception types: ArgumentException for an invalid protocol name or argument, NotSupportedException for an unsupported function, InvalidOperationException for an invalid state, CryptographicException for an authentication failure, and ObjectDisposedException after dispose.

Dispose every HandshakeState, Transport, and KeyPair. Transport encrypt and decrypt are serialized by a lock inside the object, so two threads may call into one transport, but a call must not be held across an await. RekeySend and RekeyReceive rekey one direction, and SetSendNonce and SetReceiveNonce set the counter of one direction.

Crypto

The AEAD ciphers and the hashes use the implementations the operating system validates, which are CryptoKit on Apple platforms, Conscrypt and OpenSSL on Android and Linux, and CNG on Windows, when the platform supplies them.

X25519, X448, BLAKE2, and the ChaCha20-Poly1305 fallback are managed Bouncy Castle code. Managed code gives weaker guarantees than libsodium about constant-time execution and about scrubbing memory. The key of the ChaCha20-Poly1305 fallback, which is used on Android below API 28, lives as long as the garbage collector allows, because Bouncy Castle's KeyParameter clones the key on construction and again on GetKey() and has no public wipe operation. The library zeros its own key arrays with CryptographicOperations.ZeroMemory.

The X25519 and X448 functions call Bouncy Castle's CalculateAgreement, which returns false for a low-order peer key, and the library then throws CryptographicException with the message The peer's public key is invalid.

Tests

dotnet test dotnet/Torann.slnx runs all 1,352 shared vectors with none skipped, the security tests, and the key derivation and shared secret examples of RFC 7748 §6.1 and §6.2 in Rfc7748Tests. The test project reaches the fixed-ephemeral entry point through InternalsVisibleTo.

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.3.1: the first published release of the 0.3 line; 0.3.0 was tagged but not published, and the library is unchanged since that tag. 0.3.0: breaking: Protocol is renamed NoiseProtocol, the name used by the Swift, Kotlin, Flutter, and React Native packages released from the same repository tag. KeyPair.PublicKey returns a copy on every read. A low-order peer public key (all-zero DH output) now throws CryptographicException and ends the handshake. A tag mismatch throws AuthenticationTagMismatchException with the fixed message "The authentication tag did not match."; psk modifier digits must be ASCII digits without a sign; an empty protocol name reports "'' is not a valid Noise protocol name." The NuGet README is the C# package README under dotnet/. 0.2.0: every Noise handshake pattern (one-way, fundamental, deferred) with psk modifiers; Curve448; BLAKE2s/BLAKE2b; one-directional Transport for one-way patterns; the full cacophony and snow vector suites (1,352 vectors) run with none skipped.