[go: nahoru, domu]

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

Extensions to PSI Logic, Updated CI, and Bug Fixes #494

Merged
merged 3 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix use of deprecated sprintf (#27)
* Fix  deprecated sprintf in GTestApproxNums.cpp
  • Loading branch information
faberga committed Jul 14, 2023
commit 17c33b5abdee0bd9a82ade987c19da5fae488350
2 changes: 1 addition & 1 deletion .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
package_build: [ON, OFF]
hexl: [ON, OFF]
c_compiler: [gcc, clang]
os: [macos-latest, ubuntu-20.04, ubuntu-22.04]
os: [macos-latest, ubuntu-22.04]
include: # Use g++ with gcc only and clang++ with clang only
- c_compiler: gcc
cxx_compiler: g++
Expand Down
12 changes: 10 additions & 2 deletions tests/GTestApproxNums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <algorithm>
#include <complex>

#include <cstdio>

#include <helib/norms.h>
#include <helib/helib.h>
#include <helib/debugging.h>
Expand Down Expand Up @@ -511,10 +513,13 @@ TEST_P(GTestApproxNums, generalOpsWorks)

std::vector<std::complex<double>> tmp_p(p1); // tmp = c1
helib::Ctxt tmp(c1);
sprintf(buffer, "tmp=c1>>=%d", (int)shamt);

EXPECT_TRUE(snprintf(buffer, sizeof(buffer), "tmp=c1>>=%d", (int)shamt) > 0);

rotate(tmp_p,
shamt); // ea.shift(tmp, random amount in [-nSlots/2,nSlots/2])
ea.rotate(tmp, shamt);

if (helib_test::verbose) {
CheckCtxt(tmp, buffer);
}
Expand All @@ -527,12 +532,15 @@ TEST_P(GTestApproxNums, generalOpsWorks)
}
EXPECT_TRUE(ciphertextMatches(ea, secretKey, p2, c2, epsilon));

sprintf(buffer, "c2>>>=%d", (int)rotamt);
EXPECT_TRUE(snprintf(buffer, sizeof(buffer), "c2>>>=%d", (int)rotamt) > 0);

rotate(p2, rotamt); // ea.rotate(c2, random amount in [1-nSlots, nSlots-1])
ea.rotate(c2, rotamt);

if (helib_test::verbose) {
CheckCtxt(c2, buffer);
}

EXPECT_TRUE(ciphertextMatches(ea, secretKey, p2, c2, epsilon));

negateVec(p1); // c1.negate()
Expand Down
4 changes: 2 additions & 2 deletions tests/GTestGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ TEST_P(GTestGeneral, correctlyImplementsMixOfOperationsOverFourCiphertexts)

helib::PtxtArray tmp_p(p1); // tmp = c1
helib::Ctxt tmp(c1);
sprintf(buffer, "tmp=c1>>=%d", (int)shamt);
EXPECT_TRUE(snprintf(buffer, sizeof(buffer), "tmp=c1>>=%d", (int)shamt) > 0);
shift(tmp_p, shamt); // ea.shift(tmp, random amount in [-nSlots/2,nSlots/2])
ea.shift(tmp, shamt);
if (!helib_test::noPrint)
Expand All @@ -328,7 +328,7 @@ TEST_P(GTestGeneral, correctlyImplementsMixOfOperationsOverFourCiphertexts)
CheckCtxt(c2, "c2+=tmp");
EXPECT_TRUE(ciphertextMatches(ea, secretKey, p2, c2));

sprintf(buffer, "c2>>>=%d", (int)rotamt);
EXPECT_TRUE(snprintf(buffer, sizeof(buffer), "c2>>>=%d", (int)rotamt) > 0);
rotate(p2, rotamt); // ea.rotate(c2, random amount in [1-nSlots, nSlots-1])
ea.rotate(c2, rotamt);
if (!helib_test::noPrint)
Expand Down