Skip to content

Commit

Permalink
remove ark-poly for most crates
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenfeizhang committed Aug 23, 2022
1 parent 8281e7c commit af6fc8b
Show file tree
Hide file tree
Showing 32 changed files with 754 additions and 254 deletions.
7 changes: 5 additions & 2 deletions arithmetic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
name = "arithmetic"
version = "0.1.0"
edition = "2021"
authors = [
"Zhenfei Zhang<zhenfei.zhang@hotmail.com>",
"Binyi Chen"
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -10,7 +14,7 @@ edition = "2021"
ark-ff = { version = "^0.3.0", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
ark-poly = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = [ "derive" ] }
ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] }

rand_chacha = { version = "0.3.0", default-features = false }
Expand All @@ -27,7 +31,6 @@ parallel = [
"rayon",
"ark-std/parallel",
"ark-ff/parallel",
"ark-poly/parallel"
]
print-trace = [
"ark-std/print-trace"
Expand Down
68 changes: 65 additions & 3 deletions arithmetic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
mod errors;
mod multilinear_polynomial;
mod util;
mod virtual_polynomial;

pub use errors::ArithErrors;
pub use multilinear_polynomial::{random_zero_mle_list, DenseMultilinearExtension};
pub use virtual_polynomial::{build_eq_x_r, VPAuxInfo, VirtualPolynomial};
pub mod prelude;

use ark_ff::{Field, Zero};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::{
fmt::Debug,
hash::Hash,
ops::{Add, AddAssign, Index, Neg, SubAssign},
rand::Rng,
vec::Vec,
};

/// This trait describes an interface for the multilinear extension
/// of an array.
/// The latter is a multilinear polynomial represented in terms of its
/// evaluations over the domain {0,1}^`num_vars` (i.e. the Boolean hypercube).
///
/// Index represents a point, which is a vector in {0,1}^`num_vars` in little
/// endian form. For example, `0b1011` represents `P(1,1,0,1)`
pub trait MultilinearExtension<F: Field>:
Sized
+ Clone
+ Debug
+ Hash
+ PartialEq
+ Eq
+ Add
+ Neg
+ Zero
+ CanonicalSerialize
+ CanonicalDeserialize
+ for<'a> AddAssign<&'a Self>
+ for<'a> AddAssign<(F, &'a Self)>
+ for<'a> SubAssign<&'a Self>
+ Index<usize>
{
/// Returns the number of variables in `self`
fn num_vars(&self) -> usize;

/// Evaluates `self` at the given the vector `point` in slice.
/// If the number of variables does not match, return `None`.
fn evaluate(&self, point: &[F]) -> Option<F>;

/// Outputs an `l`-variate multilinear extension where value of evaluations
/// are sampled uniformly at random.
fn rand<R: Rng>(num_vars: usize, rng: &mut R) -> Self;

/// Relabel the point by swapping `k` scalars from positions `a..a+k` to
/// positions `b..b+k`, and from position `b..b+k` to position `a..a+k`
/// in vector.
///
/// This function turns `P(x_1,...,x_a,...,x_{a+k - 1},...,x_b,...,x_{b+k -
/// 1},...,x_n)` to `P(x_1,...,x_b,...,x_{b+k - 1},...,x_a,...,x_{a+k -
/// 1},...,x_n)`
fn relabel(&self, a: usize, b: usize, k: usize) -> Self;

/// Reduce the number of variables of `self` by fixing the
/// `partial_point.len()` variables at `partial_point`.
fn fix_variables(&self, partial_point: &[F]) -> Self;

/// Returns a list of evaluations over the domain, which is the boolean
/// hypercube.
fn to_evaluations(&self) -> Vec<F>;
}
Loading

0 comments on commit af6fc8b

Please sign in to comment.