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::{
keys::sapling::{find_group_hash, Diversifier, TransmissionKey},
serde_helpers,
serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize},
serialization::{
serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize,
},
types::amount::{Amount, NonNegative},
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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