Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publico #3

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.9)
cmake_minimum_required(VERSION 3.28)
set(TARGET faz_ecc_avx2)
set(CMAKE_BUILD_TYPE Release)
project(${TARGET} C)
Expand Down
7 changes: 2 additions & 5 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
cmake_minimum_required(VERSION 2.8.4)

# Other Tests using GTest suite.
enable_language(CXX)
add_definitions(-mavx2)
set(CMAKE_CXX_STANDARD 11)

include(ExternalProject)
include("GNUInstallDirs")
set(GBENCH_VERSION "v1.5.1")
ExternalProject_Add(benchmark-download
URL "https://api.github.com/repos/google/benchmark/tarball/${GBENCH_VERSION}"
URL_HASH "SHA256=440ded04a56a63043d9112da1b787be550f59d0df3c13eb0f9d40e6b3e805cc6"
GIT_REPOSITORY "https://github.com/google/benchmark"
GIT_TAG "v1.8.5"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
Expand Down
13 changes: 7 additions & 6 deletions bench/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ int main(void) {
bench_third_party();

bench_fp25519();
bench_x25519();
bench_ed25519();

bench_fp448();
bench_x448();
bench_ed448();

bench_hash25519();
// bench_x25519();
// bench_ed25519();
//
// bench_fp448();
// bench_x448();
// bench_ed448();

printf("==== End of Benchmarking ====\n");
return 0;
Expand Down
20 changes: 10 additions & 10 deletions bench/bench.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#ifndef PALETA_BENCH_H
#define PALETA_BENCH_H

void bench_third_party();
void bench_fp25519();
void bench_ecc25519();
void bench_x25519();
void bench_ed25519();
void bench_hash25519();
void bench_third_party(void);
void bench_fp25519(void);
void bench_ecc25519(void);
void bench_x25519(void);
void bench_ed25519(void);
void bench_hash25519(void);

void bench_fp448();
void bench_ecc448();
void bench_x448();
void bench_ed448();
void bench_fp448(void);
void bench_ecc448(void);
void bench_x448(void);
void bench_ed448(void);

#endif /* PALETA_BENCH_H */
4 changes: 2 additions & 2 deletions bench/bench_ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ static void bench_ecdh(const X_ECDH* ecdh) {
ecdh->freeKey(shared_secret);
}

void bench_x25519() {
void bench_x25519(void) {
printf("===== Benchmarking DH ====\n");
printf("====== X25519 x64 ======\n");
bench_ecdh(&X25519_x64);
printf("====== X25519 AVX2 ======\n");
bench_ecdh(&X25519);
}

void bench_x448() {
void bench_x448(void) {
printf("===== Benchmarking DH ====\n");
printf("====== X448 AVX2 ======\n");
bench_ecdh(&X448);
Expand Down
4 changes: 2 additions & 2 deletions bench/bench_eddsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ static void bench_ed448context(const SignatureSchemeCtx *eddsa) {
eddsa->freeSignature(signature);
}

void bench_ed25519() {
void bench_ed25519(void) {
printf("== Benchmarking EdDSA ====\n");
printf("====== Ed25519 AVX2 ======\n");
bench_ed255pure(&Ed25519.Pure);
}

void bench_ed448() {
void bench_ed448(void) {
printf("== Benchmarking EdDSA ====\n");
printf("====== Ed448 AVX2 ======\n");
bench_ed448context(&Ed448.PureContext);
Expand Down
4 changes: 2 additions & 2 deletions bench/bench_fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void bench_4w(const Arith_4w *fp) {
fp->misc.free(c);
}

void bench_fp25519() {
void bench_fp25519(void) {
printf("=== Benchmarking Arith ===\n");
printf("====== p=2^255-19 ======\n");
printf("====== 1-way (full) ======\n");
Expand All @@ -76,7 +76,7 @@ void bench_fp25519() {
bench_4w(&Fp25519._4w_red.arith);
}

void bench_fp448() {
void bench_fp448(void) {
printf("=== Benchmarking Arith ===\n");
printf("==== p=2^448-2^224-1 =====\n");
printf("====== 1-way (full) ======\n");
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "clocks.h"

void bench_hash25519() {
void bench_hash25519(void) {
printf("=== Benchmarking Hash ====\n");
printf("===== Hash25519 AVX2 =====\n");

Expand Down
4 changes: 2 additions & 2 deletions bench/bench_third_party.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "clocks.h"

static void bench_sha512_2w() {
static void bench_sha512_2w(void) {
const int BENCH = 500;
const int NUM = 2;
const int MSG_LEN = 64;
Expand All @@ -25,7 +25,7 @@ static void bench_sha512_2w() {
}
}

void bench_third_party() {
void bench_third_party(void) {
const int BENCH = 500;
const int message_length = 64;
uint8_t message[message_length];
Expand Down
2 changes: 1 addition & 1 deletion bench/clocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/time.h>
#include <time.h>

uint64_t time_now() {
uint64_t time_now(void) {
struct timeval tv;
uint64_t ret;

Expand Down
2 changes: 1 addition & 1 deletion bench/clocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
(unsigned long)((end_c - start_c) / iterations)); \
} while (0)

uint64_t time_now();
uint64_t time_now(void);
uint64_t cycles_now(void);

/* _CLOCKS_H_ */
Expand Down
2 changes: 0 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)

include_directories(../include)

add_executable(example_field field.c)
Expand Down
2 changes: 1 addition & 1 deletion include/faz_eddsa_avx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace faz{
namespace eddsa{
#endif /* __cplusplus */

#define ZeroOperandReturnKey(X) uint8_t * (*X)()
#define ZeroOperandReturnKey(X) uint8_t * (*X)(void)
#define Oper1Void(NAME, TYPE) void (*NAME)(TYPE C)
#define Oper1File(NAME, TYPE) void (*NAME)(FILE* file, TYPE A)

Expand Down
2 changes: 1 addition & 1 deletion src/eltfp25519_1w_redradix.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ DECL(void, print)(FILE *file, argElement_1w a) {
print_hex_bytes(file, a_bytes, SIZE_FP25519);
}

DECL(argElement_1w, alloc)() {
DECL(argElement_1w, alloc)(void) {
return (argElement_1w) allocate_bytes((4 * ((NUM_DIGITS_FP25519 + 3) / 4)) * sizeof(uint64_t));
}

Expand Down
2 changes: 1 addition & 1 deletion src/eltfp25519_2w_redradix.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ DECL(__m256i, cmp)(argElement_2w a, argElement_2w b) {
return SET64(0, c1, 0, c0);
}

DECL(argElement_2w, alloc)() {
DECL(argElement_2w, alloc)(void) {
return (argElement_2w) allocate_bytes((NUM_DIGITS_FP25519 / 2) * sizeof(__m256i));
}

Expand Down
2 changes: 1 addition & 1 deletion src/eltfp25519_4w_redradix.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ DECL(void, srt)(argElement_4w c, argElement_4w a) {
FN(invsqrt)(c, c, a);
}

DECL(argElement_4w,alloc)() {
DECL(argElement_4w,alloc)(void) {
return (argElement_4w) allocate_bytes(NUM_DIGITS_FP25519 * sizeof(__m256i));
}

Expand Down
2 changes: 1 addition & 1 deletion src/eltfp448_1w_redradix.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ DECL(void, print)(FILE *file, argElement_1w a) {
print_hex_bytes(file, a_bytes, SIZE_FP448);
}

DECL(argElement_1w, alloc)() {
DECL(argElement_1w, alloc)(void) {
return (argElement_1w) allocate_bytes( (NUM_DIGITS_FP448) * sizeof(uint64_t));
}

Expand Down
2 changes: 1 addition & 1 deletion src/eltfp448_2w_redradix.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ DECL(__m256i, cmp)(argElement_2w a, argElement_2w b) {
return SET64(0, c1, 0, c0);
}

DECL(argElement_2w, alloc)() {
DECL(argElement_2w, alloc)(void) {
return (argElement_2w) allocate_bytes((NUM_DIGITS_FP448 / 2) * sizeof(__m256i));
}

Expand Down
2 changes: 1 addition & 1 deletion src/eltfp448_4w_redradix.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ DECL(void, ser)(uint8_t *buf, argElement_4w a) {
ser_Fp448_1w_redradix(buf+3*SIZE_FP448,a3);
}

DECL(argElement_4w,alloc)() {
DECL(argElement_4w,alloc)(void) {
return (argElement_4w) allocate_bytes(NUM_DIGITS_FP448 * sizeof(__m256i));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ladder255.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "edwards255.h"
#include <string.h>

static inline uint8_t *allocX25519_Key() {
static inline uint8_t *allocX25519_Key(void) {
return (uint8_t *) allocate_bytes(ECDH25519_KEY_SIZE_BYTES * sizeof(uint8_t));
}

Expand Down
2 changes: 1 addition & 1 deletion src/ladder448.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @return
*/
static inline uint8_t * allocX448_Key() {
static inline uint8_t * allocX448_Key(void) {
return (uint8_t*) allocate_bytes(ECDH448_KEY_SIZE_BYTES * sizeof(uint8_t));
}

Expand Down
4 changes: 2 additions & 2 deletions src/sign255.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ static inline void printEd25519_Signature(FILE * file,uint8_t *sig) {
*
* @return
*/
static inline uint8_t *allocEd25519_Key() {
static inline uint8_t *allocEd25519_Key(void) {
return (uint8_t *) allocate_bytes(ED25519_KEY_SIZE_BYTES_PARAM * sizeof(uint8_t));
}

/**
*
* @return
*/
static inline uint8_t *allocEd25519_Signature() {
static inline uint8_t *allocEd25519_Signature(void) {
return (uint8_t *) allocate_bytes(ED25519_SIG_SIZE_BYTES_PARAM * sizeof(uint8_t));
}

Expand Down
4 changes: 2 additions & 2 deletions src/sign448.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ static inline void printEd448_Signature(FILE *file, uint8_t *sig) {
*
* @return
*/
static inline uint8_t *allocEd448_Key() {
static inline uint8_t *allocEd448_Key(void) {
return (uint8_t *) allocate_bytes(ED448_KEY_SIZE_BYTES_PARAM * sizeof(uint8_t));
}

/**
*
* @return
*/
static inline uint8_t *allocEd448_Signature() {
static inline uint8_t *allocEd448_Signature(void) {
return (uint8_t *) allocate_bytes(ED448_SIG_SIZE_BYTES_PARAM * sizeof(uint8_t));
}

Expand Down
9 changes: 3 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
cmake_minimum_required(VERSION 2.8.4)

include_directories(../include)
include_directories(../third_party)

# Other Tests using GTest suite.
enable_language(CXX)
add_definitions(-mavx2)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

# Some Tests
add_executable(test_mine EXCLUDE_FROM_ALL
Expand All @@ -27,10 +25,9 @@ target_link_libraries(test_mine
# download gtest
include(ExternalProject)
include("GNUInstallDirs")
set(GTEST_VERSION "release-1.10.0")
ExternalProject_Add(googletest-download
URL "https://api.github.com/repos/google/googletest/tarball/${GTEST_VERSION}"
URL_HASH "SHA256=e4a7cd97c903818abe7ddb129db9c41cc9fd9e2ded654be57ced26d45c72e4c9"
GIT_REPOSITORY "https://github.com/google/googletest"
GIT_TAG "v1.15.2"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
Expand Down
1 change: 1 addition & 0 deletions tests/test_ed25519.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iomanip>
#include <faz_eddsa_avx2.h>
#include <gtest/gtest.h>
#include "vectors.h"
Expand Down
1 change: 1 addition & 0 deletions tests/test_fp25519_avx2.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iomanip>
#include <faz_fp_avx2.h>
#include <gmp.h>
#include <gtest/gtest.h>
Expand Down
1 change: 1 addition & 0 deletions tests/test_fp25519_x64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iomanip>
#include <faz_fp_avx2.h>
#include <gmp.h>
#include <gtest/gtest.h>
Expand Down
1 change: 1 addition & 0 deletions tests/test_fp448_x64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iomanip>
#include <faz_fp_avx2.h>
#include <gmp.h>
#include <gtest/gtest.h>
Expand Down
1 change: 1 addition & 0 deletions tests/test_hash255.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iomanip>
#include <faz_hash_avx2.h>
#include <gtest/gtest.h>
#include <prng.h>
Expand Down
1 change: 1 addition & 0 deletions tests/test_x25519.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iomanip>
#include <faz_ecdh_avx2.h>
#include <gtest/gtest.h>

Expand Down
2 changes: 1 addition & 1 deletion third_party/cpu_caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int cpu_has(enum Capabilities c) {
return ret;
}

void machine_info() {
void machine_info(void) {
printf("=== Environment Information ====\n");
printf("Program compiled with: %s\n", __VERSION__);
unsigned int eax, ebx, ecx, edx;
Expand Down
2 changes: 1 addition & 1 deletion third_party/cpu_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
extern "C" {
#endif /* __cplusplus */

void machine_info();
void machine_info(void);

#ifdef __cplusplus
} /* extern C */
Expand Down
Loading