1

I wanted to try to decode my EU covid passport, and found these instructions for python. I was trying to do it in nodejs which I am more familiar with

There is a 3 stage process

  • decode Base 45
  • decompress
  • extract cose data

I have the code below, but the cose.encrypt.read is hitting the catch method with an error Unknown tag, 18

Any ideas?

const base45 = require("base45");
const zlib = require("zlib");
const cose = require("cose-js");

passport =
    "HC1:NCFO...";

// removes HC1:
payload = passport.slice(4);

// returns buffer
const decoded = base45.decode(payload);

// Use inflate https://stackoverflow.com/questions/47652769/zlib-node-js-cant-extract-compressed-data-from-python
const decompressed = zlib.inflateSync(decoded);
console.log(decompressed);

cose.encrypt
    .read(decompressed)
    .then((buf) => {
        console.log("Protected message: " + buf.toString("utf8"));
    })
    .catch((error) => {
        console.log("!!", error);
    });
jps
  • 20,041
  • 15
  • 75
  • 79
Simon H
  • 20,332
  • 14
  • 71
  • 128
  • I am stuck at last step too, but I don't know anything anout node.js, I only know browser javascript; I succesfully decoded the BASE45 string and the zlib string, but the decoding of the resulting string using CBOR.js library fails, any suggestion? – jumpjack Sep 10 '21 at 13:20
  • I suggest you open a new question with more details of the error you experience. I may be able to answer now that I've made more progress in understanding things, and I am doing it in the browser too – Simon H Sep 10 '21 at 16:01
  • Currently I am not authorized to post any more question. – jumpjack Sep 11 '21 at 09:07

1 Answers1

0

I subsequently found https://dev.to/lmillucci/javascript-how-to-decode-the-greenpass-qr-code-3dh0 which had a working nodejs solution in it :-)

Simon H
  • 20,332
  • 14
  • 71
  • 128