Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 765f281adb | |||
| 314f95d76d | |||
| 6f1cce5d13 | |||
| 1404bb83e7 | |||
| f1f96883e1 | |||
| d890f5bc9c | |||
| 45fd2ee201 |
@@ -28,3 +28,6 @@
|
||||
[submodule "libraries/libfc/libraries/ff"]
|
||||
path = libraries/libfc/libraries/ff
|
||||
url = https://github.com/AntelopeIO/libff
|
||||
[submodule "libraries/libfc/libraries/bn256"]
|
||||
path = libraries/libfc/libraries/bn256
|
||||
url = https://github.com/AntelopeIO/bn256
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
file(GLOB BENCHMARK "*.cpp")
|
||||
add_executable( benchmark ${BENCHMARK} )
|
||||
|
||||
target_link_libraries( benchmark fc Boost::program_options )
|
||||
target_link_libraries( benchmark fc bn256 Boost::program_options )
|
||||
target_include_directories( benchmark PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace benchmark {
|
||||
// update this map when a new feature is supported
|
||||
// key is the name and value is the function doing benchmarking
|
||||
std::map<std::string, std::function<void()>> features {
|
||||
{ "bn_256", bn_256_benchmarking },
|
||||
{ "alt_bn_128", alt_bn_128_benchmarking },
|
||||
{ "modexp", modexp_benchmarking },
|
||||
{ "key", key_benchmarking },
|
||||
|
||||
@@ -14,6 +14,7 @@ std::map<std::string, std::function<void()>> get_features();
|
||||
void print_header();
|
||||
bytes to_bytes(const std::string& source);
|
||||
|
||||
void bn_256_benchmarking();
|
||||
void alt_bn_128_benchmarking();
|
||||
void modexp_benchmarking();
|
||||
void key_benchmarking();
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
#include <bn256.h>
|
||||
#include <benchmark.hpp>
|
||||
|
||||
namespace benchmark {
|
||||
|
||||
void benchmark_bn_256_g1() {
|
||||
const auto x = int512_t("17482507071749278111455282041915610272829864719113987536544577255487650163890");
|
||||
auto f = [&]() {
|
||||
bn256::g1 g1{};
|
||||
g1.scalar_base_mult(x);
|
||||
};
|
||||
|
||||
benchmarking("bn_256_g1", f);
|
||||
}
|
||||
|
||||
void benchmark_bn_256_g2() {
|
||||
const auto x = int512_t("14506523411943850241455301787384885005987154472366374992538170185465884650319");
|
||||
auto f = [&]() {
|
||||
bn256::g2 g2{};
|
||||
g2.scalar_base_mult(x);
|
||||
};
|
||||
|
||||
benchmarking("bn_256_g2", f);
|
||||
}
|
||||
|
||||
void benchmark_bn_256_pair() {
|
||||
bn256::g1 g1{bn256::g1::curve_gen};
|
||||
bn256::g2 g2{bn256::g2::twist_gen};
|
||||
auto f = [&]() {
|
||||
bn256::pair(g1, g2);
|
||||
};
|
||||
|
||||
benchmarking("bn_256_pair", f);
|
||||
}
|
||||
|
||||
void bn_256_benchmarking() {
|
||||
benchmark_bn_256_g1();
|
||||
benchmark_bn_256_g2();
|
||||
benchmark_bn_256_pair();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ set( USE_ASM OFF CACHE BOOL "" FORCE)
|
||||
set( IS_LIBFF_PARENT OFF CACHE BOOL "" FORCE)
|
||||
set( FF_INSTALL_COMPONENT "${FC_INSTALL_COMPONENT}")
|
||||
add_subdirectory( libraries/ff )
|
||||
add_subdirectory( libraries/bn256 )
|
||||
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
|
||||
Submodule
+1
Submodule libraries/libfc/libraries/bn256 added at a8786a2e40
Reference in New Issue
Block a user