diff --git a/nim/circom_witnessgen/field.nim b/nim/circom_witnessgen/field.nim index 98141f7..e9a4dcb 100644 --- a/nim/circom_witnessgen/field.nim +++ b/nim/circom_witnessgen/field.nim @@ -89,4 +89,9 @@ func `-`*(x, y: F ): F = ( var z : F = x ; z -= y ; return z ) func `*`*(x, y: F ): F = ( var z : F = x ; z *= y ; return z ) func `/`*(x, y: F ): F = ( var z : F = x ; z *= invF(y) ; return z ) +func powF*(x: F, y: B): F = + var z: F = x + z.pow_vartime(y) + return z + #------------------------------------------------------------------------------- diff --git a/nim/circom_witnessgen/semantics.nim b/nim/circom_witnessgen/semantics.nim index 6aefeeb..fc27c50 100644 --- a/nim/circom_witnessgen/semantics.nim +++ b/nim/circom_witnessgen/semantics.nim @@ -149,7 +149,7 @@ func evalDuoOpNode(op: DuoOp, x: F, y: F): F = of Div: return if isZeroF(y): zeroF else: x / y of Add: return x + y of Sub: return x - y - of Pow: assert( false, "Pow: not yet implemented" ) + of Pow: return powF(x, fToBig(y)) # assert( false, "Pow: not yet implemented" ) of Idiv: assert( false, "Idiv: not yet implemented" ) # return bigToF( fToBig(x) div fToBig(y) ) of Mod: assert( false, "Mod: not yet implemented" ) # return bigToF( fToBig(x) mod fToBig(y) ) of Eq: return boolToF( x === y ) diff --git a/nim/main.nim b/nim/main.nim index 9fc92a6..21ce4da 100644 --- a/nim/main.nim +++ b/nim/main.nim @@ -6,10 +6,9 @@ import circom_witnessgen/export_wtns #------------------------------------------------------------------------------- -const graph_file: string = "../tmp/graph4.bin" -const input_file: string = "../tmp/input4.json" -const wtns_file: string = "../tmp/nim4.wtns" -const comp_file: string = "../tmp/nim4_full.bin" +const graph_file: string = "../tmp/graph3.bin" +const input_file: string = "../tmp/input3.json" +const wtns_file: string = "../tmp/nim3.wtns" #------------------------------------------------------------------------------- @@ -23,10 +22,6 @@ when isMainModule: let gr = loadGraph(graph_file) # echo $gr - # echo "generating full computation" - # let comp = generateFullComputation( gr, inp ) - # exportFeltSequence(comp_file, comp) - echo "generating witness" let wtns = generateWitness( gr, inp ) exportWitness(wtns_file, wtns) \ No newline at end of file