aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2024-04-07 13:21:53 +0200
committerÖzgür Kesim <oec@codeblau.de>2024-04-07 13:21:53 +0200
commit438b69e74b416918ef855c4a28d90779ea1e455c (patch)
tree7a5d02831cb63ebda981d05b6b9a826fa2bc7596
parent5733f293044bfe0d3210e7c4688172d53d54a7e0 (diff)
client->bidder
-rw-r--r--auction.go4
-rw-r--r--bidder/auction.go (renamed from client/client.go)16
-rw-r--r--bidder/bid.go (renamed from client/bid.go)11
-rw-r--r--bidder/bid_test.go (renamed from client/bid_test.go)2
-rw-r--r--bidder/option.go (renamed from client/option.go)2
5 files changed, 23 insertions, 12 deletions
diff --git a/auction.go b/auction.go
index 50d6a2b..aeff7b3 100644
--- a/auction.go
+++ b/auction.go
@@ -36,9 +36,7 @@ type SignedDesciption struct {
}
// Bidder is the interface that the Auction engine uses to communicate
-// with an bidder implementation
type Bidder interface {
Result()
- Broadcast()
- Unicast()
+ Send(msg []byte, sig []byte)
}
diff --git a/client/client.go b/bidder/auction.go
index 19f0d35..7991504 100644
--- a/client/client.go
+++ b/bidder/auction.go
@@ -1,4 +1,4 @@
-package client
+package bidder
import (
"fmt"
@@ -11,7 +11,7 @@ import (
type Auction struct {
description *seal.Description
- bid *bid
+ bidder seal.Bidder
log func(string, ...any)
verbose func(string, ...any)
@@ -42,13 +42,19 @@ func NewAuction(description *seal.Description, options ...Option) (auction *Auct
}
func (a *Auction) Join(price uint64) error {
- bid, e := newBid(price, a.description.BitLength)
+ bidder, e := newBid(price, a.description.BitLength)
if e != nil {
return e
}
- a.debug("created bid: %#v\n", bid)
+ a.debug("created bid: %#v\n", bidder.(*bid))
- a.bid = bid
+ 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 {
+ return fmt.Errorf("Auction.Received not implemented")
+} \ No newline at end of file
diff --git a/client/bid.go b/bidder/bid.go
index 3651d1d..5aa27c2 100644
--- a/client/bid.go
+++ b/bidder/bid.go
@@ -1,9 +1,10 @@
-package client
+package bidder
import (
"crypto/ed25519"
"fmt"
+ "kesim.org/seal"
. "kesim.org/seal/nizk"
"kesim.org/seal/nizk/commit"
@@ -22,7 +23,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) (*bid, error) {
+func newBid(price uint64, bitlength uint8) (seal.Bidder, error) {
if bitlength > 63 {
return nil, fmt.Errorf("bitlength too large, maximum is 63")
} else if 0 != (price >> bitlength) {
@@ -59,4 +60,10 @@ func (bid *bid) Commit() (c []*commit.Commitment, pub ed25519.PublicKey, sig []b
c[i] = bid.bits[i].Commit()
}
return c, bid.ID, nil
+}
+
+func (bid *bid) Result() {
+}
+
+func (bid *bid) Send(msg []byte, sig []byte) {
} \ No newline at end of file
diff --git a/client/bid_test.go b/bidder/bid_test.go
index 52c4c3c..a479e5d 100644
--- a/client/bid_test.go
+++ b/bidder/bid_test.go
@@ -1,4 +1,4 @@
-package client
+package bidder
import (
"testing"
diff --git a/client/option.go b/bidder/option.go
index c2b1e5d..45b4729 100644
--- a/client/option.go
+++ b/bidder/option.go
@@ -1,4 +1,4 @@
-package client
+package bidder
import (
"log"