|
@ -73,39 +73,39 @@ func GenerateProof(pk *types.Pk, w types.Witness) (*types.Proof, []*big.Int, err |
|
|
proof.C = new(bn256.G1).ScalarBaseMult(big.NewInt(0)) |
|
|
proof.C = new(bn256.G1).ScalarBaseMult(big.NewInt(0)) |
|
|
proofBG1 := new(bn256.G1).ScalarBaseMult(big.NewInt(0)) |
|
|
proofBG1 := new(bn256.G1).ScalarBaseMult(big.NewInt(0)) |
|
|
|
|
|
|
|
|
var waitGroup sync.WaitGroup |
|
|
|
|
|
waitGroup.Add(4) |
|
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
|
|
wg.Add(4) |
|
|
|
|
|
go func() { |
|
|
for i := 0; i < pk.NVars; i++ { |
|
|
for i := 0; i < pk.NVars; i++ { |
|
|
proof.A = new(bn256.G1).Add(proof.A, new(bn256.G1).ScalarMult(pk.A[i], w[i])) |
|
|
proof.A = new(bn256.G1).Add(proof.A, new(bn256.G1).ScalarMult(pk.A[i], w[i])) |
|
|
} |
|
|
} |
|
|
wg.Done() |
|
|
wg.Done() |
|
|
}(&waitGroup) |
|
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
|
|
|
|
|
}() |
|
|
|
|
|
go func() { |
|
|
for i := 0; i < pk.NVars; i++ { |
|
|
for i := 0; i < pk.NVars; i++ { |
|
|
proof.B = new(bn256.G2).Add(proof.B, new(bn256.G2).ScalarMult(pk.B2[i], w[i])) |
|
|
proof.B = new(bn256.G2).Add(proof.B, new(bn256.G2).ScalarMult(pk.B2[i], w[i])) |
|
|
} |
|
|
} |
|
|
wg.Done() |
|
|
wg.Done() |
|
|
}(&waitGroup) |
|
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
|
|
|
|
|
}() |
|
|
|
|
|
go func() { |
|
|
for i := 0; i < pk.NVars; i++ { |
|
|
for i := 0; i < pk.NVars; i++ { |
|
|
proofBG1 = new(bn256.G1).Add(proofBG1, new(bn256.G1).ScalarMult(pk.B1[i], w[i])) |
|
|
proofBG1 = new(bn256.G1).Add(proofBG1, new(bn256.G1).ScalarMult(pk.B1[i], w[i])) |
|
|
} |
|
|
} |
|
|
wg.Done() |
|
|
wg.Done() |
|
|
}(&waitGroup) |
|
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
|
|
|
|
|
}() |
|
|
|
|
|
go func() { |
|
|
for i := pk.NPublic + 1; i < pk.NVars; i++ { |
|
|
for i := pk.NPublic + 1; i < pk.NVars; i++ { |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(pk.C[i], w[i])) |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(pk.C[i], w[i])) |
|
|
} |
|
|
} |
|
|
wg.Done() |
|
|
wg.Done() |
|
|
}(&waitGroup) |
|
|
|
|
|
waitGroup.Wait() |
|
|
|
|
|
|
|
|
}() |
|
|
|
|
|
wg.Wait() |
|
|
|
|
|
|
|
|
h := calculateH(pk, w) |
|
|
h := calculateH(pk, w) |
|
|
|
|
|
|
|
|
var waitGroup2 sync.WaitGroup |
|
|
|
|
|
waitGroup2.Add(2) |
|
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
|
|
|
|
|
var wg2 sync.WaitGroup |
|
|
|
|
|
wg2.Add(2) |
|
|
|
|
|
go func() { |
|
|
proof.A = new(bn256.G1).Add(proof.A, pk.VkAlpha1) |
|
|
proof.A = new(bn256.G1).Add(proof.A, pk.VkAlpha1) |
|
|
proof.A = new(bn256.G1).Add(proof.A, new(bn256.G1).ScalarMult(pk.VkDelta1, r)) |
|
|
proof.A = new(bn256.G1).Add(proof.A, new(bn256.G1).ScalarMult(pk.VkDelta1, r)) |
|
|
|
|
|
|
|
@ -114,15 +114,15 @@ func GenerateProof(pk *types.Pk, w types.Witness) (*types.Proof, []*big.Int, err |
|
|
|
|
|
|
|
|
proofBG1 = new(bn256.G1).Add(proofBG1, pk.VkBeta1) |
|
|
proofBG1 = new(bn256.G1).Add(proofBG1, pk.VkBeta1) |
|
|
proofBG1 = new(bn256.G1).Add(proofBG1, new(bn256.G1).ScalarMult(pk.VkDelta1, s)) |
|
|
proofBG1 = new(bn256.G1).Add(proofBG1, new(bn256.G1).ScalarMult(pk.VkDelta1, s)) |
|
|
wg.Done() |
|
|
|
|
|
}(&waitGroup2) |
|
|
|
|
|
go func(wg *sync.WaitGroup) { |
|
|
|
|
|
|
|
|
wg2.Done() |
|
|
|
|
|
}() |
|
|
|
|
|
go func() { |
|
|
for i := 0; i < len(h); i++ { |
|
|
for i := 0; i < len(h); i++ { |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(pk.HExps[i], h[i])) |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(pk.HExps[i], h[i])) |
|
|
} |
|
|
} |
|
|
wg.Done() |
|
|
|
|
|
}(&waitGroup2) |
|
|
|
|
|
waitGroup2.Wait() |
|
|
|
|
|
|
|
|
wg2.Done() |
|
|
|
|
|
}() |
|
|
|
|
|
wg2.Wait() |
|
|
|
|
|
|
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(proof.A, s)) |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(proof.A, s)) |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(proofBG1, r)) |
|
|
proof.C = new(bn256.G1).Add(proof.C, new(bn256.G1).ScalarMult(proofBG1, r)) |
|
|