Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vlayer-xyz/noir-base64
Base64 encoding for Aztec's noir language
https://github.com/vlayer-xyz/noir-base64
Last synced: 3 months ago
JSON representation
Base64 encoding for Aztec's noir language
- Host: GitHub
- URL: https://github.com/vlayer-xyz/noir-base64
- Owner: vlayer-xyz
- License: mit
- Created: 2023-11-19T05:42:02.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-03T14:56:06.000Z (11 months ago)
- Last Synced: 2024-04-23T23:12:19.153Z (7 months ago)
- Language: Rust
- Homepage:
- Size: 25.4 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-noir - Base64 - a library for base64 encoding (Get Coding / Libraries)
README
# Noir base64
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Nargo Test 🌌](https://github.com/zkworks-xyz/noir-base64/actions/workflows/test.yaml/badge.svg)](https://github.com/zkworks-xyz/noir-base64/actions/workflows/test.yaml)
**Noir base64** contains functions for base64 string and `u8` array encoding for Aztec's **Noir** language
## Installation
In your `Nargo.toml` file, add the following dependency:
```toml
[dependencies]
base64 = { tag = "v0.1.2", git = "https://github.com/zkworks-xyz/noir-base64" }
```## Usage
```rust
use dep::base64;fn main() {
let result: [u8; 8] = base64::encode_str("foobar", [0; 8]);
}
```## API
Library exposes two functions:```rust
pub fn encode_str(input: str, mut result: [u8; M]) -> [u8; M]
```- `input` - string to encode. Max string length is 600.
- `result` - array of bytes to store result in. It should have a proper size otherwise function will fail on assert.
Due to Noir language limitations result size need to be known at compile time and should be calculated by user.
Value of this parameter are irrelevant, only size matters.
- Returns `result` array with encoded string. Function result is also stored in mutable `result` array argument.```rust
pub fn encode(input: [u8; N], mut result: [u8; M], url_safe: bool) -> [u8; M]
```- `input` - array of bytes to encode. Max array size is 600.
- `result` - array of bytes to store result in. It should have a proper size otherwise function will fail on assert.
Due to Noir language limitations result size need to be known at compile time and should be calculated by user.
Values in this array are irrelevant, only size matters.
- `url_safe` - if `true` then `+` and `/` characters will be replaced with `-` and `_` respectively ([RFC4648](https://datatracker.ietf.org/doc/html/rfc4648#section-5))
- Returns `result` array with encoded string. Function result is also stored in mutable `result` array argument.Base64 **decoding** is not supported yet. Will be implemented in future releases.
## Example project
Directory [examples/base64_example/](https://github.com/zkworks-xyz/noir-base64/tree/main/examples/base64_example) contains example Noir project with `base64` library as dependency.## License
This project is licensed under the MIT License. See the [LICENSE](https://github.com/zkworks-xyz/noir-base64/blob/main/LICENSE) file for details.