DChain single-node blockchain + React Native messenger client. Core: - PBFT consensus with multi-sig validator admission + equivocation slashing - BadgerDB + schema migration scaffold (CurrentSchemaVersion=0) - libp2p gossipsub (tx/v1, blocks/v1, relay/v1, version/v1) - Native Go contracts (username_registry) alongside WASM (wazero) - WebSocket gateway with topic-based fanout + Ed25519-nonce auth - Relay mailbox with NaCl envelope encryption (X25519 + Ed25519) - Prometheus /metrics, per-IP rate limit, body-size cap Deployment: - Single-node compose (deploy/single/) with Caddy TLS + optional Prometheus - 3-node dev compose (docker-compose.yml) with mocked internet topology - 3-validator prod compose (deploy/prod/) for federation - Auto-update from Gitea via /api/update-check + systemd timer - Build-time version injection (ldflags → node --version) - UI / Swagger toggle flags (DCHAIN_DISABLE_UI, DCHAIN_DISABLE_SWAGGER) Client (client-app/): - Expo / React Native / NativeWind - E2E NaCl encryption, typing indicator, contact requests - Auto-discovery of canonical contracts, chain_id aware, WS reconnect on node switch Documentation: - README.md, CHANGELOG.md, CONTEXT.md - deploy/single/README.md with 6 operator scenarios - deploy/UPDATE_STRATEGY.md with 4-layer forward-compat design - docs/contracts/*.md per contract
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
// cmd/peerid — prints the libp2p peer ID for a key file.
|
|
// Usage: peerid --key node1.json
|
|
package main
|
|
|
|
import (
|
|
"crypto/ed25519"
|
|
"encoding/hex"
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
libp2pcrypto "github.com/libp2p/go-libp2p/core/crypto"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
)
|
|
|
|
type keyJSON struct {
|
|
PubKey string `json:"pub_key"`
|
|
PrivKey string `json:"priv_key"`
|
|
}
|
|
|
|
func main() {
|
|
keyFile := flag.String("key", "", "path to key JSON file")
|
|
listenIP := flag.String("ip", "0.0.0.0", "IP for multiaddr output")
|
|
port := flag.String("port", "4001", "port for multiaddr output")
|
|
flag.Parse()
|
|
|
|
if *keyFile == "" {
|
|
log.Fatal("--key is required")
|
|
}
|
|
|
|
data, err := os.ReadFile(*keyFile)
|
|
if err != nil {
|
|
log.Fatalf("read key: %v", err)
|
|
}
|
|
var kj keyJSON
|
|
if err := json.Unmarshal(data, &kj); err != nil {
|
|
log.Fatalf("parse key: %v", err)
|
|
}
|
|
|
|
privBytes, err := hexDecode(kj.PrivKey)
|
|
if err != nil {
|
|
log.Fatalf("decode priv key: %v", err)
|
|
}
|
|
|
|
privStd := ed25519.PrivateKey(privBytes)
|
|
lk, _, err := libp2pcrypto.KeyPairFromStdKey(&privStd)
|
|
if err != nil {
|
|
log.Fatalf("convert key: %v", err)
|
|
}
|
|
|
|
pid, err := peer.IDFromPrivateKey(lk)
|
|
if err != nil {
|
|
log.Fatalf("peer ID: %v", err)
|
|
}
|
|
|
|
fmt.Printf("pub_key: %s\n", kj.PubKey)
|
|
fmt.Printf("peer_id: %s\n", pid)
|
|
fmt.Printf("multiaddr: /ip4/%s/tcp/%s/p2p/%s\n", *listenIP, *port, pid)
|
|
}
|
|
|
|
func hexDecode(s string) ([]byte, error) {
|
|
return hex.DecodeString(s)
|
|
}
|