Skip to content

Commit

Permalink
elliptic-curve: bump crypto-bigint to v0.2.1 (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri authored Jun 22, 2021
1 parent 81d1341 commit c8369ab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions elliptic-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ categories = ["cryptography", "no-std"]
keywords = ["crypto", "ecc", "elliptic", "weierstrass"]

[dependencies]
crypto-bigint = { version = "0.2", features = ["generic-array"] }
crypto-bigint = { version = "0.2.1", features = ["generic-array"] }
generic-array = { version = "0.14", default-features = false }
rand_core = { version = "0.6", default-features = false }
subtle = { version = "2.4", default-features = false }
Expand All @@ -35,8 +35,8 @@ hex-literal = "0.3"

[features]
default = ["arithmetic"]
alloc = []
arithmetic = ["ff", "group"]
alloc = [] # todo: activate `group/alloc` when weak feature activation is available
arithmetic = ["crypto-bigint/zeroize", "ff", "group", "zeroize"]
bits = ["arithmetic", "ff/bits"]
dev = ["arithmetic", "hex-literal", "pem", "zeroize"]
ecdh = ["arithmetic", "zeroize"]
Expand Down
25 changes: 20 additions & 5 deletions elliptic-curve/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ff::{Field, PrimeField};
use hex_literal::hex;

#[cfg(feature = "bits")]
use crate::{bigint, group::ff::PrimeFieldBits, ScalarBits};
use crate::{group::ff::PrimeFieldBits, ScalarBits};

#[cfg(feature = "jwk")]
use crate::JwkParameters;
Expand Down Expand Up @@ -157,14 +157,29 @@ impl PrimeField for Scalar {

#[cfg(feature = "bits")]
impl PrimeFieldBits for Scalar {
type ReprBits = [bigint::Limb; 32 / bigint::LIMB_BYTES];
#[cfg(target_pointer_width = "32")]
type ReprBits = [u32; 8];
#[cfg(target_pointer_width = "64")]
type ReprBits = [u64; 4];

fn to_le_bits(&self) -> ScalarBits<MockCurve> {
(*self.0.limbs()).into()
let mut limbs = Self::ReprBits::default();

for (i, limb) in self.0.limbs().iter().cloned().enumerate() {
limbs[i] = limb.into();
}

limbs.into()
}

fn char_le_bits() -> ScalarBits<MockCurve> {
(*MockCurve::ORDER.limbs()).into()
let mut limbs = Self::ReprBits::default();

for (i, limb) in MockCurve::ORDER.limbs().iter().cloned().enumerate() {
limbs[i] = limb.into();
}

limbs.into()
}
}

Expand Down Expand Up @@ -304,7 +319,7 @@ impl From<&Scalar> for FieldBytes {

impl Zeroize for Scalar {
fn zeroize(&mut self) {
self.0.as_mut().zeroize()
self.0.as_mut().zeroize();
}
}

Expand Down

0 comments on commit c8369ab

Please sign in to comment.