From 73ae75fc389832b7e9eb735b22faf9b361d88c8f Mon Sep 17 00:00:00 2001 From: Arkadiusz Konior Date: Tue, 28 Nov 2023 12:49:50 +0100 Subject: [PATCH 1/4] Readme update --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d009c37..1df0008 100644 --- a/README.md +++ b/README.md @@ -28,18 +28,27 @@ Library exposes two functions: ```rust pub fn encode_str(input: str, mut result: [u8; M]) -> [u8; M] -pub fn encode(input: [u8; N], mut result: [u8; M], url_safe: bool) -> [u8; M] ``` -- `input` - input string or array of bytes to encode. Max input length is 600. -- `result` - array of bytes to store result in. it should have a proper size otherwise function will fail on assert. +- `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 is irrelevant, only size matters. + 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 the same as `result` argument. +- Returns `result` array with encoded string. Function result is also stored in mutable `result` array argument. ## Example project -Directory `examples/base64_example/` contains example Noir project with `base64` library as dependency. +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 From b6f81939b68afaca2e0179091b6a029f88c0f1d9 Mon Sep 17 00:00:00 2001 From: Arkadiusz Konior Date: Tue, 28 Nov 2023 12:50:23 +0100 Subject: [PATCH 2/4] Update example to version `v0.1.1` --- examples/base64_example/Nargo.toml | 2 +- examples/base64_example/src/main.nr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/base64_example/Nargo.toml b/examples/base64_example/Nargo.toml index 10ed5fa..62a0c74 100644 --- a/examples/base64_example/Nargo.toml +++ b/examples/base64_example/Nargo.toml @@ -5,4 +5,4 @@ authors = [""] compiler_version = ">=0.19.2" [dependencies] -base64 = { tag = "v0.1.0", git = "https://github.com/zkworks-xyz/noir-base64" } +base64 = { tag = "v0.1.1", git = "https://github.com/zkworks-xyz/noir-base64" } diff --git a/examples/base64_example/src/main.nr b/examples/base64_example/src/main.nr index 77c3971..e826819 100644 --- a/examples/base64_example/src/main.nr +++ b/examples/base64_example/src/main.nr @@ -2,7 +2,7 @@ use dep::base64; use dep::std; fn main() { - let result: [u8; 8] = base64::encode_str("foobar", [0; 8], false); + let result: [u8; 8] = base64::encode_str("foobar", [0; 8]); std::println(result); } From 8c3001007df2b5cf946f4879d24e80047640976a Mon Sep 17 00:00:00 2001 From: Arkadiusz Konior Date: Tue, 28 Nov 2023 12:57:07 +0100 Subject: [PATCH 3/4] Configure .gitattributes --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a8654f4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.nr linguist-language=rust + From f538862e3c3a5dfc6621e317d4c58305ab3b27fa Mon Sep 17 00:00:00 2001 From: Arkadiusz Konior Date: Tue, 28 Nov 2023 13:16:13 +0100 Subject: [PATCH 4/4] decoding info --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1df0008..fc274fc 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ pub fn encode(input: [u8; N], mut result: [u8; M], url_safe: bool) -> [u8; - `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.