summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 2a84e1a226def2d3a25c1f66043a1f2f7b8ad794 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# NoshiTalk v2.0.0 - Zero-Knowledge Encrypted Chat

Sistema di chat sicuro con crittografia end-to-end e architettura zero-knowledge.

## Caratteristiche

- **End-to-End Encryption**: X25519 ECDH + AES-GCM-256
- **Perfect Forward Secrecy**: Chiavi effimere per ogni sessione
- **Zero-Knowledge Server**: Il server è un relay cieco - non può leggere i messaggi
- **Memory Protection**: memguard per protezione della memoria
- **Zero Logging**: Nessun dato viene salvato su disco
- **Tor Ready**: Configurabile come hidden service

## Architettura

```
Browser (Web Crypto API)
    ↓ SSE (Server-Sent Events) + HTTP POST
Go Server (blind relay)
    ↓ SSE + POST
Browser (Web Crypto API)
```

La crittografia avviene interamente nel browser:
1. Il browser genera keypair X25519 effimero
2. Scambia chiavi pubbliche con altri utenti via server
3. Deriva shared secret con ECDH
4. Cripta/decripta messaggi con AES-GCM-256

Il server vede solo blob crittografati.

## Build

```bash
# Richiede Go 1.21+
go mod tidy
CGO_ENABLED=0 go build -ldflags="-s -w" -o noshitalk main.go
```

## Esecuzione

```bash
# Default porta 8080
./noshitalk

# Porta custom
NOSHITALK_PORT=3000 ./noshitalk
```

## Deployment con Tor Hidden Service

1. Installa Tor:
```bash
apt install tor
```

2. Configura `/etc/tor/torrc`:
```
HiddenServiceDir /var/lib/tor/noshitalk/
HiddenServicePort 80 127.0.0.1:8080
```

3. Riavvia Tor:
```bash
systemctl restart tor
```

4. Ottieni indirizzo .onion:
```bash
cat /var/lib/tor/noshitalk/hostname
```

## Deployment con Apache (opzionale)

```apache
<VirtualHost *:443>
    ServerName chat.example.com
    
    SSLEngine on
    SSLCertificateFile /path/to/cert.pem
    SSLCertificateKeyFile /path/to/key.pem
    
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/
    
    # SSE requires no buffering
    SetEnv proxy-sendchunked 1
    SetEnv proxy-nokeepalive 1
</VirtualHost>
```

## Systemd Service

Crea `/etc/systemd/system/noshitalk.service`:

```ini
[Unit]
Description=NoshiTalk Secure Chat
After=network.target

[Service]
Type=simple
User=noshitalk
ExecStart=/opt/noshitalk/noshitalk
Restart=on-failure
RestartSec=5
Environment=NOSHITALK_PORT=8080

# Security hardening
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes

[Install]
WantedBy=multi-user.target
```

```bash
systemctl daemon-reload
systemctl enable noshitalk
systemctl start noshitalk
```

## API Endpoints

| Endpoint | Method | Descrizione |
|----------|--------|-------------|
| `/` | GET | Interfaccia web |
| `/join` | POST | Entra in chat |
| `/leave` | POST | Esci dalla chat |
| `/events` | GET | SSE stream messaggi |
| `/send` | POST | Invia messaggio |
| `/key-exchange` | GET/POST | Scambio chiavi pubbliche |
| `/health` | GET | Health check |

## Sicurezza

- **Browser**: Web Crypto API per X25519/AES-GCM (nativo, no librerie esterne)
- **Server**: memguard per protezione memoria, cleanup sicuro
- **Rete**: Supporto TLS, Tor hidden service
- **Policy**: Zero logging, auto-purge alla disconnessione

## File

```
noshitalk-web/
├── main.go              # Server Go con SSE
├── static/
│   └── index.html       # Frontend con Web Crypto API
├── go.mod
├── go.sum
└── README.md
```

## Note

- Il browser DEVE supportare Web Crypto API con X25519 (Chrome 113+, Firefox 72+)
- Per browser più vecchi, considera fallback a curve25519-js (non incluso)
- La chat pubblica attualmente usa encryption semplificata per demo
- Per produzione seria, implementa proper group encryption (Signal Protocol)

## Licenza

MIT