diff options
Diffstat (limited to 'nizk/commit.go')
-rw-r--r-- | nizk/commit.go | 26 |
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) } |