Update to subtle 2.0
This commit is contained in:
parent
a50b09caaa
commit
e3f219ae84
|
@ -14,9 +14,8 @@ version = "1"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.subtle]
|
[dependencies.subtle]
|
||||||
version = "0.7"
|
version = "2"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["generic-impls"]
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
||||||
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||||
|
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
use byteorder::{ByteOrder, LittleEndian};
|
||||||
use subtle::{Choice, ConditionallyAssignable, ConditionallySelectable, ConstantTimeEq};
|
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
|
||||||
|
|
||||||
/// Represents an element of `GF(q)`.
|
/// Represents an element of `GF(q)`.
|
||||||
// The internal representation of this type is four 64-bit unsigned
|
// The internal representation of this type is four 64-bit unsigned
|
||||||
|
|
23
src/lib.rs
23
src/lib.rs
|
@ -6,7 +6,7 @@ extern crate std;
|
||||||
|
|
||||||
use core::ops::{Add, AddAssign, Neg, Sub, SubAssign};
|
use core::ops::{Add, AddAssign, Neg, Sub, SubAssign};
|
||||||
|
|
||||||
use subtle::{Choice, ConditionallyAssignable, ConditionallySelectable, ConstantTimeEq};
|
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod util;
|
mod util;
|
||||||
|
@ -47,6 +47,15 @@ impl PartialEq for AffinePoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ConditionallySelectable for AffinePoint {
|
||||||
|
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
|
||||||
|
AffinePoint {
|
||||||
|
u: Fq::conditional_select(&a.u, &b.u, choice),
|
||||||
|
v: Fq::conditional_select(&a.v, &b.v, choice),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Represents the affine point `(u/z, v/z)` with
|
/// Represents the affine point `(u/z, v/z)` with
|
||||||
/// `z` nonzero and `t1 * t2 = uv/z`.
|
/// `z` nonzero and `t1 * t2 = uv/z`.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
@ -69,6 +78,18 @@ impl ConstantTimeEq for ExtendedPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ConditionallySelectable for ExtendedPoint {
|
||||||
|
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
|
||||||
|
ExtendedPoint {
|
||||||
|
u: Fq::conditional_select(&a.u, &b.u, choice),
|
||||||
|
v: Fq::conditional_select(&a.v, &b.v, choice),
|
||||||
|
z: Fq::conditional_select(&a.z, &b.z, choice),
|
||||||
|
t1: Fq::conditional_select(&a.t1, &b.t1, choice),
|
||||||
|
t2: Fq::conditional_select(&a.t2, &b.t2, choice),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for ExtendedPoint {
|
impl PartialEq for ExtendedPoint {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.ct_eq(other).unwrap_u8() == 1
|
self.ct_eq(other).unwrap_u8() == 1
|
||||||
|
|
Loading…
Reference in New Issue