Trait holochain_types::prelude::dependencies::subtle::ConstantTimeEq
source · [−]Expand description
An Eq
-like trait that produces a Choice
instead of a bool
.
Example
use subtle::ConstantTimeEq;
let x: u8 = 5;
let y: u8 = 13;
assert_eq!(x.ct_eq(&y).unwrap_u8(), 0);
assert_eq!(x.ct_eq(&x).unwrap_u8(), 1);
Required methods
Implementations on Foreign Types
sourceimpl<T> ConstantTimeEq for [T] where
T: ConstantTimeEq,
impl<T> ConstantTimeEq for [T] where
T: ConstantTimeEq,
sourcepub fn ct_eq(&self, _rhs: &[T]) -> Choice
pub fn ct_eq(&self, _rhs: &[T]) -> Choice
Check whether two slices of ConstantTimeEq
types are equal.
Note
This function short-circuits if the lengths of the input slices are different. Otherwise, it should execute in time independent of the slice contents.
Since arrays coerce to slices, this function works with fixed-size arrays:
let a: [u8; 8] = [0,1,2,3,4,5,6,7];
let b: [u8; 8] = [0,1,2,3,0,1,2,3];
let a_eq_a = a.ct_eq(&a);
let a_eq_b = a.ct_eq(&b);
assert_eq!(a_eq_a.unwrap_u8(), 1);
assert_eq!(a_eq_b.unwrap_u8(), 0);
sourceimpl<U> ConstantTimeEq for Output<U> where
U: UniversalHash,
impl<U> ConstantTimeEq for Output<U> where
U: UniversalHash,
sourceimpl ConstantTimeEq for CompressedRistretto
impl ConstantTimeEq for CompressedRistretto
pub fn ct_eq(&self, other: &CompressedRistretto) -> Choice
sourceimpl ConstantTimeEq for EdwardsPoint
impl ConstantTimeEq for EdwardsPoint
pub fn ct_eq(&self, other: &EdwardsPoint) -> Choice
sourceimpl ConstantTimeEq for CompressedEdwardsY
impl ConstantTimeEq for CompressedEdwardsY
pub fn ct_eq(&self, other: &CompressedEdwardsY) -> Choice
sourceimpl ConstantTimeEq for RistrettoPoint
impl ConstantTimeEq for RistrettoPoint
sourcepub fn ct_eq(&self, other: &RistrettoPoint) -> Choice
pub fn ct_eq(&self, other: &RistrettoPoint) -> Choice
Test equality between two RistrettoPoint
s.
Returns
Choice(1)
if the twoRistrettoPoint
s are equal;Choice(0)
otherwise.
sourceimpl ConstantTimeEq for MontgomeryPoint
impl ConstantTimeEq for MontgomeryPoint
Equality of MontgomeryPoint
s is defined mod p.