Skip to content

Commit

Permalink
Same formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgoergens committed Nov 26, 2024
1 parent e7fa4a9 commit 8969dde
Show file tree
Hide file tree
Showing 106 changed files with 866 additions and 912 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
for cargo_toml in $(git ls-files '**/Cargo.toml'); do
(
cd "$(dirname ${cargo_toml})"
cargo fmt --check
cargo +nightly fmt --check
cargo check --all-targets
)
done
Expand Down
2 changes: 1 addition & 1 deletion circ_blocks/circ_fields/src/ext_field.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ff::{
derive::subtle::{Choice, ConditionallySelectable, ConstantTimeEq},
Field,
derive::subtle::{Choice, ConditionallySelectable, ConstantTimeEq},
};
use rand::RngCore;
use serde::{Deserialize, Serialize};
Expand Down
8 changes: 2 additions & 6 deletions circ_blocks/circ_fields/src/ff_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ macro_rules! def_field {
fn from(mut i: i64) -> Self {
let u = i.abs_diff(0);
let neg = i < 0;
if neg {
-Ft::from(u)
} else {
Ft::from(u)
}
if neg { -Ft::from(u) } else { Ft::from(u) }
}
}

Expand All @@ -100,7 +96,7 @@ macro_rules! def_field {

#[cfg(test)]
mod test {
use super::{Ft, FMOD};
use super::{FMOD, Ft};
use ff::Field;
use rand::thread_rng;
use rug::Integer;
Expand Down
10 changes: 6 additions & 4 deletions circ_blocks/circ_fields/src/int_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
use datasize::DataSize;
use paste::paste;
use rug::{
ops::{RemRounding, RemRoundingAssign},
Integer,
ops::{RemRounding, RemRoundingAssign},
};
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
use std::sync::Arc;
use std::{
fmt::{self, Display, Formatter},
ops::Deref,
sync::Arc,
};

#[derive(PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash, Serialize, Deserialize, DataSize)]
pub struct IntField {
Expand Down
14 changes: 8 additions & 6 deletions circ_blocks/circ_fields/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub mod moduli {
}

use ext_field::FGoldilocksExt2;
use ff_field::{FBls12381, FBn254, FCurve25519, FGoldilocks};
use ff_field::{F_BLS12381_FMOD, F_BN254_FMOD, F_CURVE25519_FMOD, F_GOLDILOCKS_FMOD};
use ff_field::{
F_BLS12381_FMOD_ARC, F_BN254_FMOD_ARC, F_CURVE25519_FMOD_ARC, F_GOLDILOCKS_FMOD_ARC,
F_BLS12381_FMOD, F_BLS12381_FMOD_ARC, F_BN254_FMOD, F_BN254_FMOD_ARC, F_CURVE25519_FMOD,
F_CURVE25519_FMOD_ARC, F_GOLDILOCKS_FMOD, F_GOLDILOCKS_FMOD_ARC, FBls12381, FBn254,
FCurve25519, FGoldilocks,
};
use int_field::IntField;

Expand All @@ -26,9 +26,11 @@ use ff::Field;
use paste::paste;
use rug::Integer;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Debug, Display, Formatter};
use std::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use std::sync::Arc;
use std::{
fmt::{self, Debug, Display, Formatter},
ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign},
sync::Arc,
};

// TODO: rework this using macros?

Expand Down
3 changes: 1 addition & 2 deletions circ_blocks/circ_fields/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::*;
use rand::thread_rng;
use rand::Rng;
use rand::{Rng, thread_rng};
use rug::ops::RemRounding;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion circ_blocks/circ_hc/examples/u32.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use circ_hc::{generate_hashcons_rc, Node as NodeTrait, Table as TableTrait};
use circ_hc::{Node as NodeTrait, Table as TableTrait, generate_hashcons_rc};

generate_hashcons_rc!(u32);

Expand Down
3 changes: 1 addition & 2 deletions circ_blocks/circ_hc/src/hashconsing/example_u8.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Warning: this file is generated from src/template.rs and generate_u8.zsh
use hashconsing::*;
use hashconsing::{HConsed, HashConsign};
use hashconsing::{HConsed, HashConsign, *};

use crate::Id;

Expand Down
3 changes: 1 addition & 2 deletions circ_blocks/circ_hc/src/hashconsing/macro_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#[macro_export]
macro_rules! generate_hashcons_hashconsing {
($Op:ty) => {
use hashconsing::*;
use hashconsing::{HConsed, HashConsign};
use hashconsing::{HConsed, HashConsign, *};

use $crate::Id;

Expand Down
3 changes: 1 addition & 2 deletions circ_blocks/circ_hc/src/hashconsing/template.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use hashconsing::*;
use hashconsing::{HConsed, HashConsign};
use hashconsing::{HConsed, HashConsign, *};

use std::net::SocketAddrV6 as TemplateOp;

Expand Down
6 changes: 4 additions & 2 deletions circ_blocks/circ_hc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::cmp::{Eq, Ord, PartialEq, PartialOrd};
use std::hash::Hash;
use std::{
cmp::{Eq, Ord, PartialEq, PartialOrd},
hash::Hash,
};

#[cfg(feature = "hashconsing")]
pub mod hashconsing;
Expand Down
8 changes: 5 additions & 3 deletions circ_blocks/circ_hc/src/raw/example_u8.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Warning: this file is generated from src/template.rs and generate_u8.zsh
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};

use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::thread_local;
use std::{
cell::{Cell, RefCell},
rc::Rc,
thread_local,
};

use crate::Id;

Expand Down
8 changes: 5 additions & 3 deletions circ_blocks/circ_hc/src/raw/macro_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ macro_rules! generate_hashcons_raw {
($Op:ty) => {
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};

use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::thread_local;
use std::{
cell::{Cell, RefCell},
rc::Rc,
thread_local,
};

use $crate::Id;

Expand Down
10 changes: 6 additions & 4 deletions circ_blocks/circ_hc/src/raw/template.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};

use std::cell::{Cell, RefCell};
use std::net::SocketAddrV6 as TemplateOp;
use std::rc::Rc;
use std::thread_local;
use std::{
cell::{Cell, RefCell},
net::SocketAddrV6 as TemplateOp,
rc::Rc,
thread_local,
};

use crate::Id;

Expand Down
16 changes: 10 additions & 6 deletions circ_blocks/circ_hc/src/rc/example_u8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ use fxhash::FxHashMap as HashMap;

use crate::Id;
use log::trace;
use std::borrow::Borrow;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::thread_local;
use std::{
borrow::Borrow,
cell::{Cell, RefCell},
rc::Rc,
thread_local,
};

#[allow(dead_code)]
struct NodeData {
Expand Down Expand Up @@ -297,8 +299,10 @@ impl crate::Weak<u8> for Weak {

mod hash {
use super::{Node, NodeData, NodeDataRef, Weak};
use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::{
borrow::Borrow,
hash::{Hash, Hasher},
};

impl Hash for Node {
fn hash<H: Hasher>(&self, state: &mut H) {
Expand Down
16 changes: 10 additions & 6 deletions circ_blocks/circ_hc/src/rc/macro_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ macro_rules! generate_hashcons_rc {
use fxhash::FxHashMap as HashMap;

use log::trace;
use std::borrow::Borrow;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::thread_local;
use std::{
borrow::Borrow,
cell::{Cell, RefCell},
rc::Rc,
thread_local,
};
use $crate::Id;

#[allow(dead_code)]
Expand Down Expand Up @@ -300,8 +302,10 @@ macro_rules! generate_hashcons_rc {

mod hash {
use super::{Node, NodeData, NodeDataRef, Weak};
use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::{
borrow::Borrow,
hash::{Hash, Hasher},
};

impl Hash for Node {
fn hash<H: Hasher>(&self, state: &mut H) {
Expand Down
18 changes: 11 additions & 7 deletions circ_blocks/circ_hc/src/rc/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use fxhash::FxHashMap as HashMap;

use crate::Id;
use log::trace;
use std::borrow::Borrow;
use std::cell::{Cell, RefCell};
use std::net::SocketAddrV6 as TemplateOp;
use std::rc::Rc;
use std::thread_local;
use std::{
borrow::Borrow,
cell::{Cell, RefCell},
net::SocketAddrV6 as TemplateOp,
rc::Rc,
thread_local,
};

#[allow(dead_code)]
struct NodeData {
Expand Down Expand Up @@ -297,8 +299,10 @@ impl crate::Weak<TemplateOp> for Weak {

mod hash {
use super::{Node, NodeData, NodeDataRef, Weak};
use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use std::{
borrow::Borrow,
hash::{Hash, Hasher},
};

impl Hash for Node {
fn hash<H: Hasher>(&self, state: &mut H) {
Expand Down
2 changes: 1 addition & 1 deletion circ_blocks/circ_hc/src/test/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn test_rng() -> ChaChaRng {

use crate::{Node, Table};

use rand::{distributions::Distribution, Rng, SeedableRng};
use rand::{Rng, SeedableRng, distributions::Distribution};
use rand_distr::Geometric;
use std::time::{Duration, Instant};

Expand Down
4 changes: 1 addition & 3 deletions circ_blocks/circ_hc/src/test/gc_hook.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::{Id, Node, Table};
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use std::{cell::RefCell, collections::HashMap, rc::Rc};

/// One step in the test.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion circ_blocks/circ_hc/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ mod rc {
crate::rc::generate_hashcons!(u8);
}
use hc_u8::Table;
//use crate::rc::example_u8::Table;
// use crate::rc::example_u8::Table;

mod tiny {
#[test]
Expand Down
16 changes: 4 additions & 12 deletions circ_blocks/circ_waksman/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
//!
//! Reference: "On Arbitrary Waksman Networks and their Vulnerability", by Bruno Beauquier and Eric Darrot.
use fxhash::FxHashMap as HashMap;
use fxhash::FxHashSet as HashSet;
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};
use std::collections::VecDeque;

use std::fmt::Debug;
use std::hash::Hash;
use std::{fmt::Debug, hash::Hash};

#[derive(Debug, Clone)]
/// A network configuration
Expand Down Expand Up @@ -268,9 +266,7 @@ pub fn symbolic_apply<T: Clone, Cond, SwitchFn: FnMut(&T, &T, Cond) -> (T, T)>(
mod tests {
use super::*;
use itertools::Itertools;
use rand::seq::SliceRandom;
use rand::Rng;
use rand::SeedableRng;
use rand::{Rng, SeedableRng, seq::SliceRandom};

fn test_on_data(data: Vec<usize>) {
let cfg = Config::for_sorting(data.clone());
Expand Down Expand Up @@ -417,11 +413,7 @@ mod tests {
data,
&mut switches,
&mut |top: &usize, bot: &usize, cond: bool| {
if cond {
(*bot, *top)
} else {
(*top, *bot)
}
if cond { (*bot, *top) } else { (*top, *bot) }
},
);
assert_eq!(apply_normal, apply_sym);
Expand Down
13 changes: 5 additions & 8 deletions circ_blocks/examples/cp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use circ::cfg::{
clap::{self, Parser, ValueEnum},
CircOpt,
clap::{self, Parser, ValueEnum},
};
use std::path::PathBuf;

Expand Down Expand Up @@ -59,13 +59,10 @@ fn main() {
Mirage::cp_prove_fs(&opts.prover_key, &opts.inputs, &opts.proof, opts.rands).unwrap();
}
ProofAction::Verify => {
assert!(Mirage::cp_verify_fs(
&opts.verifier_key,
&opts.inputs,
&opts.proof,
opts.commits
)
.unwrap());
assert!(
Mirage::cp_verify_fs(&opts.verifier_key, &opts.inputs, &opts.proof, opts.commits)
.unwrap()
);
}
ProofAction::Commit => {
assert_eq!(
Expand Down
12 changes: 7 additions & 5 deletions circ_blocks/examples/opa_bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use circ::cfg::clap::{self, Parser};
use circ::ir::term::*;
use circ::target::aby::assignment::ilp;
use circ::term;
use circ::{
cfg::clap::{self, Parser},
ir::term::*,
target::aby::assignment::ilp,
term,
};

#[derive(Debug, Parser)]
#[command(
Expand Down Expand Up @@ -30,5 +32,5 @@ fn main() {
..Default::default()
};
let _assignment = ilp::assign(&cs, "hycc");
//dbg!(&assignment);
// dbg!(&assignment);
}
2 changes: 1 addition & 1 deletion circ_blocks/examples/zk.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use circ::cfg::{
clap::{self, Parser, ValueEnum},
CircOpt,
clap::{self, Parser, ValueEnum},
};
use std::path::PathBuf;

Expand Down
Loading

0 comments on commit 8969dde

Please sign in to comment.