GithubHelp home page GithubHelp logo

cryptography.ecdsa's Introduction

NuGet version Build Status

Cryptography.ECDSA (secp256k1 only)

This library implements transaction signing algorithm secp256k1 which is used in several blockchains like Bitcoin, EOS and Graphene-based Steem, Golos, BitShares. The library is based on https://github.com/warner/python-ecdsa and https://github.com/bitcoin-core/secp256k1) No other curves are included. C#, MIT license.

Usage

//Sign message
var seckey = Hex.HexToBytes("80f3a375e00cc5147f30bee97bb5d54b31a12eee148a1ac31ac9edc4ecd13bc1f80cc8148e");
var data = Sha256Manager.GetHash(msg);
var sig = Secp256K1Manager.SignCompressedCompact(data, seckey);

Instalation

Install-Package Cryptography.ECDSA.Secp256k1

cryptography.ecdsa's People

Contributors

anch7 avatar korzunav avatar pmartynov avatar raphaelgabbarelli avatar steepshot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cryptography.ecdsa's Issues

how to replicate the sing behaviour

I am trying to replicate some javascript code to sign into the dApp. The JS code looks like that:

// Check if this is a master password, if so try to generate the private key
if (key && !steem.auth.isWif(key))
     key = steem.auth.getPrivateKeys(username, key, ['posting']).posting;

// Check that the key is a valid private key.
try { steem.auth.wifToPublic(key); }
catch (err) { return { success: false, error: `Invalid password or private posting key for account @${username}` }; }

// Sign the login request using the provided private key
params.ts = Date.now();
params.sig = eosjs_ecc.sign(username + params.ts, key);

the code I am using looks like that:

let sign (message: string) postingKey =
    let secKey = CBase58.DecodePrivateWif postingKey
    let digest = message |>Encoding.Default.GetBytes |> Sha256Manager.GetHash    
    Secp256K1Manager.SignCompressedCompact(digest, secKey) |> Hex.ToString

let private uri name key = 
    let ts = int64(DateTime.UtcNow.Subtract(unixStart).TotalMilliseconds)
    let signature = sign name key 
    let parameters = 
        $"name={name}&ts={ts}&sig={signature}"

I have tried to use SingCompact instead of SignCompressedCompact, as well as Hex to convert string to byte[], as well as trying to return value with Base58 instead of Hext.ToString but I am not able to generate a similar output as JS code.
I am not sure what I am doing wrong.

Seckey is giving the ArgumentOutOfRangeException

I run the readme example

`
//Sign message
var seckey = Hex.HexToBytes("80f3a375e00cc5147f30bee97bb5d54b31a12eee148a1ac31ac9edc4ecd13bc1f80cc8148e");

var data = Sha256Manager.GetHash(msg);

var sig = Secp256K1Manager.SignCompressedCompact(data, seckey);
`

and I got the exception
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values. Arg_ParamName_Name'

message (msg0 is created like that:
`
let ts = getTimestamp()

let msg = $"{username}{ts}"

let data = Cryptography.ECDSA.Sha256Manager.GetHash(Encoding.UTF8.GetBytes(msg))
`

I have found th reason the sec key is 37 characters long instead of 32. Not sure why if I am using the example from the readme

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.