- 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
69 lines
1.5 KiB
Markdown
69 lines
1.5 KiB
Markdown
# quicproquo Python FFI Client
|
|
|
|
Python wrapper around `libquicproquo_ffi` using `ctypes`.
|
|
|
|
## Build the FFI library
|
|
|
|
```bash
|
|
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
|
|
|
|
```bash
|
|
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
|
|
|
|
```bash
|
|
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
|
|
|
|
```bash
|
|
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`:
|
|
|
|
```bash
|
|
export QPQ_FFI_LIB=/path/to/libquicproquo_ffi.so
|
|
```
|
|
|
|
## Programmatic usage
|
|
|
|
```python
|
|
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)
|
|
```
|