diff --git a/test-input/.gitignore b/test-input/.gitignore index 644bca4..0e968e7 100644 --- a/test-input/.gitignore +++ b/test-input/.gitignore @@ -2,3 +2,4 @@ cli *.circom *.json +tmp/ \ No newline at end of file diff --git a/test-input/README.md b/test-input/README.md index bc18df6..d10923a 100644 --- a/test-input/README.md +++ b/test-input/README.md @@ -7,6 +7,7 @@ Quickstart: $ nimble build cli $ ./cli --help -Example: +Examples: - $ ./cli -v --merkle_depth=18 --limit_bits=12 --circom=main.circom --output=input.json + $ ./cli -v --merkle_depth=18 --limit_bits=12 --circom=main.circom --output=input.json --partial=partial.json + $ ./cli -v -d=16 -b=10 --output=tmp/input.json --partial=tmp/partial.json diff --git a/test-input/src/cli.nim b/test-input/src/cli.nim index 6e5651c..b31140f 100644 --- a/test-input/src/cli.nim +++ b/test-input/src/cli.nim @@ -20,19 +20,19 @@ type FullConfig = object globCfg: GlobalConfig seed: int64 outFile: string + partialFile: string circomFile: string - partial: bool verbose: bool how_many: int const defaultFullCfg = - FullConfig( globCfg: defaultGlobalConfig - , seed: 0 - , outFile: "" - , circomFile: "" - , partial: false - , verbose: false - , how_many: 1 + FullConfig( globCfg: defaultGlobalConfig + , seed: 0 + , outFile: "" + , partialFile: "" + , circomFile: "" + , verbose: false + , how_many: 1 ) #------------------------------------------------------------------------------- @@ -42,15 +42,15 @@ proc printHelp() = echo "$ ./cli [options] --output=proof_input.json --circom=proof_main.circom" echo "" echo "available options:" - echo " -h, --help : print this help" - echo " -v, --verbose : verbose output (print the actual parameters)" - echo " -d, --merkle_depth = : Merkle tree depth (default: 20)" - echo " -b, --limit_bits = : log2 of maximum number of messages per epoch (default: 16)" - echo " -s, --seed = : seed to generate the fake data (eg. 12345; default: random)" - echo " -o, --output = : the JSON file into which we write the proof inputs" - echo " -c, --circom = : the circom main component to create with these parameters" - echo " -n, --count = : generate K proof inputs at the same time (instead of 1)" - echo " -p, --partial : generate partial input" + echo " -h, --help : print this help" + echo " -v, --verbose : verbose output (print the actual parameters)" + echo " -d, --merkle_depth = : Merkle tree depth (default: 20)" + echo " -b, --limit_bits = : log2 of maximum number of messages per epoch (default: 16)" + echo " -s, --seed = : seed to generate the fake data (eg. 12345; default: random)" + echo " -o, --output = : the JSON file into which we write the full proof inputs" + echo " -p, --partial = : the JSON file into which we write the partial inputs" + echo " -c, --circom = : the circom main component to create with these parameters" + echo " -n, --count = : generate K proof inputs at the same time (instead of 1)" echo "" quit() @@ -84,8 +84,8 @@ proc parseCliOptions(): FullConfig = of "b", "limit_bits" : globCfg.limit_bits = parseInt(value) of "s", "seed" : fullCfg.seed = int64(parseInt(value)) of "o", "output" : fullCfg.outFile = value + of "p", "partial" : fullCfg.partialFile = value of "c", "circom" : fullCfg.circomFile = value - of "p", "partial" : fullCfg.partial = true of "n", "count" : fullCfg.how_many = parseInt(value) else: echo "Unknown option: ", key @@ -114,7 +114,6 @@ proc printConfig(fullCfg: FullConfig) = echo "merkle_depth = " & ($globCfg.merkle_depth) echo "limit_bits = " & ($globCfg.limit_bits) echo "random seed = " & ($fullCfg.seed) - echo "partial = " & ($fullCfg.partial) echo "how many inputs = " & ($fullCfg.how_many) #------------------------------------------------------------------------------- @@ -159,16 +158,23 @@ when isMainModule: echo "writing circom main component into `" & fname & "`" writeCircomMainComponent(fullCfg, fname) - if fullCfg.outFile != "": - let fname = fullCfg.outFile + if (fullCfg.outFile != "") or (fullCfg.partialFile != ""): + + if (globCfg.merkle_depth > 16): + echo "note: for depth > 16 this may take a while... (we are generating a full Poseidon2 Merkle tree)" + let secretTree = genTreeWithSecrets( globCfg ) let prfInput = genProofInput( globCfg , secretTree ) - if fullCfg.partial: + + if fullCfg.outFile != "": + let fname = fullCfg.outFile + echo "writing full proof input into `" & fname & "`..." + exportProofInput( fname, prfInput ) + + if fullCfg.partialFile != "": + let fname = fullCfg.partialFile echo "writing partial proof input into `" & fname & "`..." let partial = extractPartialInputs( prfInput ) exportPartialInput( fname, partial ) - else: - echo "writing full proof input into `" & fname & "`..." - exportProofInput( fname, prfInput ) echo "done" diff --git a/test-input/src/gen_inputs.nim b/test-input/src/gen_inputs.nim index b7a9fff..7d3ed7e 100644 --- a/test-input/src/gen_inputs.nim +++ b/test-input/src/gen_inputs.nim @@ -35,7 +35,7 @@ proc genTreeWithSecrets*(globCfg: GlobalConfig): TreeWithSecrets = for i in 0.. /dev/null && pwd ) source ${MY_DIR}/params.sh -CLI_ARGS="--merkle_depth=${MERKLE_DEPTH} \ +CLI_ARGS="--verbose \ + --merkle_depth=${MERKLE_DEPTH} \ --limit_bits=${LIMIT_BITS}" if [[ "$1" == "--export" ]] then echo "exporting CLI_ARGS" + echo $CLI_ARGS export CLI_ARGS fi diff --git a/workflow/params.sh b/workflow/params.sh index 6051be7..d060a55 100644 --- a/workflow/params.sh +++ b/workflow/params.sh @@ -1,6 +1,6 @@ #!/bin/bash -MERKLE_DEPTH=10 # depth of the Merkle tree -LIMIT_BITS=6 # log2 of the maximal possible rate limit per epoch +MERKLE_DEPTH=20 # depth of the Merkle tree +LIMIT_BITS=16 # log2 of the maximal possible rate limit per epoch # SEED=1234567 # seed for creating fake data diff --git a/workflow/prove.sh b/workflow/prove.sh index 01ad74c..eb1d20f 100755 --- a/workflow/prove.sh +++ b/workflow/prove.sh @@ -22,8 +22,9 @@ fi echo "" echo "generating the input for the proof circuit..." +echo "cli default arguments: $CLI_ARGS" -${NIMCLI_DIR}/cli $CLI_ARGS --output=input.json +${NIMCLI_DIR}/cli $CLI_ARGS --output=input.json --partial=partial.json # --- generate the witness ---