Cryptography.ECDSA .NET lib v.2.0-2.1 from @steepshot teamsteemCreated with Sketch.

in #steem7 years ago

lib_21.PNG

View on Github

Version 2.0

Increased speed of creating signatures ~ 300 times. The speed increase is achieved due to the use of a different signature generation mechanism based on the library https://github.com/bitcoin-core/secp256k1

Methods supported:

  • Sign - an ordinary signature
  • SignCompressedCompact - compressed signature
  • GetPublicKey - getting the public key
  • Base58.GetBytes - translate WIF key into a base58 form (needed to create a signature)
  • GetMessageHash - hashes the message using sha256 (required to create a signature)

githup_partner.png

Version 2.1

Some of the methods for the library https://github.com/bitcoin-core/secp256k1 were translated from C to C#, which allowed to make a standardized, cross-platform assembly (.NET Standard) that can be connected to mobile solutions based on Xamarin.

Methods supported:

  • GetMessageHash - hashes the message using sha256 (required to create a signature)
  • SignCompressedCompact - a compressed signature in the canonical form. The solution is adapted for Graphene (65 bytes will be returned):
    // code for recovery + compression code (compressed) + compact code (compact).
    sig[0] = recid + 4 + 27
    sig[1] - vector r = 32 bits
    sig[33] - vector s = 32 bits

Steepshot team progress on .Net encryption & signing

Discuss

1493588297_social-56.png in Telegram
steemit-chat_360.png in Steemit.chat
64x64.png email us

Sort:  

@steepshot great post keep on steeming ahead

This post received a 3.0% upvote from @randowhale thanks to @jimjam1210! For more information, click here!

Good project indeed, thanks for sharing and more success to you. Upvoted and following you in order to stay in touch and send in my support. Success.

Can you explain how the speed is increased? i don't quite understand the mechanism... @steepshot.

Hi, there are several popular implementations of secp256k1:

The fastest implementation is https://github.com/bitcoin-core/secp256k1/. This is achieved by the fact that the low-level library written on C using inline Assembly, Boolean logic, with minimum of method calls and memory allocate.

How can we use C code in C#:

  • use mechanism P/Invoke in order to connect C assembly, but this mechanism has several drawbacks including lowering of the performance, as well as inconvenience when connecting to different solutions and architectures (like Android, iOS). Of the benefits - when you change the C source code you just need to replace the old assembly with a new one.
  • translate the C code to C#. In view of the affinity of these languages the task of translation is relatively simple (depends of code size and there are still small differences to consider). This method has one drawback - when you change the original library, you must manually correct the C# code (which in this case plays no role, because the source library is already tested and is almost constant). In this case we get the winnings in speed (since there is no P/Invoke), receive managed code that can assemble universal cross-platform build and collect in nuget package.

Nice, thanks for this work. What are the next step?