use crate::ec::{EcBasis, EcCurve, EcPoint, JacPoint};
use crate::fp::{Fp2, FpBackend};
pub mod basis_change;
pub mod chain;
pub mod couple;
pub mod gluing;
pub mod isogeny;
pub mod splitting;
pub mod theta_structure;
pub const HD_EXTRA_TORSION: u32 = 2;
#[derive(Clone, Debug)]
pub struct ThetaCouplePoint<L: FpBackend> {
pub p1: EcPoint<L>,
pub p2: EcPoint<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaKernelCouplePoints<L: FpBackend> {
pub t1: ThetaCouplePoint<L>,
pub t2: ThetaCouplePoint<L>,
pub t1m2: ThetaCouplePoint<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaCoupleJacPoint<L: FpBackend> {
pub p1: JacPoint<L>,
pub p2: JacPoint<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaCoupleCurve<L: FpBackend> {
pub e1: EcCurve<L>,
pub e2: EcCurve<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaCoupleCurveWithBasis<L: FpBackend> {
pub e1: EcCurve<L>,
pub e2: EcCurve<L>,
pub b1: EcBasis<L>,
pub b2: EcBasis<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaPoint<L: FpBackend> {
pub x: Fp2<L>,
pub y: Fp2<L>,
pub z: Fp2<L>,
pub t: Fp2<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaPointCompact<L: FpBackend> {
pub x: Fp2<L>,
pub y: Fp2<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaStructure<L: FpBackend> {
pub null_point: ThetaPoint<L>,
pub precomputation: bool,
pub cap_xyz0: Fp2<L>, pub cap_yzt0: Fp2<L>, pub cap_xzt0: Fp2<L>, pub cap_xyt0: Fp2<L>,
pub xyz0: Fp2<L>, pub yzt0: Fp2<L>, pub xzt0: Fp2<L>, pub xyt0: Fp2<L>, }
#[derive(Clone, Debug)]
pub struct TranslationMatrix<L: FpBackend> {
pub g00: Fp2<L>,
pub g01: Fp2<L>,
pub g10: Fp2<L>,
pub g11: Fp2<L>,
}
#[derive(Clone, Debug)]
pub struct BasisChangeMatrix<L: FpBackend> {
pub m: [[Fp2<L>; 4]; 4],
}
#[derive(Clone, Debug)]
pub struct PrecompBasisChangeMatrix {
pub m: [[u8; 4]; 4],
}
#[derive(Clone, Debug)]
pub struct ThetaGluing<L: FpBackend> {
pub domain: ThetaCoupleCurve<L>,
pub xy_k1_8: ThetaCoupleJacPoint<L>,
pub image_k1_8: ThetaPointCompact<L>,
pub basis_change: BasisChangeMatrix<L>,
pub precomputation: ThetaPoint<L>,
pub codomain: ThetaPoint<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaIsogeny<L: FpBackend> {
pub t1_8: ThetaPoint<L>,
pub t2_8: ThetaPoint<L>,
pub hadamard_bool_1: bool,
pub hadamard_bool_2: bool,
pub domain: ThetaStructure<L>,
pub precomputation: ThetaPoint<L>,
pub codomain: ThetaStructure<L>,
}
#[derive(Clone, Debug)]
pub struct ThetaSplitting<L: FpBackend> {
pub basis_change: BasisChangeMatrix<L>,
pub b: ThetaStructure<L>,
}
impl<L: FpBackend> Default for ThetaPoint<L> {
#[inline]
fn default() -> Self {
Self {
x: Fp2::zero(),
y: Fp2::zero(),
z: Fp2::zero(),
t: Fp2::zero(),
}
}
}
impl<L: FpBackend> Default for ThetaPointCompact<L> {
#[inline]
fn default() -> Self {
Self {
x: Fp2::zero(),
y: Fp2::zero(),
}
}
}
impl<L: FpBackend> Default for ThetaStructure<L> {
#[inline]
fn default() -> Self {
Self {
null_point: ThetaPoint::default(),
precomputation: false,
cap_xyz0: Fp2::zero(),
cap_yzt0: Fp2::zero(),
cap_xzt0: Fp2::zero(),
cap_xyt0: Fp2::zero(),
xyz0: Fp2::zero(),
yzt0: Fp2::zero(),
xzt0: Fp2::zero(),
xyt0: Fp2::zero(),
}
}
}
impl<L: FpBackend> Default for BasisChangeMatrix<L> {
#[inline]
fn default() -> Self {
Self {
m: core::array::from_fn(|_| core::array::from_fn(|_| Fp2::zero())),
}
}
}
impl<L: FpBackend> Default for TranslationMatrix<L> {
#[inline]
fn default() -> Self {
Self {
g00: Fp2::zero(),
g01: Fp2::zero(),
g10: Fp2::zero(),
g11: Fp2::zero(),
}
}
}
impl<L: FpBackend> Default for ThetaCouplePoint<L> {
#[inline]
fn default() -> Self {
Self {
p1: EcPoint::identity(),
p2: EcPoint::identity(),
}
}
}
impl<L: FpBackend> Default for ThetaCoupleJacPoint<L> {
#[inline]
fn default() -> Self {
Self {
p1: JacPoint::identity(),
p2: JacPoint::identity(),
}
}
}
impl<L: FpBackend> Default for ThetaCoupleCurve<L> {
#[inline]
fn default() -> Self {
Self {
e1: EcCurve::default(),
e2: EcCurve::default(),
}
}
}