diff options
author | Özgür Kesim <oec@codeblau.de> | 2024-11-14 20:16:07 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2024-11-14 20:16:07 +0100 |
commit | af8cde07213596f1064628833ada0a105b6b5461 (patch) | |
tree | 39a83e6533eefa28c98fe2af62b252fffb086cc4 /nizk/commit.go | |
parent | 04c4b67fcaa85c9b4d8bc379b6938a169866e093 (diff) |
simplify api even more, make it also more robust
Diffstat (limited to 'nizk/commit.go')
-rw-r--r-- | nizk/commit.go | 11 |
1 files changed, 4 insertions, 7 deletions
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 |