MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / TreeHashInput

Class TreeHashInput

mlspp/src/treekem.cpp:818–1127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816};
817
818struct TreeHashInput
819{
820 var::variant<LeafNodeHashInput, ParentNodeHashInput> node;
821 TLS_SERIALIZABLE(node);
822 TLS_TRAITS(tls::variant<NodeType>)
823};
824
825const bytes&
826TreeKEMPublicKey::get_hash(NodeIndex index)
827{
828 if (hashes.count(index) > 0) {
829 return hashes.at(index);
830 }
831
832 auto hash_input = bytes{};
833 const auto& node = node_at(index);
834 if (index.level() == 0) {
835 auto input = LeafNodeHashInput{ LeafIndex(index), {} };
836 if (!node.blank()) {
837 input.leaf_node = node.leaf_node();
838 }
839
840 hash_input = tls::marshal(TreeHashInput{ input });
841 } else {
842 auto input = ParentNodeHashInput{
843 {},
844 get_hash(index.left()),
845 get_hash(index.right()),
846 };
847
848 if (!node.blank()) {
849 input.parent_node = node.parent_node();
850 }
851
852 hash_input = tls::marshal(TreeHashInput{ input });
853 }
854
855 auto hash = suite.digest().hash(hash_input);
856 hashes.insert_or_assign(index, hash);
857 return hashes.at(index);
858}
859
860// struct {
861// HPKEPublicKey encryption_key;
862// opaque parent_hash<V>;
863// opaque original_sibling_tree_hash<V>;
864// } ParentHashInput;
865struct ParentHashInput
866{
867 const HPKEPublicKey& public_key;
868 const bytes& parent_hash;
869 const bytes& original_child_resolution;
870
871 TLS_SERIALIZABLE(public_key, parent_hash, original_child_resolution)
872};
873
874bytes
875TreeKEMPublicKey::parent_hash(const ParentNode& parent,

Callers

nothing calls this directly

Calls 15

LeafIndexClass · 0.85
NodeIndexClass · 0.85
ProtocolErrorClass · 0.85
countFunction · 0.85
NodeCountClass · 0.85
countMethod · 0.80
levelMethod · 0.80
blankMethod · 0.80
leaf_nodeMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80

Tested by

no test coverage detected