Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions p256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ serde = ["ecdsa-core?/serde", "elliptic-curve/serde", "primeorder?/serde", "serd
sha256 = ["digest", "sha2"]
test-vectors = ["dep:hex-literal"]



[[bench]]
name = "ecdsa"
harness = false
Expand All @@ -76,6 +74,21 @@ harness = false
name = "scalar"
harness = false

# NOTE: these are the only lints we explicitly want to configure for p256
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(cpubits, values("16", "32", "64"))']

# NOTE: can't use `lints.workspace` because we override `lints.rust.unexpected_cfgs`
[lints.rust]
missing_copy_implementations = "warn"
missing_debug_implementations = "warn"
missing_docs = "warn"
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_lifetimes = "warn"
unused_qualifications = "warn"

# NOTE: can't use `lints.workspace` because we override `lints.rust.unexpected_cfgs`
[lints.clippy]
borrow_as_ptr = "warn"
Expand Down Expand Up @@ -107,20 +120,5 @@ unnecessary_safety_comment = "warn"
unwrap_in_result = "warn"
unwrap_used = "warn"

# NOTE: can't use `lints.workspace` because we override `lints.rust.unexpected_cfgs`
[lints.rust]
missing_copy_implementations = "warn"
missing_debug_implementations = "warn"
missing_docs = "warn"
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_lifetimes = "warn"
unused_qualifications = "warn"

# NOTE: these are the only lints we explicitly want to configure for p256
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(cpubits, values("16", "32", "64"))']

[package.metadata.docs.rs]
all-features = true
56 changes: 49 additions & 7 deletions p384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ serde = ["ecdsa-core?/serde", "elliptic-curve/serde", "primeorder?/serde", "serd
sha384 = ["digest", "sha2"]
test-vectors = ["hex-literal"]

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(p384_backend, values("bigint", "fiat"))', # default: "fiat"
'cfg(cpubits, values("16", "32", "64"))'
]

[[bench]]
name = "field"
harness = false
Expand All @@ -79,5 +72,54 @@ harness = false
name = "scalar"
harness = false

# NOTE: these are the only lints we explicitly want to configure for p256
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(p384_backend, values("bigint", "fiat"))', # default: "bigint"
'cfg(cpubits, values("16", "32", "64"))'
]

# NOTE: can't use `lints.workspace` because we override `lints.rust.unexpected_cfgs`
[lints.rust]
missing_copy_implementations = "warn"
missing_debug_implementations = "warn"
missing_docs = "warn"
trivial_casts = "warn"
trivial_numeric_casts = "warn"
unused_lifetimes = "warn"
unused_qualifications = "warn"

# NOTE: can't use `lints.workspace` because we override `lints.rust.unexpected_cfgs`
[lints.clippy]
borrow_as_ptr = "warn"
cast_lossless = "warn"
cast_possible_truncation = "warn"
cast_possible_wrap = "warn"
cast_precision_loss = "warn"
cast_sign_loss = "warn"
checked_conversions = "warn"
from_iter_instead_of_collect = "warn"
implicit_saturating_sub = "warn"
manual_assert = "warn"
map_unwrap_or = "warn"
missing_errors_doc = "warn"
missing_panics_doc = "warn"
mod_module_files = "warn"
must_use_candidate = "warn"
needless_range_loop = "allow"
ptr_as_ptr = "warn"
redundant_closure_for_method_calls = "warn"
ref_as_ptr = "warn"
return_self_not_must_use = "warn"
semicolon_if_nothing_returned = "warn"
trivially_copy_pass_by_ref = "warn"
std_instead_of_alloc = "warn"
std_instead_of_core = "warn"
undocumented_unsafe_blocks = "warn"
unnecessary_safety_comment = "warn"
unwrap_in_result = "warn"
unwrap_used = "warn"

[package.metadata.docs.rs]
all-features = true
4 changes: 3 additions & 1 deletion p384/benches/field.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! secp384r1 field element benchmarks

#![allow(missing_docs, reason = "benchmark")]

use core::hint::black_box;
use criterion::{
BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement,
Expand Down Expand Up @@ -27,7 +29,7 @@ fn test_field_element_y() -> FieldElement {
fn bench_field_element_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) {
let x = test_field_element_x();
let y = test_field_element_y();
group.bench_function("mul", |b| b.iter(|| &x * &y));
group.bench_function("mul", |b| b.iter(|| x * y));
}

fn bench_field_element_square<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) {
Expand Down
8 changes: 5 additions & 3 deletions p384/benches/scalar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! secp384r1 scalar arithmetic benchmarks

#![allow(missing_docs, reason = "benchmark")]

use core::hint::black_box;
use criterion::{
BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement,
};
Expand All @@ -11,7 +14,6 @@ use p384::{
ops::MulByGeneratorVartime,
},
};
use std::hint::black_box;

fn test_scalar_x() -> Scalar {
Scalar::from_repr(
Expand All @@ -36,10 +38,10 @@ fn bench_point_mul_by_generator<M: Measurement>(group: &mut BenchmarkGroup<'_, M
let m = test_scalar_x();
let s = Scalar::from_repr(m.into()).unwrap();
group.bench_function("generator-scalar mul", |b| {
b.iter(|| ProjectivePoint::mul_by_generator(&black_box(s)))
b.iter(|| ProjectivePoint::mul_by_generator(&black_box(s)));
});
group.bench_function("generator-scalar mul (variable-time)", |b| {
b.iter(|| ProjectivePoint::mul_by_generator_vartime(&black_box(s)))
b.iter(|| ProjectivePoint::mul_by_generator_vartime(&black_box(s)));
});
}

Expand Down
9 changes: 7 additions & 2 deletions p384/src/arithmetic/hash2curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ mod tests {
.unwrap()
/ NonZero::new(U384::from_u8(4)).unwrap();
assert_eq!(
Array::from_iter(params.c1.iter().rev().flat_map(|v| v.to_be_bytes())),
c1.to_be_byte_array()
c1.to_be_byte_array(),
params
.c1
.iter()
.rev()
.flat_map(|v| v.to_be_bytes())
.collect::<Array<_, _>>()
);

let c2 = FieldElement::from_u64(12).sqrt().unwrap();
Expand Down
1 change: 1 addition & 0 deletions p384/src/arithmetic/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub(crate) mod backend {
use primeorder::MulBackend;

/// Backend based on precomputed tables.
#[derive(Clone, Copy, Debug)]
pub struct PrecomputedTables;

impl MulBackend<NistP384> for PrecomputedTables {
Expand Down
2 changes: 1 addition & 1 deletion p384/tests/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ fn identity_encoding() {
AffinePoint::from_bytes(&AffinePoint::IDENTITY.to_bytes())
.unwrap()
.is_identity()
))
));
}
Loading