Skip to content

Commit

Permalink
update cuda templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ImmanuelSegol committed Aug 9, 2023
1 parent 154fcc5 commit b5ff62d
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions icicle/curves/curve_template/projective.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,41 @@
#include "curve_config.cuh"
#include "../../primitives/projective.cuh"

extern "C" ${CURVE_NAME_U}::projective_t random_projective_${CURVE_NAME_L}()
{
return ${CURVE_NAME_U}::projective_t::rand_host();
}

extern "C" ${CURVE_NAME_U}::projective_t projective_zero_${CURVE_NAME_L}()
{
return ${CURVE_NAME_U}::projective_t::zero();
}

extern "C" bool projective_is_on_curve_${CURVE_NAME_L}(${CURVE_NAME_U}::projective_t *point1)
{
return ${CURVE_NAME_U}::projective_t::is_on_curve(*point1);
}

extern "C" ${CURVE_NAME_U}::affine_t projective_to_affine_${CURVE_NAME_L}(${CURVE_NAME_U}::projective_t *point1)
{
return ${CURVE_NAME_U}::projective_t::to_affine(*point1);
}

extern "C" ${CURVE_NAME_U}::projective_t projective_from_affine_${CURVE_NAME_L}(${CURVE_NAME_U}::affine_t *point1)
{
return ${CURVE_NAME_U}::projective_t::from_affine(*point1);
}

extern "C" ${CURVE_NAME_U}::scalar_field_t random_scalar_${CURVE_NAME_L}()
{
return ${CURVE_NAME_U}::scalar_field_t::rand_host();
}

extern "C" bool eq_${CURVE_NAME_L}(${CURVE_NAME_U}::projective_t *point1, ${CURVE_NAME_U}::projective_t *point2)
{
return (*point1 == *point2) &&
!((point1->x == ${CURVE_NAME_U}::point_field_t::zero()) && (point1->y == ${CURVE_NAME_U}::point_field_t::zero()) && (point1->z == ${CURVE_NAME_U}::point_field_t::zero())) &&
!((point2->x == ${CURVE_NAME_U}::point_field_t::zero()) && (point2->y == ${CURVE_NAME_U}::point_field_t::zero()) && (point2->z == ${CURVE_NAME_U}::point_field_t::zero()));
return (*point1 == *point2) &&
!((point1->x == ${CURVE_NAME_U}::point_field_t::zero()) && (point1->y == ${CURVE_NAME_U}::point_field_t::zero()) && (point1->z == ${CURVE_NAME_U}::point_field_t::zero())) &&
!((point2->x == ${CURVE_NAME_U}::point_field_t::zero()) && (point2->y == ${CURVE_NAME_U}::point_field_t::zero()) && (point2->z == ${CURVE_NAME_U}::point_field_t::zero()));
}

#if defined(G2_DEFINED)
Expand All @@ -16,4 +46,25 @@ extern "C" bool eq_g2_${CURVE_NAME_L}(${CURVE_NAME_U}::g2_projective_t *point1,
!((point1->x == ${CURVE_NAME_U}::g2_point_field_t::zero()) && (point1->y == ${CURVE_NAME_U}::g2_point_field_t::zero()) && (point1->z == ${CURVE_NAME_U}::g2_point_field_t::zero())) &&
!((point2->x == ${CURVE_NAME_U}::g2_point_field_t::zero()) && (point2->y == ${CURVE_NAME_U}::g2_point_field_t::zero()) && (point2->z == ${CURVE_NAME_U}::g2_point_field_t::zero()));
}

extern "C" ${CURVE_NAME_U}::g2_projective_t random_g2_projective_${CURVE_NAME_L}()
{
return ${CURVE_NAME_U}::g2_projective_t::rand_host();
}

extern "C" ${CURVE_NAME_U}::g2_affine_t g2_projective_to_affine_${CURVE_NAME_L}(${CURVE_NAME_U}::g2_projective_t *point1)
{
return ${CURVE_NAME_U}::g2_projective_t::to_affine(*point1);
}

extern "C" ${CURVE_NAME_U}::g2_projective_t g2_projective_from_affine_${CURVE_NAME_L}(${CURVE_NAME_U}::g2_affine_t *point1)
{
return ${CURVE_NAME_U}::g2_projective_t::from_affine(*point1);
}

extern "C" bool g2_projective_is_on_curve_${CURVE_NAME_L}(${CURVE_NAME_U}::g2_projective_t *point1)
{
return ${CURVE_NAME_U}::g2_projective_t::is_on_curve(*point1);
}

#endif

0 comments on commit b5ff62d

Please sign in to comment.