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
9 changes: 4 additions & 5 deletions polyval/src/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,22 @@ cfg_if! {
// aarch64
mod autodetect;
mod armv8;
pub(crate) use autodetect::{InitToken, has_intrinsics};
pub(crate) use autodetect::{InitToken, init_intrinsics};
} else if #[cfg(all(
any(target_arch = "x86_64", target_arch = "x86"),
not(polyval_backend = "soft")
))] {
// x86/x86-64
mod autodetect;
mod x86;
pub(crate) use autodetect::{InitToken, has_intrinsics};
pub(crate) use autodetect::{InitToken, init_intrinsics};
} else {
// "soft" fallback implementation for other targets written in pure Rust
use universal_hash::array::{Array, ArraySize};

// Stub intrinsics "detection"
pub(crate) type InitToken = ();
pub(crate) fn has_intrinsics() -> (InitToken, bool) {
((), false)
}
pub(crate) fn init_intrinsics() {}

impl FieldElement {
/// Default degree of parallelism, i.e. how many powers of `H` to compute.
Expand Down
2 changes: 1 addition & 1 deletion polyval/src/field_element/autodetect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cpufeatures::new!(detect_intrinsics, "aes"); // `aes` implies PMULL
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
cpufeatures::new!(detect_intrinsics, "pclmulqdq");

pub(crate) use detect_intrinsics::{InitToken, init_get as has_intrinsics};
pub(crate) use detect_intrinsics::{InitToken, init as init_intrinsics};

impl FieldElement {
/// Default degree of parallelism, i.e. how many powers of `H` to compute.
Expand Down
4 changes: 2 additions & 2 deletions polyval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use crate::mulx::mulx;
pub use universal_hash;

use core::fmt::{self, Debug};
use field_element::{FieldElement, InitToken, has_intrinsics};
use field_element::{FieldElement, InitToken, init_intrinsics};
use universal_hash::{
KeyInit, ParBlocks, Reset, UhfBackend, UhfClosure, UniversalHash,
array::{Array, ArraySize},
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<const N: usize> PolyvalGeneric<N> {
/// Initialize POLYVAL with the given `H` field element and initial block.
#[must_use]
pub fn new_with_init_block(h: &Key, init_block: u128) -> Self {
let has_intrinsics = has_intrinsics().0;
let has_intrinsics = init_intrinsics();
Self {
powers_of_h: FieldElement::from(h).powers_of_h(has_intrinsics),
y: init_block.into(),
Expand Down