Fastfile Link - Generator

Comparison with database-backed generator:

[1] Berners-Lee, T., Fielding, R., & Masinter, L. (2005). Uniform Resource Identifier (URI): Generic Syntax . RFC 3986. [2] Krawczyk, H., Bellare, M., & Canetti, R. (1997). HMAC: Keyed-Hashing for Message Authentication . RFC 2104. [3] Amazon Web Services. (2024). Presigned URLs for Amazon S3 . AWS Documentation. [4] Bloom, B. H. (1970). Space/time trade-offs in hash coding with allowable errors. Communications of the ACM , 13(7), 422-426. fastfile link generator

| Metric | Value | |--------|-------| | Link generation (single thread) | 12,400 ops/sec | | Link generation (4 workers) | 48,000 ops/sec | | Verification latency (p50) | 0.9 ms | | Verification latency (p99) | 3.2 ms | | Memory per active token | 0 bytes (stateless) | | Single-use with Bloom filter | +0.3 ms, 1.2 MB for 1M tokens | RFC 3986

def verify_token(token: str): data = base64.urlsafe_b64decode(token) payload = data[:-32] recv_mac = data[-32:] computed = hmac.new(SECRET, payload, sha256).digest() if not hmac.compare_digest(recv_mac, computed): return None version, exp = struct.unpack("!BI", payload[:5]) if exp < time.time(): return None return payload[5:].decode() Test environment: AWS t3.medium (2 vCPU, 4 GB RAM), Python 3.11 + uvicorn. HMAC: Keyed-Hashing for Message Authentication

def generate_link(file_path: str, ttl_sec: int = 3600) -> str: exp = int(time.time()) + ttl_sec version = 1 payload = struct.pack("!BI", version, exp) + file_path.encode() mac = hmac.new(SECRET, payload, sha256).digest() token = base64.urlsafe_b64encode(payload + mac).decode() return f"https://files.example.com/get?token=token"