baseid-mosip
The mosip crate provides types for integrating with the Modular Open Source Identity Platform (MOSIP), including the IDA authentication API, offline QR-code credential verification, and face-based biometric presence checks for low-connectivity environments.
Key Features
Section titled “Key Features”- MOSIP authentication API —
AuthRequest/AuthResponsetypes modelling the MOSIP IDA (Identity Authentication) protocol with UIN and VID identifier support - Authentication factors — Demographic, Biometric (fingerprint/iris/face), and OTP factor types with correct serde serialization
- Offline QR credentials —
OfflineCredentialencoding personal data, issuer metadata, base64-encoded face photograph, and digital signature into a JSON payload suitable for QR codes - Offline verification —
verify_offlinechecks structural validity and expiry without network access; signature verification and biometric matching are delegated to platform-specific implementations - QR payload codec —
to_qr_payload()/from_qr_payload()for JSON serialization targeting QR code generation - Bilingual errors —
MosipErrorvariants with English and French messages for authentication failures, invalid QR codes, expired credentials, biometric mismatches, and unsupported versions
Quick Start
Section titled “Quick Start”use baseid_mosip::qr::{OfflineCredential, verify_offline};
// Create an offline credential for QR encodinglet credential = OfflineCredential { version: "1.0".to_string(), name: "Amina Okafor".to_string(), date_of_birth: Some("1990-05-15".to_string()), gender: Some("F".to_string()), address: Some("123 Lagos Road, Abuja".to_string()), phone: Some("+234-800-1234567".to_string()), email: Some("amina@example.com".to_string()), id_number: Some("NGA-1234567890".to_string()), issuer: "NIMC".to_string(), issuance_date: "2025-01-01".to_string(), expiry_date: Some("2030-01-01".to_string()), face_data: Some(base64_encoded_face.clone()), signature: Some(base64_encoded_sig.clone()),};
// Encode for QR codelet qr_payload = credential.to_qr_payload()?;
// Decode from QR scanlet decoded = OfflineCredential::from_qr_payload(&qr_payload)?;
// Offline verification (no network required)let result = verify_offline(&decoded, "2026-03-24");assert!(result.verified);assert!(result.not_expired);assert!(result.has_biometric);Authentication API
Section titled “Authentication API”use baseid_mosip::auth::{AuthRequest, AuthFactor, IdType};
let request = AuthRequest { individual_id: "1234567890".to_string(), individual_id_type: IdType::Uin, request_factors: vec![AuthFactor::Demographic, AuthFactor::Biometric], transaction_id: "txn-001".to_string(), request_time: "2026-03-15T10:00:00Z".to_string(),};Offline Verification Result
Section titled “Offline Verification Result”| Field | Description |
|---|---|
structure_valid | Whether the credential JSON structure is valid |
not_expired | Whether the credential has not passed its expiry date |
has_biometric | Whether face data is present for biometric matching |
verified | Overall verification status (true if not expired; signature check is separate) |
Key Types
Section titled “Key Types”| Type | Description |
|---|---|
AuthRequest | MOSIP IDA authentication request with individual ID, factors, and transaction ID |
AuthResponse | Authentication result with status, errors, and transaction ID |
IdType | Individual identifier type: Uin or Vid |
AuthFactor | Authentication factor: Demographic, Biometric, or Otp |
OfflineCredential | QR-encodable credential with personal data, face photo, and signature |
OfflineVerificationResult | Result of offline structural and expiry verification |
Related Crates
Section titled “Related Crates”- baseid-core — error types and
BilingualErrortrait used byMosipError - baseid-eidas — complementary EU identity framework (MOSIP targets Global South deployments)
- baseid-verifier-core — higher-level verification pipeline that can wrap MOSIP credential checks