Skip to content

Commit

Permalink
Add check input's first element is 1. Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole authored and Nicole committed Jan 13, 2025
1 parent 6fb54a2 commit 9c717ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/baby-snark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Below is a simple example demonstrating the usage of BabySnark:
let ssp = SquareSpanProgram::from_scs(SquareConstraintSystem::from_matrix(u, public.len()));
```

*Note:* You must ensure that the first element of the `input` is 1. In the code above we can see how to build a Span Program for an And Gate. There, the variable `witness` is of the form `[input_1, input_2, output]` (which satisfy `input_1 ∧ input_2 = output`) and the `public` variable must be `[1]`.

**Step 2:** Setup Proving and Verification Keys:
```rust
let (pk, vk) = setup(&ssp);
Expand Down
6 changes: 3 additions & 3 deletions examples/baby-snark/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn size_not_pow2() {
let input: &[i64] = &[1, 2, 3, 4, 5];

let witness = i64_vec_to_field(&[3, 4, 5]);
let public = i64_vec_to_field(&[1, 2]);
let public = i64_vec_to_field(&[1, 2]); // Note that the first element must be 1.
let input_field = i64_vec_to_field(input);
let u_field = normalize(i64_matrix_to_field(u), &input_field);

Expand All @@ -39,8 +39,8 @@ fn and_gate() {
i64_vec_to_field(&[-1, 0, 0, 2]),
i64_vec_to_field(&[-1, 2, 2, -4]),
];
let witness = i64_vec_to_field(&[1, 1, 1]);
let public = i64_vec_to_field(&[1]);
let witness = i64_vec_to_field(&[1, 1, 1]); // [input_1, input_2, output]
let public = i64_vec_to_field(&[1]); // This must be 1.

test_integration(u, witness, public)
}
Expand Down

0 comments on commit 9c717ef

Please # to comment.