chainers / cryptography.ecdsa Goto Github PK
View Code? Open in Web Editor NEWsecp256k1 algorythm
License: MIT License
secp256k1 algorythm
License: MIT License
Please, add support for the regular desktop.
verify(public_key, signature, msg)?? Why is it not?
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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.