From 26260f598530ce28b40babacf55e660b5f8a776e Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 9 May 2019 06:12:07 +0900 Subject: [PATCH] remove visual studio warnings --- include/mcl/ec.hpp | 18 +++++++++--------- test/elgamal_test.cpp | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/mcl/ec.hpp b/include/mcl/ec.hpp index 3cf7054..ad6e6db 100644 --- a/include/mcl/ec.hpp +++ b/include/mcl/ec.hpp @@ -731,18 +731,18 @@ public: if (ioMode & (IoSerialize | IoSerializeHexStr)) { const size_t n = Fp::getByteSize(); const size_t adj = isMSBserialize() ? 0 : 1; - char buf[sizeof(Fp) + 1]; + uint8_t buf[sizeof(Fp) + 1]; if (Fp::BaseFp::isETHserialization()) { - const char c_flag = 0x80; - const char b_flag = 0x40; - const char a_flag = 0x20; + const uint8_t c_flag = 0x80; + const uint8_t b_flag = 0x40; + const uint8_t a_flag = 0x20; if (P.isZero()) { buf[0] = c_flag | b_flag; memset(buf + 1, 0, n - 1); } else { cybozu::MemoryOutputStream mos(buf, n); P.x.save(pb, mos, IoSerialize); if (!*pb) return; - char cba = c_flag; + uint8_t cba = c_flag; if (ec::local::get_a_flag(P.y)) cba |= a_flag; buf[0] |= cba; } @@ -815,7 +815,7 @@ public: const size_t n = Fp::getByteSize(); const size_t adj = isMSBserialize() ? 0 : 1; const size_t n1 = n + adj; - char buf[sizeof(Fp) + 1]; + uint8_t buf[sizeof(Fp) + 1]; size_t readSize; if (ioMode & IoSerializeHexStr) { readSize = mcl::fp::readHexStr(buf, n1, is); @@ -827,9 +827,9 @@ public: return; } if (Fp::BaseFp::isETHserialization()) { - const char c_flag = 0x80; - const char b_flag = 0x40; - const char a_flag = 0x20; + const uint8_t c_flag = 0x80; + const uint8_t b_flag = 0x40; + const uint8_t a_flag = 0x20; *pb = false; if ((buf[0] & c_flag) == 0) { // assume compressed return; diff --git a/test/elgamal_test.cpp b/test/elgamal_test.cpp index 9532fc5..acbf75e 100644 --- a/test/elgamal_test.cpp +++ b/test/elgamal_test.cpp @@ -11,7 +11,7 @@ typedef mcl::EcT Ec; typedef mcl::ElgamalT ElgamalEc; const mcl::EcParam& para = mcl::ecparam::secp192k1; -cybozu::RandomGenerator rg; +cybozu::RandomGenerator g_rg; CYBOZU_TEST_AUTO(testEc) { @@ -26,15 +26,15 @@ CYBOZU_TEST_AUTO(testEc) Zn =

*/ ElgamalEc::PrivateKey prv; - prv.init(P, bitSize, rg); + prv.init(P, bitSize, g_rg); prv.setCache(0, 60000); const ElgamalEc::PublicKey& pub = prv.getPublicKey(); const int m1 = 12345; const int m2 = 17655; ElgamalEc::CipherText c1, c2; - pub.enc(c1, m1, rg); - pub.enc(c2, m2, rg); + pub.enc(c1, m1, g_rg); + pub.enc(c2, m2, g_rg); Zn dec1, dec2; prv.dec(dec1, c1); prv.dec(dec2, c2); @@ -69,7 +69,7 @@ CYBOZU_TEST_AUTO(testEc) ss << pub; ss >> pub2; } - pub2.enc(cc2, m2, rg); + pub2.enc(cc2, m2, g_rg); prv.dec(d, cc2); CYBOZU_TEST_EQUAL(d, m2); } @@ -86,7 +86,7 @@ CYBOZU_TEST_AUTO(testEc) } // rerandomize c1 = c2; - pub.rerandomize(c1, rg); + pub.rerandomize(c1, g_rg); // verify c1 != c2 CYBOZU_TEST_ASSERT(c1.c1 != c2.c1); CYBOZU_TEST_ASSERT(c1.c2 != c2.c2); @@ -98,7 +98,7 @@ CYBOZU_TEST_AUTO(testEc) { ElgamalEc::CipherText c; Zn m = 1234; - pub.enc(c, m, rg); + pub.enc(c, m, g_rg); c.neg(); Zn dec; prv.dec(dec, c); @@ -109,7 +109,7 @@ CYBOZU_TEST_AUTO(testEc) ElgamalEc::CipherText c; Zn m = 123; int x = 111; - pub.enc(c, m, rg); + pub.enc(c, m, g_rg); Zn dec; prv.dec(dec, c); c.mul(x); @@ -122,7 +122,7 @@ CYBOZU_TEST_AUTO(testEc) for (int i = -10; i < 10; i++) { ElgamalEc::CipherText c; const Zn mm = i; - pub.enc(c, mm, rg); + pub.enc(c, mm, g_rg); Zn dec; prv.dec(dec, c, 1000); CYBOZU_TEST_EQUAL(dec, mm); @@ -131,7 +131,7 @@ CYBOZU_TEST_AUTO(testEc) // isZeroMessage for (int m = 0; m < 10; m++) { ElgamalEc::CipherText c0; - pub.enc(c0, m, rg); + pub.enc(c0, m, g_rg); if (m == 0) { CYBOZU_TEST_ASSERT(prv.isZeroMessage(c0)); } else { @@ -142,14 +142,14 @@ CYBOZU_TEST_AUTO(testEc) { ElgamalEc::Zkp zkp; ElgamalEc::CipherText c; - pub.encWithZkp(c, zkp, 0, rg); + pub.encWithZkp(c, zkp, 0, g_rg); CYBOZU_TEST_ASSERT(pub.verify(c, zkp)); zkp.s0 += 1; CYBOZU_TEST_ASSERT(!pub.verify(c, zkp)); - pub.encWithZkp(c, zkp, 1, rg); + pub.encWithZkp(c, zkp, 1, g_rg); CYBOZU_TEST_ASSERT(pub.verify(c, zkp)); zkp.s0 += 1; CYBOZU_TEST_ASSERT(!pub.verify(c, zkp)); - CYBOZU_TEST_EXCEPTION_MESSAGE(pub.encWithZkp(c, zkp, 2, rg), cybozu::Exception, "encWithZkp"); + CYBOZU_TEST_EXCEPTION_MESSAGE(pub.encWithZkp(c, zkp, 2, g_rg), cybozu::Exception, "encWithZkp"); } }