Currently we use type Buffer to pass around leaf in plenty of the places in our codebase, e.g.:
public async findLeafIndex(treeId: MerkleTreeId, leafValue: Buffer): Promise<bigint | undefined>;
and in other places we use Fr:
public async getCommitmentIndex(commitment: Fr): Promise<bigint | undefined> {
return await this.db.findLeafIndex(MerkleTreeId.NOTE_HASH_TREE, commitment.toBuffer());
}
I think it would be better to always use Fr (and serialize it to a buffer when inserting the leaf) because otherwise there is a risk of serialization issues (I just did this mistake when I use copilot's solution of serializing bigint to a buffer instead of using our own).
Currently we use type
Bufferto pass around leaf in plenty of the places in our codebase, e.g.:and in other places we use
Fr:I think it would be better to always use
Fr(and serialize it to a buffer when inserting the leaf) because otherwise there is a risk of serialization issues (I just did this mistake when I use copilot's solution of serializing bigint to a buffer instead of using our own).