Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent privkey modified by ec_seckey_verify method #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LanfordCai
Copy link

@LanfordCai LanfordCai commented Jan 8, 2019

ec_seckey_verify method would change the value of the private key inputed as argument, but a verify method should not modify something, moreover, it's a private key. For example:

iex(2)> {pubkey, privkey} = :crypto.generate_key(:ecdh, :secp256k1)
{<<4, 93, 21, 247, 9, 127, 33, 229, 202, 110, 246, 105, 76, 192, 12, 215, 65,
   232, 238, 37, 88, 110, 2, 89, 17, 59, 158, 227, 95, 183, 115, 120, 225, 144,
   170, 19, 9, 196, 68, 64, 96, 90, 78, 173, 112, 46, 89, 88, 71, ...>>,
 <<3, 185, 32, 160, 132, 78, 43, 141, 96, 195, 72, 104, 253, 206, 48, 64, 194,
   120, 210, 131, 182, 147, 112, 208, 189, 114, 155, 211, 62, 248, 22, 158>>}
iex(3)> :ok = :libsecp256k1.ec_seckey_verify(privkey)
:ok
iex(4)> privkey
<<142, 0, 13, 110, 86, 234, 133, 174, 24, 0, 0, 0, 0, 0, 0, 0, 128, 130, 232,
  24, 0, 0, 0, 0, 224, 54, 85, 26, 0, 0, 0, 0>>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant