Skip to main content

FECTP from Python

The sans-IO session layer, over the C ABI in crates/ffi. Payloads in, frames out, and back again — you own the socket, the thread and the event loop.

Not audited. Nothing in this project has been reviewed by someone who breaks protocols for a living.

Installing

pip install fectp

Wheels for Windows x64, Linux x64 (glibc 2.28 or newer) and macOS (Apple silicon and Intel), each carrying the shared library it needs — no Rust and no compiler. Python 3.9 or newer. ctypes underneath, so nothing else is pulled in.

Running it from a checkout

cargo build -p fectp-ffi --release
python3 bindings/python/test_fectp.py

The shared library cargo just built is found under target/, or named through FECTP_LIBRARY.

What it looks like

import fectp

server = fectp.Identity.generate()
client = fectp.Identity.generate()

initiator = fectp.Initiator(client, server.public, session_id=1)
responder = fectp.Responder(server)

opening = initiator.write_init(b"data sent with the handshake")
responder.read_init(opening)                      # -> b"data sent with the handshake"

server_session, reply = responder.write_response()
client_session, _ = initiator.read_response(reply)

frame = client_session.seal(b"hello")             # put this on a socket
server_session.open(frame)                        # -> b"hello"

Initiator.read_response and Responder.write_response consume the handle they are called on, success or failure — a handshake cannot be retried from a half-read state. Using one again raises rather than corrupting memory, which is what happens without that check: removing it takes this test suite from passing to the interpreter dying.

The secret key

There is no way to read a private key out of an Identity, and the C ABI exports no such call for this to wrap.

That is the shape of the whole binding rather than an oversight. Bytes handed to Python cannot be wiped: bytes is immutable so nothing can overwrite it, the interpreter copies freely, and the memory may reach swap. Rust wipes its copy when the identity is dropped; nothing it does survives the crossing.

Identity.from_secret restores a key you stored elsewhere, and FECTP wipes the copy it makes. What you passed in is yours — use a bytearray and overwrite it afterwards, because a bytes cannot be.

Or never have it here

Identity.from_key takes a key held by a secure element, an HSM or a TPM, and FECTP never sees it:

def dh(peer_public: bytes) -> bytes:
    # Ask the device for X25519 with its private key; 32 bytes back.
    return device.derive(peer_public)

identity = fectp.Identity.from_key(device.public_key, dh)

dh runs synchronously, twice per handshake on each side. If it raises, the handshake ends with KeyUnavailable and your exception as its __cause__; the identity can be used again. Return a bytearray and the wrapper wipes it after copying.

What this does not do

The session layer only. Retransmission, congestion control, fragmentation and keep-alive are not here — they live in the fectp crate, above the layer this binds. A caller who needs reliable delivery builds it or does without.

That trade is why the binding is this shape at all (OTHER-LANGUAGES.md): binding the layer above would mean blocking calls to hold the GIL over, threads the library owns, and memory crossing the boundary in both directions.

One warning worth repeating from D63: the abandonment reporting such a caller would rebuild is the logic this project got wrong twice, and §5.5 of the specification notes that a conforming receiver cannot observe it — so wire-level test vectors cannot catch that class of mistake either.

Metadata

Release files for fectp 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fectp 0.2.1
File Interpreter ABI Platform Actions
fectp-0.2.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for fectp-0.2.1-py3-none-win_amd64.whl
fectp-0.2.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for fectp-0.2.1-py3-none-manylinux_2_28_x86_64.whl
fectp-0.2.1-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details for fectp-0.2.1-py3-none-macosx_11_0_universal2.whl

Total release size: 763.4 kB

Release files / fectp-0.2.1-py3-none-win_amd64.whl

Download URL fectp-0.2.1-py3-none-win_amd64.whl
Size 120.7 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
0d7b0487a2c90319c5c54a94d82173ceae00784d93aa214b1a812b4285242a09
BLAKE2b-256 checksum
How to use checksums
41617ce9495d29bd09db622138fdac57c07c0b171fab4a5b492a2826e99d9c4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / fectp-0.2.1-py3-none-manylinux_2_28_x86_64.whl

Download URL fectp-0.2.1-py3-none-manylinux_2_28_x86_64.whl
Size 239.5 kB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
3ec3cc4de44c12410dd40891ced73d8ee9a2506f5551d625ad40409745a1ce52
BLAKE2b-256 checksum
How to use checksums
d4780cb154867ca04d8459f4247265853e7b17f3c45812ce88b905bf15a54da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / fectp-0.2.1-py3-none-macosx_11_0_universal2.whl

Download URL fectp-0.2.1-py3-none-macosx_11_0_universal2.whl
Size 403.3 kB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
6b286cf8dde9882eae6ccee509b4020ef4ad409e7fc489a45713619ee487a829
BLAKE2b-256 checksum
How to use checksums
dce8413d79d680f3f8b29f0317bbb8bb22882d5a7f591a2fdb278c2a9e575534
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for fectp 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for fectp-0.2.1-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

3 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page