The following implementation works over bn128 paring field. Explore Cloudflare bn256 Bilinear map implementation where the implementation is defined. Some functions need to be provided both for G1 and G2 computations. The proof contains the following fields:
type Proof struct {
G1_L *bn256.G1
G2_L *bn256.G2
G2_R *bn256.G2
G2_O *bn256.G2
G2_alpha_L *bn256.G2
G2_alpha_R *bn256.G2
G2_alpha_O *bn256.G2
G2_h *bn256.G2
}
The following methods expected to be used for calculations:
-
Setup function that creates setup params.
func Setup(l1 L1, l2 L2, r R2, o O2, n uint64) *SetupParams
-
Proof function
func MakeProof(params *SetupParams, bigL1 BigL1, bigL2 BigL2, bigR BigR2, bigO BigO2, h H2) *Proof
-
Verify function
func VerifyProof(params *SetupParams, proof *Proof) error
Explore Test example to see example of proving that we know a
, such that f(1, a, 2) = 8
f(w,a,b) = w? (a * b) : (a + b)