open-standards/smart-byte/smart-byte-rs/crates/smart-byte-ilp/src/lib.rs
Transaction Science 8180ee8c71 ingest wave D: 3 crates · op-fraud-graph + smart-byte-ilp + eoc-quantize
OpenPay (1 crate, 2487 LOC, 33 tests)
  op-fraud-graph    Graph-based fraud detection. EntityKind (card/email/
                    device/IP/address/phone/BIN+last4/account) with
                    canonicalization + hashed EntityKey + billing↔shipping
                    mismatch detection. Adjacency-list FraudGraph with
                    idempotent upsert + edge-merge. Double-hashing Bloom
                    filter (capacity+FPR-sized). Union-find connected
                    components. PageRank with dangling-sink handling.
                    Louvain community detection. Shared-instrument hub
                    rings. Sliding ring-buffer velocity counters. Synthetic
                    identity heuristics (freshness + heavy-use + mail-drop).
                    Structuring / smurfing / mule-chain DFS. EntityRisk +
                    TransactionRisk + RiskBand combiner.

Smart Byte (1 crate, ~1844 LOC, 44 tests)
  smart-byte-ilp    Interledger Protocol v4. OER codec (length-determinant,
                    var-octet-string, BE u32/u64). Prepare/Fulfill/Reject
                    packet roundtrip with all 19 IL-RFC-27 reject codes.
                    SHA-256 Condition + Fulfillment with constant-time
                    verify. ILP address validator (7 schemes, 1-128 char
                    segments, 1023-byte cap, segment-aligned prefix match).
                    STREAM (15 frame types). BTP. SPSP payment-pointer
                    resolver. Open Payments API. Longest-prefix routing
                    Connector with fixed-point quote conversion + balance +
                    rate-limit checks.

EOC (1 crate, 1921 LOC, 36 tests)
  eoc-quantize      Quantization primitives. int8 (symmetric/asymmetric
                    with zero-inclusion fix), int4 (GPTQ + AWQ group quant),
                    int2 (BitNet), fp8 (E4M3/E5M2), nf4 (QLoRA). GGUF v3
                    header parse. safetensors read sketch. Calibration
                    datasets + per-channel scales. KV-cache quant. Energy
                    tradeoff curves (joules-per-token across schemes).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 16:10:10 -04:00

79 lines
3.5 KiB
Rust

//! Interledger Protocol (ILP) v4 adapter for Smart Byte.
//!
//! Interledger is the IETF + Interledger Foundation specification for
//! routing value packets across heterogeneous ledgers — banks, card
//! rails, stablecoins, central-bank ledgers, layer-2 chains — without
//! any of them having to peer with each other. A connector forwards an
//! ILP packet just like an IP router forwards an IP datagram: it knows
//! the next hop, not the destination ledger.
//!
//! This crate ingests the deployed ILPv4 protocol family into the
//! Smart Byte substrate so other crates can construct, parse, and route
//! Interledger packets without taking a runtime dependency on any
//! specific connector implementation.
//!
//! ## Layout
//!
//! * **Packet** ([`packet`]) — the three ILPv4 wire types `Prepare`,
//! `Fulfill`, `Reject`, encoded with Octet Encoding Rules (OER).
//! * **OER** ([`oer`]) — the minimal slice of ASN.1 OER required by
//! ILPv4: 8-bit length-prefix, length-determinant, variable-length
//! octet strings, and the BE-uint encoding used for amounts.
//! * **Condition** ([`condition`]) — the SHA-256 hashlock that ties a
//! `Prepare` to its eventual `Fulfill`.
//! * **Address** ([`address`]) — the dotted ILP address scheme
//! (`g.us.bank.alice`) and its allocator-prefix validator.
//! * **STREAM** ([`stream`]) — frame types for the STREAM protocol that
//! multiplexes money + data over a single ILP connection.
//! * **BTP** ([`btp`]) — the Bilateral Transfer Protocol envelope used
//! for peer connections between connectors.
//! * **SPSP** ([`spsp`]) — the Simple Payment Setup Protocol used by
//! senders to discover a receiver's destination address +
//! shared secret.
//! * **Open Payments** ([`open_payments`]) — the W3C / Interledger
//! Foundation HTTP API surface (`incoming-payments`,
//! `outgoing-payments`, `quotes`).
//! * **Connector** ([`connector`]) — a longest-prefix route table and
//! the per-hop forwarding decision (next-hop selection, currency
//! conversion, rate-limit + balance check).
//!
//! ## What's intentionally scoped out
//!
//! * Settlement engines. We carry the prepare/fulfill loop and the
//! bilateral balance counter; clearing real money against a real
//! ledger lives in the connector operator's code.
//! * Wire I/O. The packet and BTP types serialize to bytes; the
//! transport (WebSocket / HTTPS / QUIC) lives in the caller's runtime
//! crate.
//! * Full ASN.1 OER. We hand-code the subset ILPv4 actually uses; a
//! full OER codec is out of scope.
//! * Pre-shared-key derivation for STREAM. We carry the frame layer and
//! leave AEAD framing to the caller; the encryption envelope is a
//! straightforward AES-128-GCM over the frame bytes and does not need
//! to live in this crate.
#![forbid(unsafe_code)]
pub mod address;
pub mod btp;
pub mod condition;
pub mod connector;
pub mod error;
pub mod oer;
pub mod open_payments;
pub mod packet;
pub mod spsp;
pub mod stream;
pub use address::{Address, AddressScheme};
pub use btp::{BtpMessage, BtpPacketType, BtpSubProtocol};
pub use condition::{Condition, Fulfillment};
pub use connector::{Connector, ForwardDecision, Route, RouteTable};
pub use error::{IlpError, Result};
pub use oer::{decode_var_octet_string, encode_var_octet_string};
pub use open_payments::{
GrantAccess, IncomingPayment, OpenPaymentsClient, OutgoingPayment, PaymentPointer, Quote,
};
pub use packet::{Fulfill, IlpPacket, PacketType, Prepare, Reject, RejectCode};
pub use spsp::{SpspQuery, SpspResponse};
pub use stream::{Frame, FrameType, StreamPacket};