use group::{ff::PrimeField, GroupEncoding}; use halo2::pasta::pallas; #[derive(Deserialize, Serialize)] #[serde(remote = "jubjub::AffinePoint")] pub struct AffinePoint { #[serde(getter = "jubjub::AffinePoint::to_bytes")] bytes: [u8; 32], } impl From for jubjub::AffinePoint { fn from(local: AffinePoint) -> Self { jubjub::AffinePoint::from_bytes(local.bytes).unwrap() } } #[derive(Deserialize, Serialize)] #[serde(remote = "jubjub::Fq")] pub struct Fq { #[serde(getter = "jubjub::Fq::to_bytes")] bytes: [u8; 32], } impl From for jubjub::Fq { fn from(local: Fq) -> Self { jubjub::Fq::from_bytes(&local.bytes).unwrap() } } #[derive(Deserialize, Serialize)] #[serde(remote = "pallas::Affine")] pub struct Affine { #[serde(getter = "pallas::Affine::to_bytes")] bytes: [u8; 32], } impl From for pallas::Affine { fn from(local: Affine) -> Self { pallas::Affine::from_bytes(&local.bytes).unwrap() } } #[derive(Deserialize, Serialize)] #[serde(remote = "pallas::Scalar")] pub struct Scalar { #[serde(getter = "pallas::Scalar::to_repr")] bytes: [u8; 32], } impl From for pallas::Scalar { fn from(local: Scalar) -> Self { pallas::Scalar::from_repr(local.bytes).unwrap() } } #[derive(Deserialize, Serialize)] #[serde(remote = "pallas::Base")] pub struct Base { #[serde(getter = "pallas::Base::to_repr")] bytes: [u8; 32], } impl From for pallas::Base { fn from(local: Base) -> Self { pallas::Base::from_repr(local.bytes).unwrap() } }