diff options
author | Özgür Kesim <oec@codeblau.de> | 2024-11-15 10:57:43 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2024-11-15 10:57:43 +0100 |
commit | de44f1a28bc8d14f5ae1aecc11edc0624a330ec4 (patch) | |
tree | 7d329624a14ae872f5b15f8619fa8c5d75c50a0b /nizk/commit.go | |
parent | 53b2c23ec4d2260c930d6403b04a6564c0a36245 (diff) |
simplify NewBit signature
Diffstat (limited to 'nizk/commit.go')
-rw-r--r-- | nizk/commit.go | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/nizk/commit.go b/nizk/commit.go index ecb1568..93c730f 100644 --- a/nizk/commit.go +++ b/nizk/commit.go @@ -12,7 +12,7 @@ type Bit struct { β *Scalar *Commitment - prf *Proof + Proof *Proof *Stage } @@ -38,28 +38,30 @@ type Proof struct { } } -func NewBit(id Bytes, set bool) (*Bit, *Commitment, *Proof) { +func NewBit(id Bytes, set bool) *Bit { α, β := Curve.RandomScalar(), Curve.RandomScalar() return NewBitFromScalars(id, set, α, β) } -func NewBitFromScalars(id Bytes, set bool, α, β *Scalar) (*Bit, *Commitment, *Proof) { +func NewBitFromScalars(id Bytes, set bool, α, β *Scalar) *Bit { b := &Bit{ id: id, set: set, α: α, β: β, } - return b, b.commit(), b.proof() + b.commit() + b.proof() + return b } func (b *Bit) IsSet() bool { return b.set } -func (b *Bit) commit() *Commitment { +func (b *Bit) commit() { if b.Commitment != nil { - return b.Commitment + return } var C *Point @@ -75,12 +77,11 @@ func (b *Bit) commit() *Commitment { A: G.Exp(b.α), B: G.Exp(b.β), } - return b.Commitment } -func (s *Bit) proof() *Proof { - if s.prf != nil { - return s.prf +func (s *Bit) proof() { + if s.Proof != nil { + return } var e [2][2]*Point @@ -88,7 +89,8 @@ func (s *Bit) proof() *Proof { r1 = Curve.RandomScalar() r2 = Curve.RandomScalar() w = Curve.RandomScalar() - c := s.commit() + s.commit() + c := s.Commitment if s.set { e[0][0] = G.Exp(r1) @@ -119,8 +121,7 @@ func (s *Bit) proof() *Proof { pr.A = (*schnorr.Statement)(s.α).Proof(s.id) pr.B = (*schnorr.Statement)(s.β).Proof(s.id) - s.prf = pr - return pr + s.Proof = pr } func (c *Commitment) Verify(id Bytes, p *Proof) bool { |