aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bidder/auction.go22
-rw-r--r--bidder/bid.go6
-rw-r--r--bidder/bid_test.go6
-rw-r--r--bidder/option.go6
4 files changed, 16 insertions, 24 deletions
diff --git a/bidder/auction.go b/bidder/auction.go
index 7991504..15eca78 100644
--- a/bidder/auction.go
+++ b/bidder/auction.go
@@ -8,7 +8,7 @@ import (
"kesim.org/seal"
)
-type Auction struct {
+type auction struct {
description *seal.Description
bidder seal.Bidder
@@ -20,14 +20,14 @@ type Auction struct {
func nullf(string, ...any) {}
-func NewAuction(description *seal.Description, options ...Option) (auction *Auction, e error) {
+func NewAuction(description *seal.Description, options ...Option) (a *auction, e error) {
if description.BitLength > 63 {
return nil, fmt.Errorf("Invalid BitLength in description: %d", description.BitLength)
}
logger := log.New(os.Stdout, "[seal::client] ", log.LstdFlags)
- auction = &Auction{
+ a = &auction{
description: description,
log: logger.Printf,
verbose: nullf,
@@ -35,26 +35,18 @@ func NewAuction(description *seal.Description, options ...Option) (auction *Auct
}
for _, opt := range options {
- opt(auction)
+ opt(a)
}
- return auction, nil
+ return a, nil
}
-func (a *Auction) Join(price uint64) error {
- bidder, e := newBid(price, a.description.BitLength)
- if e != nil {
- return e
- }
-
- a.debug("created bid: %#v\n", bidder.(*bid))
-
+func (a *auction) Join(bidder seal.Bidder) {
a.bidder = bidder
- return nil
}
// Received is called by the consumer whenever a message came in for the auction via the dashboard
// or other means of communication.
-func (a *Auction) Received(msg []byte) error {
+func (a *auction) Received(msg []byte) error {
return fmt.Errorf("Auction.Received not implemented")
} \ No newline at end of file
diff --git a/bidder/bid.go b/bidder/bid.go
index 5aa27c2..55feaf8 100644
--- a/bidder/bid.go
+++ b/bidder/bid.go
@@ -4,7 +4,6 @@ import (
"crypto/ed25519"
"fmt"
- "kesim.org/seal"
. "kesim.org/seal/nizk"
"kesim.org/seal/nizk/commit"
@@ -23,7 +22,7 @@ type bid struct {
}
// NewBid creates a new Bidder for the given price, using the lower bits up to bitlength
-func newBid(price uint64, bitlength uint8) (seal.Bidder, error) {
+func NewBid(price uint64, bitlength uint8) (*bid, error) {
if bitlength > 63 {
return nil, fmt.Errorf("bitlength too large, maximum is 63")
} else if 0 != (price >> bitlength) {
@@ -65,5 +64,6 @@ func (bid *bid) Commit() (c []*commit.Commitment, pub ed25519.PublicKey, sig []b
func (bid *bid) Result() {
}
-func (bid *bid) Send(msg []byte, sig []byte) {
+func (bid *bid) Send(msg []byte, sig []byte) error {
+ return fmt.Errorf("bidder.Send not implemented")
} \ No newline at end of file
diff --git a/bidder/bid_test.go b/bidder/bid_test.go
index a479e5d..de6afd9 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)
}
diff --git a/bidder/option.go b/bidder/option.go
index 45b4729..d1c9783 100644
--- a/bidder/option.go
+++ b/bidder/option.go
@@ -5,14 +5,14 @@ import (
"os"
)
-type Option func(auction *Auction)
+type Option func(auction *auction)
-func OptVerbose(a *Auction) {
+func OptVerbose(a *auction) {
logger := log.New(os.Stdout, "[seal::client][verbose] ", log.LstdFlags)
a.verbose = logger.Printf
}
-func OptDebug(a *Auction) {
+func OptDebug(a *auction) {
logger := log.New(os.Stdout, "[seal::client][debug] ", log.LstdFlags)
a.debug = logger.Printf
}