Code Monkey home page Code Monkey logo

secp256k1's Introduction

secp256k1

C# Fastest Library for Secp256k1 Bitcoin curve to do fast ECC calculation

Ported from - https://github.com/iceland2k14/secp256k1

Example usage:

using secp256k1;
using System;
using System.Diagnostics;

namespace Test_secp256k1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();
            secp256k1.secp256k1 testing = new secp256k1.secp256k1();
            testing.InitSecp256Lib();
            string PVK = "0000000000000000000000000000000000000000000000000000000000008344"; //hex
            stopwatch.Start();
            Console.WriteLine(BytesToHexString(testing.PrivateKeyToH160(0, false, PVK))); //uncompressed hash160
            Console.WriteLine(BytesToHexString(testing.PrivateKeyToH160(0, true, PVK))); //compressed hash160
            Console.WriteLine(BytesToHexString(testing.PrivateKeyToH160(1, true, PVK)));//segwit (double compressed) hash160
            Console.WriteLine(testing.PrivateKeyToEthAddress(PVK));//ETH addr
            stopwatch.Stop();
            long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
            Console.WriteLine($"Completed at {elapsedMilliseconds} Milliseconds.");
        }
        static string BytesToHexString(byte[] byteArray)
        {
            string hexString = "";
            foreach (byte b in byteArray)
            {
                hexString += b.ToString("X2").ToLowerInvariant(); // X2 указывает на двузначное шестнадцатеричное число
            }
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.