openpay/ (+3 crates)
op-bnpl/ Affirm + Klarna + Afterpay/Clearpay rails. Full lifecycle
typestate (Initiated→Approved→Captured→Settled→Refunded).
Per-provider sandbox+production base URLs, regions (NA/EU/OC
for Klarna; US/AuNz/Gb/Ca/Eu for Afterpay). HMAC-SHA256
webhook verification with constant-time compare. 61 tests.
op-batch/ NACHA ACH (94-char records, PPD/CCD/WEB/TEL/CTX, R01-R99
return codes, Same-Day ACH cutoffs); SEPA pain.001.001.09
(CT) + pain.008.001.08 (DD) with SCT-Inst flagging; Fedwire
MT103/MT202/CHIPS + pacs.008.001.12 / pacs.009.001.10 +
UETR; Bacs Standard 18. Per-rail cutoff scheduler. Exception
taxonomy unified across rails. 51 tests.
op-screening/ OFAC SDN + EU consolidated + UN consolidated + HMT UK
consolidated + Australia DFAT + Canada SEMA + Japan MOF.
Levenshtein + Jaro-Winkler + Soundex + Metaphone + token
Jaccard scoring. Unicode NFKD normalisation + Cyrillic /
Arabic transliteration. Ed25519-signed BLAKE3-chained
audit log. BSA helpers: CTR + SAR pattern detection
(structuring, round-dollar, rapid-in-out). 43 tests.
smart-byte/smart-byte-rs/ (+3 crates)
smart-byte-bbs/ BBS+ signatures (IETF draft-irtf-cfrg-bbs-signatures-08).
BLS12-381 keys, signatures, disclosure proofs with
cryptographic unlinkability. bbs-2023 Data Integrity
cryptosuite. AnonCreds-shaped link secrets +
predicate proofs. SecretKey zeroize-on-drop. 49 tests.
smart-byte-didcomm/ DIDComm v2 messaging per DIF spec. Pack-encrypted
(ECDH-1PU + ECDH-ES via X25519), pack-signed (JWS),
pack-plaintext. Aries protocols: issue-credential v3,
present-proof v3, basic-message, trust-ping, discover-
features, out-of-band, coordinate-mediation, message-
pickup. Mediator role with pluggable storage. 23 tests.
smart-byte-mdl/ ISO/IEC 18013-5 mobile driver's licence + 18013-7
online presentment. mDoc + MSO with salted-hash
selective disclosure (per item; SHA-256 digest tree).
org.iso.18013.5.1 namespace + AAMVA add-on. ES256
device-auth + issuer-auth. QR-code device-engagement
scaffolding. 28 tests.
eoc/eoc-rs/ (+3 crates)
eoc-local/ Local-inference backends behind one NeuralBackend:
llama.cpp (GGUF, Q4/Q5/Q6/Q8/F16/F32 quantisation),
MLX (Apple Silicon, feature-gated), MLC-LLM (TVM, feature-
gated marker), ONNX Runtime. GGUF file-format reader.
HuggingFace tokenizers. Greedy / top-k / top-p / temperature /
Mirostat samplers. Model registry scanning ~/.eoc/models/.
Joule attribution via eoc-meter. 39 tests.
eoc-rerank/ BM25 sparse + HNSW dense + RRF + min-max hybrid fusion.
Cohere v3.5 + Voyage v2 + bge-reranker v2-m3 + ms-marco
MiniLM + ColBERT v2 rerankers. Two-stage pipeline:
retrieve top-K hybrid → cross-encoder rerank → top-N.
KV-stage recovery shim into the cascade. 31 tests.
eoc-eval/ 15 canonical eval harnesses: MMLU, MMLU-Pro, GPQA,
HumanEval (pass@1 with python3 sandbox), BBH, IFEval (25
verifiable constraints), AlpacaEval, AGIEval, HellaSwag,
ARC (Easy + Challenge), TruthfulQA (MC1+MC2), BoolQ,
GSM8K, MATH (boxed-answer equivalence), Winogrande. Real
questions in BuiltinSamples. EvalRunner emits joules-per-
correct alongside accuracy. 49 tests.
Quality:
- cargo check across all three workspaces: clean
- cargo clippy --all-targets -- -D warnings on every new crate: clean
- 374 new tests, 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).
104 lines
3.3 KiB
Rust
104 lines
3.3 KiB
Rust
//! Public BBS+ message generators.
|
|
//!
|
|
//! Per `draft-irtf-cfrg-bbs-signatures-08` § 4.1.1
|
|
//! (`create_generators`), the generators used to bind messages into a
|
|
//! signature are derived deterministically from a domain-separation
|
|
//! tag and an integer index. The draft uses RFC 9380 `hash_to_curve`
|
|
//! over G1 (suite `BLS12381G1_XMD:SHA-256_SSWU_RO_`) with the input
|
|
//! `seed || I2OSP(index, 8)`.
|
|
//!
|
|
//! Because `bls12_381` 0.8's `hash_to_curve` API is bound to the
|
|
//! `digest` 0.9 trait family it accepts `sha2 0.9::Sha256` (re-exported
|
|
//! locally as `sha2_v9::Sha256`). This is the same SHA-256 algorithm
|
|
//! the IETF draft prescribes; the version split is purely a crate
|
|
//! dependency artefact.
|
|
//!
|
|
//! The generator set produced here is ordered:
|
|
//!
|
|
//! ```text
|
|
//! [ H_0, H_1, H_2, ..., H_{count-1} ]
|
|
//! ```
|
|
//!
|
|
//! Conventionally `H_0` is the "blinding" generator paired with the
|
|
//! signature's `s` term and `H_1 .. H_{count-1}` are the per-message
|
|
//! generators. Smart Byte's sign/verify treats the first
|
|
//! `message_count + 2` generators as `(H0, H_msg_0..H_msg_{n-1}, Q)`.
|
|
|
|
use bls12_381::{
|
|
G1Projective,
|
|
hash_to_curve::{ExpandMsgXmd, HashToCurve},
|
|
};
|
|
|
|
/// Per-instance domain-separation tag prefix used when deriving
|
|
/// generators.
|
|
pub const GENERATOR_DST_PREFIX: &[u8] =
|
|
b"SMART_BYTE_BBS_2026_BLS12381G1_XMD:SHA-256_SSWU_RO_MSG_GEN_";
|
|
|
|
/// Derive `count` independent G1 generators from a public domain
|
|
/// string.
|
|
///
|
|
/// The output is deterministic: callers passing the same `domain` and
|
|
/// `count` always get the same generator vector. This is critical for
|
|
/// interop with other BBS+ implementations and for the W3C
|
|
/// `bbs-2023` cryptosuite which makes the generator set part of the
|
|
/// public signing parameters.
|
|
pub fn message_generators(domain: &[u8], count: usize) -> Vec<G1Projective> {
|
|
let mut dst = Vec::with_capacity(GENERATOR_DST_PREFIX.len() + domain.len());
|
|
dst.extend_from_slice(GENERATOR_DST_PREFIX);
|
|
dst.extend_from_slice(domain);
|
|
|
|
let mut out = Vec::with_capacity(count);
|
|
for i in 0..count {
|
|
// I2OSP(i, 8) — eight big-endian bytes.
|
|
let i_bytes = (i as u64).to_be_bytes();
|
|
let g = <G1Projective as HashToCurve<ExpandMsgXmd<sha2_v9::Sha256>>>::hash_to_curve(
|
|
i_bytes, &dst,
|
|
);
|
|
out.push(g);
|
|
}
|
|
out
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn deterministic_for_same_inputs() {
|
|
let a = message_generators(b"domain-1", 5);
|
|
let b = message_generators(b"domain-1", 5);
|
|
assert_eq!(a, b);
|
|
}
|
|
|
|
#[test]
|
|
fn distinct_for_different_domains() {
|
|
let a = message_generators(b"domain-1", 5);
|
|
let b = message_generators(b"domain-2", 5);
|
|
for (x, y) in a.iter().zip(b.iter()) {
|
|
assert_ne!(x, y);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn distinct_indices_distinct_points() {
|
|
let g = message_generators(b"d", 8);
|
|
for i in 0..g.len() {
|
|
for j in (i + 1)..g.len() {
|
|
assert_ne!(g[i], g[j]);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn no_generator_is_identity() {
|
|
let g = message_generators(b"d", 12);
|
|
for p in &g {
|
|
assert!(!bool::from(p.is_identity()));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn count_zero_is_empty() {
|
|
assert!(message_generators(b"d", 0).is_empty());
|
|
}
|
|
}
|