Skip to content

v0.4.0

@cbergoon cbergoon tagged this 14 Aug 01:27
Adds serialization and an opt-in RFC 6962 construction, and fixes four
correctness bugs. The default construction is unchanged: roots, proofs and
indexes are byte for byte identical to v0.3.0.

New:
- Marshal/Unmarshal for binary, JSON and gob, closing #13. A tree is encoded
  as the seed it rebuilds from, and the recorded root makes decoding
  self-checking
- NewTreeWithOptions, with WithHasher, WithSortedSiblings and WithRFC6962
- WithRFC6962 prefixes leaf and interior hashes and splits odd node counts
  rather than duplicating them, closing the second preimage weakness and
  CVE-2012-2459 for trees that opt in
- Sorted() and RFC6962() accessors
- ErrNoContent, ErrNilContent and ErrContentNotFound sentinels

Fixed:
- VerifyTree recomputed from content but never checked the hashes recorded on
  the nodes, so an edited interior hash went unnoticed
- a nil entry in the content slice panicked instead of returning an error
- Node.sort was dead

Behaviour changes, same signatures:
- GetMerklePath returns ErrContentNotFound for content that is not in the
  tree, where it previously returned nil, nil, nil
- VerifyTree is stricter, and now rejects a tree whose stored node hashes have
  been edited
Assets 2
Loading