cloudflare / circl

CIRCL: Cloudflare Interoperable Reusable Cryptographic Library
http://blog.cloudflare.com/introducing-circl
Other
1.22k stars 136 forks source link

FourQ ecc_mul_double implementation #495

Closed LINCKODE closed 2 months ago

LINCKODE commented 2 months ago

Implemented ecc_mul_double as DoubleScalarMult in curve.go . Please advise me if the code does not adhere to project standards, I'm somewhat new to Go. 😅

armfazh commented 2 months ago

Hi @LINCKODE what is the use case for this function? and usually, the operation kG+lP is performed using a better algorithm than performing kG, lP, and then add these points.

LINCKODE commented 2 months ago

Thanks for the reply! This function is required for verifying Schnorr signatures over FourQ. You can see how it is being used in FourQLib's SchnorrQ_Verify function. I see that FourQLib defines another way of performing this calculation, but that requires the use of endomorphisms, which I am not familiar with. If you know of another way of doing this, I'd be happy to give it a go.

armfazh commented 2 months ago

See the implementation of CombinedMult for the P384 curve. https://github.com/cloudflare/circl/blob/main/ecc/p384/p384opt.go#L135

This method is generic and agnostic to the use of endomorphisms.

LINCKODE commented 2 months ago

That looks interesting, doing both multiplications in one loop. Ill have to look at this a bit closer to fully understand how it works, then I'll try to replicate it for FourQ. Thanks for the hint!

armfazh commented 2 months ago

I'm gonna close this PR to keep our list short, happy to review when you push a new PR with the other algorithm.