Easy-X25519 1.0.0

.NET Standard 2.0
Install-Package Easy-X25519 -Version 1.0.0
dotnet add package Easy-X25519 --version 1.0.0
<PackageReference Include="Easy-X25519" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Easy-X25519 --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Easy-X25519, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Easy-X25519 as a Cake Addin
#addin nuget:?package=Easy-X25519&version=1.0.0

// Install Easy-X25519 as a Cake Tool
#tool nuget:?package=Easy-X25519&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

X25519 in C#

A simple library based on Golang's Curve25519 library.

Features

  • Easy to use front end
  • Completely re written the Golang's crypto library in C#
  • Nearly fast (about 3000 Keys and Agreements/s)
  • Universal library with .Net Standard (You can also use this library anywhere in .Net (Read more below)

Install

Use Nuget

Install-Package Easy-X25519

Link to library on Nuget

Usage

Key Generation

var alice = X25519KeyAgreement.GenerateKeyPair();

In this example, alice is X25519KeyPair struct that contains public key and private key as 32 byte length byte arrays.

Key Agreement

// generate keys
var alice = X25519KeyAgreement.GenerateKeyPair();
var bob = X25519KeyAgreement.GenerateKeyPair();
// generate shared secret
var shared1 = X25519KeyAgreement.Agreement(alice.PrivateKey, bob.PublicKey);
var shared2 = X25519KeyAgreement.Agreement(bob.PrivateKey, alice.PublicKey);
// now the shared1 and shared2 must be same

Use in older versions of .Net

This library is built with .Net Standard 2; Means that minimum frameworks are .Net Core 2 and .Net framework 4.6.1. Full list. You might want to use this library in .Net 2. It's easy to make this library in earlier version of .Net

Note: Due to usage of RNGCryptoServiceProvider this library is not compatible with .Net Core 1.X.

Here are steps to include this library in your project:

  1. At first copy Internal.cs and X25519.cs from here into your project.
  2. If you are using .Net Framework 4 or lower, you will get an error because IReadonlyList is available since .Net framework 4.5. To fix this problem, just change IReadOnlyList<byte> in Internal.cs to byte[]. This should fix the problem.
  3. Use the library

Benchmarks

These benchmarks are done with .Net Core 3.1 on Intel-i7 4790K 4.0GHz.

Full key agreement done in 00:00:00.0093703
Key generation done in 00:00:00.3615465. That is about 2770 keys/sec
Key agreements done in 00:00:00.2800316. That is about 3571 agreement/sec

I also benchmarked the curve25519_generic (not the assembly one) and this library is about twice slower than Golang. Golang key agreement was about 6625 agreement/s.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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
1.0.0 794 3/19/2020

Initial Release