Add browser UI with in-browser signature verification
Every node now serves a search and listing-detail UI at GET /. It is vanilla TypeScript, bundled unminified into web/dist (committed) and embedded with go:embed, so `go build` is enough to run a node. The browser verifies each listing itself (certificate, binding, validity, signature, proof-of-work) with pure-JS ed25519, so a gateway can withhold listings but not forge them. Unverifiable results are hidden and their content is never shown. Listing text is only inserted via textContent and the UI is served with a strict CSP. Canonical JSON is reimplemented in TypeScript and tested against a golden fixture signed by the Go code. /api/v1/status now reports difficulty. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,15 @@ func Generate() (*Identity, error) {
|
||||
return &Identity{priv: priv}, nil
|
||||
}
|
||||
|
||||
// FromSeed builds an identity from a 32-byte ed25519 seed. It exists so tests
|
||||
// and fixtures can use fixed keys; real keys come from Generate or a phrase.
|
||||
func FromSeed(seed []byte) (*Identity, error) {
|
||||
if len(seed) != ed25519.SeedSize {
|
||||
return nil, fmt.Errorf("identity: seed must be %d bytes", ed25519.SeedSize)
|
||||
}
|
||||
return &Identity{priv: ed25519.NewKeyFromSeed(seed)}, nil
|
||||
}
|
||||
|
||||
// Load reads an identity previously written by Save.
|
||||
func Load(path string) (*Identity, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
|
||||
Reference in New Issue
Block a user