Orchard: add a serde helper for pallas::Base
This commit is contained in:
parent
41a41db923
commit
d11a4419ac
|
@ -1,11 +1,12 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use halo2::{arithmetic::FieldExt, pasta::pallas};
|
use halo2::pasta::pallas;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
primitives::redpallas::{self, SpendAuth},
|
primitives::redpallas::{self, SpendAuth},
|
||||||
serialization::{
|
serialization::{
|
||||||
ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize,
|
serde_helpers, ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize,
|
||||||
|
ZcashSerialize,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +31,8 @@ pub struct Action {
|
||||||
pub nullifier: note::Nullifier,
|
pub nullifier: note::Nullifier,
|
||||||
/// The randomized validating key for spendAuthSig,
|
/// The randomized validating key for spendAuthSig,
|
||||||
pub rk: redpallas::VerificationKeyBytes<SpendAuth>,
|
pub rk: redpallas::VerificationKeyBytes<SpendAuth>,
|
||||||
/// 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,
|
pub cm_x: pallas::Base,
|
||||||
/// An encoding of an ephemeral Pallas public key.
|
/// An encoding of an ephemeral Pallas public key.
|
||||||
pub ephemeral_key: keys::EphemeralPublicKey,
|
pub ephemeral_key: keys::EphemeralPublicKey,
|
||||||
|
|
|
@ -64,6 +64,19 @@ impl From<Scalar> for pallas::Scalar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
#[serde(remote = "pallas::Base")]
|
||||||
|
pub struct Base {
|
||||||
|
#[serde(getter = "pallas::Base::to_bytes")]
|
||||||
|
bytes: [u8; 32],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Base> for pallas::Base {
|
||||||
|
fn from(local: Base) -> Self {
|
||||||
|
pallas::Base::from_bytes(&local.bytes).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[serde(remote = "futures::future::Either")]
|
#[serde(remote = "futures::future::Either")]
|
||||||
pub enum Either<A, B> {
|
pub enum Either<A, B> {
|
||||||
|
|
Loading…
Reference in New Issue