| Copyright | (c) Eric Crockett 2011-2017 Chris Peikert 2011-2017 |
|---|---|
| License | GPL-2 |
| Maintainer | ecrockett0@email.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.RLWE.Challenges.Common
Description
Utility functions for handling exceptions and creating file paths.
- type ChallengeID = Int32
- type InstanceID = Int32
- type InstDRBG = GenBuffered CtrDRBG
- type T = CT
- data ChallengeU = CU !Challenge ![InstanceU]
- data InstanceU
- = IC {
- secret :: !Secret
- instc :: !InstanceCont
- | ID {
- secret :: !Secret
- instd :: !InstanceDisc
- | IR {
- secret :: !Secret
- instr :: !InstanceRLWR
- = IC {
- type Zq q = ZqBasic q Int64
- type RRq q = RRq q Double
- challengeList :: MonadIO m => FilePath -> m [String]
- checkFileExists :: (MonadIO m, MonadError String m) => FilePath -> m ()
- parseBeaconAddr :: MonadError String m => Challenge -> m BeaconAddr
- suppressedSecretID :: InstanceID -> Record -> Int32 -> InstanceID
- challengeFilesDir :: FilePath -> String -> FilePath
- challFilePath :: FilePath -> String -> FilePath
- instFilePath :: FilePath -> String -> InstanceID -> FilePath
- secretFilePath :: FilePath -> String -> InstanceID -> FilePath
- beaconFilePath :: FilePath -> BeaconEpoch -> FilePath
- certFilePath :: FilePath -> FilePath
- instIDString :: InstanceID -> String
- throwErrorIf :: MonadError String m => Bool -> String -> m ()
- throwErrorUnless :: MonadError String m => Bool -> String -> m ()
- maybeThrowError :: MonadError String m => Maybe a -> String -> m a
- printPassFailGeneric :: MonadIO m => Color -> String -> String -> ExceptT String m a -> m (Maybe a)
- printPassFail :: MonadIO m => String -> String -> ExceptT String m a -> m (Maybe a)
- printPassWarn :: MonadIO m => String -> String -> ExceptT String m a -> m (Maybe a)
- printANSI :: MonadIO m => Color -> String -> m ()
Documentation
type ChallengeID = Int32 Source #
type InstanceID = Int32 Source #
type InstDRBG = GenBuffered CtrDRBG Source #
data ChallengeU Source #
Holds an (untyped) proto-buf Ring-LWE/LWR challenge.
Holds an (untyped) proto-buf Ring-LWE/LWR instance.
Constructors
| IC | |
Fields
| |
| ID | |
Fields
| |
| IR | |
Fields
| |
challengeList :: MonadIO m => FilePath -> m [String] Source #
Yield a list of challenge names by getting all directory contents and filtering on all directories whose names start with "chall".
checkFileExists :: (MonadIO m, MonadError String m) => FilePath -> m () Source #
Do nothing if the file exists, otherwise throw an exception in the monad.
parseBeaconAddr :: MonadError String m => Challenge -> m BeaconAddr Source #
Parse the beacon time/offset used to reveal a challenge from a proto-buf stream.
suppressedSecretID :: InstanceID -> Record -> Int32 -> InstanceID Source #
Yield the ID of the suppressed secret for a challenge, given a beacon record and a byte offset.
Directory Structure
challengeFilesDir :: FilePath -> String -> FilePath Source #
The root directory for challenges and their instances.
challFilePath :: FilePath -> String -> FilePath Source #
The name for a challenge file is some string with a .challenge extension.
instFilePath :: FilePath -> String -> InstanceID -> FilePath Source #
The name for an instance file is some string followed by a hex ID with a .instance extension.
secretFilePath :: FilePath -> String -> InstanceID -> FilePath Source #
The name for a secret file is some string followed by a hex ID with the .secret extension.
beaconFilePath :: FilePath -> BeaconEpoch -> FilePath Source #
The name of a beacon XML file.
certFilePath :: FilePath -> FilePath Source #
The filename for the NIST X509 certificate.
instIDString :: InstanceID -> String Source #
Hex representation of the instance ID.
Functions for easy exceptions.
throwErrorIf :: MonadError String m => Bool -> String -> m () Source #
Throw an error if the condition is True.
throwErrorUnless :: MonadError String m => Bool -> String -> m () Source #
Throw an error if the condition is False.
maybeThrowError :: MonadError String m => Maybe a -> String -> m a Source #
Throw an error if the input is Nothing.
Arguments
| :: MonadIO m | |
| => Color | Color to print failure message. |
| -> String | String to print if computation succeeds. |
| -> String | String to print if computation fails. |
| -> ExceptT String m a | Computation to test. |
| -> m (Maybe a) |
Pretty printing of error messages.
printPassFail :: MonadIO m => String -> String -> ExceptT String m a -> m (Maybe a) Source #
Specialized version of printPassFailGeneric that fails in red.
printPassWarn :: MonadIO m => String -> String -> ExceptT String m a -> m (Maybe a) Source #
Specialized version of printPassFailGeneric that fails in yellow.