Skip to content

Commit

Permalink
elliptic-curve: test EncodedPoint::conditional_select (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri authored Dec 17, 2020
1 parent aac590b commit 515b006
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions elliptic-curve/src/sec1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ mod tests {
use crate::{weierstrass, Curve};
use generic_array::{typenum::U32, GenericArray};
use hex_literal::hex;
use subtle::ConditionallySelectable;

#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
struct ExampleCurve;
Expand Down Expand Up @@ -669,6 +670,18 @@ mod tests {
assert_eq!(compressed_point.as_bytes(), &COMPRESSED_BYTES[..]);
}

#[test]
fn conditional_select() {
let a = EncodedPoint::from_bytes(&COMPRESSED_BYTES[..]).unwrap();
let b = EncodedPoint::from_bytes(&UNCOMPRESSED_BYTES[..]).unwrap();

let a_selected = EncodedPoint::conditional_select(&a, &b, 0.into());
assert_eq!(a, a_selected);

let b_selected = EncodedPoint::conditional_select(&a, &b, 1.into());
assert_eq!(b, b_selected);
}

#[test]
fn identity() {
let identity_point = EncodedPoint::identity();
Expand Down

0 comments on commit 515b006

Please sign in to comment.