Does anyone with experience with cose-js know how to add a cbor tag to a cose signature? More specifically the tag "18" indicating that it is cose-sign1.
I am studying COSE for my computer science course and I need to encode a secret recipe using CBOR and COSE, using the cose-sign1 procedure.
const payload = Buffer.from('mysecretfoodrecipe', 'base64')
const headers = {
'p': {'alg': 'ES256', 'kid': 'chefsid'},
'u': []
};
const signer = {
'key': {
'd': Buffer.from('mysecretrecipesignature', 'hex')
}
};
cose.sign.create(
headers,
payload,
signer)
.then((buf) => {
console.log('Signed message: ' + buf.toString('hex'));
console.log(headers, payload, signer)
return buf.toString('hex')
}).catch((error) => {
console.log(error);
});
Currently you get this --> {[[protected header, unprotected header], [payload], [signature]]}.
But I require this --> {Number: 18 Content: [[protected header, unprotected header], [payload], [signature]]}
Any ideas?
Thanks