Skip to content

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.

  • MOSIP authentication APIAuthRequest / AuthResponse types 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 credentialsOfflineCredential encoding personal data, issuer metadata, base64-encoded face photograph, and digital signature into a JSON payload suitable for QR codes
  • Offline verificationverify_offline checks structural validity and expiry without network access; signature verification and biometric matching are delegated to platform-specific implementations
  • QR payload codecto_qr_payload() / from_qr_payload() for JSON serialization targeting QR code generation
  • Bilingual errorsMosipError variants with English and French messages for authentication failures, invalid QR codes, expired credentials, biometric mismatches, and unsupported versions
use baseid_mosip::qr::{OfflineCredential, verify_offline};
// Create an offline credential for QR encoding
let 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 code
let qr_payload = credential.to_qr_payload()?;
// Decode from QR scan
let 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);
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(),
};
FieldDescription
structure_validWhether the credential JSON structure is valid
not_expiredWhether the credential has not passed its expiry date
has_biometricWhether face data is present for biometric matching
verifiedOverall verification status (true if not expired; signature check is separate)
TypeDescription
AuthRequestMOSIP IDA authentication request with individual ID, factors, and transaction ID
AuthResponseAuthentication result with status, errors, and transaction ID
IdTypeIndividual identifier type: Uin or Vid
AuthFactorAuthentication factor: Demographic, Biometric, or Otp
OfflineCredentialQR-encodable credential with personal data, face photo, and signature
OfflineVerificationResultResult of offline structural and expiry verification
  • baseid-core — error types and BilingualError trait used by MosipError
  • baseid-eidas — complementary EU identity framework (MOSIP targets Global South deployments)
  • baseid-verifier-core — higher-level verification pipeline that can wrap MOSIP credential checks