An open API service indexing awesome lists of open source software.

https://github.com/lunastev/essentials

A minimalist utility library for the Noir programming language, focused on providing essential zero-knowledge circuit components with a clean and practical API.
https://github.com/lunastev/essentials

essentials library noir-lang sha256

Last synced: 4 days ago
JSON representation

A minimalist utility library for the Noir programming language, focused on providing essential zero-knowledge circuit components with a clean and practical API.

Awesome Lists containing this project

README

          

# essentials

A minimalist utility library for the Noir programming language, focused on providing essential zero-knowledge circuit components with a clean and practical API.

---

## โœจ Features

* `hash_sha256`: Compute SHA-256 hash of a byte array (uses official Noir sha256 submodule)
* `verify_equal`: Assert that two Field values are equal
* `is_even`: Check if a Field value is even (casts to u32 internally)
* `check_in_range`: Assert that a Field is within a given inclusive range (uses u32 casting)

---

## ๐Ÿ“ฆ Installation

1. Clone this repo with submodules:

```bash
git clone --recurse-submodules https://github.com/yourname/essentials.git
```

2. Or add it to an existing Noir project:

```bash
git submodule add https://github.com/yourname/essentials.git essentials
```

3. Then in your `Nargo.toml`:

```toml
[dependencies]
essentials = { path = "./essentials" }
sha256 = { path = "./essentials/sha256" }
```

---

## ๐Ÿงช Usage

Example in your main Noir file:

```noir
use essentials::hash::hash_sha256;
use essentials::logic::{verify_equal, is_even};
use essentials::range::check_in_range;

fn main() {
let x: Field = 4;
let y: Field = 4;

verify_equal(x, y);
assert(is_even(x));
check_in_range(x, 1, 10);
}
```

---

## ๐Ÿ“ File Structure

```
essentials/
โ”œโ”€โ”€ Nargo.toml
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ lib.nr
โ”‚ โ”œโ”€โ”€ hash.nr
โ”‚ โ”œโ”€โ”€ logic.nr
โ”‚ โ””โ”€โ”€ range.nr
โ””โ”€โ”€ sha256/ (submodule)
```

---

## ๐Ÿชช License

This project is licensed under the [Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/2.0/).