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.

47 lines
1.0 KiB

  1. package proof
  2. import (
  3. "math/big"
  4. "github.com/arnaucube/go-snark/bn128"
  5. "github.com/arnaucube/go-snark/circuit"
  6. "github.com/arnaucube/go-snark/fields"
  7. "github.com/arnaucube/go-snark/r1csqap"
  8. )
  9. type utils struct {
  10. Bn bn128.Bn128
  11. FqR fields.Fq
  12. PF r1csqap.PolynomialField
  13. }
  14. // Utils is the data structure holding the BN128, FqR Finite Field over R, PolynomialField, that will be used inside the snarks operations
  15. var Utils = prepareUtils()
  16. func prepareUtils() utils {
  17. bn, err := bn128.NewBn128()
  18. if err != nil {
  19. panic(err)
  20. }
  21. // new Finite Field
  22. fqR := fields.NewFq(bn.R)
  23. // new Polynomial Field
  24. pf := r1csqap.NewPolynomialField(fqR)
  25. return utils{
  26. Bn: bn,
  27. FqR: fqR,
  28. PF: pf,
  29. }
  30. }
  31. // Proof is
  32. type Proof interface{}
  33. // Setup is
  34. type Setup interface {
  35. Z() []*big.Int
  36. Init(witnessLength int, circuit circuit.Circuit, alphas, betas, gammas [][]*big.Int) error
  37. Generate(circuit circuit.Circuit, w []*big.Int, px []*big.Int) (Proof, error)
  38. Verify(circuit circuit.Circuit, proof Proof, publicSignals []*big.Int, debug bool) bool
  39. }