mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-31 04:21:23 +00:00
Move redjubjub into zcash_primitives
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -552,6 +552,7 @@ dependencies = [
|
|||||||
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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_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_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",
|
"sapling-crypto 0.0.1",
|
||||||
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@@ -24,7 +24,6 @@ use sapling_crypto::{
|
|||||||
fs::{Fs, FsRepr},
|
fs::{Fs, FsRepr},
|
||||||
FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder, ToUniform, Unknown,
|
FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder, ToUniform, Unknown,
|
||||||
},
|
},
|
||||||
redjubjub::{self, Signature},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use sapling_crypto::circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH;
|
use sapling_crypto::circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH;
|
||||||
@@ -62,6 +61,7 @@ use sapling_crypto::primitives::{ProofGenerationKey, ViewingKey};
|
|||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
merkle_tree::CommitmentTreeWitness,
|
merkle_tree::CommitmentTreeWitness,
|
||||||
note_encryption::sapling_ka_agree,
|
note_encryption::sapling_ka_agree,
|
||||||
|
redjubjub::{self, Signature},
|
||||||
sapling::{merkle_hash, spend_sig},
|
sapling::{merkle_hash, spend_sig},
|
||||||
transaction::components::Amount,
|
transaction::components::Amount,
|
||||||
zip32, JUBJUB,
|
zip32, JUBJUB,
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
use ff::{PrimeField, PrimeFieldRepr};
|
use ff::{PrimeField, PrimeFieldRepr};
|
||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::jubjub::{FixedGenerators, JubjubEngine};
|
||||||
jubjub::{FixedGenerators, JubjubEngine},
|
use zcash_primitives::redjubjub::{PrivateKey, PublicKey, Signature};
|
||||||
redjubjub::{PrivateKey, PublicKey, Signature},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::JUBJUB;
|
use super::JUBJUB;
|
||||||
|
|
||||||
|
@@ -23,5 +23,3 @@ pub mod circuit;
|
|||||||
pub mod pedersen_hash;
|
pub mod pedersen_hash;
|
||||||
pub mod primitives;
|
pub mod primitives;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod redjubjub;
|
|
||||||
pub mod util;
|
|
||||||
|
@@ -20,3 +20,6 @@ rand_core = "0.5"
|
|||||||
rand_os = "0.2"
|
rand_os = "0.2"
|
||||||
sapling-crypto = { path = "../sapling-crypto" }
|
sapling-crypto = { path = "../sapling-crypto" }
|
||||||
sha2 = "0.8"
|
sha2 = "0.8"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
rand_xorshift = "0.2"
|
||||||
|
@@ -15,6 +15,9 @@ extern crate rand_os;
|
|||||||
extern crate sapling_crypto;
|
extern crate sapling_crypto;
|
||||||
extern crate sha2;
|
extern crate sha2;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
extern crate rand_xorshift;
|
||||||
|
|
||||||
use sapling_crypto::jubjub::JubjubBls12;
|
use sapling_crypto::jubjub::JubjubBls12;
|
||||||
|
|
||||||
pub mod block;
|
pub mod block;
|
||||||
@@ -23,9 +26,11 @@ pub mod legacy;
|
|||||||
pub mod merkle_tree;
|
pub mod merkle_tree;
|
||||||
pub mod note_encryption;
|
pub mod note_encryption;
|
||||||
pub mod prover;
|
pub mod prover;
|
||||||
|
pub mod redjubjub;
|
||||||
pub mod sapling;
|
pub mod sapling;
|
||||||
mod serialize;
|
mod serialize;
|
||||||
pub mod transaction;
|
pub mod transaction;
|
||||||
|
mod util;
|
||||||
pub mod zip32;
|
pub mod zip32;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@@ -4,11 +4,11 @@ use pairing::bls12_381::{Bls12, Fr};
|
|||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
jubjub::{edwards, fs::Fs, Unknown},
|
jubjub::{edwards, fs::Fs, Unknown},
|
||||||
primitives::{Diversifier, PaymentAddress, ProofGenerationKey},
|
primitives::{Diversifier, PaymentAddress, ProofGenerationKey},
|
||||||
redjubjub::{PublicKey, Signature},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
merkle_tree::CommitmentTreeWitness,
|
merkle_tree::CommitmentTreeWitness,
|
||||||
|
redjubjub::{PublicKey, Signature},
|
||||||
sapling::Node,
|
sapling::Node,
|
||||||
transaction::components::{Amount, GROTH_PROOF_SIZE},
|
transaction::components::{Amount, GROTH_PROOF_SIZE},
|
||||||
};
|
};
|
||||||
@@ -78,11 +78,11 @@ pub(crate) mod mock {
|
|||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
jubjub::{edwards, fs::Fs, FixedGenerators, Unknown},
|
jubjub::{edwards, fs::Fs, FixedGenerators, Unknown},
|
||||||
primitives::{Diversifier, PaymentAddress, ProofGenerationKey, ValueCommitment},
|
primitives::{Diversifier, PaymentAddress, ProofGenerationKey, ValueCommitment},
|
||||||
redjubjub::{PublicKey, Signature},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
merkle_tree::CommitmentTreeWitness,
|
merkle_tree::CommitmentTreeWitness,
|
||||||
|
redjubjub::{PublicKey, Signature},
|
||||||
sapling::Node,
|
sapling::Node,
|
||||||
transaction::components::{Amount, GROTH_PROOF_SIZE},
|
transaction::components::{Amount, GROTH_PROOF_SIZE},
|
||||||
JUBJUB,
|
JUBJUB,
|
||||||
|
@@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
use ff::{Field, PrimeField, PrimeFieldRepr};
|
use ff::{Field, PrimeField, PrimeFieldRepr};
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
|
use sapling_crypto::jubjub::{
|
||||||
|
edwards::Point, FixedGenerators, JubjubEngine, JubjubParams, Unknown,
|
||||||
|
};
|
||||||
use std::io::{self, Read, Write};
|
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> {
|
fn read_scalar<E: JubjubEngine, R: Read>(reader: R) -> io::Result<E::Fs> {
|
||||||
let mut s_repr = <E::Fs as PrimeField>::Repr::default();
|
let mut s_repr = <E::Fs as PrimeField>::Repr::default();
|
||||||
@@ -208,8 +210,7 @@ mod tests {
|
|||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
use rand_core::SeedableRng;
|
use rand_core::SeedableRng;
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
|
use sapling_crypto::jubjub::{edwards, fs::Fs, JubjubBls12};
|
||||||
use jubjub::{JubjubBls12, fs::Fs, edwards};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@@ -7,11 +7,11 @@ use sapling_crypto::{
|
|||||||
jubjub::{fs::Fs, FixedGenerators, JubjubBls12},
|
jubjub::{fs::Fs, FixedGenerators, JubjubBls12},
|
||||||
pedersen_hash::{pedersen_hash, Personalization},
|
pedersen_hash::{pedersen_hash, Personalization},
|
||||||
primitives::Note,
|
primitives::Note,
|
||||||
redjubjub::{PrivateKey, PublicKey, Signature},
|
|
||||||
};
|
};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
|
|
||||||
use crate::merkle_tree::Hashable;
|
use crate::merkle_tree::Hashable;
|
||||||
|
use crate::redjubjub::{PrivateKey, PublicKey, Signature};
|
||||||
use JUBJUB;
|
use JUBJUB;
|
||||||
|
|
||||||
pub(crate) const SAPLING_COMMITMENT_TREE_DEPTH: usize =
|
pub(crate) const SAPLING_COMMITMENT_TREE_DEPTH: usize =
|
||||||
|
@@ -6,7 +6,6 @@ use rand::{rngs::OsRng, seq::SliceRandom, CryptoRng, RngCore};
|
|||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
jubjub::fs::Fs,
|
jubjub::fs::Fs,
|
||||||
primitives::{Diversifier, Note, PaymentAddress},
|
primitives::{Diversifier, Note, PaymentAddress},
|
||||||
redjubjub::PrivateKey,
|
|
||||||
};
|
};
|
||||||
use zip32::ExtendedSpendingKey;
|
use zip32::ExtendedSpendingKey;
|
||||||
|
|
||||||
@@ -16,6 +15,7 @@ use crate::{
|
|||||||
merkle_tree::{CommitmentTreeWitness, IncrementalWitness},
|
merkle_tree::{CommitmentTreeWitness, IncrementalWitness},
|
||||||
note_encryption::{generate_esk, Memo, SaplingNoteEncryption},
|
note_encryption::{generate_esk, Memo, SaplingNoteEncryption},
|
||||||
prover::TxProver,
|
prover::TxProver,
|
||||||
|
redjubjub::PrivateKey,
|
||||||
sapling::{spend_sig, Node},
|
sapling::{spend_sig, Node},
|
||||||
transaction::{
|
transaction::{
|
||||||
components::{amount::DEFAULT_FEE, Amount, OutputDescription, SpendDescription, TxOut},
|
components::{amount::DEFAULT_FEE, Amount, OutputDescription, SpendDescription, TxOut},
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use ff::{PrimeField, PrimeFieldRepr};
|
use ff::{PrimeField, PrimeFieldRepr};
|
||||||
use pairing::bls12_381::{Bls12, Fr, FrRepr};
|
use pairing::bls12_381::{Bls12, Fr, FrRepr};
|
||||||
use sapling_crypto::{
|
use sapling_crypto::jubjub::{edwards, Unknown};
|
||||||
jubjub::{edwards, Unknown},
|
|
||||||
redjubjub::{PublicKey, Signature},
|
|
||||||
};
|
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
|
|
||||||
use legacy::Script;
|
use legacy::Script;
|
||||||
|
use redjubjub::{PublicKey, Signature};
|
||||||
use JUBJUB;
|
use JUBJUB;
|
||||||
|
|
||||||
pub mod amount;
|
pub mod amount;
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use hex;
|
use hex;
|
||||||
use sapling_crypto::redjubjub::Signature;
|
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
use redjubjub::Signature;
|
||||||
use serialize::Vector;
|
use serialize::Vector;
|
||||||
|
|
||||||
pub mod builder;
|
pub mod builder;
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
use rand_os::OsRng;
|
use rand_os::OsRng;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::jubjub::{fs::Fs, FixedGenerators};
|
||||||
jubjub::{fs::Fs, FixedGenerators},
|
|
||||||
redjubjub::PrivateKey,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{components::Amount, sighash::signature_hash, Transaction, TransactionData};
|
use super::{components::Amount, sighash::signature_hash, Transaction, TransactionData};
|
||||||
use legacy::Script;
|
use legacy::Script;
|
||||||
|
use redjubjub::PrivateKey;
|
||||||
use JUBJUB;
|
use JUBJUB;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
use blake2b_simd::Params;
|
use blake2b_simd::Params;
|
||||||
|
use sapling_crypto::jubjub::{JubjubEngine, ToUniform};
|
||||||
use jubjub::{JubjubEngine, ToUniform};
|
|
||||||
|
|
||||||
pub fn hash_to_scalar<E: JubjubEngine>(persona: &[u8], a: &[u8], b: &[u8]) -> E::Fs {
|
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();
|
let mut hasher = Params::new().hash_length(64).personal(persona).to_state();
|
@@ -6,12 +6,12 @@ use pairing::bls12_381::{Bls12, Fr};
|
|||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
jubjub::{edwards, fs::Fs, Unknown},
|
jubjub::{edwards, fs::Fs, Unknown},
|
||||||
primitives::{Diversifier, PaymentAddress, ProofGenerationKey},
|
primitives::{Diversifier, PaymentAddress, ProofGenerationKey},
|
||||||
redjubjub::{PublicKey, Signature},
|
|
||||||
};
|
};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
merkle_tree::CommitmentTreeWitness,
|
merkle_tree::CommitmentTreeWitness,
|
||||||
prover::TxProver,
|
prover::TxProver,
|
||||||
|
redjubjub::{PublicKey, Signature},
|
||||||
sapling::Node,
|
sapling::Node,
|
||||||
transaction::components::{Amount, GROTH_PROOF_SIZE},
|
transaction::components::{Amount, GROTH_PROOF_SIZE},
|
||||||
JUBJUB,
|
JUBJUB,
|
||||||
|
@@ -11,10 +11,12 @@ use sapling_crypto::{
|
|||||||
},
|
},
|
||||||
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
|
jubjub::{edwards, fs::Fs, FixedGenerators, JubjubBls12, Unknown},
|
||||||
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
|
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ValueCommitment},
|
||||||
redjubjub::{PrivateKey, PublicKey, Signature},
|
|
||||||
};
|
};
|
||||||
use zcash_primitives::{
|
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;
|
use super::compute_value_balance;
|
||||||
|
@@ -4,9 +4,11 @@ use pairing::bls12_381::{Bls12, Fr};
|
|||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
circuit::multipack,
|
circuit::multipack,
|
||||||
jubjub::{edwards, FixedGenerators, JubjubBls12, Unknown},
|
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;
|
use super::compute_value_balance;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user