aboutsummaryrefslogtreecommitdiff
path: root/nizk/commit.go
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2024-11-12 10:45:26 +0100
committerÖzgür Kesim <oec@codeblau.de>2024-11-12 10:45:26 +0100
commit023e460a8729e28bb398948f3279c58e38712cb8 (patch)
tree0ad102e02a7ac9af9967b6d1b8fc866c5eeb4287 /nizk/commit.go
parentad14fd02ec12a06ff72049c57364cfef22a107a2 (diff)
refactor: commit and stage1 now incremental
Diffstat (limited to 'nizk/commit.go')
-rw-r--r--nizk/commit.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/nizk/commit.go b/nizk/commit.go
index 7f46d36..5b703d9 100644
--- a/nizk/commit.go
+++ b/nizk/commit.go
@@ -11,7 +11,7 @@ import (
//
// for given C, A and B
-type Bid struct {
+type Bit struct {
bitSet bool
α *Scalar
β *Scalar
@@ -23,32 +23,32 @@ type Commitment struct {
C *Point // g^(ab)g^(bitSet)
}
-func NewBid(bitSet bool) *Bid {
+func NewBit(bitSet bool) *Bit {
α, β := Curve.RandomScalar(), Curve.RandomScalar()
- return NewBidFromScalars(bitSet, α, β)
+ return NewBitFromScalars(bitSet, α, β)
}
-func NewBidFromScalars(bitSet bool, α, β *Scalar) *Bid {
- return &Bid{
+func NewBitFromScalars(bitSet bool, α, β *Scalar) *Bit {
+ return &Bit{
α: α,
β: β,
bitSet: bitSet,
}
}
-func commitment(α, β *Scalar, bitSet bool) *Commitment {
+func (b *Bit) commitment() *Commitment {
var C *Point
- c := α.Mul(β)
+ c := b.α.Mul(b.β)
- if bitSet {
+ if b.bitSet {
C = G.Exp(c.Add(One))
} else {
C = G.Exp(c)
}
return &Commitment{
C: C,
- A: G.Exp(α),
- B: G.Exp(β),
+ A: G.Exp(b.α),
+ B: G.Exp(b.β),
}
}
@@ -62,7 +62,7 @@ type Proof struct {
}
}
-func (s *Bid) proof(id Bytes, c *Commitment) *Proof {
+func (s *Bit) proof(id Bytes, c *Commitment) *Proof {
var e [2][2]*Point
var r1, r2, w *Scalar
r1 = Curve.RandomScalar()
@@ -101,8 +101,8 @@ func (s *Bid) proof(id Bytes, c *Commitment) *Proof {
return pr
}
-func (s *Bid) Commit(id Bytes) (*Commitment, *Proof) {
- c := commitment(s.α, s.β, s.bitSet)
+func (s *Bit) Commit(id Bytes) (*Commitment, *Proof) {
+ c := s.commitment()
return c, s.proof(id, c)
}