|
1 | 1 | //define name and version
|
2 | 2 | const appname = "cardano-signer"
|
3 |
| -const version = "1.24.0" |
| 3 | +const version = "1.24.1" |
4 | 4 |
|
5 | 5 | //external dependencies
|
6 | 6 | const CardanoWasm = require("@emurgo/cardano-serialization-lib-nodejs")
|
@@ -718,7 +718,10 @@ function verifyCIP8(workMode = "verify-cip8", calling_args = process.argv.slice(
|
718 | 718 | if ( ( sub_args['nohashcheck'] === false ) && ! sign_addr.matchPubKey ) { //exit with an error if the address does not contain the pubKey hash
|
719 | 719 | throw {'msg': `The given ${sign_addr.type} address '${sign_addr.addr}' does not belong to the public key in the COSE_Key.`};
|
720 | 720 | }
|
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')); } |
722 | 725 | } else {
|
723 | 726 | //read the sign_addr from the protectedHeader
|
724 | 727 | sign_addr = readAddr2hex(sign_addr_buffer.toString('hex'), pubKey);
|
@@ -774,7 +777,9 @@ function verifyCIP8(workMode = "verify-cip8", calling_args = process.argv.slice(
|
774 | 777 | // alg (1) - must be set to EdDSA (-8)
|
775 | 778 | // 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.
|
776 | 779 | // "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') |
778 | 783 |
|
779 | 784 | //generate the data to verify, as a serialized cbor of the Sig_structure
|
780 | 785 | //Sig_structure = [
|
@@ -802,7 +807,7 @@ function verifyCIP8(workMode = "verify-cip8", calling_args = process.argv.slice(
|
802 | 807 | 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
|
803 | 808 | content += `"signature": "${signature_hex}", "publicKey": "${pubKey}"`;
|
804 | 809 | 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)} }` } |
806 | 811 | content += ` }`
|
807 | 812 | } else { //generate content in text format
|
808 | 813 | var content = `${verified}`;
|
|
0 commit comments