floodyberry / ed25519-donna

Implementations of a fast Elliptic-curve Digital Signature Algorithm
169 stars 47 forks source link

Batch verification discrepancy? #17

Open ghost opened 10 years ago

ghost commented 10 years ago

I'm getting strange results with ed25519_sign_open_batch vs ed25519_sign_open.

I'm generating signatures with your library and js-nacl, and I've tried to follow your batch example as best as I can despite my inexperience.

In this case, I'm verifying 3 signatures. The arrays for batch verification are built from a single loop except for the first position in the array.

When verifying individually, all check out. The total batch verification does not return 0. The first in the valid array returns 1, the second 0, and the third 1.

I noticed from the docs that /* valid[i] will be set to 1 if the individual signature was valid, 0 otherwise */. Is that correct?

Regardless of what the values are, it returns in this same pattern, but I always have 3 signatures to batch verify for easy testing. I could setup a larger test, but that would take some time.

Am I doing something obviously wrong based upon this information?

Thank you so much for this great library! The individual signing and verifying is incredibly fast!

ghost commented 10 years ago

Also, is there a limit to the size of the batch?

Thank you again so very much in advance!

floodyberry commented 10 years ago

Can you add the data for the 3 signatures so I can take a look at what's happening?

There is no limit on the size of the batch. Internally the signatures are broken in to blocks of 64 signatures to try at once, but that is an arbitrary number selected for performance. I DO notice I only use the batch verification if the number of signatures to test is MORE than 3, while the SUPERCOP version does 3 or more. I'll see if that is affecting your tests as well

ghost commented 10 years ago

I'll get up an example as soon as I can.

Thank you for your great support!