use.std::math::ecgfp5::group #! Generates the public key, point H #! the private key is expected as input and is a 319-bit random #! number of 10 32-bit limbs. export.gen_privatekey.8 exec.group::gen_mul end #! Given a random scalar r on stack #! this routine computes the first elliptic curve point C_a #! C_a = r*G, G is the generator of elliptic curve #! Expected stack state #! [r0, r1, ..., r9] #! Final stack state #! [Ca_x0, ..., C_x4, Ca_y0, ..., Ca_y4, Ca_inf] export.encrypt_ca.8 exec.group::gen_mul end #! Given public key, point H generated in gen_privatekey as coordinates (X,Y) on stack #! and message M, elliptic curve points (a,b) also as coordinates (X,Y) on stack #! and random scalar r on stack #! this routine computes the second elliptic curve point C_b #! C_b = M + r*H #! Expected stack state #! [H_x0, ..., H_x4, H_y0, ..., H_y4, H_inf, r0, r1, ..., M_x0, ..., M_x4, M_y0, ..., M_y4, M_inf,] #! Final stack state #! [Cb_x0, ..., Cb_x4, Cb_y0, ..., Cb_y4, Cb_inf] export.encrypt_cb.20 exec.group::mul exec.group::add end #! Rerandomises the first half of an ElGamal ciphertext Ca #! and random scalar r to produce a rerandomised ciphertext C'a #! Expected stack state #! [r0, r1, ..., Ca_x0, ..., Ca_x4, Ca_y0, ..., Ca_y4, Ca_inf, ...] #! #! Final stack state #! [C'a_x0, ..., C'a_x4, C'a_y0, ..., C'a_y4, C'a_inf] export.remask_ca.5 exec.group::gen_mul exec.group::add end #! Rerandomises the second half of an ElGamal ciphertext Cb given a public key H #! and random scalar r to produce a rerandomised ciphertext C'b #! Expected stack state #! [H_x0, ..., H_x4, H_y0, ..., H_y4, H_inf, ..., r0, r1, ..., Cb_x0, ..., Cb_x4, Cb_y0, ..., Cb_y4, Cb_inf] #! #! Final stack state #! [C'b_x0, ..., C'b_x4, C'b_y0, ..., C'b_y4, C'b_inf] export.remask_cb.14 exec.group::mul exec.group::add end