From c3ece42c4933cd308a6593ccc9436b44bf74620e Mon Sep 17 00:00:00 2001 From: Marcel Keller Date: Tue, 3 Oct 2023 13:32:57 +1100 Subject: [PATCH] Fix bugs in binary circuit inputs. --- GC/Processor.hpp | 4 ++-- GC/ShareSecret.hpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/GC/Processor.hpp b/GC/Processor.hpp index 87296edf..22b484d2 100644 --- a/GC/Processor.hpp +++ b/GC/Processor.hpp @@ -99,7 +99,7 @@ template void GC::Processor::check_input(const U& in, const int* params) { int n_bits = *params; - auto test = in >> (n_bits - 1); + auto test = in >> n_bits; if (n_bits == 1) { if (not (in == 0 or in == 1)) @@ -110,7 +110,7 @@ void GC::Processor::check_input(const U& in, const int* params) if (params[1] == 0) throw runtime_error( "input out of range for a " + std::to_string(n_bits) - + "-bit signed integer: " + to_string(in)); + + "-bit (un)signed integer: " + to_string(in)); else throw runtime_error( "input out of range for a " + to_string(n_bits) diff --git a/GC/ShareSecret.hpp b/GC/ShareSecret.hpp index db57e3dd..510e1a82 100644 --- a/GC/ShareSecret.hpp +++ b/GC/ShareSecret.hpp @@ -159,8 +159,11 @@ void Processor::inputb(typename T::Input& input, ProcessorBase& input_process for (int i = 0; i < DIV_CEIL(x.n_bits, dl); i++) { auto& res = S[x.dest + i]; - res.my_input(input, bigint(whole_input >> (i * dl)).get_si(), + res.my_input(input, + (whole_input > 0) ? + whole_input.get_ui() : whole_input.get_si(), min(dl, x.n_bits - i * dl)); + whole_input >>= dl; } } else