tdrerup / elliptic-curve-solidity

A pure solidity implementation of elliptic curve math, parameterised for curve secp256r1 / prime256v1 / p256.
MIT License
103 stars 21 forks source link

Added SECP256K1 functionality #3

Open aratrika1996 opened 3 years ago

aratrika1996 commented 3 years ago

We needed to modify your repo to support the SECP256K1 curve, so we forked it and did so. The reason we needed to do this was so that we could verify a digital signature created using the Avalanche cryptocurrency platform's X Chain, in Solidity. If you are not familiar with Avalanche yet, it has three chains, called X, P, and C. The C, or "Contract" chain uses an exact clone of the EVM and thus can run any code that can be run in Ethereum. The X Chain uses cryptography more like bitcoin does, so its digital signatures are different from Ethereum's and cannot just be verified using the EVM's built-in function ecrecover. That's a quick overview. For more information, see this tutorial that we wrote here: https://github.com/red-dev-inc/sig-verify-tutorial.

Quick disclaimer, we are not cryptographers--just software devs who are end-users of cryptographic tools--so please do look this code over carefully before you include it in your project. We have included test scripts which you can run, similar to the test scripts you already have.

tdrerup commented 3 years ago

Thank you for the contribution! It will be a while before I can review this request, unfortunately.