Skip to main content

rgtp — Python bindings for the Red Giant Transport Protocol

PyPI version Python 3.9+ License: MIT

RGTP is a stateless, receiver-driven, chunk-based, pre-encrypted, Merkle-verified, FEC-protected data transport protocol over UDP and raw Ethernet.

This package provides Python 3.9+ bindings via ctypes, with full asyncio async/await support.

Installation

pip install rgtp

The package requires librgtp to be installed on your system. See the main repository for build instructions.

Set RGTP_LIB_PATH to point to the library if it is not on the default search path:

export RGTP_LIB_PATH=/usr/local/lib/librgtp.so
pip install rgtp

Quick Start

Expose data (server side)

import rgtp

rgtp.init()

with rgtp.Socket() as sock:
    data = open("large-file.bin", "rb").read()
    with rgtp.expose(sock, data) as surface:
        exposure_id = surface.exposure_id()
        print(f"Exposure ID: {exposure_id.hex()}")
        # distribute exposure_id and key out-of-band to pullers

        # Serve pull requests until done
        while True:
            rgtp.poll(surface, timeout_ms=1000)

rgtp.cleanup()

Pull data (client side)

import rgtp

rgtp.init()

with rgtp.Socket() as sock:
    surface = rgtp.pull_start(sock, ("192.168.1.10", 9000), exposure_id)
    with surface:
        chunks = {}
        while surface.progress() < 1.0:
            data, chunk_index = rgtp.pull_next(surface)
            chunks[chunk_index] = data

rgtp.cleanup()

Async/await

import asyncio
import rgtp

async def expose_file(path: str) -> None:
    rgtp.init()
    data = open(path, "rb").read()
    with rgtp.Socket() as sock:
        surface = await rgtp.async_expose(sock, data)
        with surface:
            print(f"Exposure ID: {surface.exposure_id().hex()}")
            while True:
                rgtp.poll(surface, timeout_ms=100)

asyncio.run(expose_file("large-file.bin"))

CLI

The package installs two command-line tools:

# Expose a file
rgtp-expose large-file.bin --port 9000

# Pull a file
rgtp-pull 192.168.1.10:9000 <exposure-id-hex> output.bin

API Reference

Library lifecycle

rgtp.init()          # Must be called once before any other function
rgtp.cleanup()       # Release all global resources
rgtp.version()       # Returns version string e.g. "1.0.0"
rgtp.strerror(code)  # Human-readable error description

Socket

sock = rgtp.Socket()   # Create and bind a UDP socket
sock.close()           # Destroy socket (also called by context manager)

Exposer

surface = rgtp.expose(sock, data: bytes) -> rgtp.Surface
rgtp.poll(surface, timeout_ms=100)        # Serve pull requests
surface.exposure_id() -> bytes            # 16-byte Exposure_ID
surface.progress() -> float               # Always 0.0 for exposer
surface.close()                           # Zeroize key and free

Puller

surface = rgtp.pull_start(sock, (host, port), exposure_id: bytes)
data, chunk_index = rgtp.pull_next(surface, buf_size=65536)
surface.progress() -> float               # [0.0, 1.0]

Async wrappers

surface = await rgtp.async_expose(sock, data)
data, idx = await rgtp.async_pull_next(surface, buf_size=65536)

Exceptions

try:
    rgtp.init()
except rgtp.RgtpError as e:
    print(e.code)     # e.g. -4 (RGTP_ERR_CRYPTO_INIT)
    print(e.message)  # human-readable description

Error Codes

Code Constant Meaning
0 RGTP_OK Success
-1 RGTP_ERR_NOMEM Memory allocation failed
-2 RGTP_ERR_INVALID_ARG Invalid argument
-3 RGTP_ERR_SOCKET Socket operation failed
-4 RGTP_ERR_CRYPTO_INIT Crypto library init failed
-5 RGTP_ERR_ENCRYPT AEAD encryption failed
-6 RGTP_ERR_DECRYPT AEAD decryption failed
-7 RGTP_ERR_AUTH_FAIL Authentication tag mismatch
-8 RGTP_ERR_MERKLE_FAIL Merkle proof verification failed
-9 RGTP_ERR_FEC_FAIL FEC decoding failed
-10 RGTP_ERR_TRUNCATED Packet truncated
-11 RGTP_ERR_CHUNK_INDEX_OOB Chunk index out of bounds
-12 RGTP_ERR_TIMEOUT Operation timed out
-13 RGTP_ERR_RATE_LIMITED Rate limit exceeded
-14 RGTP_ERR_NOT_SUPPORTED Feature not supported
-15 RGTP_ERR_INTERNAL Internal invariant violation

License

MIT — see LICENSE.

Metadata

Release files for rgtp 1.0.0

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

Source distribution (sdist)

Source distribution for rgtp 1.0.0
File Size Uploaded Provenance Actions
rgtp-1.0.0.tar.gz 13.4 kB Without provenance Details for rgtp-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rgtp 1.0.0
File Interpreter ABI Platform Actions
rgtp-1.0.0-py3-none-any.whl Python 3 none any Details for rgtp-1.0.0-py3-none-any.whl

Total release size: 23.4 kB

Release files / rgtp-1.0.0.tar.gz

Download URL rgtp-1.0.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d34293230d43fa9745d8461bda69bf08182dac53f2a4669b5716e22e3458e143
BLAKE2b-256 checksum
How to use checksums
a46bbe3469981c0001ac9a473c94aac6b17d2b7dac2b10ae116614534f434687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / rgtp-1.0.0-py3-none-any.whl

Download URL rgtp-1.0.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56308f7af4ce5eff054fab6843067fb2677891645737c6d0c995cd34a7b301c3
BLAKE2b-256 checksum
How to use checksums
a3bdd6042d6c142c296006ca23c02fcc89b578dc64920e46388de9869428ed5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for rgtp 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

1.0.0 This release

2 release files No 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