paulmillr / noble-ed25519

Fastest 4KB JS implementation of ed25519 signatures
https://paulmillr.com/noble
MIT License
414 stars 50 forks source link

Export utils.invert(number, (mod)) #54

Closed dsernst closed 2 years ago

dsernst commented 2 years ago

Export the existing invert() function in utils

https://github.com/paulmillr/noble-ed25519/blob/a08955c9b15648f3f7ff5beaecbb0b0156bb5a65/index.ts#L672

And adds it to the README docs

paulmillr commented 2 years ago

What do you need it for?

dsernst commented 2 years ago

Modular division, trying to keep dependencies down

paulmillr commented 2 years ago

I understand, but could you clarify what protocol you're developing or which part of it requires inversion.

I don't want to expose unneeded internals in case these can be replaced by simple helper functions, like we've did with isTorsionFree() — there was no need in exposing multiplyUnsafe.

dsernst commented 2 years ago

It's for siv.org. We use them in a number of places, in particular for calculating Lagrangians in a secret sharing ceremony, and some ZK proofs.

No worries if you'd rather keep this library more focused though, we can work off a fork instead. There are a number of other changes we've made - like exposing Ristretto.multiplyUnsafe() for speeding up proof verifications, and adding .toString() as an alias of .toHex() so it automatically stringifies better for debugging, .join(), etc.

paulmillr commented 2 years ago

It would be great if you could open a pull request for all these changes. I'm sure i'd like to merge improvements that make writing new protocols easier.

dsernst commented 2 years ago

Done: