ZenGo-X / curv

Rust language general purpose elliptic curve cryptography.
MIT License
264 stars 111 forks source link

Implementation of `base_point2` #63

Open kigawas opened 5 years ago

kigawas commented 5 years ago
    // from https://github.com/KZen-networks/curv/pull/61/commits/3bd540e13a1152ccf51b7adf276887860482e44e
    pub fn base_point2() -> Self {
        let g = Self::generator();

        let hash = HSha256::create_hash(&[&g.bytes_compressed_to_big_int()]);
        let hash = HSha256::create_hash(&[&hash]);
        let hash = HSha256::create_hash(&[&hash]);

        let mut possible_pk = vec![2u8];
        possible_pk.append(&mut BigInt::to_vec(&hash));

        Self {
            purpose: "random",
            ge: PK::from_slice(possible_pk.as_slice()).unwrap(),
        }
    }

Is there a better way than generating another fixed (not random) base point by taking original base point's sha256 hash? The hash is not necessarily a valid x coordinate of a point on curve, so we take the hash over and over again until we find such a valid x.

The question is: why we use this method instead of picking a number k and multiply it with original base point to get another base point? Or is that because we want to get a valid base point without revealing the number k?

omershlo commented 5 years ago

We need a point that no one knows the k of that point, yes