diff --git a/src/service/internal_tables_access.h b/src/service/internal_tables_access.h index e14c39c7d153..ccc52e66f7d4 100644 --- a/src/service/internal_tables_access.h +++ b/src/service/internal_tables_access.h @@ -395,6 +395,7 @@ namespace ccf ccf::CoseEndorsement endorsement{}; std::vector pheaders{}; std::vector key_to_endorse{}; + std::vector previous_root{}; endorsement.endorsing_key = service_key.public_key_der(); @@ -426,9 +427,7 @@ namespace ccf } const auto root = previous_service_last_signed_root->get().value(); - pheaders.push_back(ccf::crypto::cose_params_string_bytes( - ccf::crypto::COSE_PHEADER_KEY_MERKLE_ROOT, - std::vector(root.h.begin(), root.h.end()))); + previous_root.assign(root.h.begin(), root.h.end()); } else { @@ -450,6 +449,11 @@ namespace ccf ccf::crypto::COSE_PHEADER_KEY_RANGE_END, endorsement.endorsement_epoch_end->to_str())); } + if (!previous_root.empty()) + { + pheaders.push_back(ccf::crypto::cose_params_string_bytes( + ccf::crypto::COSE_PHEADER_KEY_MERKLE_ROOT, previous_root)); + } try {