indutny / elliptic

Fast Elliptic Curve Cryptography in plain javascript
1.68k stars 373 forks source link

[FEATURE] Need equivalent of secp256k1_ec_seckey_tweak_add #312

Open bitsanity opened 7 months ago

bitsanity commented 7 months ago

I would like to take a private key (m) and add a tweak to it, a hash of something (S):

p = m + hash(S)

I can do point addition with elliptic okay, but I am having difficulty figuring out how to do scalar addition. I see the official secp256k1 C library has this function:

int secp256k1_ec_seckey_tweak_add(
  const secp256k1_context* ctx,
  unsigned char *seckey,
  const unsigned char *tweak32
)

And the tiny-secp256k1 typescript module has this:

export function privateAdd(
  d: Uint8Array,
  tweak: Uint8Array
): Uint8Array | null

How best to do same with elliptic?