I am trying to find a good implementation of Merkle Tree generation in Golang, and I need the tree to be resilient to Second Preimage Attack

I have found this standard implementation in the golang docs, but it looks to me like it is susceptible to Second Preimage Attacks, since it only uses 1 hashing algorithm for the leaf and interior nodes. Is this right?

Is so, is there a standard implementation of this available?

  • $\begingroup$ Does this answer your question? How does second pre-image attack on Merkle Signature Scheme work? $\endgroup$
    – kodlu
    Commented Aug 24, 2022 at 19:39
  • 1
    $\begingroup$ I've had read through that, and this makes me believe that the above implementation is not safe, however I am not 100% sure so wanted clarification on here $\endgroup$ Commented Aug 24, 2022 at 20:03
  • $\begingroup$ ok fair enough... $\endgroup$
    – kodlu
    Commented Aug 24, 2022 at 20:27
  • $\begingroup$ One cryptography hash function is enough as long as one puts level indicator into hashing, see here $\endgroup$
    – kelalaka
    Commented Aug 27, 2022 at 11:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.