ZenGo-X / curv

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

update serialize for curve25519 #19

Closed omershlo closed 5 years ago

omershlo commented 6 years ago

https://github.com/KZen-networks/cryptography-utils/blob/master/src/elliptic/curves/curve25519.rs#L133

Currently curve25519 do not provide a method to print x coordinate of a point and our serialize method is using (x,y). Our current solution is to serielize (y,y) and derive x from y. We need to update the our serde such that it will support one coordinate . or to implement the coordinate derivation ourselves:

        //taken from https://doc-internal.dalek.rs/src/curve25519_dalek/edwards.rs.html#144
        let y = self.ge.as_bytes().clone();
        let Y = SK::from_bytes_mod_order(y);
        let Z = SK::one();
        let YY = Y*Y;
        let u = &YY - &Z;
        let v = &(&YY * &constants::EDWARDS_D) + &Z;
        let (is_nonzero_square, mut X) = sqrt_ratio(&u, &v);
omershlo commented 5 years ago

done