add Pow operation

This commit is contained in:
Balazs Komuves 2025-03-18 12:52:54 +01:00
parent b8052dbf34
commit a597168daf
No known key found for this signature in database
GPG Key ID: F63B7AEF18435562
3 changed files with 9 additions and 9 deletions

View File

@ -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
#-------------------------------------------------------------------------------

View File

@ -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 )

View File

@ -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)