1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#![allow(non_snake_case)]
use crate::curve::twedwards::extended::ExtendedPoint;
use std::fmt;
use subtle::{Choice, ConstantTimeEq};
pub struct RistrettoPoint(ExtendedPoint);
#[derive(Copy, Clone)]
pub struct CompressedRistretto([u8; 56]);
impl fmt::Debug for CompressedRistretto {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.0[..].fmt(formatter)
}
}
impl ConstantTimeEq for CompressedRistretto {
fn ct_eq(&self, other: &CompressedRistretto) -> Choice {
self.as_bytes().ct_eq(other.as_bytes())
}
}
impl PartialEq for CompressedRistretto {
fn eq(&self, other: &CompressedRistretto) -> bool {
self.ct_eq(other).into()
}
}
impl Eq for CompressedRistretto {}
impl CompressedRistretto {
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
}
impl RistrettoPoint {
pub fn identity() -> RistrettoPoint {
RistrettoPoint(ExtendedPoint::identity())
}
pub fn equals(&self, other: &RistrettoPoint) -> bool {
let XY = self.0.X * other.0.Y;
let YX = self.0.Y * other.0.X;
XY == YX
}
pub fn encode(&self) -> CompressedRistretto {
todo!()
}
}
impl CompressedRistretto {
pub fn identity() -> CompressedRistretto {
CompressedRistretto([0; 56])
}
pub fn decode(&self) -> Option<RistrettoPoint> {
todo!()
}
}