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.

52 lines
869 B

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