Files
Chris Nennemann db46b72f58 feat: Sprint 3 — C FFI bindings, WASM compilation, Python example, SDK docs
- Create quicproquo-ffi crate with 7 extern "C" functions: connect,
  login, send, receive, disconnect, last_error, free_string
  (produces libquicproquo_ffi.so and .a)
- Feature-gate quicproquo-core for WASM: identity, hybrid_kem,
  safety_numbers, sealed_sender, app_message, padding, transcript
  all compile to wasm32-unknown-unknown
- Add Python ctypes example (examples/python/qpq_client.py) with
  QpqClient wrapper class and CLI
- Add SDK documentation: FFI reference, WASM guide, qpq-gen generators
- Update Dockerfile for quicproquo-ffi workspace member
2026-03-03 23:47:40 +01:00

1.5 KiB

quicproquo Python FFI Client

Python wrapper around libquicproquo_ffi using ctypes.

Build the FFI library

cargo build --release -p quicproquo-ffi

This produces:

  • Linux: target/release/libquicproquo_ffi.so
  • macOS: target/release/libquicproquo_ffi.dylib
  • Windows: target/release/quicproquo_ffi.dll

Usage

python examples/python/qpq_client.py \
    --server 127.0.0.1:7000 \
    --ca-cert server-cert.der \
    --server-name localhost \
    --username alice \
    --password secret

Send a message

python examples/python/qpq_client.py \
    --server 127.0.0.1:7000 \
    --ca-cert server-cert.der \
    --username alice --password secret \
    --send-to bob --message "hello from Python"

Receive messages

python examples/python/qpq_client.py \
    --server 127.0.0.1:7000 \
    --ca-cert server-cert.der \
    --username bob --password secret \
    --receive --timeout 10000

Library path

The script auto-detects the library in target/release/ or target/debug/. Override with QPQ_FFI_LIB:

export QPQ_FFI_LIB=/path/to/libquicproquo_ffi.so

Programmatic usage

from qpq_client import QpqClient, _find_library, _load_library

lib = _load_library(_find_library())
with QpqClient(lib) as client:
    client.connect("127.0.0.1:7000", "server-cert.der", "localhost")
    client.login("alice", "secret")
    client.send("bob", "hello")
    messages = client.receive(timeout_ms=5000)