· 9 years ago · Nov 25, 2016, 10:26 PM
1void crypto_ops::generate_key_image(const public_key &pub, const secret_key &sec, key_image &image) {
2 ge_p3 point;
3 ge_p2 point2;
4 assert(sc_check(&sec) == 0);
5 hash_to_ec(pub, point);
6 ge_scalarmult(&point2, &sec, &point);
7 ge_tobytes(&image, &point2);
8 }
9
10static void hash_to_ec(const public_key &key, ge_p3 &res) {
11 hash h;
12 ge_p2 point;
13 ge_p1p1 point2;
14 cn_fast_hash(std::addressof(key), sizeof(public_key), h);
15 ge_fromfe_frombytes_vartime(&point, reinterpret_cast<const unsigned char *>(&h));
16 ge_mul8(&point2, &point);
17 ge_p1p1_to_p3(&res, &point2);
18 }