aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auction.go16
-rw-r--r--bidder/auction.go19
-rw-r--r--bidder/bid.go4
-rw-r--r--bidder/bid_test.go6
4 files changed, 22 insertions, 23 deletions
diff --git a/auction.go b/auction.go
index df1d372..e4f53b7 100644
--- a/auction.go
+++ b/auction.go
@@ -7,8 +7,6 @@ import (
"encoding/base32"
"encoding/json"
"time"
-
- "kesim.org/seal/nizk/commit"
)
type Type int
@@ -38,20 +36,6 @@ type SignedDescription struct {
SellerSignature []byte
}
-// Auction is the simple interface for the engine
-type Auction interface {
- Join(bidder Bidder) // A bidder calls this to join the auction
- Message(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
-}
-
func (sd *SignedDescription) Verify() (bool, error) {
// TODO: need to normalize this encoding
buf := &bytes.Buffer{}
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)
}