diff --git a/zebra-chain/src/orchard/action.rs b/zebra-chain/src/orchard/action.rs index 01df0346..9d37fcae 100644 --- a/zebra-chain/src/orchard/action.rs +++ b/zebra-chain/src/orchard/action.rs @@ -1,11 +1,12 @@ use std::io; -use halo2::{arithmetic::FieldExt, pasta::pallas}; +use halo2::pasta::pallas; use crate::{ primitives::redpallas::{self, SpendAuth}, serialization::{ - ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize, + serde_helpers, ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, + ZcashSerialize, }, }; @@ -30,7 +31,8 @@ pub struct Action { pub nullifier: note::Nullifier, /// The randomized validating key for spendAuthSig, pub rk: redpallas::VerificationKeyBytes, - /// The 𝑥-coordinate of the note commitment for the output note. + /// The x-coordinate of the note commitment for the output note. + #[serde(with = "serde_helpers::Base")] pub cm_x: pallas::Base, /// An encoding of an ephemeral Pallas public key. pub ephemeral_key: keys::EphemeralPublicKey, diff --git a/zebra-chain/src/serialization/serde_helpers.rs b/zebra-chain/src/serialization/serde_helpers.rs index df9fb201..05fc674d 100644 --- a/zebra-chain/src/serialization/serde_helpers.rs +++ b/zebra-chain/src/serialization/serde_helpers.rs @@ -64,6 +64,19 @@ impl From for pallas::Scalar { } } +#[derive(Deserialize, Serialize)] +#[serde(remote = "pallas::Base")] +pub struct Base { + #[serde(getter = "pallas::Base::to_bytes")] + bytes: [u8; 32], +} + +impl From for pallas::Base { + fn from(local: Base) -> Self { + pallas::Base::from_bytes(&local.bytes).unwrap() + } +} + #[derive(Deserialize, Serialize)] #[serde(remote = "futures::future::Either")] pub enum Either {