chain: move serde_helpers into serialization.

This commit is contained in:
Henry de Valence 2020-08-14 23:06:03 -07:00
parent b36fe8f937
commit cee7d0b8eb
11 changed files with 25 additions and 32 deletions

View File

@ -14,8 +14,9 @@ use rand_core::{CryptoRng, RngCore};
use crate::{ use crate::{
keys::sapling::{find_group_hash, Diversifier, TransmissionKey}, keys::sapling::{find_group_hash, Diversifier, TransmissionKey},
serde_helpers, serialization::{
serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize}, serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize,
},
types::amount::{Amount, NonNegative}, types::amount::{Amount, NonNegative},
}; };

View File

@ -1,10 +1,8 @@
//! Equihash Solution and related items. //! Equihash Solution and related items.
use crate::{ use crate::serialization::{
serde_helpers, serde_helpers, ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize,
serialization::{ ZcashSerialize,
ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize,
},
}; };
use std::{fmt, io}; use std::{fmt, io};

View File

@ -31,8 +31,9 @@ use proptest_derive::Arbitrary;
use crate::{ use crate::{
redjubjub::{self, SpendAuth}, redjubjub::{self, SpendAuth},
serde_helpers, serialization::{
serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize}, serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize,
},
Network, Network,
}; };

View File

@ -12,7 +12,6 @@
extern crate serde; extern crate serde;
mod merkle_tree; mod merkle_tree;
mod serde_helpers;
pub mod addresses; pub mod addresses;
pub mod block; pub mod block;

View File

@ -3,10 +3,7 @@ use std::{fmt, io};
#[cfg(test)] #[cfg(test)]
use proptest::{arbitrary::any, prelude::*}; use proptest::{arbitrary::any, prelude::*};
use crate::{ use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
serde_helpers,
serialization::{SerializationError, ZcashDeserialize, ZcashSerialize},
};
/// A ciphertext component for encrypted output notes. /// A ciphertext component for encrypted output notes.
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]

View File

@ -5,10 +5,7 @@ use proptest::{arbitrary::any, prelude::*};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
serde_helpers,
serialization::{SerializationError, ZcashDeserialize, ZcashSerialize},
};
/// A ciphertext component for encrypted output notes. /// A ciphertext component for encrypted output notes.
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]

View File

@ -2,8 +2,7 @@ use std::{fmt, io};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::serde_helpers; use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize};
/// An encoding of a BCTV14 proof, as used in Zcash. /// An encoding of a BCTV14 proof, as used in Zcash.
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]

View File

@ -1,8 +1,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{fmt, io}; use std::{fmt, io};
use crate::serde_helpers; use crate::serialization::{serde_helpers, SerializationError, ZcashDeserialize, ZcashSerialize};
use crate::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize};
/// An encoding of a Groth16 proof, as used in Zcash. /// An encoding of a Groth16 proof, as used in Zcash.
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]

View File

@ -12,6 +12,8 @@ mod write_zcash;
mod zcash_deserialize; mod zcash_deserialize;
mod zcash_serialize; mod zcash_serialize;
pub(crate) mod serde_helpers;
pub mod sha256d; pub mod sha256d;
pub use error::SerializationError; pub use error::SerializationError;

View File

@ -1,18 +1,18 @@
use super::equihash_solution::EQUIHASH_SOLUTION_SIZE;
use serde_big_array::big_array; use serde_big_array::big_array;
big_array! { big_array! {
BigArray; BigArray;
+EQUIHASH_SOLUTION_SIZE, + 1344, // `EquihashSolution`
80, // `sapling::OutCiphertext` 80, // `sapling::OutCiphertext`
580, // `sapling::EncryptedCiphertext` 580, // `sapling::EncryptedCiphertext`
601, // `sprout::EncryptedCiphertext` 601, // `sprout::EncryptedCiphertext`
296, // `bctv14::Bctv14Proof` 296, // `Bctv14Proof`
196, // `Groth16Proof`
} }
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
#[serde(remote = "jubjub::AffinePoint")] #[serde(remote = "jubjub::AffinePoint")]
pub(crate) struct AffinePoint { pub struct AffinePoint {
#[serde(getter = "jubjub::AffinePoint::to_bytes")] #[serde(getter = "jubjub::AffinePoint::to_bytes")]
bytes: [u8; 32], bytes: [u8; 32],
} }
@ -25,7 +25,7 @@ impl From<AffinePoint> for jubjub::AffinePoint {
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
#[serde(remote = "jubjub::Fq")] #[serde(remote = "jubjub::Fq")]
pub(crate) struct Fq { pub struct Fq {
#[serde(getter = "jubjub::Fq::to_bytes")] #[serde(getter = "jubjub::Fq::to_bytes")]
bytes: [u8; 32], bytes: [u8; 32],
} }
@ -38,7 +38,7 @@ impl From<Fq> for jubjub::Fq {
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
#[serde(remote = "futures::future::Either")] #[serde(remote = "futures::future::Either")]
pub(crate) enum Either<A, B> { pub enum Either<A, B> {
Left(A), Left(A),
Right(B), Right(B),
} }

View File

@ -2,7 +2,7 @@ use crate::{
commitments, keys, notes, commitments, keys, notes,
proofs::Groth16Proof, proofs::Groth16Proof,
redjubjub::{self, Binding, SpendAuth}, redjubjub::{self, Binding, SpendAuth},
serde_helpers, serialization::serde_helpers,
treestate::note_commitment_tree::SaplingNoteTreeRootHash, treestate::note_commitment_tree::SaplingNoteTreeRootHash,
}; };
use futures::future::Either; use futures::future::Either;