check circom files extension

This commit is contained in:
Dmitriy Ryajov 2024-02-09 19:12:51 -06:00
parent 002f68291e
commit 83df993feb
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 14 additions and 12 deletions

View File

@ -258,26 +258,28 @@ proc new*(
engine = BlockExcEngine.new(repoStore, wallet, network, blockDiscovery, peerStore, pendingBlocks)
store = NetworkStore.new(engine, repoStore)
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
prover = if config.persistence:
if not fileAccessible($config.circomR1cs, {AccessFlags.Read}):
if not fileAccessible($config.circomR1cs, {AccessFlags.Read}) and
$(config.circomR1cs).endsWith(".r1cs"):
error "Circom R1CS file not accessible"
raise (ref Defect)(
msg: "r1cs file not readable or doesn't exist")
msg: "r1cs file not readable, doesn't exist or wrong extension (.r1cs)")
if not fileAccessible($config.circomWasm, {AccessFlags.Read}):
error "Circom WASM file not accessible"
if not fileAccessible($config.circomWasm, {AccessFlags.Read}) and
$(config.circomWasm).endsWith(".wasm"):
error "Circom wasm file not accessible"
raise (ref Defect)(
msg: "wasm file not readable or doesn't exist")
msg: "wasm file not readable, doesn't exist or wrong extension (.wasm)")
let zkey = if not config.circomNoZkey:
if not fileAccessible($config.circomNoZkey, {AccessFlags.Read}):
error "Circom WASM file not accessible"
if not fileAccessible($config.circomZkey, {AccessFlags.Read}) and
$(config.circomZkey).endsWith(".zkey"):
error "Circom zkey file not accessible"
raise (ref Defect)(
msg: "wasm file not readable or doesn't exist")
$config.circomNoZkey
else:
""
msg: "zkey file not readable, doesn't exist or wrong extension (.zkey)")
$config.circomZkey
else: ""
some Prover.new(store, CircomCompat.init($config.circomR1cs, $config.circomWasm, zkey))
else: