Skip to content

Commit

Permalink
Add some usage instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly committed May 5, 2024
1 parent 4ef9ab6 commit b5a9fca
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand All @@ -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 <options> : Generate an ALBA proof file from a (random) set of items"
, "alba verify <options> : Verify an ALBA proof. Note that options must be consistent with"
, " the options used for proving"
, ""
, "Options:"
, "--security <int> : The security level of the proof (default: 128)"
, "--size <int> : The number of elements in the input set (default: 100)"
, "--len <int> : The length (in bytes) of each item in the input set (default: 8)"
, "--honest-ratio <int>"
, " : The assumed percentage of \"honest\" items in the input set (default: 80)"
, "--output <file> : 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}}
Expand Down Expand Up @@ -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)

0 comments on commit b5a9fca

Please sign in to comment.