Files
Picus/scripts/parse-results.ipynb
2023-08-16 16:56:02 -07:00

597 lines
25 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "acc74ec8-9917-449a-a6ff-f26e9500ca73",
"metadata": {},
"outputs": [],
"source": [
"import re"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a9f60fb1-8959-494e-9db2-3b89b0aa5ce5",
"metadata": {},
"outputs": [],
"source": [
"# choose between utils or core\n",
"# SERIES = \"utils\"\n",
"SERIES = \"core\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "223a4731-4194-4469-b7fb-28a6b0c33615",
"metadata": {},
"outputs": [],
"source": [
"bmrks = None\n",
"if SERIES == \"utils\":\n",
" bmrks = [\n",
" \"AND@gates.circom\",\n",
" \"BabyAdd@babyjub.circom\",\n",
" \"BabyDbl@babyjub.circom\",\n",
" \"BabyPbk@babyjub.circom\",\n",
" \"BinSub@binsub.circom\",\n",
" \"BinSum@binsum.circom\",\n",
" \"BitElementMulAny@escalarmulany.circom\",\n",
" \"Bits2Num_strict@bitify.circom\",\n",
" \"Bits2Num@bitify.circom\",\n",
" \"Bits2Point_Strict@pointbits.circom\",\n",
" \"CompConstant@compconstant.circom\",\n",
" \"Decoder@multiplexer.circom\",\n",
" \"Edwards2Montgomery@montgomery.circom\",\n",
" \"EscalarMulAny@escalarmulany.circom\",\n",
" \"EscalarProduct@multiplexer.circom\",\n",
" \"GreaterEqThan@comparators.circom\",\n",
" \"GreaterThan@comparators.circom\",\n",
" \"IsEqual@comparators.circom\",\n",
" \"IsZero@comparators.circom\",\n",
" \"LessEqThan@comparators.circom\",\n",
" \"LessThan@comparators.circom\",\n",
" \"MiMC7@mimc.circom\",\n",
" \"MiMCFeistel@mimcsponge.circom\",\n",
" \"MiMCSponge@mimcsponge.circom\",\n",
" \"Montgomery2Edwards@montgomery.circom\",\n",
" \"MontgomeryAdd@montgomery.circom\",\n",
" \"MontgomeryDouble@montgomery.circom\",\n",
" \"MultiAND@gates.circom\",\n",
" \"MultiMiMC7@mimc.circom\",\n",
" \"MultiMux1@mux1.circom\",\n",
" \"MultiMux2@mux2.circom\",\n",
" \"MultiMux3@mux3.circom\",\n",
" \"MultiMux4@mux4.circom\",\n",
" \"Multiplexer@multiplexer.circom\",\n",
" \"Multiplexor2@escalarmulany.circom\",\n",
" \"Mux1@mux1.circom\",\n",
" \"Mux2@mux2.circom\",\n",
" \"Mux3@mux3.circom\",\n",
" \"Mux4@mux4.circom\",\n",
" \"NAND@gates.circom\",\n",
" \"NOR@gates.circom\",\n",
" \"NOT@gates.circom\",\n",
" \"Num2Bits_strict@bitify.circom\",\n",
" \"Num2Bits@bitify.circom\",\n",
" \"Num2BitsNeg@bitify.circom\",\n",
" \"OR@gates.circom\",\n",
" \"Pedersen@pedersen_old.circom\",\n",
" \"Pedersen@pedersen.circom\",\n",
" \"Point2Bits_Strict@pointbits.circom\",\n",
" \"Poseidon@poseidon.circom\",\n",
" \"Segment@pedersen.circom\",\n",
" \"SegmentMulAny@escalarmulany.circom\",\n",
" \"SegmentMulFix@escalarmulfix.circom\",\n",
" \"Sigma@poseidon.circom\",\n",
" \"Sign@sign.circom\",\n",
" \"Switcher@switcher.circom\",\n",
" \"Window4@pedersen.circom\",\n",
" \"WindowMulFix@escalarmulfix.circom\",\n",
" \"XOR@gates.circom\",\n",
" ]\n",
"else:\n",
" bmrks = [\n",
" \"AND@gates@circomlib.circom\",\n",
" \"BabyAdd@babyjub@circomlib.circom\",\n",
" \"BabyDbl@babyjub@circomlib.circom\",\n",
" \"BabyPbk@babyjub@circomlib.circom\",\n",
" \"BinSub@binsub@circomlib_16.circom\",\n",
" \"BinSum@binsum@circomlib_32_2.circom\",\n",
" \"BinSum@binsum@circomlib_32_5.circom\",\n",
" \"BitElementMulAny@escalarmulany@circomlib.circom\",\n",
" \"Bits2Num@bitify@circomlib_1.circom\",\n",
" \"Bits2Num@bitify@circomlib_128.circom\",\n",
" \"Bits2Num@bitify@circomlib_16.circom\",\n",
" \"Bits2Num@bitify@circomlib_253.circom\",\n",
" \"Bits2Num@bitify@circomlib_254.circom\",\n",
" \"Bits2Num@bitify@circomlib_256.circom\",\n",
" \"Bits2Num@bitify@circomlib_32.circom\",\n",
" \"Bits2Num@bitify@circomlib_64.circom\",\n",
" \"Bits2Num@bitify@circomlib_8.circom\",\n",
" \"Bits2Num_strict@bitify@circomlib.circom\",\n",
" \"Bits2Point@pointbits@circomlib.circom\",\n",
" \"Bits2Point_Strict@pointbits@circomlib.circom\",\n",
" \"Edwards2Montgomery@montgomery@circomlib.circom\",\n",
" \"GreaterEqThan@comparators@circomlib_16.circom\",\n",
" \"GreaterEqThan@comparators@circomlib_32.circom\",\n",
" \"GreaterEqThan@comparators@circomlib_8.circom\",\n",
" \"GreaterThan@comparators@circomlib_16.circom\",\n",
" \"GreaterThan@comparators@circomlib_32.circom\",\n",
" \"GreaterThan@comparators@circomlib_8.circom\",\n",
" \"IsEqual@comparators@circomlib.circom\",\n",
" \"IsZero@comparators@circomlib.circom\",\n",
" \"LessEqThan@comparators@circomlib_16.circom\",\n",
" \"LessEqThan@comparators@circomlib_32.circom\",\n",
" \"LessEqThan@comparators@circomlib_8.circom\",\n",
" \"Main@main@circomlib.circom\",\n",
" \"Montgomery2Edwards@montgomery@circomlib.circom\",\n",
" \"MontgomeryAdd@montgomery@circomlib.circom\",\n",
" \"MontgomeryDouble@montgomery@circomlib.circom\",\n",
" \"Multiplexor2@escalarmulany@circomlib.circom\",\n",
" \"Mux1@mux1@circomlib.circom\",\n",
" \"Mux2@mux2@circomlib.circom\",\n",
" \"Mux3@mux3@circomlib.circom\",\n",
" \"Mux4@mux4@circomlib.circom\",\n",
" \"NAND@gates@circomlib.circom\",\n",
" \"NOR@gates@circomlib.circom\",\n",
" \"NOT@gates@circomlib.circom\",\n",
" \"Num2Bits@bitify@circomlib_1.circom\",\n",
" \"Num2Bits@bitify@circomlib_128.circom\",\n",
" \"Num2Bits@bitify@circomlib_16.circom\",\n",
" \"Num2Bits@bitify@circomlib_253.circom\",\n",
" \"Num2Bits@bitify@circomlib_254.circom\",\n",
" \"Num2Bits@bitify@circomlib_256.circom\",\n",
" \"Num2Bits@bitify@circomlib_32.circom\",\n",
" \"Num2Bits@bitify@circomlib_64.circom\",\n",
" \"Num2Bits@bitify@circomlib_8.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_1.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_128.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_16.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_253.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_254.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_256.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_32.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_64.circom\",\n",
" \"Num2BitsNeg@bitify@circomlib_8.circom\",\n",
" \"Num2Bits_strict@bitify@circomlib.circom\",\n",
" \"OR@gates@circomlib.circom\",\n",
" \"Pedersen@pedersen@circomlib_1.circom\",\n",
" \"Pedersen@pedersen@circomlib_128.circom\",\n",
" \"Pedersen@pedersen@circomlib_16.circom\",\n",
" \"Pedersen@pedersen@circomlib_253.circom\",\n",
" \"Pedersen@pedersen@circomlib_254.circom\",\n",
" \"Pedersen@pedersen@circomlib_256.circom\",\n",
" \"Pedersen@pedersen@circomlib_32.circom\",\n",
" \"Pedersen@pedersen@circomlib_64.circom\",\n",
" \"Pedersen@pedersen@circomlib_8.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_1.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_128.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_16.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_253.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_254.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_256.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_32.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_64.circom\",\n",
" \"Pedersen@pedersen_old@circomlib_8.circom\",\n",
" \"Point2Bits@pointbits@circomlib.circom\",\n",
" \"Point2Bits_Strict@pointbits@circomlib.circom\",\n",
" \"SMTHash1@smthash_mimc@circomlib.circom\",\n",
" \"SMTHash1@smthash_poseidon@circomlib.circom\",\n",
" \"SMTHash2@smthash_mimc@circomlib.circom\",\n",
" \"SMTHash2@smthash_poseidon@circomlib.circom\",\n",
" \"SMTProcessorLevel@smtprocessorlevel@circomlib.circom\",\n",
" \"SMTProcessorSM@smtprocessorsm@circomlib.circom\",\n",
" \"SMTVerifierLevel@smtverifierlevel@circomlib.circom\",\n",
" \"SMTVerifierSM@smtverifiersm@circomlib.circom\",\n",
" \"Sha256_2@sha256_2@circomlib.circom\",\n",
" \"Sha256compression@sha256compression@circomlib.circom\",\n",
" \"Sigma@poseidon@circomlib.circom\",\n",
" \"Sigma@poseidon_old@circomlib.circom\",\n",
" \"SigmaPlus@sigmaplus@circomlib.circom\",\n",
" \"Sign@sign@circomlib.circom\",\n",
" \"Switcher@switcher@circomlib.circom\",\n",
" \"T1@t1@circomlib.circom\",\n",
" \"T2@t2@circomlib.circom\",\n",
" \"Window4@pedersen@circomlib.circom\",\n",
" \"WindowMulFix@escalarmulfix@circomlib.circom\",\n",
" \"XOR@gates@circomlib.circom\",\n",
" ]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf438ce8-e7e1-48e1-9000-1aa123498977",
"metadata": {},
"outputs": [],
"source": [
"# parse stats\n",
"with open(\"../logs/compile-{}.log\".format(SERIES), \"r\") as f:\n",
" raw = f.read()\n",
" ll = raw.split(\"=================== \")\n",
" ll = list(filter(lambda p:len(p)>0, ll))\n",
"\n",
"stats = {}\n",
"for p in ll:\n",
" pname = p[:p.index(\":\")]\n",
" # print(\"# processing {}\".format(pname))\n",
" if pname not in bmrks:\n",
" # print(\"# skipping {}\".format(pname))\n",
" continue\n",
" re_nlcnst = int(re.search(r\"\\nnon-linear constraints: (.*)\\n\", p).group(1))\n",
" re_lcnst = int(re.search(r\"\\nlinear constraints: (.*)\\n\", p).group(1))\n",
" re_prvin = int(re.search(r\"\\nprivate inputs: (.*)\\n\", p).group(1))\n",
" re_pubin = int(re.search(r\"\\npublic inputs: (.*)\\n\", p).group(1))\n",
" re_prvout = int(re.search(r\"\\nprivate outputs: (.*)\\n\", p).group(1))\n",
" re_pubout = int(re.search(r\"\\npublic outputs: (.*)\\n\", p).group(1))\n",
" re_wires = int(re.search(r\"\\nwires: (.*)\\n\", p).group(1))\n",
" stats[pname] = {}\n",
" stats[pname][\"non-linear constraints\"] = re_nlcnst\n",
" stats[pname][\"linear constraints\"] = re_lcnst\n",
" stats[pname][\"total constraints\"] = re_nlcnst + re_lcnst\n",
" stats[pname][\"private inputs\"] = re_prvin\n",
" stats[pname][\"private inputs\"] = re_pubin\n",
" stats[pname][\"total inputs\"] = re_prvin + re_pubin\n",
" stats[pname][\"private outputs\"] = re_prvout\n",
" stats[pname][\"public outputs\"] = re_pubout\n",
" stats[pname][\"total outputs\"] = re_prvout + re_pubout\n",
" stats[pname][\"wires\"] = re_wires\n",
" stats[pname][\"witness\"] = re_wires - re_prvin - re_pubin - re_prvout - re_pubout\n",
" cat = None\n",
" if stats[pname][\"total constraints\"]<100:\n",
" cat = \"small\"\n",
" elif stats[pname][\"total constraints\"]>=100 and stats[pname][\"total constraints\"]<1000:\n",
" cat = \"medium\"\n",
" else:\n",
" cat = \"large\"\n",
" stats[pname][\"cat\"] = cat"
]
},
{
"cell_type": "markdown",
"id": "30d7580a-046b-4f13-b4e0-e83f6fe88029",
"metadata": {},
"source": [
"## print Table 1, \"circomlib-SERIES\" part"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "221c5156-c4d0-4e9b-93a7-db82be2980fa",
"metadata": {},
"outputs": [],
"source": [
"# compute row \"circomlib-SERIES\" of Table 1\n",
"all_cnst = [stats[p][\"total constraints\"] for p in stats.keys()]\n",
"avg_cnst = round(sum(all_cnst)/len(all_cnst))\n",
"all_out = [stats[p][\"total outputs\"] for p in stats.keys()]\n",
"avg_out = round(sum(all_out)/len(all_out))\n",
"\n",
"print('Table 1, \"circomlib-{}\" part'.format(SERIES))\n",
"TEMPLATE = \"{:^15} | {:^10} | {:^20} | {:^20}\"\n",
"print(TEMPLATE.format(\"Benchmark Set\", \"# circuits\", \"Avg. # constraints\", \"Avg. # output signals\"))\n",
"print(TEMPLATE.format(\"circomlib-{}\".format(SERIES), len(stats), avg_cnst, avg_out))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b19eae8b-90e0-46a1-a263-b0c3f4cd217d",
"metadata": {},
"outputs": [],
"source": [
"# parse time\n",
"with open(\"../logs/full-{}.log\".format(SERIES), \"r\") as f:\n",
" raw = f.read()\n",
" for fn in bmrks:\n",
" fn0 = fn.replace(\".circom\", \".r1cs\")\n",
" sp = raw.find(fn0)\n",
" s0 = raw.find(\"elapsed: \", sp)\n",
" ss = raw.find(\"seconds\", s0)\n",
" t = int(raw[s0+len(\"elapsed: \"):ss])\n",
" stats[fn][\"time\"] = t\n",
"\n",
"# self check\n",
"for p in stats.keys():\n",
" if \"time\" not in stats[p]:\n",
" print(\"# panic: time for {} doesn't exist, check your experiment again!\".format(p))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "36b75881-f73e-4a0e-91e6-741d6e182ede",
"metadata": {},
"outputs": [],
"source": [
"# parse result\n",
"for ff in bmrks:\n",
" with open(\"../logs/full-{}/{}.log\".format(SERIES, ff.replace(\".circom\",\"\")),\"r\") as f:\n",
" raw = f.read()\n",
" if \"# weak uniqueness: unsafe\" in raw:\n",
" stats[ff][\"res\"] = \"unsafe\"\n",
" elif \"# weak uniqueness: safe\" in raw:\n",
" stats[ff][\"res\"] = \"safe\"\n",
" elif \"# weak uniqueness: unknown\" in raw:\n",
" stats[ff][\"res\"] = \"unknown\"\n",
" else:\n",
" stats[ff][\"res\"] = \"unknown\"\n",
"\n",
"# self check\n",
"for p in stats.keys():\n",
" if \"res\" not in stats[p]:\n",
" print(\"# panic: result data for {} doesn't exist, check your experiment again!\".format(p))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "34ae5a3b-4038-4798-83f3-278abcbe6f8f",
"metadata": {},
"outputs": [],
"source": [
"def compute_table2(cat):\n",
"\n",
" cat_in = [stats[p][\"total inputs\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_in = round(sum(cat_in)/len(cat_in))\n",
"\n",
" cat_out = [stats[p][\"total outputs\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_out = round(sum(cat_out)/len(cat_out))\n",
"\n",
" cat_witness = [stats[p][\"witness\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_witness = round(sum(cat_witness)/len(cat_witness))\n",
"\n",
" cat_wires = [stats[p][\"wires\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_wires = round(sum(cat_wires)/len(cat_wires))\n",
"\n",
" cat_lcnst = [stats[p][\"linear constraints\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_lcnst = round(sum(cat_lcnst)/len(cat_lcnst))\n",
"\n",
" cat_nlcnst = [stats[p][\"non-linear constraints\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_nlcnst = round(sum(cat_nlcnst)/len(cat_nlcnst))\n",
"\n",
" cat_cnst = [stats[p][\"total constraints\"] for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
" avg_cat_cnst = round(sum(cat_cnst)/len(cat_cnst))\n",
"\n",
" subkeys = [p for p in stats.keys() if cat == \"overall\" or stats[p][\"cat\"] == cat]\n",
"\n",
" # need to exclude timeouts\n",
" cat_time = [stats[p][\"time\"] for p in stats.keys() if (cat == \"overall\" or stats[p][\"cat\"] == cat) and (stats[p][\"res\"] == \"safe\" or stats[p][\"res\"] == \"unsafe\") and stats[p][\"time\"] < 600]\n",
" avg_cat_time = round(sum(cat_time)/len(cat_time))\n",
"\n",
" cat_check = [stats[p][\"res\"] for p in stats.keys() if (cat == \"overall\" or stats[p][\"cat\"] == cat) and stats[p][\"res\"] == \"safe\"]\n",
"\n",
" cat_cross = [stats[p][\"res\"] for p in stats.keys() if (cat == \"overall\" or stats[p][\"cat\"] == cat) and stats[p][\"res\"] == \"unsafe\"]\n",
" if cat == \"overall\" or cat == \"small\":\n",
" # +1 for the additional \"BitElementMulAny@escalarmulany.r1cs\" solved by counter-example procedure\n",
" if SERIES == \"utils\":\n",
" cat_cross.append(stats[\"BitElementMulAny@escalarmulany.circom\"])\n",
" if SERIES == \"core\":\n",
" cat_cross.append(stats[\"BitElementMulAny@escalarmulany@circomlib.circom\"])\n",
"\n",
" TEMPLATE = \"{:^20} | {:^5}\"\n",
" print(TEMPLATE.format(\"in\", avg_cat_in))\n",
" print(TEMPLATE.format(\"out\", avg_cat_out))\n",
" print(TEMPLATE.format(\"witness\", avg_cat_witness))\n",
" print(TEMPLATE.format(\"total (variables)\", avg_cat_wires))\n",
" print()\n",
" print(TEMPLATE.format(\"linear\", avg_cat_lcnst))\n",
" print(TEMPLATE.format(\"non-linear\", avg_cat_nlcnst))\n",
" print(TEMPLATE.format(\"total (constraints)\", avg_cat_cnst))\n",
" print()\n",
" print(TEMPLATE.format(\"Total (#)\", len(subkeys)))\n",
" print(TEMPLATE.format(\"Avg. Time (s)\", avg_cat_time))\n",
" print(TEMPLATE.format(\"check (#)\", len(cat_check)))\n",
" print(TEMPLATE.format(\"cross (#)\", len(cat_cross)))\n",
" print(TEMPLATE.format(\"Solved (%)\", (len(cat_check) + len(cat_cross)) / len(subkeys)))"
]
},
{
"cell_type": "markdown",
"id": "b3bf8061-5a5b-458a-9895-e3c91416a005",
"metadata": {
"tags": []
},
"source": [
"## print Table 2, \"circomlib-SERIES\" part"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e4ce7974-ed66-468b-967d-8f1af4e43600",
"metadata": {},
"outputs": [],
"source": [
"# compute column of \"circomlib-SERIES\" - \"small\" in Table 2\n",
"print('------> Table 2, \"circomlib-{}\" part, \"small\"'.format(SERIES))\n",
"compute_table2(\"small\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e356396-f845-4613-8883-86abea19de75",
"metadata": {},
"outputs": [],
"source": [
"# compute column of \"circomlib-SERIES\" - \"medium\" in Table 2\n",
"print('------> Table 2, \"circomlib-{}\" part, \"medium\"'.format(SERIES))\n",
"compute_table2(\"medium\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a4224c77-4c4f-4d86-91a2-e45e600ccde2",
"metadata": {},
"outputs": [],
"source": [
"# compute column of \"circomlib-SERIES\" - \"large\" in Table 2\n",
"print('------> Table 2, \"circomlib-{}\" part, \"large\"'.format(SERIES))\n",
"compute_table2(\"large\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7dd4387b-f56c-45ff-a91e-bf485cfddff2",
"metadata": {},
"outputs": [],
"source": [
"# compute column of \"circomlib-SERIES\" - \"overall\" in Table 2\n",
"print('------> Table 2, \"circomlib-{}\" part, \"overall\"'.format(SERIES))\n",
"compute_table2(\"overall\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a1c82272-f3e0-44df-873e-991a376747c1",
"metadata": {},
"outputs": [],
"source": [
"# parse result for ucp-SERIES\n",
"for ff in bmrks:\n",
" with open(\"../logs/ucp-{}/{}.log\".format(SERIES, ff.replace(\".circom\",\"\")),\"r\") as f:\n",
" raw = f.read()\n",
" if \"# weak uniqueness: unsafe\" in raw:\n",
" stats[ff][\"ucp_res\"] = \"unsafe\"\n",
" elif \"# weak uniqueness: safe\" in raw:\n",
" stats[ff][\"ucp_res\"] = \"safe\"\n",
" elif \"# weak uniqueness: unknown\" in raw:\n",
" stats[ff][\"ucp_res\"] = \"unknown\"\n",
" else:\n",
" stats[ff][\"ucp_res\"] = \"unknown\"\n",
"\n",
"# self check\n",
"for p in stats.keys():\n",
" if \"ucp_res\" not in stats[p]:\n",
" print(\"# panic: ucp result data for {} doesn't exist, check your experiment again!\".format(p))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "206e1712-b2ca-4566-863d-61c366cfa79f",
"metadata": {},
"outputs": [],
"source": [
"# parse result for smt-SERIES\n",
"for ff in bmrks:\n",
" with open(\"../logs/smt-{}/{}.log\".format(SERIES, ff.replace(\".circom\",\"\")),\"r\") as f:\n",
" raw = f.read()\n",
" if \"# weak uniqueness: unsafe\" in raw:\n",
" stats[ff][\"smt_res\"] = \"unsafe\"\n",
" elif \"# weak uniqueness: safe\" in raw:\n",
" stats[ff][\"smt_res\"] = \"safe\"\n",
" elif \"# weak uniqueness: unknown\" in raw:\n",
" stats[ff][\"smt_res\"] = \"unknown\"\n",
" else:\n",
" stats[ff][\"smt_res\"] = \"unknown\"\n",
"\n",
"# self check\n",
"for p in stats.keys():\n",
" if \"smt_res\" not in stats[p]:\n",
" print(\"# panic: smt result data for {} doesn't exist, check your experiment again!\".format(p))"
]
},
{
"cell_type": "markdown",
"id": "a723b1b2-428d-491b-963c-7aaf9968a112",
"metadata": {},
"source": [
"## print Figure 11, \"circomlib-SERIES\" part"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9872f6a4-f46e-4485-89be-a96d3176c91e",
"metadata": {},
"outputs": [],
"source": [
"# compute solved% for full-SERIES\n",
"full_check = [stats[p][\"res\"] for p in stats.keys() if stats[p][\"res\"] == \"safe\"]\n",
"full_cross = [stats[p][\"res\"] for p in stats.keys() if stats[p][\"res\"] == \"unsafe\"]\n",
"# +1 for the additional \"BitElementMulAny@escalarmulany.r1cs\" solved by counter-example procedure\n",
"if SERIES == \"utils\":\n",
" full_cross.append(stats[\"BitElementMulAny@escalarmulany.circom\"])\n",
"if SERIES == \"core\":\n",
" full_cross.append(stats[\"BitElementMulAny@escalarmulany@circomlib.circom\"])\n",
"full_percentage = (len(full_check) + len(full_cross)) / len(stats)\n",
"\n",
"# compute solved% for ucp-SERIES\n",
"ucp_check = [stats[p][\"ucp_res\"] for p in stats.keys() if stats[p][\"ucp_res\"] == \"safe\"]\n",
"ucp_cross = [stats[p][\"ucp_res\"] for p in stats.keys() if stats[p][\"ucp_res\"] == \"unsafe\"]\n",
"ucp_percentage = (len(ucp_check) + len(ucp_cross)) / len(stats)\n",
"\n",
"# compute solved% for smt-SERIES\n",
"smt_check = [stats[p][\"smt_res\"] for p in stats.keys() if stats[p][\"smt_res\"] == \"safe\"]\n",
"smt_cross = [stats[p][\"smt_res\"] for p in stats.keys() if stats[p][\"smt_res\"] == \"unsafe\"]\n",
"smt_percentage = (len(smt_check) + len(smt_cross)) / len(stats)\n",
"\n",
"print('------> Figure 11, \"circomlib-{}\" part'.format(SERIES))\n",
"print(\"FULL: {:.2}\\nUCP: {:.2}\\nSMT: {:.2}\".format(full_percentage, ucp_percentage, smt_percentage))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7beaba17-ee8e-4d8b-bf3d-c34b231a3a31",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "ee61eb3c-65e0-411b-934c-a1ac6a8ef285",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "258c6610-54a7-46ce-a28c-2ab0bc12fb6f",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c27cf2e-39ee-4405-aaeb-22d84a1a33da",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "base"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}