Skip to content

Commit

Permalink
Merge branch 'main' into amore
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Sep 11, 2024
2 parents bbbd9ce + 32640e7 commit bb8c752
Show file tree
Hide file tree
Showing 134 changed files with 2,502 additions and 1,123 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/gmp-sec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,16 @@ jobs:
config:
- {
name: "Windows Latest - MinGW",
artifact: "windows-mingw.tar.xz",
os: windows-latest,
cc: "gcc"
}
- {
name: "Ubuntu Latest - GCC",
artifact: "linux-gcc.tar.xz",
os: ubuntu-latest,
cc: "gcc",
}
- {
name: "Ubuntu Latest - Clang",
artifact: "linux-clang.tar.xz",
os: ubuntu-latest,
cc: "clang",
}
Expand All @@ -39,6 +36,11 @@ jobs:
os: macos-latest,
cc: "clang",
}

defaults:
run:
shell: ${{ matrix.config.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -66,11 +68,10 @@ jobs:

- name: Run CMake (MingW)
if: ${{ (runner.os == 'Windows') && (matrix.config.cc == 'gcc') }}
shell: bash
run: |
mkdir build
cd build
cmake -DSEED= -DBENCH=0 -DARITH=gmp-sec -G "MinGW Makefiles" ..
cmake -DSEED= -DBENCH=0 -DARITH=gmp-sec -G "Unix Makefiles" ..
- name: Run CMake (standard)
if: ${{ !(runner.os == 'Windows') }}
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/gmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@ jobs:
config:
- {
name: "Windows Latest - MinGW",
artifact: "windows-mingw.tar.xz",
os: windows-latest,
cc: "gcc"
}
- {
name: "Ubuntu Latest - GCC",
artifact: "linux-gcc.tar.xz",
os: ubuntu-latest,
cc: "gcc",
}
- {
name: "Ubuntu Latest - Clang",
artifact: "linux-clang.tar.xz",
os: ubuntu-latest,
cc: "clang",

}
- {
name: "MacOS Latest",
os: macos-latest,
cc: "clang",
}

defaults:
run:
shell: ${{ matrix.config.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}

steps:
- uses: actions/checkout@v4

Expand All @@ -54,27 +57,25 @@ jobs:
if: ${{ (runner.os == 'Windows') && (matrix.config.cc == 'gcc') }}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
msystem: UCRT64
install: >-
gmp
gmp-devel
git
base-devel
gcc
cmake
gmp
gmp-devel
update: true

- name: Run CMake (MingW)
if: ${{ (runner.os == 'Windows') && (matrix.config.cc == 'gcc') }}
shell: bash
run: |
mkdir build
cd build
cmake -DSEED= -DBENCH=0 -DARITH=gmp -G "MinGW Makefiles" ..
cmake -DSEED= -DBENCH=0 -DARITH=gmp -G "Unix Makefiles" ..
- name: Run CMake (standard)
if: ${{ !(runner.os == 'Windows') }}
shell: bash
run: |
mkdir build
cd build
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ else()
set(CFLAGS "$ENV{CFLAGS}" CACHE STRING "User-chosen compiler flags.")
endif()

# Remove annoying flags when compiler cannot compute buffer sizes.
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CFLAGS "${CFLAGS} -Wno-stringop-overflow -Wno-stringop-overread")
endif()

if(AUSAN)
set(DFLAGS "${DFLAGS} -ggdb -fsanitize=address -fsanitize=undefined")
endif()
Expand Down
84 changes: 42 additions & 42 deletions bench/bench_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,9 +1342,9 @@ static void bbs(void) {

static int cls(void) {
int i, code = RLC_ERR;
bn_t r, t, u, v, _v[4];
g1_t a, A, b, B, c, _A[4], _B[4];
g2_t x, y, z, _z[4];
bn_t r, t, u, v, vs[4];
g1_t a, A, b, B, c, As[4], Bs[4];
g2_t x, y, z, zs[4];
uint8_t m[5] = { 0, 1, 2, 3, 4 };
const uint8_t *ms[5] = {m, m, m, m, m};
const size_t ls[5] = {sizeof(m), sizeof(m), sizeof(m), sizeof(m), sizeof(m)};
Expand All @@ -1362,10 +1362,10 @@ static int cls(void) {
g2_null(y);
g2_null(z);
for (i = 0; i < 4; i++) {
bn_null(_v[i]);
g1_null(_A[i]);
g1_null(_B[i]);
g2_null(_z[i]);
bn_null(vs[i]);
g1_null(As[i]);
g1_null(Bs[i]);
g2_null(zs[i]);
}

bn_new(r);
Expand All @@ -1381,10 +1381,10 @@ static int cls(void) {
g2_new(y);
g2_new(z);
for (i = 0; i < 4; i++) {
bn_new(_v[i]);
g1_new(_A[i]);
g1_new(_B[i]);
g2_new(_z[i]);
bn_new(vs[i]);
g1_new(As[i]);
g1_new(Bs[i]);
g2_new(zs[i]);
}

BENCH_RUN("cp_cls_gen") {
Expand Down Expand Up @@ -1413,15 +1413,15 @@ static int cls(void) {
} BENCH_END;

BENCH_RUN("cp_clb_gen (5)") {
BENCH_ADD(cp_clb_gen(t, u, _v, x, y, _z, 5));
BENCH_ADD(cp_clb_gen(t, u, vs, x, y, zs, 5));
} BENCH_END;

BENCH_RUN("cp_clb_sig (5)") {
BENCH_ADD(cp_clb_sig(a, _A, b, _B, c, ms, ls, t, u, _v, 5));
BENCH_ADD(cp_clb_sig(a, As, b, Bs, c, ms, ls, t, u, vs, 5));
} BENCH_END;

BENCH_RUN("cp_clb_ver (5)") {
BENCH_ADD(cp_clb_ver(a, _A, b, _B, c, ms, ls, x, y, _z, 5));
BENCH_ADD(cp_clb_ver(a, As, b, Bs, c, ms, ls, x, y, zs, 5));
} BENCH_END;

bn_free(r);
Expand All @@ -1437,18 +1437,18 @@ static int cls(void) {
g2_free(y);
g2_free(z);
for (i = 0; i < 4; i++) {
bn_free(_v[i]);
g1_free(_A[i]);
g1_free(_B[i]);
g2_free(_z[i]);
bn_free(vs[i]);
g1_free(As[i]);
g1_free(Bs[i]);
g2_free(zs[i]);
}
return code;
}

static void pss(void) {
bn_t ms[10], n, u, v, _v[10];
bn_t ms[10], n, u, v, vs[10];
g1_t a, b;
g2_t g, x, y, _y[10];
g2_t g, x, y, ys[10];

bn_null(n);
bn_null(u);
Expand All @@ -1470,12 +1470,12 @@ static void pss(void) {
g1_get_ord(n);
for (int i = 0; i < 10; i++) {
bn_null(ms[i]);
bn_null(_v[i]);
g2_null(_y[i]);
bn_null(vs[i]);
g2_null(ys[i]);
bn_new(ms[i]);
bn_rand_mod(ms[i], n);
bn_new(_v[i]);
g2_new(_y[i]);
bn_new(vs[i]);
g2_new(ys[i]);
}

BENCH_RUN("cp_pss_gen") {
Expand All @@ -1491,15 +1491,15 @@ static void pss(void) {
} BENCH_END;

BENCH_RUN("cp_psb_gen (10)") {
BENCH_ADD(cp_psb_gen(u, _v, g, x, _y, 10));
BENCH_ADD(cp_psb_gen(u, vs, g, x, ys, 10));
} BENCH_END;

BENCH_RUN("cp_psb_sig (10)") {
BENCH_ADD(cp_psb_sig(a, b, ms, u, _v, 10));
BENCH_ADD(cp_psb_sig(a, b, ms, u, vs, 10));
} BENCH_END;

BENCH_RUN("cp_psb_ver (10)") {
BENCH_ADD(cp_psb_ver(a, b, ms, g, x, _y, 10));
BENCH_ADD(cp_psb_ver(a, b, ms, g, x, ys, 10));
} BENCH_END;

bn_free(u);
Expand All @@ -1511,17 +1511,17 @@ static void pss(void) {
g2_free(y);
for (int i = 0; i < 10; i++) {
bn_free(ms[i]);
bn_free(_v[i]);
g1_free(_y[i]);
bn_free(vs[i]);
g1_free(ys[i]);
}
}

#if defined(WITH_MPC)

static void mpss(void) {
bn_t m[2], n, u[2], v[2], ms[10][2], _v[10][2];
bn_t m[2], n, u[2], v[2], ms[10][2], vs[10][2];
g1_t g, s[2];
g2_t h, x[2], y[2], _y[10][2];
g2_t h, x[2], y[2], ys[10][2];
gt_t r[2];
mt_t tri[3][2];
pt_t t[2];
Expand Down Expand Up @@ -1560,12 +1560,12 @@ static void mpss(void) {
g1_get_ord(n);
for (int j = 0; j < 10; j++) {
bn_null(ms[j][i]);
bn_null(_v[j][i]);
g2_null(_y[j][i]);
bn_null(vs[j][i]);
g2_null(ys[j][i]);
bn_new(ms[j][i]);
bn_rand_mod(ms[j][i], n);
bn_new(_v[j][i]);
g2_new(_y[j][i]);
bn_new(vs[j][i]);
g2_new(ys[j][i]);
}
}

Expand Down Expand Up @@ -1610,23 +1610,23 @@ static void mpss(void) {
mpc_mt_gen(tri[2], n);

BENCH_RUN("cp_mpsb_gen (10)") {
BENCH_ADD(cp_mpsb_gen(u, _v, h, x, _y, 10));
BENCH_ADD(cp_mpsb_gen(u, vs, h, x, ys, 10));
} BENCH_END;

BENCH_RUN("cp_mpsb_bct (10)") {
BENCH_ADD(cp_mpsb_bct(x, _y, 10));
BENCH_ADD(cp_mpsb_bct(x, ys, 10));
} BENCH_END;

BENCH_RUN("cp_mpsb_sig (10)") {
BENCH_ADD(cp_mpsb_sig(g, s, ms, u, _v, tri[0], tri[1], 10));
BENCH_ADD(cp_mpsb_sig(g, s, ms, u, vs, tri[0], tri[1], 10));
} BENCH_DIV(2);

BENCH_RUN("cp_mpsb_ver (10)") {
BENCH_ADD(cp_mpsb_ver(r[1], g, s, ms, h, x[0], _y, NULL, tri[2], t, 10));
BENCH_ADD(cp_mpsb_ver(r[1], g, s, ms, h, x[0], ys, NULL, tri[2], t, 10));
} BENCH_DIV(2);

BENCH_RUN("cp_mpsb_ver (10,sk)") {
BENCH_ADD(cp_mpsb_ver(r[1], g, s, ms, h, x[0], _y, _v, tri[2], t, 10));
BENCH_ADD(cp_mpsb_ver(r[1], g, s, ms, h, x[0], ys, vs, tri[2], t, 10));
} BENCH_DIV(2);

bn_free(n);
Expand All @@ -1646,8 +1646,8 @@ static void mpss(void) {
pt_free(t[i]);
for (int j = 0; j < 10; j++) {
bn_free(ms[j][i]);
bn_free(_v[j][i]);
g2_free(_y[j][i]);
bn_free(vs[j][i]);
g2_free(ys[j][i]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static void arith(void) {
fb_st t[RLC_FB_TABLE_MAX];
dv_t e;
bn_t f;
int bits;
uint_t bits;

fb_null(a);
fb_null(b);
Expand Down
9 changes: 9 additions & 0 deletions bench/bench_fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,15 @@ static void arith(void) {
BENCH_END;
#endif

#if FP_SMB == BINAR || !defined(STRIP)
BENCH_RUN("fp_smb_binar") {
fp_rand(a);
fp_sqr(a, a);
BENCH_ADD(fp_smb_binar(a));
}
BENCH_END;
#endif

#if FP_SMB == DIVST || !defined(STRIP)
BENCH_RUN("fp_smb_divst") {
fp_rand(a);
Expand Down
6 changes: 6 additions & 0 deletions bench/bench_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ static void arith(void) {
}
BENCH_END;

BENCH_RUN("gt_frb (1)") {
gt_rand(a);
BENCH_ADD(gt_frb(c, a, 1));
}
BENCH_END;

BENCH_RUN("gt_exp") {
gt_rand(a);
pc_get_ord(d);
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <sys/stat.h>
#include <fcntl.h>

static void test_bytes(uint8_t *buf, int size, void *args) {
static void test_bytes(uint8_t *buf, size_t size, void *args) {
int c, l, fd = *(int *)args;

if (fd == -1) {
Expand Down
6 changes: 3 additions & 3 deletions cmake/gmp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ find_path(GMP_INCLUDE_DIR gmp.h
)

if(STBIN)
find_library(GMP_LIBRARIES NAMES libgmp.a gmp.lib libgmp-10 libgmp gmp)
find_library(GMP_LIBRARIES NAMES libgmp.a libgmp.dll.a gmp.lib libgmp-10 libgmp gmp)
else(STBIN)
find_library(GMP_LIBRARIES NAMES libgmp.so gmp.lib libgmp-10 libgmp gmp)
find_library(GMP_LIBRARIES NAMES libgmp.so libgmp.dll.so gmp.lib libgmp-10 libgmp gmp)
endif(STBIN)

if(GMP_INCLUDE_DIR AND GMP_LIBRARIES)
Expand All @@ -61,7 +61,7 @@ endif()
if(GMP_FOUND)
message(STATUS "Configured GMP: -I${GMP_INCLUDE_DIR} -L${GMP_LIBRARIES}")
else(GMP_FOUND)
message(STATUS "Could NOT find GMP")
message(STATUS "Could NOT find GMP!")
endif(GMP_FOUND)

mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES)
Loading

0 comments on commit bb8c752

Please sign in to comment.