1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00
ZoKrates/zokrates_stdlib/stdlib/ecc/edwardsCompress.zok
2020-06-05 17:11:07 +02:00

20 lines
481 B
Text

import "utils/pack/nonStrictUnpack256" as unpack256
// Compress JubJub Curve Point to 256bit array using big endianness bit order
// Python reference code from pycrypto:
// def compress(self):
// x = self.x.n
// y = self.y.n
// return int.to_bytes(y | ((x & 1) << 255), 32, "big")
def main(field[2] pt) -> (bool[256]):
field x = pt[0]
field y = pt[1]
bool[256] xBits = unpack256(x)
bool[256] yBits = unpack256(y)
bool sign = xBits[255]
yBits[0] = sign
return yBits