aboutsummaryrefslogtreecommitdiff
path: root/nizk
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@kesim.org>2024-11-10 11:53:19 +0100
committerÖzgür Kesim <oec@kesim.org>2024-11-10 11:53:19 +0100
commitf98e43234a3b7a9823ac9b9e68c7c595c10ebe7d (patch)
tree2e1e5dac6c3a3ae4465baeb9179d0718c5cd8b28 /nizk
parent2100500f1a0a8534a5d6f900b4e35ad9a09aa339 (diff)
start refactor
Diffstat (limited to 'nizk')
-rw-r--r--nizk/commit/commit.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/nizk/commit/commit.go b/nizk/commit/commit.go
index d044077..84ba8e5 100644
--- a/nizk/commit/commit.go
+++ b/nizk/commit/commit.go
@@ -12,10 +12,10 @@ import (
// for given C, A and B
type Statement struct {
+ bitSet bool
a *Scalar
b *Scalar
- plus bool
- *Commitment
+ Commitment
}
type Commitment struct {
@@ -25,25 +25,25 @@ type Commitment struct {
Proof *Proof
}
-func NewStatement(a, b *Scalar, plus bool) *Statement {
+func NewStatement(a, b *Scalar, bitSet bool) *Statement {
return &Statement{
a: a,
b: b,
- plus: plus,
- Commitment: commitment(a, b, plus),
+ bitSet: bitSet,
+ Commitment: commitment(a, b, bitSet),
}
}
-func commitment(a, b *Scalar, plus bool) *Commitment {
+func commitment(a, b *Scalar, bitSet bool) Commitment {
var C *Point
c := a.Mul(b)
- if plus {
+ if bitSet {
C = G.Exp(c.Add(One))
} else {
C = G.Exp(c)
}
- return &Commitment{
+ return Commitment{
C: C,
A: G.Exp(a),
B: G.Exp(b),
@@ -52,7 +52,7 @@ func commitment(a, b *Scalar, plus bool) *Commitment {
func (s *Statement) Commit(id Bytes) *Commitment {
s.Commitment.Proof = s.Proof(id)
- return s.Commitment
+ return &s.Commitment
}
type Proof struct {
@@ -72,7 +72,7 @@ func (s *Statement) Proof(id Bytes) *Proof {
r2 = Curve.RandomScalar()
w = Curve.RandomScalar()
- if s.plus {
+ if s.bitSet {
e[0][0] = G.Exp(r1)
e[0][1] = s.B.Exp(r1).Mul(G.Exp(w))
e[1][0] = G.Exp(r2)
@@ -87,7 +87,7 @@ func (s *Statement) Proof(id Bytes) *Proof {
ch := Challenge(G, s.C, s.A, s.B, e[0][0], e[0][1], e[1][0], e[1][1], id)
pr := &Proof{Id: id}
- if s.plus {
+ if s.bitSet {
pr.C.Ch[0] = w
pr.C.Ch[1] = ch.Sub(w)
pr.C.R[0] = r1.Sub(s.a.Mul(pr.C.Ch[0]))