Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Fr for leafValue everywhere in our API #3172

Closed
benesjan opened this issue Nov 1, 2023 · 0 comments · Fixed by #3173
Closed

Use Fr for leafValue everywhere in our API #3172

benesjan opened this issue Nov 1, 2023 · 0 comments · Fixed by #3173

Comments

@benesjan
Copy link
Contributor

benesjan commented Nov 1, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant