14 m_leaf_idx(0), m_randomness(0, 0x00) {
17 if(raw_sig.size() != (params.len() + params.tree_height() + 1) * params.element_size() +
sizeof(uint32_t)) {
21 for(
size_t i = 0; i < 4; i++) {
22 m_leaf_idx = ((m_leaf_idx << 8) | raw_sig[i]);
25 if(m_leaf_idx >= params.total_number_of_signatures()) {
29 auto begin = raw_sig.begin() +
sizeof(uint32_t);
30 auto end = begin + params.element_size();
31 std::copy(begin, end, std::back_inserter(m_randomness));
33 for(
size_t i = 0; i < params.len(); i++) {
35 end = begin + params.element_size();
37 m_tree_sig.ots_signature.back().reserve(params.element_size());
38 std::copy(begin, end, std::back_inserter(m_tree_sig.ots_signature.back()));
41 for(
size_t i = 0; i < params.tree_height(); i++) {
43 end = begin + params.element_size();
45 m_tree_sig.authentication_path.back().reserve(params.element_size());
46 std::copy(begin, end, std::back_inserter(m_tree_sig.authentication_path.back()));
51 std::vector<uint8_t> result{
static_cast<uint8_t
>(m_leaf_idx >> 24U),
52 static_cast<uint8_t
>(m_leaf_idx >> 16U),
53 static_cast<uint8_t
>(m_leaf_idx >> 8U),
54 static_cast<uint8_t
>(m_leaf_idx)};
56 std::copy(m_randomness.begin(), m_randomness.end(), std::back_inserter(result));
58 for(
const auto& sig :
tree().ots_signature) {
59 std::copy(sig.begin(), sig.end(), std::back_inserter(result));
62 for(
const auto& auth :
tree().authentication_path) {
63 std::copy(auth.begin(), auth.end(), std::back_inserter(result));