@@ -139,15 +139,18 @@ func RootFromConsistencyProof(hasher merkle.LogHasher, size1, size2 uint64, proo
139139 // Now len(proof) == inner+border, and proof is effectively a suffix of
140140 // inclusion proof for entry |size1-1| in a tree of size |size2|.
141141
142- // Verify the first root.
143- mask := (size1 - 1 ) >> uint (shift ) // Start chaining from level |shift|.
144- hash1 := chainInnerRight (hasher , seed , proof [:inner ], mask )
145- hash1 = chainBorderRight (hasher , hash1 , proof [inner :])
146- if err := verifyMatch (hash1 , root1 ); err != nil {
147- return nil , err
142+ // Verify the first root, if included in the proof.
143+ if start != 0 {
144+ mask := (size1 - 1 ) >> uint (shift ) // Start chaining from level |shift|.
145+ hash1 := chainInnerRight (hasher , seed , proof [:inner ], mask )
146+ hash1 = chainBorderRight (hasher , hash1 , proof [inner :])
147+ if err := verifyMatch (hash1 , root1 ); err != nil {
148+ return nil , err
149+ }
148150 }
149151
150152 // Verify the second root.
153+ mask := (size1 - 1 ) >> uint (shift ) // Start chaining from level |shift|.
151154 hash2 := chainInner (hasher , seed , proof [:inner ], mask )
152155 hash2 = chainBorderRight (hasher , hash2 , proof [inner :])
153156 return hash2 , nil
0 commit comments