Closed wanseob closed 4 years ago
Added Fr field for jubjub curve. FR class inherits FQ and the example code is below
FR
FQ
from ethsnarks.field import FQ, FR from ethsnarks.jubjub import Point G = Point.from_y(FQ(20819045374670962167435360035096875258406992893633759881276124905556507972311)) def test_homomorphic_encryption(): a = FR(3) b = FR(-1) P = G*(a+b) Q = G*a + G*b print("a: ", a) # a: 3 print("b: ", b) # b: 21888242871839275222246405745257275088614511777268538073601725287587578984327 print("G*(a+b): ", P) # x: 173245..., y: 200221... print("G*(a) + G(b): ", Q) # x: 173245..., y: 200221... print("G*(a+b) == G*(a) + G(b): ", P == Q) # True if __name__ == "__main__": test_homomorphic_encryption()
Thanks, this is really clean and simple and will definitely be useful.
@HarryR Thanks for the quick review!
Added Fr field for jubjub curve.
FR
class inheritsFQ
and the example code is below