MCPcopy Create free account
hub / github.com/RustCrypto/utils / CtSelectArray

Interface CtSelectArray

ctutils/src/traits/ct_select.rs:46–52  ·  view source on GitHub ↗

Implementing this trait enables use of the [`CtSelect`] trait to construct `[T; N]` where `T` is the `Self` type implementing the trait, via a blanket impl. All types which impl [`Clone`] + [`CtAssignSlice`] + [`CtSelect`] will receive a blanket impl of this trait and thus also be usable with the [`CtSelect`] impl for `[T; N]`.

Source from the content-addressed store, hash-verified

44/// All types which impl [`Clone`] + [`CtAssignSlice`] + [`CtSelect`] will receive a blanket impl
45/// of this trait and thus also be usable with the [`CtSelect`] impl for `[T; N]`.
46pub trait CtSelectArray<const N: usize>: CtSelect + Sized {
47 /// Select between `a` and `b` in constant-time based on `choice`.
48 #[must_use]
49 fn ct_select_array(a: &[Self; N], b: &[Self; N], choice: Choice) -> [Self; N] {
50 core::array::from_fn(|i| Self::ct_select(&a[i], &b[i], choice))
51 }
52}
53
54impl<T, const N: usize> CtSelect for [T; N]
55where

Callers

nothing calls this directly

Implementers 1

ct_select.rsctutils/src/traits/ct_select.rs

Calls

no outgoing calls

Tested by

no test coverage detected