open-standards/openpay/crates/op-iso8583/src/lib.rs
Transaction Science 01d4ad9c7b Ingest batch 2: 9 new crates across openpay / smart-byte / eoc
openpay/ (+3 crates, ~8400 LOC, 162 tests)
  op-iso8583/         ISO 8583 messages for direct acquirer / card-network
                      connectivity. MTIs, primary+secondary bitmaps, full
                      DE catalogue, BCD/ASCII/EBCDIC/LLVAR/LLLVAR codecs,
                      five dialects (Visa Base I, Mastercard MDS, Amex GNS,
                      Discover, JCB), network-management messages
                      (sign-on/echo/cutover), DE 55 EMV TLV.
  op-mobile-wallets/  Apple Pay (ECDH-P256 + AES-256-GCM), Google Pay ECv2
                      (ECDH + HKDF + AES-256-CTR + HMAC), Samsung Pay. PAN
                      never leaves the decryption boundary as a String;
                      lands in VaultRef. No-PAN-leakage assertions per
                      wallet.
  op-routing/         Least-cost routing + MCC-aware routing + intelligent
                      retry / soft-decline recovery. 231-MCC catalogue.
                      Real ISO 8583 DE-39 soft/hard decline taxonomies.

smart-byte/smart-byte-rs/ (+3 crates, ~7100 LOC, 96 tests)
  smart-byte-vc/      W3C Verifiable Credentials 2.0: VCDM, presentations,
                      Data Integrity proofs (eddsa-jcs-2022), VC-JWT,
                      SD-JWT (selective disclosure), Bitstring Status
                      List 2021. Cargo-bridge maps VCs to Smart Byte
                      envelopes with SAID stability.
  smart-byte-did/     W3C DID resolution: did:key (Ed25519/P-256/secp256k1),
                      did:web (HTTPS), did:peer (numalgo 2+4), did:jwk,
                      did:ion (feature-gated stub). DID URL dereferencer.
  smart-byte-pq/      Post-quantum signatures: ML-DSA-44/65/87 (FIPS 204),
                      SLH-DSA across 12 parameter sets (FIPS 205), FN-DSA
                      (draft FIPS 206, feature-gated). Hybrid Ed25519 +
                      ML-DSA pattern for the transition. Secret-key
                      zeroize-on-drop.

eoc/eoc-rs/ (+3 crates, ~6450 LOC, 76 tests)
  eoc-vendor-api/     NeuralBackend implementations: Anthropic, OpenAI,
                      Google, Mistral, Cohere, Groq, Together, Fireworks.
                      SSE streaming. Prompt-caching where supported.
                      Joule estimates per published energy coefficient
                      (12-model curated table).
  eoc-embeddings/     21 embedding models behind one Embedder trait:
                      OpenAI v3 (3), Cohere v3 (3), Voyage (5), Mistral,
                      Jina, plus local ONNX (BGE x3, nomic, mxbai, GTE,
                      E5) behind 'local' feature. Matryoshka-style
                      dimension projection. Per-content-hash cache.
  eoc-route-learned/  RouteLLM-style matrix-factorisation router +
                      multinomial-logreg classifier + LinUCB / Thompson
                      bandits for online learning. LearnedCascade wraps
                      the rule-based cascade with a confidence-threshold
                      skip policy. Synthetic-eval accuracy: MF 0.935,
                      LogReg 0.980.

Quality:
- cargo check across all three workspaces: clean
- cargo clippy --all-targets -- -D warnings on every new crate: clean
- 334 new tests total; all passing
- #![forbid(unsafe_code)] across every new crate
- No unwrap/expect outside #[cfg(test)]

Rust 1.95.0 edition 2024 (inherited via root rust-toolchain.toml).
2026-05-23 18:12:24 -04:00

79 lines
3.2 KiB
Rust

//! # `op-iso8583`
//!
//! ISO 8583 codec for OpenPay. Used by acquirers and PSPs that connect
//! **directly** to a card network's authorization rail (Visa Base I,
//! Mastercard MDS, Amex GNS, Discover, JCB) rather than via a hosted
//! processor. This is the bottom of the card stack — the wire format
//! the network actually speaks.
//!
//! ## What's here
//!
//! - [`message::Iso8583Message`] — typed message frame (MTI + bitmaps + DEs).
//! - [`bitmap::Bitmaps`] — primary + secondary bitmap codec.
//! - [`fields`] — DE catalog and typed accessors (PAN, amount, STAN,
//! RRN, response code, EMV blob, MAC, ...).
//! - [`codec`] — wire-format codecs (BCD, ASCII, EBCDIC, binary,
//! LLVAR, LLLVAR).
//! - [`dialect`] — per-network profiles ([`dialect::VisaBaseI`],
//! [`dialect::MastercardMds`], [`dialect::AmexGns`],
//! [`dialect::DiscoverCard`], [`dialect::Jcb`]).
//! - [`network_mgmt`] — 0800/0810 sign-on / echo / key-change / cutover.
//! - [`emv`] — DE 55 EMV TLV walker.
//! - [`error`] — sealed error enum.
//!
//! ## Round-trip contract
//!
//! Every message in `tests/fixtures/` must encode→decode→encode to the
//! exact same byte sequence. Network conformance tests use this as the
//! gatekeeper.
//!
//! ## Safety & quality
//!
//! - `#![forbid(unsafe_code)]`.
//! - No `unwrap` / `expect` outside `#[test]`.
//! - All decoders are bounds-checked; no panics on malformed input.
#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![warn(clippy::pedantic)]
// Pedantic carve-outs that don't fit ISO 8583's byte-level codecs:
// - cast_possible_truncation: byte/nibble math is the whole job here;
// every narrowing cast is byte-aligned by construction (mod 256,
// mod 16, etc.) and adding `u8::try_from` everywhere just buries
// the intent.
// - cast_sign_loss / cast_lossless: same byte-arithmetic story.
// - module_name_repetitions: matches the rest of the OpenPay tree.
// - missing_errors_doc: every `Result`-returning function carries
// its error documentation in the prose just above; clippy's
// doc-section heuristic is too narrow.
// - doc_markdown: card-network proper nouns (VisaNet, AmexNet,
// V.I.P., GNS, MDS, K_round) trip the "code-fence me" detector;
// wrapping them is hostile to readers who recognize them as
// industry terms.
// - manual_is_multiple_of: `% N != 0` is what the wire spec says;
// rewriting as `.is_multiple_of` reads worse next to the ISO 8583
// prose that describes the modular structure.
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::cast_possible_truncation)]
#![allow(clippy::cast_sign_loss)]
#![allow(clippy::cast_lossless)]
#![allow(clippy::doc_markdown)]
#![allow(clippy::manual_is_multiple_of)]
pub mod bitmap;
pub mod codec;
pub mod dialect;
pub mod emv;
pub mod error;
pub mod fields;
pub mod message;
pub mod network_mgmt;
pub use bitmap::Bitmaps;
pub use dialect::{AmexGns, Dialect, DiscoverCard, Jcb, MastercardMds, VisaBaseI};
pub use emv::{EmvTag, EmvTlv};
pub use error::{Error, Result};
pub use fields::{Encoding, FieldSpec, FieldValue, LengthRule, default_catalog};
pub use message::{Iso8583Message, Mti};
pub use network_mgmt::{NetworkMgmtCode, build_request, build_response};