You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
501 B

  1. package main
  2. import (
  3. "os"
  4. "github.com/urfave/cli"
  5. "github.com/arnaucube/go-snark/circuit"
  6. )
  7. func compile(context *cli.Context) error {
  8. circuitPath := context.Args().Get(0)
  9. // load circuit
  10. circuitFile, err := os.Open(circuitPath)
  11. if err != nil {
  12. return err
  13. }
  14. parser := circuit.NewParser(circuitFile)
  15. // parse circuit
  16. cir, err := parser.Parse()
  17. if err != nil {
  18. return err
  19. }
  20. // flat code to R1CS
  21. cir.GenerateR1CS()
  22. // save circuit
  23. return saveToFile(compiledFileName, cir)
  24. }