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

Add support for inverting and negating private keys #125

Merged
merged 8 commits into from
Jan 26, 2018
Prev Previous commit
Improve memory usage of privateKeyModInverse
  • Loading branch information
kripod committed Jan 18, 2018
commit 20a123577f7ecd590cba39c376e9bc8d42924100
8 changes: 4 additions & 4 deletions src/privatekey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ NAN_METHOD(privateKeyModInverse) {
v8::Local<v8::Object> private_key_buffer = info[0].As<v8::Object>();
CHECK_TYPE_BUFFER(private_key_buffer, EC_PRIVATE_KEY_TYPE_INVALID);
CHECK_BUFFER_LENGTH(private_key_buffer, 32, EC_PRIVATE_KEY_LENGTH_INVALID);
const unsigned char* private_key = (const unsigned char*) node::Buffer::Data(private_key_buffer);
unsigned char private_key[32];
memcpy(&private_key[0], node::Buffer::Data(private_key_buffer), 32);

secp256k1_scalar s;
int overflow = 0;
Expand All @@ -93,11 +94,10 @@ NAN_METHOD(privateKeyModInverse) {

secp256k1_scalar_inverse(&s, &s);

unsigned char b[32];
secp256k1_scalar_get_b32(b, &s);
secp256k1_scalar_get_b32(private_key, &s);
secp256k1_scalar_clear(&s);

info.GetReturnValue().Set(COPY_BUFFER(&b[0], 32));
info.GetReturnValue().Set(COPY_BUFFER(&private_key[0], 32));
}

NAN_METHOD(privateKeyTweakAdd) {
Expand Down