Consensys / gnark

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license
https://hackmd.io/@gnark
Apache License 2.0
1.41k stars 366 forks source link

feat: add format specifiers for `api.Println` or implement `api.Printf` #1239

Open George551556 opened 2 months ago

George551556 commented 2 months ago

To be precise, I think you can add a func like api.Printf("this is my var %fv. ", circuit.x), and hope it have the same performance with fmt.Printf()


func (circuit *Circuit) Define(api frontend.API) error{
    api.Printf("this is my var %fv. ", circuit.x)
}
go
cmd output: this is my var 2
ivokub commented 2 months ago

It could be useful - I think we could have different formatting options:

zliucd commented 1 month ago

@ivokub In addition to api.Println(), it's possible to provide a new API api.Fmt() that feeds the printing content to a string?

ivokub commented 1 month ago

It is possible, but we currently don't have it on the roadmap. I think it could be a suitable task for external contribution though.