use crate::edwards::EdwardsPoint;
use crate::field::FieldElement;
use subtle::Choice;
use subtle::ConstantTimeEq;
#[derive(Copy, Clone, Debug)]
pub struct MontgomeryPoint(pub [u8; 32]);
impl ConstantTimeEq for MontgomeryPoint {
fn ct_eq(&self, other: &MontgomeryPoint) -> Choice {
let self_fe = FieldElement::from_bytes(&self.0);
let other_fe = FieldElement::from_bytes(&other.0);
self_fe.ct_eq(&other_fe)
}
}
impl Default for MontgomeryPoint {
fn default() -> MontgomeryPoint {
MontgomeryPoint([0u8; 32])
}
}
impl PartialEq for MontgomeryPoint {
fn eq(&self, other: &MontgomeryPoint) -> bool {
self.ct_eq(other).unwrap_u8() == 1u8
}
}
impl Eq for MontgomeryPoint {}
impl MontgomeryPoint {
pub fn as_bytes<'a>(&'a self) -> &'a [u8; 32] {
&self.0
}
pub fn to_bytes(&self) -> [u8; 32] {
self.0
}
pub fn to_edwards(&self, _sign: u8) -> Option<EdwardsPoint> {
unimplemented!()
}
}