mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-08-01 12:51:30 +00:00
Migrate remaining crates to rand 0.5
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -328,7 +328,7 @@ dependencies = [
|
|||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pairing 0.14.2",
|
"pairing 0.14.2",
|
||||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sapling-crypto 0.0.1",
|
"sapling-crypto 0.0.1",
|
||||||
"zcash_primitives 0.0.0",
|
"zcash_primitives 0.0.0",
|
||||||
"zcash_proofs 0.0.0",
|
"zcash_proofs 0.0.0",
|
||||||
@@ -576,7 +576,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bech32 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"pairing 0.14.2",
|
"pairing 0.14.2",
|
||||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sapling-crypto 0.0.1",
|
"sapling-crypto 0.0.1",
|
||||||
"zcash_primitives 0.0.0",
|
"zcash_primitives 0.0.0",
|
||||||
]
|
]
|
||||||
@@ -608,7 +608,7 @@ dependencies = [
|
|||||||
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ff 0.4.0",
|
"ff 0.4.0",
|
||||||
"pairing 0.14.2",
|
"pairing 0.14.2",
|
||||||
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sapling-crypto 0.0.1",
|
"sapling-crypto 0.0.1",
|
||||||
"zcash_primitives 0.0.0",
|
"zcash_primitives 0.0.0",
|
||||||
]
|
]
|
||||||
|
@@ -22,7 +22,7 @@ libc = "0.2"
|
|||||||
pairing = { path = "../pairing" }
|
pairing = { path = "../pairing" }
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
rand = "0.4"
|
rand = "0.5"
|
||||||
sapling-crypto = { path = "../sapling-crypto" }
|
sapling-crypto = { path = "../sapling-crypto" }
|
||||||
zcash_primitives = { path = "../zcash_primitives" }
|
zcash_primitives = { path = "../zcash_primitives" }
|
||||||
zcash_proofs = { path = "../zcash_proofs" }
|
zcash_proofs = { path = "../zcash_proofs" }
|
||||||
|
@@ -13,4 +13,4 @@ sapling-crypto = { path = "../sapling-crypto" }
|
|||||||
zcash_primitives = { path = "../zcash_primitives" }
|
zcash_primitives = { path = "../zcash_primitives" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.4"
|
rand = "0.5"
|
||||||
|
@@ -112,7 +112,10 @@ pub fn decode_extended_full_viewing_key(
|
|||||||
/// };
|
/// };
|
||||||
/// use zcash_primitives::JUBJUB;
|
/// use zcash_primitives::JUBJUB;
|
||||||
///
|
///
|
||||||
/// let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
/// let rng = &mut XorShiftRng::from_seed([
|
||||||
|
/// 0x59, 0x62, 0xbe, 0x3d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
|
||||||
|
/// 0xbc, 0xe5,
|
||||||
|
/// ]);
|
||||||
///
|
///
|
||||||
/// let pa = PaymentAddress {
|
/// let pa = PaymentAddress {
|
||||||
/// diversifier: Diversifier([0u8; 11]),
|
/// diversifier: Diversifier([0u8; 11]),
|
||||||
@@ -121,7 +124,7 @@ pub fn decode_extended_full_viewing_key(
|
|||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, &pa),
|
/// encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, &pa),
|
||||||
/// "ztestsapling1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjq6awtaj",
|
/// "ztestsapling1qqqqqqqqqqqqqqqqqrjq05nyfku05msvu49mawhg6kr0wwljahypwyk2h88z6975u563j0ym7pe",
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub fn encode_payment_address(hrp: &str, addr: &PaymentAddress<Bls12>) -> String {
|
pub fn encode_payment_address(hrp: &str, addr: &PaymentAddress<Bls12>) -> String {
|
||||||
@@ -148,7 +151,10 @@ pub fn encode_payment_address(hrp: &str, addr: &PaymentAddress<Bls12>) -> String
|
|||||||
/// };
|
/// };
|
||||||
/// use zcash_primitives::JUBJUB;
|
/// use zcash_primitives::JUBJUB;
|
||||||
///
|
///
|
||||||
/// let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
/// let rng = &mut XorShiftRng::from_seed([
|
||||||
|
/// 0x59, 0x62, 0xbe, 0x3d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
|
||||||
|
/// 0xbc, 0xe5,
|
||||||
|
/// ]);
|
||||||
///
|
///
|
||||||
/// let pa = PaymentAddress {
|
/// let pa = PaymentAddress {
|
||||||
/// diversifier: Diversifier([0u8; 11]),
|
/// diversifier: Diversifier([0u8; 11]),
|
||||||
@@ -158,7 +164,7 @@ pub fn encode_payment_address(hrp: &str, addr: &PaymentAddress<Bls12>) -> String
|
|||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// decode_payment_address(
|
/// decode_payment_address(
|
||||||
/// HRP_SAPLING_PAYMENT_ADDRESS,
|
/// HRP_SAPLING_PAYMENT_ADDRESS,
|
||||||
/// "ztestsapling1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjq6awtaj",
|
/// "ztestsapling1qqqqqqqqqqqqqqqqqrjq05nyfku05msvu49mawhg6kr0wwljahypwyk2h88z6975u563j0ym7pe",
|
||||||
/// ),
|
/// ),
|
||||||
/// Ok(Some(pa)),
|
/// Ok(Some(pa)),
|
||||||
/// );
|
/// );
|
||||||
@@ -194,7 +200,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn payment_address() {
|
fn payment_address() {
|
||||||
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
let rng = &mut XorShiftRng::from_seed([
|
||||||
|
0x59, 0x62, 0xbe, 0x3d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
|
||||||
|
0xbc, 0xe5,
|
||||||
|
]);
|
||||||
|
|
||||||
let addr = PaymentAddress {
|
let addr = PaymentAddress {
|
||||||
diversifier: Diversifier([0u8; 11]),
|
diversifier: Diversifier([0u8; 11]),
|
||||||
@@ -202,9 +211,9 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let encoded_main =
|
let encoded_main =
|
||||||
"zs1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjqj2ug6x";
|
"zs1qqqqqqqqqqqqqqqqqrjq05nyfku05msvu49mawhg6kr0wwljahypwyk2h88z6975u563j8nfaxd";
|
||||||
let encoded_test =
|
let encoded_test =
|
||||||
"ztestsapling1qqqqqqqqqqqqqqqqqqxrrfaccydp867g6zg7ne5ht37z38jtfyw0ygmp0ja6hhf07twjq6awtaj";
|
"ztestsapling1qqqqqqqqqqqqqqqqqrjq05nyfku05msvu49mawhg6kr0wwljahypwyk2h88z6975u563j0ym7pe";
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
encode_payment_address(constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, &addr),
|
encode_payment_address(constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, &addr),
|
||||||
@@ -235,7 +244,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_diversifier() {
|
fn invalid_diversifier() {
|
||||||
let rng = &mut XorShiftRng::from_seed([0x3dbe6259, 0x8d313d76, 0x3237db17, 0xe5bc0654]);
|
let rng = &mut XorShiftRng::from_seed([
|
||||||
|
0x59, 0x62, 0xbe, 0x3d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
|
||||||
|
0xbc, 0xe5,
|
||||||
|
]);
|
||||||
|
|
||||||
let addr = PaymentAddress {
|
let addr = PaymentAddress {
|
||||||
diversifier: Diversifier([1u8; 11]),
|
diversifier: Diversifier([1u8; 11]),
|
||||||
|
@@ -11,6 +11,6 @@ blake2b_simd = "0.5"
|
|||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
ff = { path = "../ff" }
|
ff = { path = "../ff" }
|
||||||
pairing = { path = "../pairing" }
|
pairing = { path = "../pairing" }
|
||||||
rand = "0.4"
|
rand = "0.5"
|
||||||
sapling-crypto = { path = "../sapling-crypto" }
|
sapling-crypto = { path = "../sapling-crypto" }
|
||||||
zcash_primitives = { path = "../zcash_primitives" }
|
zcash_primitives = { path = "../zcash_primitives" }
|
||||||
|
@@ -3,7 +3,7 @@ use bellman::groth16::{
|
|||||||
};
|
};
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use pairing::bls12_381::{Bls12, Fr};
|
use pairing::bls12_381::{Bls12, Fr};
|
||||||
use rand::{OsRng, Rand};
|
use rand::OsRng;
|
||||||
use sapling_crypto::{
|
use sapling_crypto::{
|
||||||
circuit::{
|
circuit::{
|
||||||
multipack,
|
multipack,
|
||||||
@@ -59,7 +59,7 @@ impl SaplingProvingContext {
|
|||||||
let mut rng = OsRng::new().expect("should be able to construct RNG");
|
let mut rng = OsRng::new().expect("should be able to construct RNG");
|
||||||
|
|
||||||
// We create the randomness of the value commitment
|
// We create the randomness of the value commitment
|
||||||
let rcv = Fs::rand(&mut rng);
|
let rcv = Fs::random(&mut rng);
|
||||||
|
|
||||||
// Accumulate the value commitment randomness in the context
|
// Accumulate the value commitment randomness in the context
|
||||||
{
|
{
|
||||||
@@ -194,7 +194,7 @@ impl SaplingProvingContext {
|
|||||||
// We construct ephemeral randomness for the value commitment. This
|
// We construct ephemeral randomness for the value commitment. This
|
||||||
// randomness is not given back to the caller, but the synthetic
|
// randomness is not given back to the caller, but the synthetic
|
||||||
// blinding factor `bsk` is accumulated in the context.
|
// blinding factor `bsk` is accumulated in the context.
|
||||||
let rcv = Fs::rand(&mut rng);
|
let rcv = Fs::random(&mut rng);
|
||||||
|
|
||||||
// Accumulate the value commitment randomness in the context
|
// Accumulate the value commitment randomness in the context
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user