-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68c6563
commit 0461e36
Showing
15 changed files
with
505 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/main/scala/fhetest/Checker/ExceptionMsgKeyword.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package fhetest.Checker | ||
|
||
import fhetest.Generate.ValidFilter | ||
import fhetest.Generate.getValidFilterList //TODO | ||
import fhetest.Generate.Utils.InvalidFilterIdx | ||
|
||
type LibConfigArgumentName = String | ||
|
||
val libConfigArguments: Set[LibConfigArgumentName] = | ||
Set( | ||
"Scheme", | ||
"RingDim", | ||
"MulDepth", | ||
"PlaindMod", | ||
"ModSize", | ||
"FirstModSize", | ||
"ScalingModSize", | ||
"SecurityLevel", | ||
"ScalingTechnique", | ||
"Len", | ||
"Bound", | ||
"RotateBound", | ||
) | ||
|
||
// TODO: fill out | ||
// Note: Keywords should be in lower cases! | ||
def mapLibConfigArgument2Keywords( | ||
argName: LibConfigArgumentName, | ||
): Set[String] = { | ||
val commonKeywords = | ||
Set(" parameters", "ring dimension", " ringdim", " primes", " overflow") | ||
val modSizeKeywords = Set(" moduli", " bit_sizes", "bit length") | ||
val uniqueKeywords = argName match { | ||
case "Scheme" => Set("scheme") | ||
case "RingDim" => Set("ring dimension", " ringdim") | ||
case "MulDepth" => | ||
Set( | ||
"multiplicative depth", | ||
" towers", | ||
"end of modulus switching chain", | ||
"removing last element of dcrtpoly", | ||
"scale out of bounds", | ||
"encoded values are too large", | ||
) | ||
case "PlainMod" => Set(" plain_modulus", " plaintext_modulus") | ||
case "ModSize" => modSizeKeywords | ||
case "FirstModSize" => modSizeKeywords ++ Set() | ||
case "ScalingModSize" => modSizeKeywords ++ Set() | ||
case "SecurityLevel" => Set("security level", " SecurityLevel") | ||
case "ScalingTechnique" => Set("security mode") | ||
case "Len" => | ||
Set( | ||
"values_matrix size", | ||
" values_size", | ||
// "should not be greater than ringdim", // Currently, overlap with " ringDim" in commonKeywords | ||
) | ||
case "Bound" => Set("encoded values are too large") | ||
case "RotateBound" => Set("out_of_range", "evalkey for index") | ||
case s: String => | ||
throw new Exception(s"$s is not defined as LibConfigArgument.") | ||
} | ||
commonKeywords ++ uniqueKeywords | ||
} | ||
|
||
val validFilters = | ||
getValidFilterList().map(filter => filter.getSimpleName.replace("$", "")) | ||
|
||
def mapFilterName2LibConfigArgumentMap( | ||
filterName: String, | ||
): LibConfigArgumentName = | ||
filterName match { | ||
case "FilterBoundIsLessThanPlainMod" => "Bound" | ||
case "FilterBoundIsLessThanPowerOfModSize" => "Bound" | ||
case "FilterFirstModSizeIsLargest" => "FirstModSize" | ||
case "FilterLenIsLessThanRingDim" => "Len" | ||
case "FilterModSizeIsBeteween14And60bits" => "ModSize" | ||
case "FilterMulDepthIsEnough" => "MulDepth" | ||
case "FilterMulDepthIsNotNegative" => "MulDepth" | ||
case "FilterOpenFHEBFVModuli" => "ModSize" | ||
case "FilterPlainModEnableBatching" => "PlainMod" | ||
case "FilterPlainModIsPositive" => "PlainMod" | ||
case "FilterRingDimIsPowerOfTwo" => "RingDim" | ||
case "FilterRotateBoundTest" => "RotateBound" | ||
case "FilterScalingTechniqueByScheme" => "ScalingTechnique" | ||
case s: String => throw new Exception(s"Keyword for $s is undifined.") | ||
} | ||
|
||
def getKeywordsFromFilters( | ||
invalidFilterIdxList: List[InvalidFilterIdx], | ||
): Set[String] = { | ||
val invalidFilterNameList = invalidFilterIdxList.map { | ||
case i => validFilters.apply(i) | ||
} | ||
invalidFilterNameList.foldLeft(Set[String]()) { (acc, filterName) => | ||
{ | ||
val argName = mapFilterName2LibConfigArgumentMap(filterName) | ||
val keywords = mapLibConfigArgument2Keywords(argName) | ||
acc ++ keywords | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.