Skip to content

Commit

Permalink
Fix round-off-one errors in Random.between max bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeho committed Mar 11, 2024
1 parent 0442950 commit bd85b99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/fhetest/Generate/LibConfigGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def generateLibConfig(encType: ENC_TYPE, valid: Boolean): LibConfig = {
if valid then
randomScheme match {
case Scheme.BFV | Scheme.BGV =>
Some(Random.between(1, randomEncParams.plainMod))
Some(Random.between(1, randomEncParams.plainMod + 1))
case Scheme.CKKS =>
Some(Random.between(1, math.pow(2, randomFirstModSize)))
Some(Random.between(1, math.pow(2, randomFirstModSize) + 1))
}
else
randomScheme match {
case Scheme.BFV | Scheme.BGV =>
Some(Random.between(1, 1000))
case Scheme.CKKS => Some(Random.between(1, math.pow(2, 64)))
Some(Random.between(1, 1000 + 1))
case Scheme.CKKS => Some(Random.between(1, math.pow(2, 64) + 1))
}
LibConfig(
randomScheme,
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/fhetest/Phase/Check.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ case object Check {
} else {
if (debug) {
println(
s"Program $i is skipped due to HE overflow check: 2^$overflowBound",
s"Program $i is skipped due to HE overflow check: $overflowBound",
)
}
None
Expand Down

0 comments on commit bd85b99

Please sign in to comment.