diff --git a/app/Main.hs b/app/Main.hs index e176e090..28544fd4 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -24,7 +24,7 @@ defaultOptions = Options { size = 100 , len = 8 - , params = Params 8 8 80 20 + , params = Params 128 128 80 20 , output = "proof.alba" } @@ -47,6 +47,26 @@ main = do Verified{} -> putStrLn ("Verified proof " <> show prf) other -> putStrLn ("Cannot verify proof " <> show prf <> ", failure: " <> show other) >> exitWith (ExitFailure 1) +usage :: IO () +usage = + putStrLn $ + unlines + [ "alba: Command-line utility for creating and verifying ALBA proofs" + , "" + , "Usage:" + , "alba prove : Generate an ALBA proof file from a (random) set of items" + , "alba verify : Verify an ALBA proof. Note that options must be consistent with" + , " the options used for proving" + , "" + , "Options:" + , "--security : The security level of the proof (default: 128)" + , "--size : The number of elements in the input set (default: 100)" + , "--len : The length (in bytes) of each item in the input set (default: 8)" + , "--honest-ratio " + , " : The assumed percentage of \"honest\" items in the input set (default: 80)" + , "--output : The file containing proof to write or verify (default: alba.proof)" + ] + adjustForSize :: Options -> Options adjustForSize opts@Options{size, params = pars@Params{n_p, n_f}} = opts{params = pars{n_p = size * n_p `div` 100, n_f = size * n_f `div` 100}} @@ -78,5 +98,8 @@ parseOptions = \case let rat = read hn opts <- parseOptions rest pure $ opts{params = (params opts){n_p = rat, n_f = 100 - rat}} + ("--output" : output : rest) -> do + opts <- parseOptions rest + pure $ opts{output} other -> do - error ("Invalid arguments: " <> unwords other) + usage >> exitWith (ExitFailure 2)