cargo fmt

This commit is contained in:
Nicholas Ward 2021-07-21 13:05:40 -07:00
parent 1dd850b0e5
commit 7f92a33964
7 changed files with 51 additions and 9 deletions

View File

@ -1,4 +1,5 @@
use num_bigint::BigUint;
use crate::field::field::Field;
/// Finds a set of shifts that result in unique cosets for the multiplicative subgroup of size

View File

@ -5,8 +5,8 @@ use std::iter::{Product, Sum};
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use itertools::Itertools;
use num_bigint::BigUint;
use num::Integer;
use num_bigint::BigUint;
use rand::Rng;
use serde::{Deserialize, Serialize};
@ -248,7 +248,14 @@ impl Field for CrandallField {
}
fn from_canonical_biguint(n: BigUint) -> Self {
let last_two : Vec<_> = n.to_u32_digits().iter().rev().take(2).pad_using(2, |_| &0u32).map(|x| *x as u64).collect();
let last_two: Vec<_> = n
.to_u32_digits()
.iter()
.rev()
.take(2)
.pad_using(2, |_| &0u32)
.map(|x| *x as u64)
.collect();
let n_u64 = last_two[0] + (1u64 << 32) * last_two[1];
Self(n_u64)
}

View File

@ -91,7 +91,14 @@ impl Field for QuadraticCrandallField {
}
fn from_canonical_biguint(n: BigUint) -> Self {
let last_four : Vec<_> = n.to_u32_digits().iter().rev().take(4).pad_using(4, |_| &0u32).map(|x| *x as u64).collect();
let last_four: Vec<_> = n
.to_u32_digits()
.iter()
.rev()
.take(4)
.pad_using(4, |_| &0u32)
.map(|x| *x as u64)
.collect();
let last_u64 = last_four[0] + (1u64 << 32) * last_four[1];
let next_last_u64 = last_four[2] + (1u64 << 32) * last_four[3];

View File

@ -124,7 +124,14 @@ impl Field for QuarticCrandallField {
}
fn from_canonical_biguint(n: BigUint) -> Self {
let last_eight : Vec<_> = n.to_u32_digits().iter().rev().take(8).pad_using(8, |_| &0u32).map(|x| *x as u64).collect();
let last_eight: Vec<_> = n
.to_u32_digits()
.iter()
.rev()
.take(8)
.pad_using(8, |_| &0u32)
.map(|x| *x as u64)
.collect();
let last_u64 = last_eight[0] + (1u64 << 32) * last_eight[1];
let next_last_u64 = last_eight[2] + (1u64 << 32) * last_eight[3];
let third_last_u64 = last_eight[4] + (1u64 << 32) * last_eight[5];

View File

@ -4,8 +4,8 @@ use std::hash::Hash;
use std::iter::{Product, Sum};
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use num_bigint::BigUint;
use num::{Integer, Zero};
use num_bigint::BigUint;
use rand::Rng;
use serde::de::DeserializeOwned;
use serde::Serialize;

View File

@ -145,6 +145,7 @@ macro_rules! test_arithmetic {
($field:ty) => {
mod arithmetic {
use std::ops::{Add, Mul, Neg, Sub};
use num_bigint::BigUint;
use crate::field::field::Field;
@ -216,7 +217,14 @@ macro_rules! test_arithmetic {
assert_eq!(zero.try_inverse(), None);
for &x in &[BigUint::from(1u32), BigUint::from(2u32), BigUint::from(3u32), order - 3u32, order - 2u32, order - 1u32] {
for &x in &[
BigUint::from(1u32),
BigUint::from(2u32),
BigUint::from(3u32),
order - 3u32,
order - 2u32,
order - 1u32,
] {
let x = <$field>::from_canonical_biguint(x);
let inv = x.inverse();
assert_eq!(x * inv, one);
@ -248,7 +256,13 @@ macro_rules! test_arithmetic {
let zero = <$field>::ZERO;
let order = <$field>::order();
for &i in &[BigUint::from(0u32), BigUint::from(1u32), BigUint::from(2u32), order - 2u32, order - 1u32] {
for &i in &[
BigUint::from(0u32),
BigUint::from(1u32),
BigUint::from(2u32),
order - 2u32,
order - 1u32,
] {
let i_f = <$field>::from_canonical_biguint(i);
assert_eq!(i_f + -i_f, zero);
}
@ -292,7 +306,10 @@ macro_rules! test_arithmetic {
fn subtraction() {
type F = $field;
let (a, b) = (F::from_canonical_biguint((F::order() + 1u32) / 2u32), F::TWO);
let (a, b) = (
F::from_canonical_biguint((F::order() + 1u32) / 2u32),
F::TWO,
);
let x = a * b;
assert_eq!(x, F::ONE);
assert_eq!(F::ZERO - x, F::NEG_ONE);

View File

@ -59,7 +59,10 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
inputs.push(proof.pow_witness);
let hash = self.hash_n_to_m(inputs, 1, false)[0];
self.assert_leading_zeros(hash, config.proof_of_work_bits + (64 - F::order().bits()) as u32);
self.assert_leading_zeros(
hash,
config.proof_of_work_bits + (64 - F::order().bits()) as u32,
);
}
pub fn verify_fri_proof(