Fix bugs in binary circuit inputs.

This commit is contained in:
Marcel Keller
2023-10-03 13:32:57 +11:00
parent fd42b4a8b2
commit c3ece42c49
2 changed files with 6 additions and 3 deletions

View File

@@ -99,7 +99,7 @@ template<class U>
void GC::Processor<T>::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<T>::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)

View File

@@ -159,8 +159,11 @@ void Processor<T>::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