# ProofMode UniFFI Bindings
Language bindings for the ProofMode Rust library generated using UniFFI.
## Available Bindings
### Python Bindings
Built with maturin. The `python` feature includes UniFFI, sequoia-openpgp, polars, and c2pa.
### Ruby Bindings
Built with uniffi-bindgen and the FFI gem. The `ruby` feature includes UniFFI, sequoia-openpgp, polars, and c2pa.
## UniFFI Exported Functions
The compiled Rust library exports the following UniFFI functions (defined in `src/uniffi_wrapper.rs`):
- `get_version()` - Get library version
- `get_file_hash(data)` - Calculate SHA-256 hash of media data
- `generate_proof_mobile(callbacks, data, metadata)` - Generate cryptographic proofs with platform callbacks
- `check_files_mobile(files, progress_callback)` - Verify proof files with progress reporting
## Usage
### Python
```python
from proofmode import get_version, get_file_hash
version = get_version()
with open("photo.jpg", "rb") as f:
data = f.read()
hash_val = get_file_hash(data)
```
### Ruby
```ruby
require 'proofmode'
version = ProofMode.get_proofmode_version
data = File.binread("photo.jpg").bytes
hash_val = ProofMode.get_file_hash(data)
```
## Mobile Callback Interface
The bindings support mobile platform integration through callback interfaces:
```python
class MobileCallbacks:
def get_location(self) -> Optional[LocationInfo]:
# Return device GPS location
def get_device_info(self) -> Optional[DeviceInfo]:
# Return device manufacturer, model, etc.
def get_network_info(self) -> Optional[NetworkInfo]:
# Return network type, carrier, cell tower info
def save_data(self, hash_val: str, filename: str, data: bytes) -> bool:
# Save binary data to device storage
def save_text(self, hash_val: str, filename: str, text: str) -> bool:
# Save text data to device storage
def sign_data(self, data: bytes) -> Optional[bytes]:
# Sign data using device keys
```
## Building
```bash
# Build the Rust library with UniFFI support
cargo build --release --no-default-features --features ruby
# Generate language bindings
cargo run --release --bin uniffi-bindgen --no-default-features --features uniffi -- \
generate --library target/release/libproofmode.so --language ruby --out-dir ruby/lib/
cargo run --release --bin uniffi-bindgen --no-default-features --features uniffi -- \
generate --library target/release/libproofmode.so --language python --out-dir python/
# Build Python wheel with maturin
maturin build --release
```
## Dependencies
- **Rust library** built with `--features uniffi` (or `ruby`/`python`/`mobile` which include it)
- **Python**: Standard library (ctypes)
- **Ruby**: `ffi` gem for FFI bindings