Support

We're here to help you get the most out of Truestamp. Find answers to common questions or get in touch with our support team.

Community & Updates

Share feedback, follow what we're building next, and see what just shipped. Each opens right here in a popup, so no separate account is needed.

Knowledge Base

Browse the concepts behind Truestamp. Pick a domain to explore, follow the links between concepts, or search across everything.

Some Aspects of Merkle Tree - DEV Community

Sergey Shandar's developer article on Merkle tree implementation pitfalls: second preimage and length extension attacks, distinguishing data from branch nodes, and hash alignment limits in content-addressable networks.

Open resource

Overview

“Some Aspects of Merkle Tree” is a developer article by Sergey Shandar published on DEV Community. It examines practical implementation pitfalls of Merkle trees rather than restating their basic mechanics, with an emphasis on security vulnerabilities and the efficiency limits that matter when Merkle hashing is used for incremental validation in content-addressable networks. The article models a tree over data digests using a cryptographic compression function that takes two child digests and returns their parent digest.

Key points

  • Merkle trees split large content into fixed segments so a downloader can validate pieces incrementally, detecting corrupted or malicious data early without first fetching an entire large file.
  • Second preimage attack: a naive tree cannot tell a leaf (data) digest apart from an internal (branch) digest, so an attacker can pass off an intermediate hash as though it were data and still validate. Shandar’s fixes are to hash data blocks with a distinct function from the internal compression function, or to tag each digest with a single bit (0 for data, 1 for a hash result).
  • Length extension attack: because a valid Merkle root can itself be reused as a node inside a larger tree, an attacker can construct a valid hash for an appended data block; the mitigation is to transform the root hash before publishing it.
  • Deduplication and shift resistance: Merkle-based chunking only deduplicates when identical content chunks line up with tree boundaries, so inserting or shifting bytes can misalign chunks and defeat the savings.
  • The distinction between data nodes and branch nodes is the central correctness concern, and domain separation between the two is the recurring remedy.

Relevance to Truestamp

Truestamp’s Merkle proofs follow RFC 6962, which addresses exactly the second preimage concern this article raises by prefixing leaf inputs and internal-node inputs with distinct bytes, a form of hash domain separation. The article is a concise developer-level motivation for why that leaf-versus-branch Merkle tree distinction is required before inclusion proofs can be trusted.

Citations

  1. Some Aspects of Merkle Tree - DEV Community. Sergey Shandar, DEV Community (dev.to).

Get Help

API Documentation

Comprehensive guides for the REST and GraphQL APIs, including interactive documentation and code examples.

View API Docs

FAQ

Quick answers to the most commonly asked questions about timestamping and verification.

Browse FAQ

Email Support

Send us a message and our team will respond within 24 hours.

[email protected]

Security Issues

Report security vulnerabilities through our responsible disclosure program.

[email protected]