HarryR / ethsnarks

A toolkit for viable zk-SNARKS on Ethereum, Web, Mobile and Desktop
GNU Lesser General Public License v3.0
240 stars 57 forks source link

align compression func with doc description #165

Open yueawang opened 3 years ago

yueawang commented 3 years ago

Hi, HarryR

I found the point compression code is inconsistent with the doc description, so I make some change based on https://ed25519.cr.yp.to/eddsa-20150704.pdf.

changes are:

specifically, x is negative if the (b − 1)-bit encoding of x is lexicographically larger than the (b − 1)-bit encoding of −x.

and

This encoding is also used to define a b-bit encoding of each element (x, y) ∈ E as a b-bit string (x, y), namely the (b − 1)-bit encoding of y followed by a sign bit; the sign bit is 1 if and only if x is negative.

Please correct me if I am wrong. Thanks!

Signed-off-by: yue.wang yue.wang@loopring.io