summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGab Virebent <gabriel1@virebent.art>2026-07-01 17:41:47 +0200
committerGab Virebent <gabriel1@virebent.art>2026-07-01 17:41:47 +0200
commit78d57b1090a5a23abce2a732f091a4ef007d60cc (patch)
tree997b816317241db94810f789eb7122857b27ddd2 /cmd
parentaa459e3b84cc4c5d908f3781c9253848c18640c3 (diff)
downloadnymdrop-78d57b1090a5a23abce2a732f091a4ef007d60cc.tar.gz
nymdrop-78d57b1090a5a23abce2a732f091a4ef007d60cc.tar.xz
nymdrop-78d57b1090a5a23abce2a732f091a4ef007d60cc.zip
Add client-side proof of work and fix X25519 WebCrypto API usage
Self-contained hashcash-style PoW on /submit: client finds a nonce so SHA-256("<unix-ts>:<nonce>") has enough leading zero bits, sent as an X-Nymdrop-Pow header; server verifies and rejects expired or replayed stamps, no challenge round-trip required. Difficulty tunable via --pow-difficulty without a rebuild. Also fixes a latent bug in the browser crypto: X25519 was being requested as ECDH with namedCurve "X25519", which is not a valid WebCrypto combination and always throws. Modern WebCrypto exposes X25519 as its own algorithm identifier.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/nymdrop/main.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/nymdrop/main.go b/cmd/nymdrop/main.go
index 9119b9c..c2090ce 100644
--- a/cmd/nymdrop/main.go
+++ b/cmd/nymdrop/main.go
@@ -8,6 +8,7 @@ import (
"nymdrop/internal/handler"
"nymdrop/internal/nolog"
"nymdrop/internal/nym"
+ "nymdrop/internal/pow"
"nymdrop/internal/relay"
)
@@ -21,6 +22,7 @@ func main() {
journalistAddr := flag.String("journalist", "", "journalist Nym address (required)")
staticDir := flag.String("static", "./static", "path to static files")
dryRun := flag.Bool("dry-run", false, "skip Nym, log payloads to stdout (testing only)")
+ powBits := flag.Int("pow-difficulty", 18, "required leading zero bits for the client-side proof of work")
flag.Parse()
if *journalistAddr == "" {
@@ -39,9 +41,10 @@ func main() {
defer nymClient.Stop()
r := relay.New(nymClient)
+ powVerifier := pow.NewVerifier(*powBits)
mux := http.NewServeMux()
- mux.Handle("/submit", handler.NewSubmit(r))
+ mux.Handle("/submit", handler.NewSubmit(r, powVerifier))
mux.Handle("/", handler.Static(*staticDir))
srv := &http.Server{