Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
migrate to new pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
shamatar committed Apr 7, 2020
1 parent 16d1747 commit d62dc2d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ bit-vec = "0.6"
cfg-if = "0.1"

# pairing = {package = "pairing_ce", path = "../pairing" }
# pairing = {package = "pairing_ce", version = "0.19" }
pairing = {package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git", branch = "affine-ops"}
pairing = {package = "pairing_ce", version = "0.20" }
byteorder = "1"

futures= {package = "futures", version = "0.3", default_features = false, features = ["executor"]}
Expand Down Expand Up @@ -53,5 +52,4 @@ nolog = []
plonk = ["blake2s_simd", "lazy_static", "tiny-keccak", "blake2s_const"]
marlin = ["blake2s_simd", "tiny-keccak", "blake2s_const"]
wasm = ["web-sys"]
nightly = ["prefetch"]
derive_serde = ["pairing/derive_serde"]
nightly = ["prefetch"]
2 changes: 1 addition & 1 deletion src/cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl fmt::Display for SynthesisError {
write!(f, "I/O error: ")?;
e.fmt(f)
} else {
write!(f, "{}", self.description())
write!(f, "{}", self.to_string())
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/plonk/transparent_engine/impl_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,21 @@ macro_rules! transparent_engine_impl {
*self
}

fn as_xy(&self) -> (&Self::Base, &Self::Base) {
(&self, &self)
}

fn into_xy_unchecked(&self) -> (Self::Base, Self::Base) {
(<$fr as crate::ff::Field>::zero(), <$fr as crate::ff::Field>::zero())
}

fn from_xy_unchecked(_x: Self::Base, _y: Self::Base) -> Self {
<$fr as crate::ff::Field>::zero()
}

fn from_xy_checked(_x: Self::Base, _y: Self::Base) -> Result<Self, crate::pairing::GroupDecodingError> {
Ok(<$fr as crate::ff::Field>::zero())
}
}

impl crate::pairing::RawEncodable for $fr {
Expand Down
6 changes: 3 additions & 3 deletions src/plonk/transparent_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod test {

#[test]
fn test_proth_field() {
use crate::ff::{Field, PrimeField};
use crate::ff::{Field, PrimeField, to_hex};
use super::Fr as FrMontNaive;
use super::proth::Fr as FrOptimized;

Expand All @@ -122,9 +122,9 @@ mod test {
let mut tmp1 = one_optimized;
tmp1.mul_assign(&one_optimized);

assert_eq!(tmp0.to_hex(), tmp1.to_hex());
assert_eq!(to_hex(&tmp0), to_hex(&tmp1));

assert_eq!(FrMontNaive::multiplicative_generator().to_hex(), FrOptimized::multiplicative_generator().to_hex());
assert_eq!(to_hex(&FrMontNaive::multiplicative_generator()), to_hex(&FrOptimized::multiplicative_generator()));
}

#[test]
Expand Down
8 changes: 8 additions & 0 deletions src/tests/dummy_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,19 @@ impl CurveAffine for Fr {
*self
}

fn as_xy(&self) -> (&Self::Base, &Self::Base) {
(&self, &self)
}

fn into_xy_unchecked(&self) -> (Self::Base, Self::Base) {
(<Fr as Field>::zero(), <Fr as Field>::zero())
}

fn from_xy_unchecked(_x: Self::Base, _y: Self::Base) -> Self {
<Fr as Field>::zero()
}

fn from_xy_checked(_x: Self::Base, _y: Self::Base) -> Result<Self, GroupDecodingError> {
Ok(<Fr as Field>::zero())
}
}

0 comments on commit d62dc2d

Please sign in to comment.