aboutsummaryrefslogtreecommitdiff
path: root/nizk/stage1.go
diff options
context:
space:
mode:
Diffstat (limited to 'nizk/stage1.go')
-rw-r--r--nizk/stage1.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/nizk/stage1.go b/nizk/stage1.go
index ee1be2c..453d683 100644
--- a/nizk/stage1.go
+++ b/nizk/stage1.go
@@ -69,10 +69,26 @@ func (b *Bit) StageFromScalars(x, r *Scalar) (c *StageCommitment) {
func (b *Bit) reveal(prev_true bool, Xs ...*Point) (r *StageReveal) {
s := b.Stage
- // TODO: Calculate Y based on the Xs and our own X_i
+ // Calculate Y based on the Xs and our own X_i
// as Π_(i<k) X_k / Π_(i>k) X_k
- // For now:
- Y := G
+ // (basically leaving our own X_i out in the calculation).
+ // We are assuming that Xs is ordered already.
+ Y := Curve.Identity()
+ found := false
+ for _, X := range Xs {
+ if !found && X.Equal(b.Stage.X) {
+ found = true
+ continue
+ }
+ if !found {
+ Y = Y.Mul(X)
+ } else {
+ Y = Y.Div(X)
+ }
+ }
+ if !found {
+ panic("own X not found in Xs")
+ }
r = &StageReveal{Y: Y}