Help needed regarding merkle implementation in noir

Just to supplement the other answer, I think the “position of the leaf in the tree” means that leftmost “leaf index” is 0 and the rightmost is ( 2^height)-1 (if height does not include root).

                                  ┏━━━┓
root:               ╭─────────────┨ r ┠─────────────╮
                    │             ┗━━━┛             │
                  ┏━┷━┓                           ┏━┷━┓
lyr2:       ╭─────┨ x ┠─────╮               ╭─────┨ x ┠─────╮
            │     ┗━━━┛     │               │     ┗━━━┛     │
          ┏━┷━┓           ┏━┷━┓           ┏━┷━┓           ┏━┷━┓
lyr1:   ╭─┨ x ┠─╮       ╭─┨ x ┠─╮       ╭─┨ x ┠─╮       ╭─┨ x ┠─╮
        │ ┗━━━┛ │       │ ┗━━━┛ │       │ ┗━━━┛ │       │ ┗━━━┛ │
      ┏━┷━┓   ┏━┷━┓   ┏━┷━┓   ┏━┷━┓   ┏━┷━┓   ┏━┷━┓   ┏━┷━┓   ┏━┷━┓
lry0: ┃ 0 ┃   ┃ 1 ┃   ┃ 2 ┃   ┃ 3 ┃   ┃ 4 ┃   ┃ 5 ┃   ┃ 6 ┃   ┃ 7 ┃
      ┗━━━┛   ┗━━━┛   ┗━━━┛   ┗━━━┛   ┗━━━┛   ┗━━━┛   ┗━━━┛   ┗━━━┛

height = 3
num_leaves = (2^height) = 2^3 = 8
59 Likes