Skip to content

Commit

Permalink
bn254 curve crate
Browse files Browse the repository at this point in the history
  • Loading branch information
yshekel committed Jun 26, 2024
1 parent d93975f commit eb89a9a
Show file tree
Hide file tree
Showing 18 changed files with 658 additions and 153 deletions.
2 changes: 1 addition & 1 deletion icicle_v3/cmake/curve.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function(setup_curve_target)
src/curves/ffi_extern.cpp
src/curves/montgomery_conversion.cpp
)
target_link_libraries(icicle_curve PUBLIC icicle_device icicle_field)
target_link_libraries(icicle_curve PUBLIC icicle_device icicle_field)
set_target_properties(icicle_curve PROPERTIES OUTPUT_NAME "icicle_curve_${CURVE}")

# Make sure CURVE is defined in the cache for backends to see
Expand Down
8 changes: 4 additions & 4 deletions icicle_v3/include/icicle/curves/montgomery_conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ namespace icicle {
const VecOpsConfig& config,
g2_affine_t* output)>;

void register_affine_g2_convert_montgomery(const std::string& deviceType, AffineG2ConvertMontImpl);
void register_g2_affine_convert_montgomery(const std::string& deviceType, AffineG2ConvertMontImpl);

#define REGISTER_AFFINE_G2_CONVERT_MONTGOMERY_BACKEND(DEVICE_TYPE, FUNC) \
namespace { \
static bool UNIQUE(_reg_affine_g2_convert_mont) = []() -> bool { \
register_affine_g2_convert_montgomery(DEVICE_TYPE, FUNC); \
register_g2_affine_convert_montgomery(DEVICE_TYPE, FUNC); \
return true; \
}(); \
}
Expand All @@ -77,12 +77,12 @@ namespace icicle {
const VecOpsConfig& config,
g2_projective_t* output)>;

void register_projective_g2_convert_montgomery(const std::string& deviceType, ProjectiveG2ConvertMontImpl);
void register_g2_projective_convert_montgomery(const std::string& deviceType, ProjectiveG2ConvertMontImpl);

#define REGISTER_PROJECTIVE_G2_CONVERT_MONTGOMERY_BACKEND(DEVICE_TYPE, FUNC) \
namespace { \
static bool UNIQUE(_reg_projective_g2_convert_mont) = []() -> bool { \
register_projective_g2_convert_montgomery(DEVICE_TYPE, FUNC); \
register_g2_projective_convert_montgomery(DEVICE_TYPE, FUNC); \
return true; \
}(); \
}
Expand Down
12 changes: 6 additions & 6 deletions icicle_v3/src/curves/montgomery_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ namespace icicle {
}

#ifdef G2
ICICLE_DISPATCHER_INST(AffineG2ConvertMont, affine_g2_convert_montgomery, AffineG2ConvertMontImpl);
ICICLE_DISPATCHER_INST(AffineG2ConvertMont, g2_affine_convert_montgomery, AffineG2ConvertMontImpl);

extern "C" eIcicleError CONCAT_EXPAND(CURVE, affine_g2_convert_montgomery)(
extern "C" eIcicleError CONCAT_EXPAND(CURVE, g2_affine_convert_montgomery)(
const g2_affine_t* input, size_t n, bool is_into, const VecOpsConfig& config, g2_affine_t* output)
{
return AffineG2ConvertMont::execute(input, n, is_into, config, output);
Expand All @@ -37,7 +37,7 @@ namespace icicle {
eIcicleError
convert_montgomery(const g2_affine_t* input, size_t n, bool is_into, const VecOpsConfig& config, g2_affine_t* output)
{
return CONCAT_EXPAND(CURVE, affine_g2_convert_montgomery)(input, n, is_into, config, output);
return CONCAT_EXPAND(CURVE, g2_affine_convert_montgomery)(input, n, is_into, config, output);
}
#endif //! G1_AFFINE_SAME_TYPE_AS_G2_AFFINE
#endif // G2
Expand All @@ -58,9 +58,9 @@ namespace icicle {
}

#ifdef G2
ICICLE_DISPATCHER_INST(ProjectiveG2ConvertMont, projective_g2_convert_montgomery, ProjectiveG2ConvertMontImpl);
ICICLE_DISPATCHER_INST(ProjectiveG2ConvertMont, g2_projective_convert_montgomery, ProjectiveG2ConvertMontImpl);

extern "C" eIcicleError CONCAT_EXPAND(CURVE, projective_g2_convert_montgomery)(
extern "C" eIcicleError CONCAT_EXPAND(CURVE, g2_projective_convert_montgomery)(
const g2_projective_t* input, uint64_t n, bool is_into, const VecOpsConfig& config, g2_projective_t* output)
{
return ProjectiveG2ConvertMont::execute(input, n, is_into, config, output);
Expand All @@ -70,7 +70,7 @@ namespace icicle {
eIcicleError convert_montgomery(
const g2_projective_t* input, uint64_t n, bool is_into, const VecOpsConfig& config, g2_projective_t* output)
{
return CONCAT_EXPAND(CURVE, projective_g2_convert_montgomery)(input, n, is_into, config, output);
return CONCAT_EXPAND(CURVE, g2_projective_convert_montgomery)(input, n, is_into, config, output);
}

#endif // G2
Expand Down
1 change: 1 addition & 0 deletions wrappers/rust_v3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"icicle-core",
"icicle-fields/icicle-babybear",
"icicle-fields/icicle-stark252",
"icicle-curves/icicle-bn254",
]
exclude = []

Expand Down
4 changes: 4 additions & 0 deletions wrappers/rust_v3/icicle-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ rayon = "1.8.1"
criterion = "0.3"
serial_test = "3.0.0"
once_cell = "1.10.0"

[features]
g2 = []
ec_ntt = []
Loading

0 comments on commit eb89a9a

Please sign in to comment.