Skip to content

Commit

Permalink
Reproduce error
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderMisztal committed Mar 9, 2023
0 parents commit 9952b5e
Show file tree
Hide file tree
Showing 7 changed files with 3,503 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
1 change: 1 addition & 0 deletions Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
votes = [1, 0, 0, 0, 0, 1]
2 changes: 2 additions & 0 deletions Verifier.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
return = "0x0000000000000000000000000000000000000000000000000000000000000000"
votes = ["0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000001"]
3,437 changes: 3,437 additions & 0 deletions contract/plonk_vk.sol

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions src/maci.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
global n_candidates = 3;
global n_voters = 2;

struct Vote {
user_id: Field,
vote: [Field; n_candidates],
signature: Field,
}

struct KeyChange {
user_id: Field,
new_key: Field,
signature: Field,
}

fn main(votes: pub [Field; n_candidates * n_voters]) -> pub Field {
let mut candidates = [0; n_candidates];
let mut max = 0;
let mut max_index = 0;
for i in 0..n_voters {
let mut sum = 0;
for j in 0..n_candidates {
let vote = votes[n_candidates * i + j];
constrain vote*(vote-1) == 0;
sum += vote;
candidates[j] = candidates[j] + vote;
if candidates[j] as u32 > max as u32 {
max = candidates[j];
max_index = j;
}
}
constrain sum == 1;
}
max_index
}
8 changes: 8 additions & 0 deletions src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mod poly;

fn main() {
let a = DensePolynomial { coeffs: [1, 2, 3] };
let b = DensePolynomial { coeffs: [1, 2, 3] };

a.mul(b)
}
15 changes: 15 additions & 0 deletions src/poly.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct DensePolynomial<N> {
coeffs: [Field; N],
}

impl DensePolynomial {
fn mul(self, other: DensePolynomial<M>) -> pub DensePolynomial<N+M-1> {
let mut coeffs = [0; N+M-1];
for i in 0..N {
for j in 0..M {
coeffs[i + j] += self.coeffs[i] * other.coeffs[j];
}
}
DensePolynomial { coeffs }
}
}

0 comments on commit 9952b5e

Please sign in to comment.