Skip to content

Commit 069bccd

Browse files
Added TLSN proxy service and make Telegram backend host configurable
1 parent 50ab546 commit 069bccd

5 files changed

Lines changed: 89 additions & 32 deletions

File tree

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ TLSNOTARY_SIGNING_KEY=
7676
TLSNOTARY_PROXY_PORT=55688
7777
TLSNOTARY_MAX_SENT_DATA=16384
7878
TLSNOTARY_MAX_RECV_DATA=65536
79+
# Hostname of the OAuth backend as it appears in TLSNotary Telegram proofs.
80+
# Must match the domain your incentives OAuth backend is reachable at.
81+
# Example: oauth.demos.sh
82+
TLSN_TELEGRAM_BACKEND_HOST=
7983

8084
# ZK Identity System Configuration
8185
# Points awarded for each successful ZK attestation (default: 10)

src/libs/blockchain/gcr/gcr_routines/GCRIdentityRoutines.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ export default class GCRIdentityRoutines {
279279
context === "telegram"
280280
? "Telegram attestation validation failed"
281281
: "Sha256 proof mismatch: Expected " +
282-
data.proofHash +
283-
" but got " +
284-
Hashing.sha256(data.proof),
282+
data.proofHash +
283+
" but got " +
284+
Hashing.sha256(data.proof),
285285
}
286286
}
287287

@@ -593,9 +593,8 @@ export default class GCRIdentityRoutines {
593593
if (!validNetworks.includes(payload.network)) {
594594
return {
595595
success: false,
596-
message: `Invalid network: ${
597-
payload.network
598-
}. Must be one of: ${validNetworks.join(", ")}`,
596+
message: `Invalid network: ${payload.network
597+
}. Must be one of: ${validNetworks.join(", ")}`,
599598
}
600599
}
601600
if (!validRegistryTypes.includes(payload.registryType)) {
@@ -1201,14 +1200,16 @@ export default class GCRIdentityRoutines {
12011200
)
12021201
break
12031202
case "tlsnadd":
1203+
case "tlsn_identity_assign":
12041204
result = await this.applyTLSNIdentityAdd(
12051205
identityEdit,
12061206
gcrMainRepository,
12071207
simulate,
12081208
)
12091209
break
1210-
1210+
12111211
case "tlsnremove":
1212+
case "tlsn_identity_remove":
12121213
result = await this.applyTLSNIdentityRemove(
12131214
identityEdit,
12141215
gcrMainRepository,
@@ -1810,13 +1811,13 @@ export default class GCRIdentityRoutines {
18101811
string,
18111812
{ server: string; pathPrefix: string }
18121813
> = {
1813-
github: { server: "api.github.com", pathPrefix: "/user" },
1814-
discord: { server: "discord.com", pathPrefix: "/api/users/@me" },
1815-
telegram: {
1816-
server: "telegram-backend",
1817-
pathPrefix: "/api/telegram/user",
1818-
},
1819-
}
1814+
github: { server: "api.github.com", pathPrefix: "/user" },
1815+
discord: { server: "discord.com", pathPrefix: "/api/users/@me" },
1816+
telegram: {
1817+
server: process.env.TLSN_TELEGRAM_BACKEND_HOST ?? "telegram-backend",
1818+
pathPrefix: "/api/telegram/user",
1819+
},
1820+
}
18201821

18211822
/**
18221823
* Add an identity via TLSNotary proof verification.

tlsnotary/.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# TLSNotary Stack — Environment Variables
2+
# Copy this file to .env and adjust values as needed.
3+
#
4+
# Usage: docker compose --env-file .env up -d
5+
6+
# Port the TLSNotary notary server is exposed on.
7+
TLSNOTARY_PORT=7047
8+
9+
# Port the wstcp WebSocket-to-TCP proxy is exposed on.
10+
# Must match TLSNOTARY_PROXY_PORT in the node's .env and
11+
# PROXY_URL (ws://<host>:<port>) in the incentives backend .env.
12+
PROXY_PORT=55688

tlsnotary/Dockerfile.proxy

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# wstcp — WebSocket-to-TCP proxy for TLSNotary
2+
#
3+
# Forwards browser WebSocket connections to the notary's TCP port so that
4+
# tlsn-js (which cannot open raw TCP sockets) can reach the notary.
5+
#
6+
# Build: docker build -f Dockerfile.proxy -t tlsn-proxy .
7+
# Run: docker run -p 55688:55688 tlsn-proxy notary:7047
8+
9+
# ── Builder ──────────────────────────────────────────────────────────────────
10+
FROM rust:alpine AS builder
11+
12+
RUN apk add --no-cache musl-dev
13+
14+
RUN cargo install wstcp
15+
16+
# ── Runtime ──────────────────────────────────────────────────────────────────
17+
FROM alpine:3.20
18+
19+
RUN apk add --no-cache ca-certificates
20+
21+
COPY --from=builder /usr/local/cargo/bin/wstcp /usr/local/bin/wstcp
22+
23+
EXPOSE 55688
24+
25+
# First arg after the image is the TCP target (e.g. notary:7047).
26+
# Override via `command:` in docker-compose.
27+
ENTRYPOINT ["wstcp", "--bind-addr", "0.0.0.0:55688"]
28+
CMD ["notary:7047"]

tlsnotary/docker-compose.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# TLSNotary Docker Notary Server
2-
# Uses the official tlsn-js compatible notary server image
1+
# TLSNotary Stack
32
#
4-
# This provides the full HTTP API + WebSocket interface that tlsn-js expects:
5-
# - GET /info - Get notary public key
6-
# - POST /session - Create session, returns sessionId
7-
# - WS /notarize?sessionId=xxx - WebSocket MPC-TLS session
3+
# Services:
4+
# notary — TLSNotary notary server (HTTP API + WebSocket MPC-TLS sessions)
5+
# proxy — wstcp WebSocket-to-TCP proxy (lets browsers reach the notary)
86
#
9-
# Environment variables:
10-
# - TLSNOTARY_PORT: Port to expose (default: 7047)
7+
# Usage:
8+
# docker compose up -d
9+
#
10+
# Environment variables (copy .env.example → .env to override defaults):
11+
# TLSNOTARY_PORT Port the notary listens on (default: 7047)
12+
# PROXY_PORT Port the wstcp proxy listens on (default: 55688)
1113

1214
services:
1315
notary:
@@ -19,16 +21,26 @@ services:
1921
ports:
2022
- "${TLSNOTARY_PORT:-7047}:7047"
2123
restart: unless-stopped
22-
healthcheck:
23-
test: [CMD, curl, -f, http://localhost:7047/info]
24-
interval: 10s
25-
timeout: 5s
26-
retries: 3
27-
start_period: 10s
28-
# Note: The Docker notary-server uses its own internal signing key
29-
# Attestations are cryptographically bound to this notary's public key
30-
# which can be retrieved via GET /info endpoint
24+
networks:
25+
- tlsn
26+
27+
proxy:
28+
container_name: tlsn-proxy-${PROXY_PORT:-55688}
29+
build:
30+
context: .
31+
dockerfile: Dockerfile.proxy
32+
ports:
33+
- "${PROXY_PORT:-55688}:55688"
34+
# Forward WebSocket connections to the notary's internal TCP port.
35+
# Uses the Docker service name so the proxy can reach the notary
36+
# without exposing any extra ports on the host.
37+
command: ["notary:7047"]
38+
restart: unless-stopped
39+
depends_on:
40+
- notary
41+
networks:
42+
- tlsn
3143

3244
networks:
33-
default:
45+
tlsn:
3446
driver: bridge

0 commit comments

Comments
 (0)