diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-19 17:58:05 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-19 17:58:05 +0200 |
| commit | 1ec316035ce9aa656dd18a05889856bce9e3aba3 (patch) | |
| tree | b50e97f50d485ef2a88ce36fe4d7511d9fe3e288 /poc/spike5_node.py | |
| parent | 171a3e175889ce30f201fcdf5c4632f480344ae6 (diff) | |
| parent | 95dd3dc13aecec85c2fd72410cd4d1f4ed582dfa (diff) | |
| download | meshbay-1ec316035ce9aa656dd18a05889856bce9e3aba3.tar.gz | |
Merge origin/main: the tree-wide ruff pass beside the Music reconnect work
Diffstat (limited to 'poc/spike5_node.py')
| -rw-r--r-- | poc/spike5_node.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/poc/spike5_node.py b/poc/spike5_node.py index 6104e00..cded922 100644 --- a/poc/spike5_node.py +++ b/poc/spike5_node.py @@ -14,20 +14,27 @@ Note: node initiates the TCP connection (reversed for POC — in production, the QUIC client connects to the node using the hole-punching from Spike 4). """ -import asyncio, json, base64, struct, os, time +import asyncio +import base64 +import json +import os +import struct +import time from pathlib import Path + +import blake3 +from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305 from cryptography.hazmat.primitives.kdf.hkdf import HKDF -from cryptography.hazmat.primitives import hashes, serialization -import blake3 MESHBAY_HOST = "meshbay.org" MESHBAY_PORT = 19003 CHUNK_SIZE = 1024 * 1024 # 1 MB TEST_FILE = Path("testfile.bin") STATE_FILE = Path("node_state.json") -PASS = "✓"; FAIL = "✗" +PASS = "✓" +FAIL = "✗" # ── Wire helpers ─────────────────────────────────────────────────────────────── @@ -125,7 +132,7 @@ async def main(): print(f" {PASS} Test file: {TEST_FILE} ({file_size/1024/1024:.1f} MB)") # Pre-compute file hash (used in HKDF info string — identifies the file) - print(f" Computing file hash...") + print(" Computing file hash...") t0 = time.perf_counter() file_hash = blake3.blake3(TEST_FILE.read_bytes()).digest() print(f" {PASS} File hash: {file_hash.hex()[:16]}... ({(time.perf_counter()-t0)*1000:.0f}ms)") @@ -166,7 +173,7 @@ async def main(): print(f" {PASS} Sent {payload_kb:.1f} KB in {send_ms:.0f}ms ({throughput:.1f} MB/s)") print(f"\n {'='*50}") - print(f" Timings (node side):") + print(" Timings (node side):") print(f" Encrypt + sign : {enc_ms:.1f} ms") print(f" TCP send : {send_ms:.0f} ms") print(f" Total : {total_ms:.0f} ms") |