![]() |
VOOZH | about |
dotnet add package starkbank-ecdsa --version 1.3.3
NuGet\Install-Package starkbank-ecdsa -Version 1.3.3
<PackageReference Include="starkbank-ecdsa" Version="1.3.3" />
<PackageVersion Include="starkbank-ecdsa" Version="1.3.3" />Directory.Packages.props
<PackageReference Include="starkbank-ecdsa" />Project file
paket add starkbank-ecdsa --version 1.3.3
#r "nuget: starkbank-ecdsa, 1.3.3"
#:package starkbank-ecdsa@1.3.3
#addin nuget:?package=starkbank-ecdsa&version=1.3.3Install as a Cake Addin
#tool nuget:?package=starkbank-ecdsa&version=1.3.3Install as a Cake Tool
This is a pure C# implementation of the Elliptic Curve Digital Signature Algorithm. It is compatible with .NET Standard 1.3, 2.0 & 2.1. It is also compatible with OpenSSL. It uses some elegant math such as Jacobian Coordinates to speed up the ECDSA on pure C#.
To install StarkBank`s ECDSA-DotNet, get the package on nugget.
We currently support secp256k1, but it's super easy to add more curves to the project. Just add them on curve.cs
We ran a test on Node 13.1.0 on a MAC Pro i5 2019. The libraries ran 100 times and showed the average times displayed bellow:
| Library | sign | verify |
|---|---|---|
| starkbank-ecdsa | 3.5ms | 6.5ms |
| nethereum | 8.5ms | 2.5ms |
How to sign a json message for Stark Bank:
using System;
using EllipticCurve;
// Generate privateKey from PEM string
PrivateKey privateKey = PrivateKey.fromPem("-----BEGIN EC PARAMETERS-----\nBgUrgQQACg==\n-----END EC PARAMETERS-----\n-----BEGIN EC PRIVATE KEY-----\nMHQCAQEEIODvZuS34wFbt0X53+P5EnSj6tMjfVK01dD1dgDH02RzoAcGBSuBBAAK\noUQDQgAE/nvHu/SQQaos9TUljQsUuKI15Zr5SabPrbwtbfT/408rkVVzq8vAisbB\nRmpeRREXj5aog/Mq8RrdYy75W9q/Ig==\n-----END EC PRIVATE KEY-----\n");
// Create message from json
string message = "{\n \"transfers\": [\n {\n \"amount\": 100000000,\n \"taxId\": \"594.739.480-42\",\n \"name\": \"Daenerys Targaryen Stormborn\",\n \"bankCode\": \"341\",\n \"branchCode\": \"2201\",\n \"accountNumber\": \"76543-8\",\n \"tags\": [\"daenerys\", \"targaryen\", \"transfer-1-external-id\"]\n }\n ]\n}";
Signature signature = Ecdsa.sign(message, privateKey);
// Generate Signature in base64. This result can be sent to Stark Bank in header as Digital-Signature parameter
Console.WriteLine(signature.toBase64());
// To double check if message matches the signature
PublicKey publicKey = privateKey.publicKey();
Console.WriteLine(Ecdsa.verify(message, signature, publicKey));
Simple use:
using System;
using EllipticCurve;
// Generate new Keys
PrivateKey privateKey = new PrivateKey();
PublicKey publicKey = privateKey.publicKey();
string message = "My test message";
// Generate Signature
Signature signature = Ecdsa.sign(message, privateKey);
// Verify if signature is valid
Console.WriteLine(Ecdsa.verify(message, signature, publicKey));
This library is compatible with OpenSSL, so you can use it to generate keys:
openssl ecparam -name secp256k1 -genkey -out privateKey.pem
openssl ec -in privateKey.pem -pubout -out publicKey.pem
Create a message.txt file and sign it:
openssl dgst -sha256 -sign privateKey.pem -out signatureDer.txt message.txt
It's time to verify:
using System;
using EllipticCurve;
string publicKeyPem = EllipticCurve.Utils.File.read("publicKey.pem");
byte[] signatureDer = EllipticCurve.Utils.File.readBytes("signatureDer.txt");
string message = EllipticCurve.Utils.File.read("message.txt");
PublicKey publicKey = PublicKey.fromPem(publicKeyPem);
Signature signature = Signature.fromDer(signatureDer);
Console.WriteLine(Ecdsa.verify(message, signature, publicKey));
You can also verify it on terminal:
openssl dgst -sha256 -verify publicKey.pem -signature signatureDer.txt message.txt
NOTE: If you want to create a Digital Signature to use in the Stark Bank, you need to convert the binary signature to base64.
openssl base64 -in signatureDer.txt -out signatureBase64.txt
With this library, you can do it:
using System;
using EllipticCurve;
byte[] signatureDer = EllipticCurve.Utils.File.readBytes("signatureDer.txt");
Signature signature = Signature.fromDer(signatureDer);
Console.WriteLine(signature.toBase64());
Run StarkbankEcdsaTests on XUnit in Visual Studio
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp1.0 netcoreapp1.0 was computed. netcoreapp1.1 netcoreapp1.1 was computed. netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard1.3 netstandard1.3 is compatible. netstandard1.4 netstandard1.4 was computed. netstandard1.5 netstandard1.5 was computed. netstandard1.6 netstandard1.6 was computed. netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net40 net40 is compatible. net403 net403 was computed. net45 net45 was computed. net451 net451 was computed. net452 net452 is compatible. net46 net46 was computed. net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen30 tizen30 was computed. tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Universal Windows Platform | uap uap was computed. uap10.0 uap10.0 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on starkbank-ecdsa:
| Package | Downloads |
|---|---|
|
SendGrid
C# client library and examples for using Twilio SendGrid API's to send mail and access Web API v3 endpoints with .NET Standard 1.3 and .NET Core support. |
|
|
StarkBank
Package Description |
|
|
Dynamicweb.Admin
Package Description |
|
|
starkinfra
SDK to facilitate C# (.NET) integrations with the Stark Infra API |
|
|
WATG.Common
WATG library of commonly used and shared functionalities |
Showing the top 2 popular GitHub repositories that depend on starkbank-ecdsa:
| Repository | Stars |
|---|---|
|
sendgrid/sendgrid-csharp
The Official Twilio SendGrid C#, .NetStandard, .NetCore API Library
|
|
|
SparkDevNetwork/Rock
An open source CMS, Relationship Management System (RMS) and Church Management System (ChMS) all rolled into one.
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.3.3 | 122,464,105 | 11/9/2021 | |
| 1.3.2 | 694,353 | 11/4/2021 | |
| 1.3.1 | 15,399,042 | 4/6/2021 | 1.3.1 has at least one vulnerability with critical severity. |
| 1.3.0 | 125,777 | 1/26/2021 | 1.3.0 has at least one vulnerability with critical severity. |
| 1.2.1 | 242,424 | 9/27/2020 | 1.2.1 has at least one vulnerability with critical severity. |
| 1.2.0 | 21,591,243 | 6/23/2020 | 1.2.0 has at least one vulnerability with critical severity. |
| 1.1.0 | 4,044 | 5/12/2020 | 1.1.0 has at least one vulnerability with critical severity. |
| 1.0.0 | 4,032 | 4/15/2020 | 1.0.0 has at least one vulnerability with critical severity. |
| 0.0.1 | 6,504 | 1/7/2020 | 0.0.1 has at least one vulnerability with critical severity. |