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

Commit

Permalink
feat: Update Arkworks' dependencies on acir_field (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri authored Feb 10, 2023
1 parent 7704246 commit 65d6130
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions acir_field/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
Expand Down
14 changes: 7 additions & 7 deletions acir_field/src/generic_ark.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -163,7 +161,7 @@ impl<F: PrimeField> FieldElement<F> {
}

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
Expand All @@ -172,7 +170,7 @@ impl<F: PrimeField> FieldElement<F> {
/// 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
Expand All @@ -189,7 +187,7 @@ impl<F: PrimeField> FieldElement<F> {
}

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
Expand Down Expand Up @@ -249,7 +247,8 @@ impl<F: PrimeField> FieldElement<F> {
}

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)
}
Expand All @@ -263,7 +262,8 @@ impl<F: PrimeField> FieldElement<F> {
// 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
}
Expand Down

0 comments on commit 65d6130

Please sign in to comment.