MTREE_VERIFY(3)

πŸ’… MTREE_VERIFY β€” bestie's guide to validating a merkle tree

okay so picture this: you're in the Librecast ecosystem, you got a merkle tree, and you need to know if it's actually valid or if it's lying to you. that's literally what mtree_verify is for. iconic behavior fr fr.


🌸 LIBRARY 🌸

it lives in the Librecast library β€” that's liblibrecast, and you link it with -llibrecast. yes bestie, the flag has a double-l. it's giving lib + librecast. just trust. 🫢


✨ SYNOPSIS ✨

#include <librecast/mtree.h>

int mtree_verify(mtree_t *tree);

and when you build, you compile and link with -llibrecast. don't forget that part or the compiler will simply not know her. 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

so mtree_verify takes your tree and re-hashes the nodes from the base all the way up to the root. like, bottom-to-top, no skips, no shortcuts.

if everything checks out and the tree is valid, she returns zero. that's it. that's the whole vibe. πŸŽ€

the way that a merkle tree works is every node's hash depends on the ones below it, so re-hashing from the base upward is the whole verification moment. if any node got messed with, the hashes stop matching and you find out. main character energy, honestly. ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

  • zero β€” the tree is valid, slay, everything is fine, go touch grass πŸ’–
  • -1 β€” the tree is not valid. something's off. not great, bestie. πŸ’€

🌈 ERRORS 🌈

None.

literally none. no errno drama, no surprise failures hiding in the docs. she returns zero or -1 and that's the entire story. periodt. πŸ’…


πŸ“ SEE ALSO πŸ“

go read those too, iykyk. πŸ“šβœ¨


and that's the whole page, bestie πŸ’œ this one's from the LIBRECAST manual, dated 2023-06-20. go verify a tree, you got this. πŸ§šβ€β™€οΈπŸŒΈ

πŸ“¦ where this page comes from