dcrypt_common/
ec_common.rs1#[cfg(feature = "std")]
4use std::vec::Vec;
5
6#[cfg(all(not(feature = "std"), feature = "alloc"))]
7extern crate alloc;
8
9#[cfg(all(not(feature = "std"), feature = "alloc"))]
10use alloc::vec::Vec;
11
12#[cfg(any(feature = "std", feature = "alloc"))]
14#[derive(Clone, Debug, PartialEq, Eq)]
15pub struct Point {
16 pub x: Vec<u8>,
17 pub y: Vec<u8>,
18 pub z: Option<Vec<u8>>, }
20
21#[cfg(any(feature = "std", feature = "alloc"))]
22impl Point {
23 pub fn new_affine(x: Vec<u8>, y: Vec<u8>) -> Self {
25 Self { x, y, z: None }
26 }
27
28 pub fn new_projective(x: Vec<u8>, y: Vec<u8>, z: Vec<u8>) -> Self {
30 Self { x, y, z: Some(z) }
31 }
32
33 pub fn is_infinity(&self) -> bool {
35 match &self.z {
36 Some(z) => z.iter().all(|&b| b == 0),
37 None => self.x.is_empty() && self.y.is_empty(),
38 }
39 }
40}
41
42#[cfg(any(feature = "std", feature = "alloc"))]
44#[derive(Clone, Debug)]
45pub struct CurveParams {
46 pub a: Vec<u8>,
48
49 pub b: Vec<u8>,
51
52 pub p: Vec<u8>,
54
55 pub order: Vec<u8>,
57
58 pub cofactor: Vec<u8>,
60
61 pub generator: Point,
63}