Skip to content

Commit

Permalink
Fix to modular addition for small numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardgeek committed Feb 21, 2023
1 parent 3834f6a commit 94e10d8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion runtime/bigint.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ uint64_t runtime_smallnumModularAdd(uint64_t a, uint64_t b, uint64_t modulus, bo
}
return result - (modulus & (int64_t)-cttk_bool_to_int(ctl));
}
if (result < a || result > modulus) {
if (result < a || result >= modulus) {
result -= modulus;
}
return result;
Expand Down
1 change: 0 additions & 1 deletion runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ static inline void runtime_copyBigint(runtime_array *dest, runtime_array *source
uint64_t runtime_smallnumMul(uint64_t a, uint64_t b, bool isSigned, bool secret);
uint64_t runtime_smallnumDiv(uint64_t a, uint64_t b, bool isSigned, bool secret);
uint64_t runtime_smallnumMod(uint64_t a, uint64_t b, bool isSigned, bool secret);
uint64_t runtime_smallnumMod(uint64_t a, uint64_t b, bool isSigned, bool secret);
uint64_t runtime_smallnumModReduce(uint64_t value, uint64_t modulus, bool isSigned, bool secret);
uint64_t runtime_smallnumExp(uint64_t base, uint32_t exponent, bool isSigned, bool secret);

Expand Down

0 comments on commit 94e10d8

Please sign in to comment.