aboutsummaryrefslogtreecommitdiff
path: root/bidder/bid.go
diff options
context:
space:
mode:
Diffstat (limited to 'bidder/bid.go')
-rw-r--r--bidder/bid.go28
1 files changed, 12 insertions, 16 deletions
diff --git a/bidder/bid.go b/bidder/bid.go
index 55feaf8..5a87aa1 100644
--- a/bidder/bid.go
+++ b/bidder/bid.go
@@ -1,7 +1,6 @@
package bidder
import (
- "crypto/ed25519"
"fmt"
. "kesim.org/seal/nizk"
@@ -10,8 +9,9 @@ import (
)
type bid struct {
- id ed25519.PrivateKey
- ID ed25519.PublicKey
+ // TODO: These should probably become ed25519.(Private|Public)Key's
+ id *Scalar
+ Id *Point
price uint64 // bigendian encoding of the bid
n uint8 // number of bits encoded in zbid.
@@ -29,18 +29,14 @@ func NewBid(price uint64, bitlength uint8) (*bid, error) {
return nil, fmt.Errorf("price %d too large for given bitlength %d", price, bitlength)
}
- var (
- e error
- bid = &bid{
- price: price,
- }
- )
-
- bid.ID, bid.id, e = ed25519.GenerateKey(nil)
- if e != nil {
- return nil, e
+ bid := &bid{
+ price: price,
+ n: bitlength,
}
+ bid.id = Curve.RandomScalar()
+ bid.Id = G.Exp(bid.id)
+
bid.bits = make([]*commit.Statement, bitlength)
for i := bitlength; i > 0; i-- {
set := (price>>(i-1)&1 != 0)
@@ -53,12 +49,12 @@ func NewBid(price uint64, bitlength uint8) (*bid, error) {
// Commit returns the public commitment to the bits and a signature
// TODO: return signature over bid
-func (bid *bid) Commit() (c []*commit.Commitment, pub ed25519.PublicKey, sig []byte) {
+func (bid *bid) Commit() (c []*commit.Commitment) {
c = make([]*commit.Commitment, len(bid.bits))
for i := range bid.bits {
- c[i] = bid.bits[i].Commit()
+ c[i] = bid.bits[i].Commit(bid.Id)
}
- return c, bid.ID, nil
+ return c
}
func (bid *bid) Result() {