Skip to content

Commit

Permalink
minor circuit, prng, coproto update
Browse files Browse the repository at this point in the history
  • Loading branch information
ladnir committed Aug 5, 2023
1 parent cb188c9 commit 3f0ced6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
37 changes: 30 additions & 7 deletions cryptoTools/Circuit/BetaLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,18 +1578,41 @@ namespace osuCrypto
BetaBundle& out)
{
auto bits = a1.mWires.size();
BetaBundle temp(1);
cd.addTempWireBundle(temp);
cd.addGate(a1.mWires[0], a2.mWires[0],
GateType::Nxor, out.mWires[0]);
BetaBundle temp(bits);

if (bits == 1)
temp[0] = out[0];
else
cd.addTempWireBundle(temp);

for (u64 i = 1; i < bits; ++i)
for (u64 i = 0; i < bits; ++i)
{
cd.addGate(a1.mWires[i], a2.mWires[i],
GateType::Nxor, temp.mWires[0]);
}

auto levels = log2ceil(bits);
for (u64 i = 0; i < levels; ++i)
{
auto step = 1ull << i;
auto size = bits / 2 / step;
BetaBundle temp2(size);
if (size == 1)
temp2[0] = out[0];
else
cd.addTempWireBundle(temp2);

for (u64 j = 0; j < size; ++j)
{
cd.addGate(
temp[2 * j + 0],
temp[2 * j + 1],
oc::GateType::And,
temp2[j]
);
}

cd.addGate(temp.mWires[0], out.mWires[0],
GateType::And, out.mWires[0]);
temp = std::move(temp2);
}
}

Expand Down
6 changes: 6 additions & 0 deletions cryptoTools/Crypto/PRNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ namespace osuCrypto

// refills the internal buffer with fresh randomness
void refillBuffer();


PRNG fork()
{
return PRNG(get<block>());
}
};

// specialization to make bool work correctly.
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/getCoproto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(USER_NAME )
set(TOKEN )
set(GIT_REPOSITORY "https://github.com/Visa-Research/coproto.git")
set(GIT_TAG "07fa4143f1ac3f2b95953b41c75c5065462371d3" )
set(GIT_TAG "859b4bda569ec2ac936c951952448e44052a911c" )

set(CLONE_DIR "${OC_THIRDPARTY_CLONE_DIR}/coproto")
set(BUILD_DIR "${CLONE_DIR}/out/build/${OC_CONFIG}")
Expand Down

0 comments on commit 3f0ced6

Please sign in to comment.