open-standards/smart-byte/smart-byte-rs/crates/smart-byte-acdc/tests/issue_present.rs
Transaction Science 68b8a2dbee ingest wave F: 3 crates · op-crypto-extra + smart-byte-acdc + eoc-memory
OpenPay (1 crate, 3751 LOC, 83 tests)
  op-crypto-extra      Extended crypto rails. Stablecoin catalog (USDC, USDT,
                       PYUSD, DAI, RLUSD, EURC, FDUSD — 26 deployments). L2
                       catalog (12 chains incl. Optimism, Arbitrum, Base,
                       zkSync Era, Polygon zkEVM, Linea, Scroll, Starknet).
                       CCTP v2 BurnMessage encode/decode + domain ids +
                       attestation. ERC-4337 UserOperation v0.7 +
                       PackedUserOperation. EIP-7702 set-EOA-code with RLP
                       signing preimage. Uniswap Permit2 single + batch
                       transfer EIP-712 hashes. EIP-2612 ERC-20 permit.
                       BOLT-11 bech32 invoices + LNURL decode. Bitcoin
                       PSBT v2 (BIP-370). Atomic-swap HTLC. Solana SPL /
                       Aleo / Aztec confidential-transfer sketches.

Smart Byte (1 crate, 2304 LOC, 30 tests)
  smart-byte-acdc      Authentic Chained Data Containers (KERI ecosystem).
                       Acdc + AcdcBuilder (targeted + untargeted) with SAID
                       derivation. JSON Schema 2020-12 validator with
                       oneOf partial-disclosure. TEL (RIP/VRT/ISS/REV)
                       with hash-chained verification. IPEX (apply/offer/
                       agree/grant/admit/spurn) chained by SAID. Edge
                       records (I2I/NI2I/DI2I) + EdgeGraph BFS traversal
                       with cycle detection. Selective disclosure with
                       full/none/subset plans + compact packing.
                       CredentialRegistry trait + InMemoryRegistry over
                       TEL. Composes with smart-byte-core + smart-byte-keri-witness.

EOC (1 crate, 1764 LOC, 16 tests)
  eoc-memory           Long-term memory primitives. Memory trait + MemoryKind +
                       EpisodeId. Episodic event log with TimeIndex range
                       queries. RDF-style Triple store with S/P/O indices.
                       Bounded attention-budget Scratchpad with
                       salience-weighted eviction. Rolling SummaryBuffer +
                       FIFO SlidingWindow. Dream-cycle consolidate()
                       (episodic → semantic). Ebbinghaus forgetting curve
                       with reinforcement. Retriever blending cosine
                       similarity + recency + saturating frequency.
                       MemGpt three-tier shape (Main/Recall/Archival).

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

56 lines
2.1 KiB
Rust

//! End-to-end: issue an ACDC via a registry and present it back via
//! IPEX (`apply` → `grant` → `admit`).
use serde_json::json;
use smart_byte_acdc::{
AcdcBuilder, AttributeSection, CredentialRegistry, InMemoryRegistry, IpexMessage,
RegistryState, SchemaSection,
ipex::verify_exchange,
};
#[test]
fn issue_then_present() {
let mut registry = InMemoryRegistry::open("Bissuer").expect("open registry");
let mut schema_body = serde_json::Map::new();
schema_body.insert("$id".into(), json!("present-schema"));
schema_body.insert("title".into(), json!("Present"));
let schema = SchemaSection::Inline(schema_body);
let mut attrs = serde_json::Map::new();
attrs.insert("i".into(), json!("Bholder"));
attrs.insert("name".into(), json!("Alice"));
let acdc = AcdcBuilder::new()
.issuer("Bissuer")
.registry(registry.registry_said())
.schema(schema)
.attributes(AttributeSection::Inline(attrs))
.build()
.expect("build acdc");
let cred_said = acdc.d;
registry.issue(acdc.clone()).expect("issue");
assert_eq!(registry.state(&cred_said), RegistryState::Active);
// Holder → issuer: apply for a credential of this schema.
let schema_said = match &acdc.s {
SchemaSection::Inline(_) => smart_byte_core::Said::hash(b"present-schema"),
SchemaSection::Reference(s) => *s,
};
let apply = IpexMessage::apply("Bholder", "Bissuer", schema_said).expect("apply");
// Issuer → holder: grant.
let grant = IpexMessage::grant("Bissuer", "Bholder", apply.d, acdc).expect("grant");
// Holder → issuer: admit.
let admit = IpexMessage::admit("Bholder", "Bissuer", grant.d).expect("admit");
verify_exchange(&[apply, grant.clone(), admit]).expect("exchange verifies");
// Verifier (some third party) takes the granted ACDC and asks the
// registry whether it is still active.
let presented = grant.e.expect("grant carries acdc");
presented.verify_said().expect("acdc said valid");
assert_eq!(registry.state(&presented.d), RegistryState::Active);
}