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

Remove usage of noble-secp256k1 tweak utils #2751

Open
paulmillr opened this issue Sep 11, 2022 · 8 comments
Open

Remove usage of noble-secp256k1 tweak utils #2751

paulmillr opened this issue Sep 11, 2022 · 8 comments
Assignees

Comments

@paulmillr
Copy link

I have removed them because I think their api is suboptimal. If you want to keep using them, copy-paste this:

https://github.com/paulmillr/noble-secp256k1/blob/37e66841eb155d21b4fe6658223140d5d7d5176e/test/index.ts#L467

@paulmillr paulmillr changed the title Remove usage of noble-secp256k1 utils Remove usage of noble-secp256k1 tweak utils Sep 11, 2022
@mmcshinsky-bitgo
Copy link
Contributor

Thanks for the update! We're making the adjustments currently internally as well as a result of the change.

@paulmillr
Copy link
Author

As a side note, your api which depended on those functions is also overengineered, e.g. return bigIntFromU8ABE(secp.utils.privateNegate(s)); could be just secp.utils.mod(-s, secp.CURVE.n). Every type conversion has potential error somewhere, which means something could go wrong.

  scalarSub(x: bigint, y: bigint): bigint {
    const negatedY = secp.utils.privateNegate(y);
    return bigIntFromU8ABE(secp.utils.privateAdd(x, negatedY));
  }
  // could just be
    scalarSub(x: bigint, y: bigint): bigint {
    return secp.utils.mod(x - y, secp.CURVE.n)
  }

@mmcshinsky-bitgo
Copy link
Contributor

That's great to know, thanks!

@brandonblack You may be interested in this.

@brandonblack
Copy link
Contributor

Thanks @paulmillr.

FWIW, removing these in a minor version caused us quite some pain when builds started spontaneously failing due to semver ^.

@paulmillr
Copy link
Author

@brandonblack sorry for this, I intend to follow semver, however, I did not even add these methods to docs, and considered them experimental. What should have been done from my end: naming them with _underscore. That should have been better communicated from my end.

@brandonblack
Copy link
Contributor

Thanks. We'll update to 1.7.0 and expand our wrapper to include these functions.

@mmcshinsky-bitgo
Copy link
Contributor

@brandonblack What is the status of this issue? Is this issue now resolved?

@brandonblack
Copy link
Contributor

@mmcshinsky-bitgo no. will probably work on it next sprint - this is only an issue when we upgrade noble-secp256k1 to 1.7+

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

No branches or pull requests

3 participants