Skip to content

Commit

Permalink
feat: Add HashMap to the stdlib (#4242)
Browse files Browse the repository at this point in the history
# Description

This PR shall bring HashMap into the `stdlib` of Noir.

## Problem\*

Resolves #4241

## Summary\*

Implementation of `HashMap` with open addressing and quadratic probing
scheme. Since Noir requires knowing loop bounds (and recursive calls) at
compile time, `HashMap` is of fixed capacity and **no** dynamic resize
is accomplished with regard to load factor.

Furthermore, contribution includes implementation of `PedersenHasher` to
be used for now. One can examine potentially better and less heavy
prehash functions.

I tried to conform with best practices of engineering, however since
Noir is in rapid development, there are certain things which may be
optimized in future, both from the code style and performance point of
view.


## Additional Context

I put the `PedersenHasher` among the `poseidon.nr` and `mimc.nr`, so one
can consider moving declaration of other pedersen-related functionality
there, however that would be a breaking change.

## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [x] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
NikitaMasych authored Feb 23, 2024
1 parent 601fd9a commit 650ffc5
Show file tree
Hide file tree
Showing 11 changed files with 834 additions and 0 deletions.
1 change: 1 addition & 0 deletions noir_stdlib/src/collections.nr
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mod vec;
mod bounded_vec;
mod map;
Loading

0 comments on commit 650ffc5

Please sign in to comment.