From 65d61307a12f25e04afad2d50e4c4db5ce97dd8c Mon Sep 17 00:00:00 2001 From: Ivan Litteri <67517699+ilitteri@users.noreply.github.com> Date: Fri, 10 Feb 2023 15:18:59 +0200 Subject: [PATCH] feat: Update Arkworks' dependencies on `acir_field` (#69) --- acir_field/Cargo.toml | 10 ++++------ acir_field/src/generic_ark.rs | 14 +++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/acir_field/Cargo.toml b/acir_field/Cargo.toml index 3a8522578..f789ec6e8 100644 --- a/acir_field/Cargo.toml +++ b/acir_field/Cargo.toml @@ -10,13 +10,14 @@ description = "The field implementation being used by ACIR." [dependencies] hex = "0.4.2" -ark-bn254 = { version = "^0.3.0", optional = true, default-features = false, features = [ +ark-bn254 = { version = "^0.4.0", optional = true, default-features = false, features = [ "curve", ] } -ark-bls12-381 = { version = "^0.3.0", optional = true, default-features = false, features = [ +ark-bls12-381 = { version = "^0.4.0", optional = true, default-features = false, features = [ "curve", ] } -ark-ff = { version = "^0.3.0", optional = true, default-features = false } +ark-ff = { version = "^0.4.0", optional = true, default-features = false } +ark-serialize = { version = "^0.4.0", default-features = false } blake2 = "0.9.1" cfg-if = "1.0.0" @@ -25,9 +26,6 @@ serde = { version = "1.0.136", features = ["derive"] } num-bigint = "0.4" num-traits = "0.2.8" -[dev-dependencies] -ark-bn254 = { version = "^0.3.0", features = ["curve"] } - [features] default = ["bn254"] bn254 = ["ark-bn254", "ark-ff"] diff --git a/acir_field/src/generic_ark.rs b/acir_field/src/generic_ark.rs index a82c93020..2e78e6c30 100644 --- a/acir_field/src/generic_ark.rs +++ b/acir_field/src/generic_ark.rs @@ -1,5 +1,3 @@ -use ark_ff::to_bytes; -use ark_ff::FpParameters; use ark_ff::PrimeField; use ark_ff::Zero; use num_bigint::BigUint; @@ -163,7 +161,7 @@ impl FieldElement { } pub fn pow(&self, exponent: &Self) -> Self { - FieldElement(self.0.pow(exponent.0.into_repr())) + FieldElement(self.0.pow(exponent.0.into_bigint())) } /// Maximum number of bits needed to represent a field element @@ -172,7 +170,7 @@ impl FieldElement { /// But the representation uses 256 bits, so the top two bits are always zero /// This method would return 254 pub const fn max_num_bits() -> u32 { - F::Params::MODULUS_BITS + F::MODULUS_BIT_SIZE } /// Maximum numbers of bytes needed to represent a field element @@ -189,7 +187,7 @@ impl FieldElement { } pub fn modulus() -> BigUint { - F::Params::MODULUS.into() + F::MODULUS.into() } /// Returns None, if the string is not a canonical /// representation of a field element; less than the order @@ -249,7 +247,8 @@ impl FieldElement { } pub fn to_hex(self) -> String { - let mut bytes = to_bytes!(self.0).unwrap(); + let mut bytes = Vec::new(); + self.0.serialize_uncompressed(&mut bytes).unwrap(); bytes.reverse(); hex::encode(bytes) } @@ -263,7 +262,8 @@ impl FieldElement { // to_be_bytes! uses little endian which is why we reverse the output // TODO: Add a little endian equivalent, so the caller can use whichever one // TODO they desire - let mut bytes = to_bytes!(self.0).unwrap(); + let mut bytes = Vec::new(); + self.0.serialize_uncompressed(&mut bytes).unwrap(); bytes.reverse(); bytes }