Skip to content

Commit ebffc12

Browse files
committed
add comments
1 parent c8dd270 commit ebffc12

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

proof/proof.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func SubtreeInclusion(index, start, end uint64) (Nodes, error) {
7676
for n := range p.IDs {
7777
p.IDs[n].Index += start >> p.IDs[n].Level
7878
}
79+
// For consistency, always shift p.ephem, regardless of whether it will be
80+
// used by the proof.
7981
p.ephem.Index += start >> p.ephem.Level
8082

8183
return p, nil
@@ -163,6 +165,8 @@ func nodes(index uint64, level uint, size uint64) Nodes {
163165
len1, len2 = 0, 0
164166
}
165167

168+
// Edge case: For perfect trees the ephemeral node is the sibling of the root
169+
// However, it will not be used in any proof.
166170
return Nodes{IDs: nodes, begin: len1, end: len2, ephem: fork.Sibling()}
167171
}
168172

@@ -236,7 +240,7 @@ func isSubtreeValid(start, end uint64) bool {
236240
}
237241

238242
// bitCeil returns the smallest power of 2 larger than n.
239-
// Panics if n > 2^63.
243+
// MUST NOT be used with n larger than uint64(1)<<63.
240244
func bitCeil(n uint64) uint64 {
241245
if n <= 1 {
242246
return 1

0 commit comments

Comments
 (0)