ivosh / node-nist

A simple low-level ANSI/NIST-ITL 1-2011 (update 2015) encoding and decoding utility library. Written in Typescript for Node.
MIT License
12 stars 6 forks source link

Hey Nice Work, No Examples on Decoding And Can I detect standard? #28

Open Hussseinkizz opened 10 months ago

Hussseinkizz commented 10 months ago

I suspect I have a ANSI/INCITS 378-2004 minutiae data binary, how do I detect the standard anyways, here is a sample well its base64 but it's binary when decoded, and according to this I have been following: https://templates.machinezoo.com it's probably ANSI/INCITS 378-2004 but though node nist can help me, there is my sample: Qj4EHM5BFwQhuIFzBCG6g/0EXlyB7QRozoGMBNjQQSwFR9CCcQVXW4LWBWZbhVEFemdAmAWJzkENBajUhR8FvG5EWQXWb4IqBdtbRTgF73xAnQX00EY2Bfl4gVkGGFaFywZkf0HyBn1fhJAGgoCEDAahfoNlBrBxgX0GzmCBIgbZYoCTBuNzgyMG43uCSAcGc0PaBwaEhe8HFopDygdIhkB6B2wCQSwHdnpE3QefikKzB7iCQU8Hx4JFTAfHCkPPCAkEQvoILYRFvAhWDED+CN+IgxgI7o2FGgjzjoRoCQKVg+QJF59CmQkhtoLcCSG7Ql0JJryDjQkroQ==

ivosh commented 10 months ago

Hi @Hussseinkizz please describe your use case and give more context to your query. How minutiae binary data was obtained? What is the processing chain? What evidences do you have to support your suspection about ANSI/INCITS 378-2004 minutiae? Indeed, ANSI/NIST-ITL 1-2011 (which node-nist implements) supports exchange of minutiae in Type-9 record. Do you know which fields the minutiae data were originally extracted from?

Hussseinkizz commented 10 months ago

Hi thanks, that was a good response, well this is why I suspect it's that: carbon(18) And then I even decoded the data following that standard and all things seem to follow but am not just sure whether am doing right thing, like I tried to mess with the data manually to try to extract the minitia data and then landed on node nist, I was like wow this could help me with this!

ivosh commented 10 months ago

Hi @Hussseinkizz, well you did not add much information from the initial post. Apart from the binary data itself, can you share anything else? Where does the data come from? From an AFIS software? Which one? From a NIST file? Which field? Can you share the whole NIST file?

Just FYI, this project implements ANSI/NIST-ITL 1-2011 but does not deal specifically with the minutiae decoding/encoding (it's a blob right now because every vendor has its own scheme). If you have a pressing need, support can be added for ANSI/INCITS 378-* encoding and decoding.

Hussseinkizz commented 10 months ago

well am in Uganda, this https://www.muehlbauer.de/solutions/border-control-document-verification/document-verification/mb-steel-reader-mobile/ made some ID cards, probably following that standard and am trying to scan the barcode and read the data, so far I could scan it, and get base64 then to binary, which after looking around seems to follow that standard I shared, as the snippet I shared, ohh that site is germany but if you got translator, if I go through this I can even contribute to node-nist, it can be the ultimate library for working with these nist standards, wish it could even detect the used standard following patterns in binary, as in it tries the binary through known formats etc!

ivosh commented 10 months ago

This is starting to be interesting. Could you please describe more the use case how and from where the data is exactly obtained?

From reading the specification for MB Steel Reader Mobile, this device is used to read various eID and ePassport documents (https://en.wikipedia.org/wiki/Machine-readable_passport).

I make the first assumption here that when you say "made some ID cards", you actually refer to Uganda national identity card, such as described here: https://washington.mofa.go.ug/visa/national-id Indeed, the Uganda ID comes with a MRZ Type 1 (3 lines x 30 characters) and a barcode.

I make the second assumption here that when the barcode on the ID card is read, it yields the base64-encoded data which you referenced in the original post. If this is really the case, then it's highly improbable the data contains fingerprint minutiae. Why?

  1. The eID and ePassport documents do not contain this kind of information. It is of no use to the authorities checking the document. They need to check the holder's information and verify the issuer, using technologies such as BAC, PA, AA etc.

  2. Relatively small amount of information found in the barcode would not be able to hold useful amount of fingerprint minutiae for further processing. And you'll still need the corresponding fingerprints in 500DPI or 1000DPI quality. Maybe Uganda authorities decided to retrieve the fingerprints from every citizen and put it on the chip inside the ID (I seriously doubt this). Still, the fingerprint minutiae will be stored on the chip inside the ID and not in the barcode zone.

  3. The format of ANSI/INCITS 378-2004 header is different from the base64-decoded binary data posted by you. The specification I found [1] says: "First four bytes of the template contain constant string "FMR\0" where '\0' stands for zero byte." I do not see that anywhere.

Please correct me where I am wrong. Please also provide more details on your use case - be exact and specific.

[1] https://templates.machinezoo.com/ansi378-2004#magic

Hussseinkizz commented 10 months ago

Hey wow thanks that's interesting to hear, you discovered all that, indeed am trying to get data from Uganda National ID barcode, now am trying to look into this: https://www.nist.gov/services-resources/software/biomdi-software-tools-supporting-standard-biometric-data-interchange yes your didn't find the magic number in binary, it's really not there but it seems only minutia data was encoded into the barcode, for example, all barcodes seem to have 50 bytes, each in pack of 5, and first 2 bits of each giving minutia type, a 10 or 01, as indicated by the standard, then the byte for the angle indeed has no byte with byte value more than 360, I strongly believe it is, I just can't figure out how to get it exactly the right way, none the less thanks friend, thanks a lot for trying to help upto this point. If there's anything or any way you think I could go around this, cause I want to match the print on that ID with a print I take here, am just trying to learn about all this but it's a bit overwhelming!!!

Hussseinkizz commented 9 months ago

Hey I solved my case, it was that standard I proved it and it worked out!

ivosh commented 9 months ago

Hi @Hussseinkizz that's interesting.

Let me recap the facts and please correct me where I am wrong:

  1. To enroll for an Uganda National identity card, apart from the standard demographic information, the applicant's facial image and fingerprints are taken.
  2. Minutiae is extracted from the fingeprints and put into the barcode on the id.
  3. The barcode according to your statement contains minutiae in the format which seems to follow ANSI/INCITS 378-2004 but only the MINUTIA part [1], starting from MINTYPE.

What is not clear to me at this point is that the whole MINUTIA record should be 6 bytes long according to the standard but the total data length from the barcode is 250 bytes (= not divisible by 6). Could you perhaps share the decoding algorithm?

[1] https://templates.machinezoo.com/ansi378-2004#minutia

Hussseinkizz commented 9 months ago

I can't share the decoding algorithms but it's 5 bytes instead of 6, because the last byte can be optional and therefore it is, all the other facts you mentioned are correct!

ivosh commented 9 months ago

@Hussseinkizz Thanks for the confirmation, that's good news! If you still feel contributing to this project, feel free to do so. Basically you've focused on decoding field 9.137 (FMD) of ANSI/NIST-ITL 1-2011. Unfortunately the format of minutia as given in ANSI/NIST-ITL 1-2011 is a bit different than the one described in ANSI/INCITS 378-2004. Nevertheless, a small utility function for decoding and encoding can be contributed from your side?

Hussseinkizz commented 9 months ago

Ok sure, am going to keep this on my radar, I will contribute the decoding bit, thanks for this great work though friend!