diff options
Diffstat (limited to 'bidder')
-rw-r--r-- | bidder/auction.go | 19 | ||||
-rw-r--r-- | bidder/bid.go | 4 | ||||
-rw-r--r-- | bidder/bid_test.go | 6 |
3 files changed, 22 insertions, 7 deletions
diff --git a/bidder/auction.go b/bidder/auction.go index 5331136..a22f005 100644 --- a/bidder/auction.go +++ b/bidder/auction.go @@ -6,12 +6,27 @@ import ( "os" "kesim.org/seal" + "kesim.org/seal/nizk/commit" ) +// Auction is the simple interface for the engine +type Auction interface { + Join(bidder Bidder) // A bidder calls this to join the auction + GotMessage(msg []byte, sig []byte) error // A bidder uses this method to publish a message +} + +// Bidder is the interface that the Auction engine uses to communicate +type Bidder interface { + Commitment() *commit.Commitment + Start(map[string]*commit.Commitment) + Result() + Receive(msg []byte) error +} + type auction struct { description *seal.Description - bidder seal.Bidder + bidder Bidder log func(string, ...any) verbose func(string, ...any) @@ -41,7 +56,7 @@ func NewAuction(description *seal.Description, options ...Option) (a *auction, e return a, nil } -func (a *auction) Join(bidder seal.Bidder) { +func (a *auction) Join(bidder Bidder) { a.bidder = bidder } diff --git a/bidder/bid.go b/bidder/bid.go index ba93a64..5f98a0c 100644 --- a/bidder/bid.go +++ b/bidder/bid.go @@ -31,8 +31,8 @@ type bid struct { 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) (b *bid, e error) { +// newBid creates a new Bidder for the given price, using the lower bits up to bitlength +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) { diff --git a/bidder/bid_test.go b/bidder/bid_test.go index de6afd9..a479e5d 100644 --- a/bidder/bid_test.go +++ b/bidder/bid_test.go @@ -5,21 +5,21 @@ import ( ) func TestBitlengthTooLarge(t *testing.T) { - bid, e := NewBid(0xFFFFFF, 70) + bid, e := newBid(0xFFFFFF, 70) if e == nil { t.Fatalf("failure expected, but got bid: %#v", bid) } } func TestPriceTooLarge(t *testing.T) { - bid, e := NewBid(0xFFFFFF, 8) + bid, e := newBid(0xFFFFFF, 8) if e == nil { t.Fatalf("failure expected, but got bid: %#v", bid) } } func TestBidOK(t *testing.T) { - bid, e := NewBid(102400, 24) + bid, e := newBid(102400, 24) if e != nil { t.Fatalf("unexpected error: %v", e) } |