Skip to content

Commit 2afe717

Browse files
committed
warning fix for Mx
1 parent 89be315 commit 2afe717

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

cryptoTools/Circuit/MxBit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ namespace osuCrypto
389389
throw RTE_LOC;
390390

391391
for (u64 i = 0; i < d.size(); ++i)
392-
*d[i] = *bZero[i] ^ (*bZero[i] ^ *bOne[i]) & *this;
392+
*d[i] = *bZero[i] ^ ((*bZero[i] ^ *bOne[i]) & *this);
393393

394394
return ret;
395395
}

cryptoTools/Circuit/MxCircuit.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace osuCrypto
2525

2626
void map(u64 key, u64 val) {
2727
if (mMap.size() <= key)
28-
mMap.resize(std::max<u64>(key + 1, mMap.size() * 2), -1);
28+
mMap.resize(std::max<u64>(key + 1, mMap.size() * 2), ~0ull);
2929
mMap[key] = val;
3030
};
3131

@@ -190,7 +190,7 @@ namespace osuCrypto
190190
{
191191

192192
auto s = node.mInput.size();
193-
if (s && node.mInput.back().offset() == -1)
193+
if (s && node.mInput.back().offset() == ~0ull)
194194
--s;
195195

196196
BetaBundle b(s);

cryptoTools/Circuit/MxCircuit.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,15 @@ namespace osuCrypto
287287

288288
Arena<Address> mArena;
289289
std::vector<Gate> mGates;
290-
u64 mPrevPrintIdx = -1;
290+
u64 mPrevPrintIdx = ~0ull;
291291

292292
void addPrint(span<const Bit*> elems,
293293
std::function<std::string(const BitVector& b)>&& p)
294294
{
295295
Gate g;
296296
g.mType = OpType::Print;
297297

298-
u64 s = (mPrevPrintIdx != -1);
298+
u64 s = (mPrevPrintIdx != ~0ull);
299299
for (u64 i = 0; i < elems.size(); ++i)
300300
s += elems[i]->isConst() == false;
301301

@@ -311,9 +311,9 @@ namespace osuCrypto
311311
consts[i] = elems[i]->constValue();
312312
}
313313

314-
if (mPrevPrintIdx != -1)
314+
if (mPrevPrintIdx != ~0ull)
315315
{
316-
g.mInput[j++] = Address(mPrevPrintIdx, -1);
316+
g.mInput[j++] = Address(mPrevPrintIdx, ~0ull);
317317
}
318318

319319
assert(j == s);
@@ -418,13 +418,13 @@ namespace osuCrypto
418418
throw std::runtime_error("MxCircuit::evaluate(...), number of inputs provided is not correct. " LOCATION);
419419
out.resize(mOutputs.size());
420420

421-
std::vector<u64> map(mGates.size(), -1);
421+
std::vector<u64> map(mGates.size(), ~0ull);
422422
u64 nc = std::accumulate(mGates.begin(), mGates.end(), 0ull, [](auto&& c, auto&& g) {
423423
return g.mNumOutputs + c;
424424
});
425425
std::unique_ptr<u8[]>vals_(new u8[nc]);
426426
auto vals = [&](const Address& a) -> auto& {
427-
assert(map[a.gate()] != -1);
427+
assert(map[a.gate()] != ~0ull);
428428
return vals_[map[a.gate()] + a.offset()];
429429
};
430430

@@ -489,7 +489,7 @@ namespace osuCrypto
489489
Print* p = dynamic_cast<Print*>(gate.mData.get());
490490

491491
auto s = gate.mInput.size();
492-
if (s && gate.mInput.back().offset() == -1)
492+
if (s && gate.mInput.back().offset() == ~0ull)
493493
--s;
494494
BitVector v(s);
495495
for (u64 j = 0; j < v.size(); ++j)

cryptoTools/Circuit/MxCircuitLibrary.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace osuCrypto
124124
else
125125
{
126126
G[i] =
127-
!signExtend(a1_, i, it) &
127+
(!signExtend(a1_, i, it)) &
128128
signExtend(a2_, i, it);
129129
}
130130
}
@@ -626,7 +626,7 @@ namespace osuCrypto
626626
throw RTE_LOC;
627627

628628
for (u64 i = 0; i < ret.size(); ++i)
629-
ret[i] = bZero[i] ^ (bZero[i] ^ bOne[i]) & b;
629+
ret[i] = bZero[i] ^ ((bZero[i] ^ bOne[i]) & b);
630630
}
631631

632632
void negate(
@@ -764,7 +764,7 @@ namespace osuCrypto
764764
// 001110
765765
// ----------------
766766
// 011 | 101101
767-
// 011 \
767+
// 011 \.
768768
// - 000 0 |
769769
// -------- |
770770
// 101101 |
@@ -786,7 +786,7 @@ namespace osuCrypto
786786
// 001 |
787787
// 011 |
788788
// - 000 0 |
789-
// ---- /
789+
// ---- /
790790
// 001 <==== remainder
791791
//
792792

tests_cryptoTools/MxCircuit_Tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void MxCircuit_asBetaCircuit_Test(const oc::CLP& cmd)
424424

425425
bool verbose = cmd.isSet("verbose");
426426
PRNG prng(ZeroBlock);
427-
auto trials = cmd.getOr("trials", 1);
427+
auto trials = cmd.getOr("trials", 1ull);
428428
for (u64 t = 0; t < trials; ++t)
429429
{
430430

0 commit comments

Comments
 (0)