NATS.NKeys 1.0.0-preview.1

Prefix Reserved
This is a prerelease version of NATS.NKeys.
dotnet add package NATS.NKeys --version 1.0.0-preview.1                
NuGet\Install-Package NATS.NKeys -Version 1.0.0-preview.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="NATS.NKeys" Version="1.0.0-preview.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NATS.NKeys --version 1.0.0-preview.1                
#r "nuget: NATS.NKeys, 1.0.0-preview.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.
// Install NATS.NKeys as a Cake Addin
#addin nuget:?package=NATS.NKeys&version=1.0.0-preview.1&prerelease

// Install NATS.NKeys as a Cake Tool
#tool nuget:?package=NATS.NKeys&version=1.0.0-preview.1&prerelease                

NKeys .NET

Build and Test NuGet

NKeys is a public-key signature system based on Ed25519 for the NATS ecosystem.

Usage

Create a new key pair:

// Create a new key pair for a user
KeyPair keyPair = KeyPair.CreatePair(PrefixByte.User);

// Get the seed
// Output example (your seed will be different):
// Seed: SUAOBFVHF4ZWKTBJ6QP4C362WLBBBFIE7ENFTPYKUGZ3M2ESOXY353LXDI
string seed = keyPair.GetSeed();
Console.WriteLine($"Seed: {seed}");

// Get the public key
// Output example (your public key will be different):
// Public key: UBIWK4X3RXCPJ4CMIAVLAFDFABMLCCMZDDLAO5OZZ2265MDLXUTOGO4B
string publicKey = keyPair.GetPublicKey();
Console.WriteLine($"Public key: {publicKey}");

Sign and verify a message:

// Using already generated seed and public key
var seed = "SOAELH6NJCEK4HST5644G4HK7TOAFZGRRJHNM4EUKUY7PPNDLIKO5IH4JM";
var publicKey = "ODPWIBQJVIQ42462QAFI2RKJC4RZHCQSIVPRDDHWFCJAP52NRZK6Z2YC";

// Create a key pair from seed
KeyPair pair1 = KeyPair.FromSeed(seed);
Assert.Equal(seed, pair1.GetSeed());
Assert.Equal(publicKey, pair1.GetPublicKey());

// Create a key pair from public key
KeyPair pair2 = KeyPair.FromPublicKey(publicKey);
Assert.Equal(publicKey, pair2.GetPublicKey());

// Sign and verify
var message = new ReadOnlyMemory<byte>([42, 43, 44]);
var signature = new Memory<byte>(new byte[64]);
pair1.Sign(message, signature);
Assert.True(pair2.Verify(message, signature));

// Verify fails with corrupt data
var corrupt = new ReadOnlyMemory<byte>([43, 44]);
Assert.False(pair2.Verify(corrupt, signature));

About

A public-key signature system based on Ed25519 for the NATS ecosystem.

See also https://github.com/nats-io/nkeys

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NATS.NKeys:

Package Downloads
NATS.Jwt

NATS JWT for .NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-preview.1 1,634 5/21/2024