Skip to content
Snippets Groups Projects
Commit ab7c61f2 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

refactor shard to use a simple vector (!12)

this MR uses a simpler `Vec` of `E::ScalarField` to represent a linear combination.

the rest of the crate has been fixed accordingly.

the goal is to let Arkworks do as much work as possible, fixing part of #2.
- `one_more` removed from `field::split_data_into_field_elements` in 5531b31a
- `one_less` removed from `field::merge_elements_into_bytes` in 5761b784

## examples
let's say we have at most $k = 3$ source shards, called $s_0$, $s_1$ and $s_2$ respectively.
this first means that all linear combinations will be at most of length 3.

if a new shard $s$ is a linear combination of the source shards, e.g. $s = \alpha s_0 + \beta s_1 + \gamma s_2$, where $\alpha$, $\beta$ and $\gamma$ are scalar elements of an elliptic curve, then the linear combination in the code will be
```rust
vec![alpha, beta, gamma]
```
> **Note**  
> the right of the vector can be truncated to remove zero elements that are not part of the linear combination and don't add any extra useful information.  
> the left stays mandatory.

e.g. we create two times a linear combination with a single one set to $1$ and the rest to $0$ with the following snippet
```rust
let mut linear_combination = Vec::new();
linear_combination.resize(i + 1, E::ScalarField::zero());
linear_combination[i] = E::ScalarField::one();
```
parent 94b544af
No related branches found
No related tags found
1 merge request!12refactor shard to use a simple vector
Pipeline #3942 passed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment