-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
193 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package extractor_test | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"github.com/consensys/gnark-crypto/ecc" | ||
"github.com/consensys/gnark/frontend" | ||
"github.com/reilabs/gnark-lean-extractor/v2/extractor" | ||
) | ||
|
||
type Nest1 struct { | ||
In1 frontend.Variable | ||
In2 [5]frontend.Variable | ||
} | ||
|
||
type Nest2 struct { | ||
In1 [4][4]frontend.Variable | ||
In2 [3]frontend.Variable | ||
} | ||
|
||
type NestedCircuit struct { | ||
N1 Nest1 | ||
N2 Nest2 | ||
} | ||
|
||
func (circuit *NestedCircuit) Define(api frontend.API) error { | ||
sum := api.Add(circuit.N1.In2[2], circuit.N2.In2[0]) | ||
api.AssertIsEqual(sum, circuit.N1.In2[1]) | ||
return nil | ||
} | ||
|
||
func TestNestedCircuit(t *testing.T) { | ||
circuit := NestedCircuit{} | ||
out, err := extractor.CircuitToLean(&circuit, ecc.BN254) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
checkOutput(t, out) | ||
} |
Oops, something went wrong.