mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-08-01 12:51:30 +00:00
cargo fmt
This commit is contained in:
@@ -52,13 +52,8 @@ pub fn prime_field(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
|||||||
|
|
||||||
let mut gen = proc_macro2::TokenStream::new();
|
let mut gen = proc_macro2::TokenStream::new();
|
||||||
|
|
||||||
let (constants_impl, sqrt_impl) = prime_field_constants_and_sqrt(
|
let (constants_impl, sqrt_impl) =
|
||||||
&ast.ident,
|
prime_field_constants_and_sqrt(&ast.ident, &repr_ident, modulus, limbs, generator);
|
||||||
&repr_ident,
|
|
||||||
modulus,
|
|
||||||
limbs,
|
|
||||||
generator,
|
|
||||||
);
|
|
||||||
|
|
||||||
gen.extend(constants_impl);
|
gen.extend(constants_impl);
|
||||||
gen.extend(prime_field_repr_impl(&repr_ident, limbs));
|
gen.extend(prime_field_repr_impl(&repr_ident, limbs));
|
||||||
@@ -359,7 +354,8 @@ fn biguint_num_bits(mut v: BigUint) -> u32 {
|
|||||||
fn exp(base: BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
|
fn exp(base: BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
|
||||||
let mut ret = BigUint::one();
|
let mut ret = BigUint::one();
|
||||||
|
|
||||||
for i in exp.to_bytes_be()
|
for i in exp
|
||||||
|
.to_bytes_be()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|x| (0..8).rev().map(move |i| (x >> i).is_odd()))
|
.flat_map(|x| (0..8).rev().map(move |i| (x >> i).is_odd()))
|
||||||
{
|
{
|
||||||
@@ -380,11 +376,13 @@ fn test_exp() {
|
|||||||
&BigUint::from_str("5489673498567349856734895").unwrap(),
|
&BigUint::from_str("5489673498567349856734895").unwrap(),
|
||||||
&BigUint::from_str(
|
&BigUint::from_str(
|
||||||
"52435875175126190479447740508185965837690552500527637822603658699938581184513"
|
"52435875175126190479447740508185965837690552500527637822603658699938581184513"
|
||||||
).unwrap()
|
)
|
||||||
|
.unwrap()
|
||||||
),
|
),
|
||||||
BigUint::from_str(
|
BigUint::from_str(
|
||||||
"4371221214068404307866768905142520595925044802278091865033317963560480051536"
|
"4371221214068404307866768905142520595925044802278091865033317963560480051536"
|
||||||
).unwrap()
|
)
|
||||||
|
.unwrap()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,7 +534,8 @@ fn prime_field_constants_and_sqrt(
|
|||||||
}
|
}
|
||||||
inv = inv.wrapping_neg();
|
inv = inv.wrapping_neg();
|
||||||
|
|
||||||
(quote! {
|
(
|
||||||
|
quote! {
|
||||||
/// This is the modulus m of the prime field
|
/// This is the modulus m of the prime field
|
||||||
const MODULUS: #repr = #repr([#(#modulus,)*]);
|
const MODULUS: #repr = #repr([#(#modulus,)*]);
|
||||||
|
|
||||||
@@ -565,7 +564,9 @@ fn prime_field_constants_and_sqrt(
|
|||||||
|
|
||||||
/// 2^s root of unity computed by GENERATOR^t
|
/// 2^s root of unity computed by GENERATOR^t
|
||||||
const ROOT_OF_UNITY: #repr = #repr(#root_of_unity);
|
const ROOT_OF_UNITY: #repr = #repr(#root_of_unity);
|
||||||
}, sqrt_impl)
|
},
|
||||||
|
sqrt_impl,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implement PrimeField for the derived type.
|
/// Implement PrimeField for the derived type.
|
||||||
|
@@ -59,9 +59,7 @@ use std::os::windows::ffi::OsStringExt;
|
|||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
merkle_tree::CommitmentTreeWitness,
|
merkle_tree::CommitmentTreeWitness,
|
||||||
note_encryption::sapling_ka_agree,
|
note_encryption::sapling_ka_agree,
|
||||||
primitives::{
|
primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ViewingKey},
|
||||||
Diversifier, Note, PaymentAddress, ProofGenerationKey, ViewingKey,
|
|
||||||
},
|
|
||||||
redjubjub::{self, Signature},
|
redjubjub::{self, Signature},
|
||||||
sapling::{merkle_hash, spend_sig},
|
sapling::{merkle_hash, spend_sig},
|
||||||
transaction::components::Amount,
|
transaction::components::Amount,
|
||||||
|
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
use bech32::{self, Error, FromBase32, ToBase32};
|
use bech32::{self, Error, FromBase32, ToBase32};
|
||||||
use pairing::bls12_381::Bls12;
|
use pairing::bls12_381::Bls12;
|
||||||
|
use std::io::{self, Write};
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
jubjub::edwards,
|
jubjub::edwards,
|
||||||
primitives::{Diversifier, PaymentAddress},
|
primitives::{Diversifier, PaymentAddress},
|
||||||
};
|
};
|
||||||
use std::io::{self, Write};
|
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
|
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
|
||||||
JUBJUB,
|
JUBJUB,
|
||||||
@@ -187,11 +187,11 @@ 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 zcash_primitives::JUBJUB;
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
jubjub::edwards,
|
jubjub::edwards,
|
||||||
primitives::{Diversifier, PaymentAddress},
|
primitives::{Diversifier, PaymentAddress},
|
||||||
};
|
};
|
||||||
use zcash_primitives::JUBJUB;
|
|
||||||
|
|
||||||
use super::{decode_payment_address, encode_payment_address};
|
use super::{decode_payment_address, encode_payment_address};
|
||||||
use crate::constants;
|
use crate::constants;
|
||||||
|
Reference in New Issue
Block a user