keep-starknet-strange / garaga

State-of-the-art Elliptic Curve operations and SNARKS verification for Cairo & Starknet 🐺.
https://garaga.gitbook.io/
MIT License
200 stars 51 forks source link

Parse Gnark go library functions from python hints and cairo #19

Closed feltroidprime closed 1 year ago

feltroidprime commented 1 year ago

We want to test Garaga against functions from https://github.com/ConsenSys/gnark-crypto/tree/master/ in our protostar tests. Gnark is an audited and trustworthy library which can be used for reference.

For example, this function that has 4 ints as input https://github.com/ConsenSys/gnark-crypto/blob/1a7a29904a7c29ba3e1c644d9752765b6ae9775e/ecc/bn254/internal/fptower/e2.go#L114

The scenario would be to use a hint to run a bash command which executes go code from inside python with the arguments parsed from Cairo, and parse stdout in python, write them to cairo, and then assert the correct in Cairo to test the functions.

Provide an example on the add function of two E2 elements in Gnark, that translates to a Fq2.add() function in cairo. Write a protostar test with the correct hint to parse and run the go functions, and test the resulting value.

Make the tool as reusable and reproducible as possible for other functions from the Gnark library.

bacharif commented 1 year ago

I pick