diff options
Diffstat (limited to 'bidder')
-rw-r--r-- | bidder/auction.go | 2 | ||||
-rw-r--r-- | bidder/bid.go | 44 |
2 files changed, 29 insertions, 17 deletions
diff --git a/bidder/auction.go b/bidder/auction.go index 15eca78..5331136 100644 --- a/bidder/auction.go +++ b/bidder/auction.go @@ -45,7 +45,7 @@ func (a *auction) Join(bidder seal.Bidder) { a.bidder = bidder } -// Received is called by the consumer whenever a message came in for the auction via the dashboard +// Received is called by the bidder whenever a message came in for the auction via the dashboard // or other means of communication. func (a *auction) Received(msg []byte) error { return fmt.Errorf("Auction.Received not implemented") diff --git a/bidder/bid.go b/bidder/bid.go index 5a87aa1..ba93a64 100644 --- a/bidder/bid.go +++ b/bidder/bid.go @@ -1,50 +1,62 @@ package bidder import ( + "crypto/ed25519" "fmt" . "kesim.org/seal/nizk" "kesim.org/seal/nizk/commit" + "kesim.org/seal/nizk/stage1" ) type bid struct { - // TODO: These should probably become ed25519.(Private|Public)Key's - id *Scalar - Id *Point + id ed25519.PrivateKey + Id ed25519.PublicKey - price uint64 // bigendian encoding of the bid - n uint8 // number of bits encoded in zbid. + price uint64 // bigendian encoding of the bid + bitlength uint8 // number of bits encoded in price. // bits are derived from zbid and the zero element in // the slice corresponds to the highest bit in zbid bits []*commit.Statement + + // The commitments we received from the bidders. + bidders map[string][]*commit.Commitment + + // sorted list of the bidders. + bidder_ids []string + + // Stage 1 data per round + stage1 []*stage1.Statement } // NewBid creates a new Bidder for the given price, using the lower bits up to bitlength -func NewBid(price uint64, bitlength uint8) (*bid, error) { +func NewBid(price uint64, bitlength uint8) (b *bid, e error) { if bitlength > 63 { return nil, fmt.Errorf("bitlength too large, maximum is 63") } else if 0 != (price >> bitlength) { return nil, fmt.Errorf("price %d too large for given bitlength %d", price, bitlength) } - bid := &bid{ - price: price, - n: bitlength, + b = &bid{ + price: price, + bitlength: bitlength, } - bid.id = Curve.RandomScalar() - bid.Id = G.Exp(bid.id) + b.Id, b.id, e = ed25519.GenerateKey(nil) + if e != nil { + return nil, e + } - bid.bits = make([]*commit.Statement, bitlength) + b.bits = make([]*commit.Statement, bitlength) for i := bitlength; i > 0; i-- { set := (price>>(i-1)&1 != 0) - a, b := Curve.RandomScalar(), Curve.RandomScalar() - bid.bits[i-1] = commit.NewStatement(a, b, set) + x, r := Curve.RandomScalar(), Curve.RandomScalar() + b.bits[i-1] = commit.NewStatement(x, r, set) } - return bid, nil + return b, nil } // Commit returns the public commitment to the bits and a signature @@ -52,7 +64,7 @@ func NewBid(price uint64, bitlength uint8) (*bid, error) { 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(bid.Id) + c[i] = bid.bits[i].Commit(Bites(bid.Id)) } return c } |