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.

50 lines
925 B

  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "github.com/arnaucube/go-snark/circuit"
  6. "github.com/urfave/cli"
  7. )
  8. func verify(context *cli.Context) error {
  9. // load circuit
  10. var cir circuit.Circuit
  11. if err := loadFromFile(compiledFileName, &cir); err != nil {
  12. return err
  13. }
  14. log.Printf("circuit: %v\n", cir)
  15. // load inputs
  16. var inputs circuit.Inputs
  17. if err := loadFromFile(publicFileName, &inputs.Public); err != nil {
  18. return err
  19. }
  20. // load setup
  21. setup, err := newSetup()
  22. if err != nil {
  23. return err
  24. }
  25. if err := loadFromFile(setupFileName, setup); err != nil {
  26. return err
  27. }
  28. log.Printf("setup: %v\n", setup)
  29. // load proof
  30. proof, err := newProof()
  31. if err != nil {
  32. return err
  33. }
  34. if err := loadFromFile(proofFileName, proof); err != nil {
  35. return err
  36. }
  37. // verify proof
  38. if ok := setup.Verify(cir, proof, inputs.Public, true); !ok {
  39. return fmt.Errorf("verif KO")
  40. }
  41. log.Printf("verif OK\n")
  42. return nil
  43. }