Easy-X25519
1.0.0
dotnet add package Easy-X25519 --version 1.0.0
NuGet\Install-Package Easy-X25519 -Version 1.0.0
<PackageReference Include="Easy-X25519" Version="1.0.0" />
paket add Easy-X25519 --version 1.0.0
#r "nuget: Easy-X25519, 1.0.0"
// 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
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:
- At first copy
Internal.cs
andX25519.cs
from here into your project. - 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>
inInternal.cs
tobyte[]
. This should fix the problem. - 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 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 was computed. 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. |
.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. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Easy-X25519:
Package | Downloads |
---|---|
Cosm.Net.Secret
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Easy-X25519:
Repository | Stars |
---|---|
UWPX/UWPX-Client
A WIP secure XMPP client for UWP (Windows 10) devices.
|
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 8,013 | 3/19/2020 |
Initial Release