use phantom_type::PhantomType;
use crate::{core::*, NonZero, Point};
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Generator<E: Curve>(PhantomType<E>);
impl<E: Curve> Generator<E> {
pub fn to_point(&self) -> Point<E> {
(*self).into()
}
pub fn to_nonzero_point(&self) -> NonZero<Point<E>> {
(*self).into()
}
}
impl<E: Curve> From<Generator<E>> for Point<E> {
#[inline]
fn from(_: Generator<E>) -> Self {
Point::from_raw_unchecked(E::Point::from(CurveGenerator))
}
}
impl<E: Curve> From<Generator<E>> for NonZero<Point<E>> {
#[inline]
fn from(g: Generator<E>) -> Self {
NonZero::new_unchecked(g.into())
}
}
impl<E: Curve> Default for Generator<E> {
fn default() -> Self {
Self(PhantomType::new())
}
}