From af8cde07213596f1064628833ada0a105b6b5461 Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Thu, 14 Nov 2024 20:16:07 +0100 Subject: simplify api even more, make it also more robust --- nizk/commit.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'nizk/commit.go') diff --git a/nizk/commit.go b/nizk/commit.go index 5634b16..ecb1568 100644 --- a/nizk/commit.go +++ b/nizk/commit.go @@ -38,18 +38,19 @@ type Proof struct { } } -func NewBit(id Bytes, set bool) *Bit { +func NewBit(id Bytes, set bool) (*Bit, *Commitment, *Proof) { α, β := Curve.RandomScalar(), Curve.RandomScalar() return NewBitFromScalars(id, set, α, β) } -func NewBitFromScalars(id Bytes, set bool, α, β *Scalar) *Bit { - return &Bit{ +func NewBitFromScalars(id Bytes, set bool, α, β *Scalar) (*Bit, *Commitment, *Proof) { + b := &Bit{ id: id, set: set, α: α, β: β, } + return b, b.commit(), b.proof() } func (b *Bit) IsSet() bool { @@ -122,10 +123,6 @@ func (s *Bit) proof() *Proof { return pr } -func (s *Bit) Commit() (*Commitment, *Proof) { - return s.commit(), s.proof() -} - func (c *Commitment) Verify(id Bytes, p *Proof) bool { var e [2][2]*Point -- cgit v1.2.3