Hi On Mon, Sep 28, 2020 at 4:45 AM Conrado P. L. GouvĂȘa <conrado...@gmail.com> wrote: > > > On Fri, Sep 25, 2020 at 3:01 PM Anatol Pomozov <anatol.pomo...@gmail.com> > wrote: > > Or more precisely it calls this code > > https://boringssl.googlesource.com/boringssl/+/master/crypto/fipsmodule/ec/felem.c#57 > > > > But I want to avoid implementing parts of EC encryption myself and looking > > for a standard Golang way to achieve my goal. > > > > Shouldn't this inversion operation be part of the standard library? > > > > My understanding is that the Go standard library prefers that the entire > underlying logic of ECC should be hidden from the user, like in > "crypto/ed25519". > > However, they can't get rid of elliptic.CryptoParams due to compatibility. > It's not a good idea in a general sense to use CryptoParams because it uses > big.Int which is not side-channel resistant. For these reasons I don't think > it's likely they'all add point inversion. > > If you do want to go on... you can "invert" a point ("negate" would be a > better term...) by simply setting y = n - y, for example: > > y := new(big.Int).Sub(curveParams.Params().N, y)
Thank you. I end up with following code for calculating "A - B" expression: x, y = ecCurve.Add(a.X, a.Y, b.X, new(big.Int).Neg(b.Y)) And it seems to work the same as the openssl version I posted above. Thank you for your help. Though having a function in the standard library (either "Sub()" or "Negate()") would make such code cleaner and easier to follow. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOMFOmX%2Banq4vLT21ocDGeu0q5VEvb6peTYBCCXEgyBNXtZm5w%40mail.gmail.com.