Implement end-to-end encrypted buyer/seller messaging
Wire format (internal/message): sealed boxes to the listing's device key (X25519 + HKDF + ChaCha20-Poly1305), padded, proof-of-work stamped, with signed owner replies and address grants. Relay validation, bounded queues, gossip on per-region message topics and sync (store, p2p). Owner side (internal/inbox, API): inbox with hidden link messages and a per-day new-thread limit, replies, grants, and a private per-listing address. Public POST/GET /api/v1/messages for buyers. Browser: noble-based sealing and reply verification checked against a Go fixture, contact form, conversation view, message list, de/en strings. Docs: PROTOCOL.md messaging section matches the implementation. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+17
-2
@@ -16,7 +16,9 @@ import (
|
||||
|
||||
"git.stinnesbeck.com/nils/allmende/internal/api"
|
||||
"git.stinnesbeck.com/nils/allmende/internal/identity"
|
||||
"git.stinnesbeck.com/nils/allmende/internal/inbox"
|
||||
"git.stinnesbeck.com/nils/allmende/internal/listing"
|
||||
"git.stinnesbeck.com/nils/allmende/internal/message"
|
||||
"git.stinnesbeck.com/nils/allmende/internal/p2p"
|
||||
"git.stinnesbeck.com/nils/allmende/internal/store"
|
||||
)
|
||||
@@ -37,7 +39,11 @@ func cmdRun(args []string) error {
|
||||
httpAddr := fs.String("http", "127.0.0.1:8080", "address for the HTTP API")
|
||||
noMDNS := fs.Bool("no-mdns", false, "do not look for peers on the local network")
|
||||
difficulty := fs.Int("difficulty", listing.DefaultDifficulty,
|
||||
"proof-of-work bits; must match the rest of the network")
|
||||
"proof-of-work bits for listings; must match the rest of the network")
|
||||
msgDifficulty := fs.Int("message-difficulty", message.DefaultDifficulty,
|
||||
"proof-of-work bits for messages; must match the rest of the network")
|
||||
maxNewThreads := fs.Int("max-new-threads", inbox.DefaultMaxNewThreads,
|
||||
"how many new conversations each of your listings can start per day")
|
||||
fs.Parse(args)
|
||||
|
||||
if len(regions) == 0 {
|
||||
@@ -61,7 +67,9 @@ func cmdRun(args []string) error {
|
||||
"expires", time.Unix(dev.Cert.ExpiresAt, 0).Format("2006-01-02"))
|
||||
}
|
||||
|
||||
st, err := store.Open(filepath.Join(*data, dbFile), store.Options{Difficulty: *difficulty})
|
||||
st, err := store.Open(filepath.Join(*data, dbFile), store.Options{
|
||||
Difficulty: *difficulty, MessageDifficulty: *msgDifficulty,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -79,6 +87,8 @@ func cmdRun(args []string) error {
|
||||
MDNS: !*noMDNS,
|
||||
Difficulty: *difficulty,
|
||||
Logger: log,
|
||||
|
||||
MessageDifficulty: *msgDifficulty,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -91,6 +101,11 @@ func cmdRun(args []string) error {
|
||||
}
|
||||
handler := api.New(api.Config{
|
||||
Store: st, Node: node, Device: dev, Regions: regions, Token: token, Difficulty: *difficulty,
|
||||
MessageDifficulty: *msgDifficulty,
|
||||
Inbox: &inbox.Inbox{
|
||||
Store: st, Device: dev, Publisher: node,
|
||||
Difficulty: *msgDifficulty, MaxNewThreads: *maxNewThreads,
|
||||
},
|
||||
})
|
||||
|
||||
ln, err := net.Listen("tcp", *httpAddr)
|
||||
|
||||
Reference in New Issue
Block a user