OpenPay (1 crate, 3277 LOC, 18 tests)
op-ewallets-asia APAC e-wallet rail adapters. Alipay Cross-Border v3,
WeChat Pay (JSAPI/Native/H5/MicroPay) with constant-time
HMAC notify, UPI 2.0 (collect/intent/mandate/VPA),
Paytm, GrabPay, GoPay (Midtrans), Touch'n Go.
EMVCo MPM TLV + CRC-16/CCITT-FALSE encoder for
PromptPay (TH), PayNow (SG), DuitNow (MY), QRIS (ID).
Transport-free traits — operators inject HTTP + RSA-SHA256
signers (keeps POS firmware / WASM consumers reqwest-free).
Smart Byte (1 crate, 1310 LOC, 15 tests)
smart-byte-zk Selective-disclosure ZK primitives.
Real: Bulletproofs over Ristretto255 (range proofs at
8/16/32/64-bit), RangePredicate / InequalityPredicate /
SetMembershipPredicate all delegating to Bulletproofs.
Stubs (documented): Groth16, PLONK — deterministic
placeholder proofs satisfying ZkScheme trait for future
arkworks integration. AnonCred sketch + VerifiablePresentation
builder.
EOC (1 crate, ~3000 LOC, 36 tests)
eoc-rag RAG orchestrator. Naive (Lewis 2020), HyDE (Gao 2022),
RAG-Fusion + RRF (Cormack 2009), Self-RAG (Asai 2023)
with Retrieve/ISREL/ISSUP/ISUSE critique tokens,
Corrective RAG (Yan 2024) with retrieval evaluator
+ external fallback, Adaptive RAG (Jeong 2024)
complexity router. Chunking: sentence-window, semantic,
recursive, late-chunking. Span-backed citations with
3-mode enforcement. SelfCheckGPT consistency guard.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
69 lines
2.1 KiB
Rust
69 lines
2.1 KiB
Rust
//! Bulletproofs range-proof integration: prove a balance lies in
|
|
//! `[0, 2^32)`.
|
|
|
|
use smart_byte_zk::bulletproofs::{
|
|
pedersen_commit, prove_range, verify_range, RangeStatement, RangeWitness,
|
|
BulletproofsRangeScheme,
|
|
};
|
|
use smart_byte_zk::scheme::ZkScheme;
|
|
|
|
#[test]
|
|
fn balance_in_u32_range_verifies() {
|
|
let balance: u64 = 1_234_567_890;
|
|
let (commitment, blinding) = pedersen_commit(balance);
|
|
let witness = RangeWitness {
|
|
value: balance,
|
|
blinding,
|
|
};
|
|
|
|
let proof = prove_range(&witness, 32, b"smart-byte-zk/test/balance").expect("prove");
|
|
assert_eq!(proof.bit_length, 32);
|
|
assert_eq!(proof.commitment, commitment.to_bytes());
|
|
|
|
let stmt = RangeStatement {
|
|
commitment,
|
|
bit_length: 32,
|
|
label: b"smart-byte-zk/test/balance",
|
|
};
|
|
assert!(verify_range(&stmt, &proof).expect("verify"));
|
|
}
|
|
|
|
#[test]
|
|
fn balance_proof_rejects_under_wrong_label() {
|
|
let balance: u64 = 42;
|
|
let (commitment, blinding) = pedersen_commit(balance);
|
|
let witness = RangeWitness {
|
|
value: balance,
|
|
blinding,
|
|
};
|
|
let proof = prove_range(&witness, 32, b"smart-byte-zk/test/balance").expect("prove");
|
|
|
|
let stmt = RangeStatement {
|
|
commitment,
|
|
bit_length: 32,
|
|
label: b"smart-byte-zk/test/wrong-label",
|
|
};
|
|
// Wrong transcript label => verification should fail (returns
|
|
// Err from the underlying bulletproofs verifier).
|
|
let result = verify_range(&stmt, &proof);
|
|
assert!(result.is_err() || result.ok() == Some(false));
|
|
}
|
|
|
|
#[test]
|
|
fn scheme_trait_round_trip() {
|
|
let scheme = BulletproofsRangeScheme;
|
|
let balance: u64 = 7777;
|
|
let (commitment, blinding) = pedersen_commit(balance);
|
|
let stmt = RangeStatement {
|
|
commitment,
|
|
bit_length: 32,
|
|
label: b"smart-byte-zk/test/scheme",
|
|
};
|
|
let witness = RangeWitness {
|
|
value: balance,
|
|
blinding,
|
|
};
|
|
let (pk, vk) = scheme.keygen(&stmt).expect("keygen");
|
|
let proof = scheme.prove(&pk, &stmt, &witness).expect("prove");
|
|
assert!(scheme.verify(&vk, &stmt, &proof).expect("verify"));
|
|
}
|