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

chore: move aes example into a code snippet #5831

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ Given a plaintext as an array of bytes, returns the corresponding aes128 ciphert

#include_code aes128 noir_stdlib/src/aes128.nr rust

```rust
fn main() {
let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16] // AES key
let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes.
}
```
#include_code aes_example test_programs/execution_success/aes_example/src/main.nr rust


<BlackBoxInfo />

<BlackBoxInfo />
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub fn aes128_encrypt<N>(input: [u8; N], iv: [u8; 16], key: [u8; 16]) -> [u8] {}
fn main() {
let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16] // AES key
let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes.
let key: [u8; 16] = [0; 16]; // AES key
let ciphertext = std::aes128::aes128_encrypt(input, iv, key); // In this case, the output length will be 16 bytes.
}
```


<BlackBoxInfo />
<BlackBoxInfo />
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub fn aes128_encrypt<N>(input: [u8; N], iv: [u8; 16], key: [u8; 16]) -> [u8] {}
fn main() {
let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16] // AES key
let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes.
let key: [u8; 16] = [0; 16]; // AES key
let ciphertext = std::aes128::aes128_encrypt(input, iv, key); // In this case, the output length will be 16 bytes.
}
```


<BlackBoxInfo />
<BlackBoxInfo />
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub fn aes128_encrypt<let N: u32>(input: [u8; N], iv: [u8; 16], key: [u8; 16]) -
fn main() {
let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16] // AES key
let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes.
let key: [u8; 16] = [0; 16]; // AES key
let ciphertext = std::aes128::aes128_encrypt(input, iv, key); // In this case, the output length will be 16 bytes.
}
```


<BlackBoxInfo />
<BlackBoxInfo />
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ pub fn aes128_encrypt<let N: u32>(input: [u8; N], iv: [u8; 16], key: [u8; 16]) -
fn main() {
let input: [u8; 4] = [0, 12, 3, 15] // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16] // AES key
let ciphertext = std::aes128::aes128_encrypt(inputs.as_bytes(), iv.as_bytes(), key.as_bytes()); // In this case, the output length will be 16 bytes.
let key: [u8; 16] = [0; 16]; // AES key
let ciphertext = std::aes128::aes128_encrypt(input, iv, key); // In this case, the output length will be 16 bytes.
}
```


<BlackBoxInfo />
<BlackBoxInfo />
7 changes: 7 additions & 0 deletions test_programs/execution_success/aes_example/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "aes_example"
type = "bin"
authors = [""]
compiler_version = ">=0.27.0"

[dependencies]
Empty file.
9 changes: 9 additions & 0 deletions test_programs/execution_success/aes_example/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// docs:start:aes_example
fn main() -> pub [u8; 16] {
let input: [u8; 4] = [0, 12, 3, 15]; // Random bytes, will be padded to 16 bytes.
let iv: [u8; 16] = [0; 16]; // Initialisation vector
let key: [u8; 16] = [0; 16]; // AES key
let ciphertext = std::aes128::aes128_encrypt(input, iv, key); // In this case, the output length will be 16 bytes.
ciphertext.as_array()
}
// docs:end:aes_example
Loading