pasta_curves/
vesta.rs

1//! The Vesta and iso-Vesta elliptic curve groups.
2
3use super::{Eq, EqAffine, Fp, Fq};
4
5/// The base field of the Vesta and iso-Vesta curves.
6pub type Base = Fq;
7
8/// The scalar field of the Vesta and iso-Vesta curves.
9pub type Scalar = Fp;
10
11/// A Vesta point in the projective coordinate space.
12pub type Point = Eq;
13
14/// A Vesta point in the affine coordinate space (or the point at infinity).
15pub type Affine = EqAffine;
16
17#[cfg(feature = "alloc")]
18#[test]
19fn test_map_to_curve_simple_swu() {
20    use crate::arithmetic::CurveExt;
21    use crate::curves::IsoEq;
22    use crate::hashtocurve::map_to_curve_simple_swu;
23
24    // The zero input is a special case.
25    let p: IsoEq = map_to_curve_simple_swu::<Fq, Eq, IsoEq>(&Fq::zero(), Eq::THETA, Eq::Z);
26    let (x, y, z) = p.jacobian_coordinates();
27
28    assert!(
29        format!("{:?}", x) == "0x2ccc4c6ec2660e5644305bc52527d904d408f92407f599df8f158d50646a2e78"
30    );
31    assert!(
32        format!("{:?}", y) == "0x29a34381321d13d72d50b6b462bb4ea6a9e47393fa28a47227bf35bc0ee7aa59"
33    );
34    assert!(
35        format!("{:?}", z) == "0x0b851e9e579403a76df1100f556e1f226e5656bdf38f3bf8601d8a3a9a15890b"
36    );
37
38    let p: IsoEq = map_to_curve_simple_swu::<Fq, Eq, IsoEq>(&Fq::one(), Eq::THETA, Eq::Z);
39    let (x, y, z) = p.jacobian_coordinates();
40
41    assert!(
42        format!("{:?}", x) == "0x165f8b71841c5abc3d742ec13fb16f099d596b781e6f5c7d0b6682b1216a8258"
43    );
44    assert!(
45        format!("{:?}", y) == "0x0dadef21de74ed7337a37dd74f126a92e4df73c3a704da501e36eaf59cf03120"
46    );
47    assert!(
48        format!("{:?}", z) == "0x0a3d6f6c1af02bd9274cc0b80129759ce77edeef578d7de968d4a47d39026c82"
49    );
50}
51
52#[cfg(feature = "alloc")]
53#[test]
54fn test_hash_to_curve() {
55    use crate::arithmetic::CurveExt;
56
57    // This test vector is chosen so that the first map_to_curve_simple_swu takes the gx1 non-square
58    // "branch" and the second takes the gx1 square "branch" (opposite to the Pallas test vector).
59    let hash = Point::hash_to_curve("z.cash:test");
60    let p: Point = hash(b"hello");
61    let (x, y, z) = p.jacobian_coordinates();
62
63    assert!(
64        format!("{:?}", x) == "0x12763505036e0e1a6684b7a7d8d5afb7378cc2b191a95e34f44824a06fcbd08e"
65    );
66    assert!(
67        format!("{:?}", y) == "0x0256eafc0188b79bfa7c4b2b393893ddc298e90da500fa4a9aee17c2ea4240e6"
68    );
69    assert!(
70        format!("{:?}", z) == "0x1b58d4aa4d68c3f4d9916b77c79ff9911597a27f2ee46244e98eb9615172d2ad"
71    );
72}