Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #392 from noir-lang/zpedro/vectors_slices_experime…
Browse files Browse the repository at this point in the history
…ntal

Refactoring. Adding experimental note
  • Loading branch information
signorecello authored Oct 3, 2023
2 parents 777721d + 9f9a306 commit 9ce1b41
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
---
title: Slices
description:
Explore the Slice data type in Noir. Understand its methods, see real-world examples, and learn how to effectively use Slices in your Noir programs.
keywords:
[
noir,
slice type,
methods,
examples,
subarrays,
]
description: Explore the Slice data type in Noir. Understand its methods, see real-world examples, and learn how to effectively use Slices in your Noir programs.
keywords: [noir, slice type, methods, examples, subarrays]
---

import Experimental from '../../../src/components/Notes/_experimental.mdx';

<Experimental />

A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size.

Expand Down
27 changes: 0 additions & 27 deletions docs/language_concepts/data_types/06_vectors.md

This file was deleted.

23 changes: 23 additions & 0 deletions docs/language_concepts/data_types/06_vectors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Vectors
description: Delve into the Vector data type in Noir. Learn about its methods, practical examples, and best practices for using Vectors in your Noir code.
keywords: [noir, vector type, methods, examples, dynamic arrays]
---

import Experimental from '../../../src/components/Notes/_experimental.mdx';

<Experimental />

A vector is a collection type similar to Rust's Vector type. It's convenient way to use slices as mutable arrays.

Example:

```rust
use dep::std::collections::vec::Vec;

let mut vector: Vec<Field> = Vec::new();
for i in 0..5 {
vector.push(i);
}
assert(vector.len() == 5);
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords:
[cryptographic primitives, Noir project, sha256, blake2s, pedersen, mimc_bn254, mimc, hash]
---

import BlackBoxInfo from './common/_blackbox.mdx';
import BlackBoxInfo from '../../../src/components/Notes/_blackbox.mdx';

## sha256

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: See how you can perform scalar multiplications over a fixed base in
keywords: [cryptographic primitives, Noir project, scalar multiplication]
---

import BlackBoxInfo from './common/_blackbox.mdx';
import BlackBoxInfo from '../../../src/components/Notes/_blackbox.mdx';

## scalar_mul::fixed_base_embedded_curve

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Learn how you can verify Schnorr signatures using Noir
keywords: [cryptographic primitives, Noir project, schnorr, signatures]
---

import BlackBoxInfo from './common/_blackbox.mdx';
import BlackBoxInfo from '../../../src/components/Notes/_blackbox.mdx';

## schnorr::verify_signature

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Learn about the cryptographic primitives regarding ECDSA over the s
keywords: [cryptographic primitives, Noir project, ecdsa, secp256k1, secp256r1, signatures]
---

import BlackBoxInfo from './common/_blackbox.mdx';
import BlackBoxInfo from '../../../src/components/Notes/_blackbox.mdx';

Noir supports ECDSA signatures verification over the secp256k1 and secp256r1 curves.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Learn about the cryptographic primitives regarding EdDSA
keywords: [cryptographic primitives, Noir project, eddsa, signatures]
---

import BlackBoxInfo from './common/_blackbox.mdx';
import BlackBoxInfo from '../../../src/components/Notes/_blackbox.mdx';

## eddsa::eddsa_poseidon_verify

Expand Down
6 changes: 6 additions & 0 deletions src/components/Notes/_experimental.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:::caution

This feature is experimental. You should expect it to change in future versions,
cause unexpected behavior, or simply not work at all.

:::
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ keywords:
]
---

:::caution

This feature is experimental. You should expect it to change in future versions,
cause unexpected behavior, or simply not work at all.

:::

A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ keywords:
]
---

:::caution

This feature is experimental. You should expect it to change in future versions,
cause unexpected behavior, or simply not work at all.

:::

A vector is a collection type similar to Rust's Vector type. It's convenient way to use slices as mutable arrays.

Example:
Expand Down
14 changes: 14 additions & 0 deletions versioned_docs/version-0.9.0/language_concepts/00_data_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ You can create arrays of primitive types or structs. There is not yet support fo

### Slices

:::caution

This feature is experimental. You should expect it to change in future versions,
cause unexpected behavior, or simply not work at all.

:::

A slice is a dynamically-sized view into a sequence of elements. They can be resized at runtime, but because they don't own the data, they cannot be returned from a circuit. You can treat slices as arrays without a constrained size.

Slices are part of the [noir standard library](../standard_library/slice_methods) so you need to import the respective module in order to work with it. For example:
Expand All @@ -227,6 +234,13 @@ fn main() -> pub Field {

### Vectors

:::caution

This feature is experimental. You should expect it to change in future versions,
cause unexpected behavior, or simply not work at all.

:::

A vector is a collection type similar to Rust's Vector type. It's convenient way to use slices as mutable arrays.

Example:
Expand Down

0 comments on commit 9ce1b41

Please sign in to comment.