Quadratic-Labs / VerkleTries_Besu

MIT License
14 stars 16 forks source link

ENH: nativelib commit_one function #29

Open thomas-quadratic opened 11 months ago

thomas-quadratic commented 11 months ago

Implement a function commit_one that computes the hash of a single value at given index, the rest of the values being null. The signature of the function should be (value: jbyteArray, index: jint) -> hash: jbyteArray

Rationale: when dealing with extensions, we have to commit to a single value. Currently, this would be done by left padding with zeroes up to the index of the value and committing all those values. Similarly to the rust-verkle library, we can implement a much more efficient way of committing to a single value by using a single scalar_multiply operation.

dragan2234 commented 11 months ago

@thomas-quadratic When do we commit to only one value? in the branch nodes? In the "extension and suffix nodes" the way I see it we always commit to 4 values (1,stem,C1,C2,0,0,0,0...) and in the C1 and C2 we commit to 128 values each.

dragan2234 commented 11 months ago

Ah I see, even in leafNodes we need to have this option