Skip to content

Commit 2d123cf

Browse files
committed
New release: cardano-signer 1.24.1
## Release Notes / Change-Logs * 1.24.1 #### CIP8/30 Updates - The CIP8/30 verification function now handles all set keys in the `protected header`. In the past the `protected header` was rebuilt for internal verification using only the `alg (map 1)` and `address` key entry.<br>Which could have caused an issue if Signature-Generators add additional keys in the `protected header`, like the optional `kid (map 4)` entry.<br>Now cardano-signer handles the header as it is and only replaces entries in the address and kid keys if an optional verification address is provided. - The *protected header map* is now also included in the `--json-extended` output for the `verify cip-8/30` command if you set the `--include-maps` flag.
1 parent 360cfd9 commit 2d123cf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/cardano-signer.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//define name and version
22
const appname = "cardano-signer"
3-
const version = "1.24.0"
3+
const version = "1.24.1"
44

55
//external dependencies
66
const CardanoWasm = require("@emurgo/cardano-serialization-lib-nodejs")
@@ -718,7 +718,10 @@ function verifyCIP8(workMode = "verify-cip8", calling_args = process.argv.slice(
718718
if ( ( sub_args['nohashcheck'] === false ) && ! sign_addr.matchPubKey ) { //exit with an error if the address does not contain the pubKey hash
719719
throw {'msg': `The given ${sign_addr.type} address '${sign_addr.addr}' does not belong to the public key in the COSE_Key.`};
720720
}
721-
721+
//replace the 'address' map in the protectedHeader with the given one
722+
protectedHeader.set('address',Buffer.from(sign_addr.hex,'hex'));
723+
//check if the optional kid (map4) "key-identifier" was also supplied in the protectedHeader. if so, also replace that entry
724+
if ( protectedHeader.has(4) ) { protectedHeader.set(4,Buffer.from(sign_addr.hex,'hex')); }
722725
} else {
723726
//read the sign_addr from the protectedHeader
724727
sign_addr = readAddr2hex(sign_addr_buffer.toString('hex'), pubKey);
@@ -774,7 +777,9 @@ function verifyCIP8(workMode = "verify-cip8", calling_args = process.argv.slice(
774777
// alg (1) - must be set to EdDSA (-8)
775778
// kid (4) - Optional, if present must be set to the same value as in the COSE_Key specified below. It is recommended to be set to the same value as in the "address" header.
776779
// "address" - must be set to the raw binary bytes of the address as per the binary spec, without the CBOR binary wrapper tag
777-
var protectedHeader_cbor_hex = Buffer.from(cbor.encode(new Map().set(1,-8).set('address',Buffer.from(sign_addr.hex,'hex')))).toString('hex')
780+
// var protectedHeader_cbor_hex = Buffer.from(cbor.encode(new Map().set(1,-8).set('address',Buffer.from(sign_addr.hex,'hex')))).toString('hex')
781+
// var protectedHeader_cbor_hex = Buffer.from(cbor.encode(new Map().set(1,-8).set(4,Buffer.from(sign_addr.hex,'hex')).set('address',Buffer.from(sign_addr.hex,'hex')))).toString('hex')
782+
var protectedHeader_cbor_hex = cbor.encode(protectedHeader).toString('hex')
778783

779784
//generate the data to verify, as a serialized cbor of the Sig_structure
780785
//Sig_structure = [
@@ -802,7 +807,7 @@ function verifyCIP8(workMode = "verify-cip8", calling_args = process.argv.slice(
802807
if ( Sig_structure_cbor_hex.length <= 2000000 ) { content += `"verifyDataHex": "${Sig_structure_cbor_hex}", `; } //only include the Sig_structure_cbor_hex if it is less than 2M of chars
803808
content += `"signature": "${signature_hex}", "publicKey": "${pubKey}"`;
804809
if ( sub_args['include-maps'] === true ) { //generate content also with JSON-Maps for the COSE_Key, COSE_Sign1 and verifyData structures
805-
content += `, "maps": { "COSE_Key": ${mapToJs(COSE_Key_structure)}, "COSE_Sign1": ${mapToJs(COSE_Sign1_structure)}, "verifyData": ${mapToJs(Sig_structure)} }` }
810+
content += `, "maps": { "COSE_Key": ${mapToJs(COSE_Key_structure)}, "COSE_Sign1": ${mapToJs(COSE_Sign1_structure)}, "verifyData": ${mapToJs(Sig_structure)}, "protectedHeader": ${mapToJs(protectedHeader)} }` }
806811
content += ` }`
807812
} else { //generate content in text format
808813
var content = `${verified}`;

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cardano-signer",
3-
"version": "1.24.0",
3+
"version": "1.24.1",
44
"description": "cardano-signer signs a given data(hex/text/file) with a signing key(hex/bech/file) or verify the signature via a public key(hex/bech/file). it can also produce a cip-8/cip-30/cip-36 conform payload signing/verification. can produce ed25519 keys from mnemonic for payment, staking, drep, constitutional commitee cold/hot keys, etc...",
55
"main": "cardano-signer.js",
66
"scripts": {

0 commit comments

Comments
 (0)