Skip to content

Conversation

Sword-Smith
Copy link
Contributor

No description provided.

Add stub for calculating a Merkle root from an authentication struct.
Also adds code to generate the witness.

Cf. Neptune-Crypto/twenty-first#228
…of leafs

When calculating the root, don't allow the list of leafs to be empty.
We think we never need the snippet with those inputs, so that should be
fine. It makes the initialization of the `t` value (that should end up
containing the root) simpler, as we can do:

```rust
let mut t = indexed_leafs.first().unwrap().1;
```

instead of
```rust
        let mut t = auth_struct
            .first()
            .copied()
            .unwrap_or_else(|| indexed_leafs.first().unwrap().1);
```

Code works with sane test.
Make Rust-shadowing and state initialization nicer.
Instead of storing this value to memory in each loop iteration, we just
calculate it from `t: Digest` when we need it.
…x, not parent_index

It's a bit more performant to store `left_index` on the stack and then
calculate from it `parent_index` and `right_index` then to store
`parent_index` as we did before and calculate the left and right index
from that.
In a mutator-set context for which this is developed, the leaf-indices
will be grouped together. The benchmark now reflects that.
@Sword-Smith
Copy link
Contributor Author

Let's fix the build on master before merging.

@jan-ferdinand
Copy link
Member

Is this PR still relevant?

@Sword-Smith
Copy link
Contributor Author

Is this PR still relevant?

I think so, yes. Currently the transaction sizes are bigger than they have to be. With this scheme, we can shrink the size of the removal records by up to 90 %. We probably won't do that prior to launch, though.

@aszepieniec
Copy link
Contributor

Probably (?) superseded by #155. (Please unclose if not accurate.)

@aszepieniec aszepieniec closed this May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants