Torann 0.3.2

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

Torann for .NET

Torann is a C# implementation of the Noise Protocol Framework, revision 34. It targets net9.0 and contains managed code only, so it runs wherever .NET runs, including iOS and Android.

The repository README explains Noise and the API that every Torann package shares.

Please see BlueConnect for an example implementation.

Functions

Kind Functions Source
Diffie-Hellman 25519, 448 Bouncy Castle
Cipher AESGCM System.Security.Cryptography (the operating system)
Cipher ChaChaPoly The operating system, or Bouncy Castle on Android below API 28
Hash SHA256, SHA512 System.Security.Cryptography
Hash BLAKE2s, BLAKE2b Bouncy Castle

Noise requires HMAC over the hash, so the library uses HMAC with BLAKE2 and 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

WriteMessage and ReadMessage write into a buffer the caller supplies and return the number of bytes written. The handshake methods return that count in 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.

Error category Exception
Invalid protocol name, invalid argument ArgumentException
Unsupported function NotSupportedException
Invalid state InvalidOperationException
Authentication failed CryptographicException
Closed ObjectDisposedException

Dispose every KeyPair, HandshakeState, and Transport.

A transport takes a lock for each encrypt and decrypt, so two threads may call into one transport. RekeySend and RekeyReceive rekey one direction. SetSendNonce and SetReceiveNonce set one direction's counter.

Crypto

Where the platform supplies them, the ciphers and the SHA-2 hashes are the operating system's: CryptoKit on Apple platforms, Conscrypt and OpenSSL on Android and Linux, and CNG on Windows.

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 library zeros the key arrays it owns with CryptographicOperations.ZeroMemory. It cannot zero Bouncy Castle's copies. KeyParameter clones the key on construction and again in GetKey(), and it has no public wipe, so the key of the ChaCha20-Poly1305 fallback remains until the garbage collector frees it.

Bouncy Castle's CalculateAgreement returns false for a low-order peer key. 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, the security tests, and the RFC 7748 §6.1 and §6.2 examples. 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.2 50 11/21/2026
0.3.1 158 10/11/2026
0.2.0 159 8/29/2026
0.1.1 141 8/23/2026

0.3.2: documentation only; the README is rewritten and the library is unchanged. 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.