Software
Türkçe okuCross-Verification of VIZ, MRZ, and DG1 Data on the Chip Using AI
We combine the visual data field, the optical MRZ, and the DG1 information from the eMRTD chip into a single, interpretable result using OCR confidence, MRZ verification steps, jMRTD, and Passive Authentication.
The same identification information on an eMRTD data page may appear in three different channels: the Visual Inspection Zone (VIZ), which is read by the human eye; the MRZ, which is machine-readable; and the DG1 on the contactless chip. Cross-validation of these three sources is a powerful tool for detecting personalization errors and data inconsistencies. AI can specifically address VIZ OCR ambiguity; however, the chip signature and Data Group integrity are verified only through ICAO Passive Authentication.
The Role of the Three Data Sources
- VIZ: Visual fields on the document, such as name, date of birth, document number, and similar information.
- MRZ: The machine-readable zone featuring a fixed character set and check digits in the ICAO Doc 9303 format.
- DG1: The LDS Data Group on the chip that carries the MRZ information.
The fact that DG1 has been read does not, by itself, prove its authenticity. The EF.SOD signature must be verified with the DS certificate, the DS chain with the CSCA, and the DG1 hash with EF.SOD.
Recommended verification sequence
- Capture a visual image of the document under controlled conditions.
- Read the VIZ fields using region-based OCR and store the character confidence scores.
- Read the MRZ and perform format and check digit validations.
- After PACE/BAC, read the EF.DG1 and EF.SOD from the chip.
- Complete the Passive Authentication result.
- Compare the VIZ, optical MRZ, and verified DG1 fields after normalization.
- Generate the result as MATCH, REVIEW, or MISMATCH with reason codes.
Reading DG1 with jMRTD
import java.io.InputStream;
import org.jmrtd.PassportService;
import org.jmrtd.lds.icao.DG1File;
import org.jmrtd.lds.icao.MRZInfo;
DG1File readDg1(PassportService service) throws Exception {
try (InputStream in = service.getInputStream(PassportService.EF_DG1)) {
return new DG1File(in);
}
}
DG1File dg1 = readDg1(passportService);
MRZInfo chipMrz = dg1.getMRZInfo();
String documentNumber = chipMrz.getDocumentNumber();
String primaryId = chipMrz.getPrimaryIdentifier();
String secondaryId = chipMrz.getSecondaryIdentifier();
String dateOfBirth = chipMrz.getDateOfBirth();
Package or method signatures may vary depending on the jMRTD version; check the API documentation for the version being used.
Normalization layer
VIZ and MRZ may represent the same information using different spelling conventions. Direct string comparisons of Unicode characters, accents, spaces, hyphens, and MRZ filler characters without normalization will produce false positives.
import java.text.Normalizer;
import java.util.Locale;
static String normalizeIdentityText(String value) {
if (value == null) return "";
String decomposed = Normalizer.normalize(value, Normalizer.Form.NFD);
return decomposed
.replaceAll("\\p{M}+", "")
.toUpperCase(Locale.ROOT)
.replace('<', ' ')
.replaceAll("[^A-Z0-9 ]", "")
.replaceAll("\\s+", " ")
.trim();
}
Country-specific transliteration policies may be more comprehensive than a general accent-removal function. The production system should use the transliteration tables defined by the issuing authority.
Field-based comparison
enum FieldStatus { MATCH, REVIEW, MISMATCH, NOT_AVAILABLE }
record FieldResult(
String field,
FieldStatus status,
double confidence,
String reason
) {}
static FieldResult compareName(
String vizValue, double vizOcrConfidence, String dg1Value) {
String viz = normalizeIdentityText(vizValue);
String chip = normalizeIdentityText(dg1Value);
if (viz.isBlank() || chip.isBlank())
return new FieldResult("name", FieldStatus.NOT_AVAILABLE, 0, "MISSING_VALUE");
if (viz.equals(chip))
return new FieldResult("name", FieldStatus.MATCH, vizOcrConfidence, "EXACT_NORMALIZED");
if (vizOcrConfidence < 0.85)
return new FieldResult("name", FieldStatus.REVIEW, vizOcrConfidence, "LOW_OCR_CONFIDENCE");
return new FieldResult("name", FieldStatus.MISMATCH, vizOcrConfidence, "VALUE_DIFFERENCE");
}
AI or fuzzy matching should not be used to silently treat different values as equal. The similarity model should generate a REVIEW priority; it should not hide exact mismatches in critical fields.
MRZ verification steps
Check digit controls for fields such as document number, date of birth, and expiration date are strong, deterministic indicators for detecting OCR errors. If the MRZ check fails, AI may generate automatic correction suggestions; the selected character change, confidence score, and alternatives must be recorded in the audit trail.
WEIGHTS = (7, 3, 1)
def mrz_value(ch: str) -> int:
if ch == '<': return 0
if ch.isdigit(): return int(ch)
return ord(ch) - ord('A') + 10
def check_digit(text: str) -> str:
total = sum(mrz_value(c) * WEIGHTS[i % 3]
for i, c in enumerate(text))
return str(total % 10)
def check_field(text: str, expected: str) -> bool:
return check_digit(text) == expected
Combination of AI Risk Score and Rule Engine
Cryptographic or check digit errors should not be left to the model. Deterministic rules run first; AI only generates OCR ambiguity, character alternatives, and review priority.
def final_decision(passive_auth, mrz_checks, field_results, ai_risk):
if passive_auth == "FAIL":
return "MISMATCH", ["PASSIVE_AUTH_FAILED"]
if not all(mrz_checks.values()):
return "REVIEW", ["MRZ_CHECK_DIGIT_FAILED"]
if any(x["status"] == "MISMATCH" for x in field_results):
return "MISMATCH", ["CROSS_SOURCE_DIFFERENCE"]
if ai_risk >= 0.60 or any(x["status"] == "REVIEW" for x in field_results):
return "REVIEW", ["AI_OR_OCR_UNCERTAINTY"]
return "MATCH", []
Sample result model
{
"passiveAuthentication": "PASS",
"sources": {"viz": "CAPTURED", "mrz": "CHECKED", "dg1": "SOD_HASH_VERIFIED"},
"fields": [
{"name": "documentNumber", "status": "MATCH"},
{"name": "dateOfBirth", "status": "MATCH"},
{"name": "surname", "status": "REVIEW", "reason": "LOW_OCR_CONFIDENCE"}
],
"decision": "REVIEW"
}
Result
VIZ, MRZ, and DG1 cross-validation; it combines visual personalization, optical reading, and chip data into a single verifiable result. AI is valuable in VIZ OCR and uncertainty management. The foundation of trust lies in MRZ rules, the EF.SOD signature, the DS–CSCA chain, and Data Group hash verification.
References
How would you rate this article?
Your feedback helps improve future articles.