Move redjubjub into zcash_primitives

This commit is contained in:
Jack Grigg 2019-05-04 17:47:18 +01:00
parent f931562431
commit 7ea6d10480
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
17 changed files with 36 additions and 31 deletions

1
Cargo.lock generated
View File

@ -552,6 +552,7 @@ dependencies = [
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_os 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sapling-crypto 0.0.1",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -24,7 +24,6 @@ use sapling_crypto::{
fs::{Fs, FsRepr},
FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder, ToUniform, Unknown,
},
redjubjub::{self, Signature},
};
use sapling_crypto::circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH;
@ -62,6 +61,7 @@ use sapling_crypto::primitives::{ProofGenerationKey, ViewingKey};
use zcash_primitives::{
merkle_tree::CommitmentTreeWitness,
note_encryption::sapling_ka_agree,
redjubjub::{self, Signature},
sapling::{merkle_hash, spend_sig},
transaction::components::Amount,
zip32, JUBJUB,

View File

@ -1,9 +1,7 @@
use ff::{PrimeField, PrimeFieldRepr};
use pairing::bls12_381::Bls12;
use sapling_crypto::{
jubjub::{FixedGenerators, JubjubEngine},
redjubjub::{PrivateKey, PublicKey, Signature},
};
use sapling_crypto::jubjub::{FixedGenerators, JubjubEngine};
use zcash_primitives::redjubjub::{PrivateKey, PublicKey, Signature};
use super::JUBJUB;

View File

@ -23,5 +23,3 @@ pub mod circuit;
pub mod pedersen_hash;
pub mod primitives;
pub mod constants;
pub mod redjubjub;
pub mod util;

View File

@ -20,3 +20,6 @@ rand_core = "0.5"
rand_os = "0.2"
sapling-crypto = { path = "../sapling-crypto" }
sha2 = "0.8"
[dev-dependencies]
rand_xorshift = "0.2"

View File

@ -15,6 +15,9 @@ extern crate rand_os;
extern crate sapling_crypto;
extern crate sha2;
#[cfg(test)]
extern crate rand_xorshift;
use sapling_crypto::jubjub::JubjubBls12;
pub mod block;
@ -23,9 +26,11 @@ pub mod legacy;
pub mod merkle_tree;
pub mod note_encryption;
pub mod prover;
pub mod redjubjub;
pub mod sapling;
mod serialize;
pub mod transaction;
mod util;
pub mod zip32;
#[cfg(test)]

View File

@ -4,11 +4,11 @@ use pairing::bls12_381::{Bls12, Fr};
use sapling_crypto::{
jubjub::{edwards, fs::Fs, Unknown},
primitives::{Diversifier, PaymentAddress, ProofGenerationKey},
redjubjub::{PublicKey, Signature},
};
use crate::{
merkle_tree::CommitmentTreeWitness,
redjubjub::{PublicKey, Signature},
sapling::Node,
transaction::components::{Amount, GROTH_PROOF_SIZE},
};
@ -78,11 +78,11 @@ pub(crate) mod mock {
use sapling_crypto::{
jubjub::{edwards, fs::Fs, FixedGenerators, Unknown},
primitives::{Diversifier, PaymentAddress, ProofGenerationKey, ValueCommitment},
redjubjub::{PublicKey, Signature},
};
use crate::{
merkle_tree::CommitmentTreeWitness,
redjubjub::{PublicKey, Signature},
sapling::Node,
transaction::components::{Amount, GROTH_PROOF_SIZE},
JUBJUB,

View File

@ -3,10 +3,12 @@
use ff::{Field, PrimeField, PrimeFieldRepr};
use rand_core::RngCore;
use sapling_crypto::jubjub::{
edwards::Point, FixedGenerators, JubjubEngine, JubjubParams, Unknown,
};
use std::io::{self, Read, Write};
use jubjub::{FixedGenerators, JubjubEngine, JubjubParams, Unknown, edwards::Point};
use util::{hash_to_scalar};
use util::hash_to_scalar;
fn read_scalar<E: JubjubEngine, R: Read>(reader: R) -> io::Result<E::Fs> {
let mut s_repr = <E::Fs as PrimeField>::Repr::default();
@ -208,8 +210,7 @@ mod tests {
use pairing::bls12_381::Bls12;
use rand_core::SeedableRng;
use rand_xorshift::XorShiftRng;
use jubjub::{JubjubBls12, fs::Fs, edwards};
use sapling_crypto::jubjub::{edwards, fs::Fs, JubjubBls12};
use super::*;

View File

@ -7,11 +7,11 @@ use sapling_crypto::{
jubjub::{fs::Fs, FixedGenerators, JubjubBls12},
pedersen_hash::{pedersen_hash, Personalization},
primitives::Note,
redjubjub::{PrivateKey, PublicKey, Signature},
};
use std::io::{self, Read, Write};
use crate::merkle_tree::Hashable;
use crate::redjubjub::{PrivateKey, PublicKey, Signature};
use JUBJUB;
pub(crate) const SAPLING_COMMITMENT_TREE_DEPTH: usize =

View File

@ -6,7 +6,6 @@ use rand::{rngs::OsRng, seq::SliceRandom, CryptoRng, RngCore};
use sapling_crypto::{
jubjub::fs::Fs,
primitives::{Diversifier, Note, PaymentAddress},
redjubjub::PrivateKey,
};
use zip32::ExtendedSpendingKey;
@ -16,6 +15,7 @@ use crate::{
merkle_tree::{CommitmentTreeWitness, IncrementalWitness},
note_encryption::{generate_esk, Memo, SaplingNoteEncryption},
prover::TxProver,
redjubjub::PrivateKey,
sapling::{spend_sig, Node},
transaction::{
components::{amount::DEFAULT_FEE, Amount, OutputDescription, SpendDescription, TxOut},

View File

@ -1,13 +1,11 @@
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use ff::{PrimeField, PrimeFieldRepr};
use pairing::bls12_381::{Bls12, Fr, FrRepr};
use sapling_crypto::{
jubjub::{edwards, Unknown},
redjubjub::{PublicKey, Signature},
};
use sapling_crypto::jubjub::{edwards, Unknown};
use std::io::{self, Read, Write};
use legacy::Script;
use redjubjub::{PublicKey, Signature};
use JUBJUB;
pub mod amount;

View File

@ -1,11 +1,11 @@
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use hex;
use sapling_crypto::redjubjub::Signature;
use sha2::{Digest, Sha256};
use std::fmt;
use std::io::{self, Read, Write};
use std::ops::Deref;
use redjubjub::Signature;
use serialize::Vector;
pub mod builder;

View File

@ -1,13 +1,11 @@
use ff::Field;
use pairing::bls12_381::Bls12;
use rand_os::OsRng;
use sapling_crypto::{
jubjub::{fs::Fs, FixedGenerators},
redjubjub::PrivateKey,
};
use sapling_crypto::jubjub::{fs::Fs, FixedGenerators};
use super::{components::Amount, sighash::signature_hash, Transaction, TransactionData};
use legacy::Script;
use redjubjub::PrivateKey;
use JUBJUB;
#[test]

View File

@ -1,6 +1,5 @@
use blake2b_simd::Params;
use jubjub::{JubjubEngine, ToUniform};
use sapling_crypto::jubjub::{JubjubEngine, ToUniform};
pub fn hash_to_scalar<E: JubjubEngine>(persona: &[u8], a: &[u8], b: &[u8]) -> E::Fs {
let mut hasher = Params::new().hash_length(64).personal(persona).to_state();

View File

@ -6,12 +6,12 @@ use pairing::bls12_381::{Bls12, Fr};
use sapling_crypto::{
jubjub::{edwards, fs::Fs, Unknown},
primitives::{Diversifier, PaymentAddress, ProofGenerationKey},
redjubjub::{PublicKey, Signature},
};
use std::path::Path;
use zcash_primitives::{
merkle_tree::CommitmentTreeWitness,
prover::TxProver,
redjubjub::{PublicKey, Signature},
sapling::Node,
transaction::components::{Amount, GROTH_PROOF_SIZE},
JUBJUB,

View File

@ -11,10 +11,12 @@ use sapling_crypto::{
},
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
redjubjub::{PrivateKey, PublicKey, Signature},
};
use zcash_primitives::{
merkle_tree::CommitmentTreeWitness, sapling::Node, transaction::components::Amount,
merkle_tree::CommitmentTreeWitness,
redjubjub::{PrivateKey, PublicKey, Signature},
sapling::Node,
transaction::components::Amount,
};
use super::compute_value_balance;

View File

@ -4,9 +4,11 @@ use pairing::bls12_381::{Bls12, Fr};
use sapling_crypto::{
circuit::multipack,
jubjub::{edwards, FixedGenerators, JubjubBls12, Unknown},
redjubjub::{PublicKey, Signature},
};
use zcash_primitives::transaction::components::Amount;
use zcash_primitives::{
redjubjub::{PublicKey, Signature},
transaction::components::Amount,
};
use super::compute_value_balance;