Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/role assignment #62

Merged
merged 13 commits into from
Oct 3, 2024
Merged
115 changes: 113 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mpc-algebra = { path = "mpc-algebra", version = "0.1.0" }
mpc-net = { path = "mpc-net", version = "0.1.0" }
mpc-trait = { path = "mpc-trait", version = "0.1.0" }
itertools = "0.13.0"
nalgebra = "0.33.0"

[dev-dependencies]
criterion = { version = "0.4", features = ["html_reports"] }
Expand Down
2 changes: 1 addition & 1 deletion arkworks/nonnative/src/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{overhead, AllocatedNonNativeFieldVar};
use ark_ff::{biginteger::BigInteger, fields::FpParameters, BitIteratorBE, One, PrimeField, Zero};
use ark_r1cs_std::eq::EqGadget;
use ark_r1cs_std::fields::fp::FpVar;
use ark_r1cs_std::fields::FieldVar;
// use hark_r1cs_std::fields::FieldVar;
use ark_r1cs_std::{alloc::AllocVar, boolean::Boolean, R1CSVar};
use ark_relations::{
ns,
Expand Down
23 changes: 21 additions & 2 deletions arkworks/r1cs-std/src/fields/fp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod cmp;

/// Represents a variable in the constraint system whose
/// value can be an arbitrary field element.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
#[must_use]
pub struct AllocatedFp<F: PrimeField> {
pub(crate) value: Option<F>,
Expand All @@ -38,7 +38,7 @@ impl<F: PrimeField> AllocatedFp<F> {
}

/// Represent variables corresponding to a field element in `F`.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
#[must_use]
pub enum FpVar<F: PrimeField> {
/// Represents a constant in the constraint system, which means that
Expand Down Expand Up @@ -644,6 +644,25 @@ impl<F: PrimeField> AllocVar<F, F> for AllocatedFp<F> {
}
}

impl<F: PrimeField> ark_std::Zero for FpVar<F> {
fn zero() -> Self {
Self::Constant(F::zero())
}

fn is_zero(&self) -> bool {
match self {
Self::Constant(c) => c.is_zero(),
Self::Var(v) => v.value.expect("value is None").is_zero(),
}
}
}

impl<F: PrimeField> ark_std::One for FpVar<F> {
fn one() -> Self {
Self::Constant(F::one())
}
}

impl<F: PrimeField> FieldVar<F, F> for FpVar<F> {
fn constant(f: F) -> Self {
Self::Constant(f)
Expand Down
Loading
Loading