Skip to content

Commit

Permalink
Merge branch 'main' into fix-curve-new
Browse files Browse the repository at this point in the history
  • Loading branch information
jotabulacios authored Feb 12, 2025
2 parents bd51922 + d78d18a commit 0fcc8c2
Show file tree
Hide file tree
Showing 14 changed files with 1,825 additions and 22 deletions.
36 changes: 36 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Security Policy

## Reporting a Vulnerability

We take the security of our project seriously. If you discover a vulnerability, we encourage you to report it responsibly so we can address it promptly.

### How to Report

1. Navigate to the **Security** tab of this repository.
2. Click on **"Report a Vulnerability"** to open the GitHub Security Advisories form.
3. Fill out the form with as much detail as possible, including:
- A clear description of the issue.
- Steps to reproduce the vulnerability.
- The affected versions or components.
- Any potential impact or severity details.

Alternatively, you can send an email to **[security@lambdaclass.com](mailto:security@lambdaclass.com)** with the same details.

### Guidelines for Reporting

- **Do not publicly disclose vulnerabilities** until we have confirmed and fixed the issue.
- Include any proof-of-concept code, if possible, to help us verify the vulnerability more efficiently.
- If applicable, specify if the vulnerability is already being exploited.

### Our Response Process

- We commit to handling reports with diligence.
- We will investigate all reported vulnerabilities thoroughly and transparently.
- Once the vulnerability has been fixed, we will disclose the details publicly to ensure awareness and understanding.


### Reward Program

While we do not currently offer a formal bug bounty program, we value your contribution and will recognize your efforts in our changelog or release notes (if you consent).

Thank you for helping us improve the security of our project!
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,12 @@ The following links, repos, companies and projects have been important in the de
- [Gnark](https://github.com/Consensys/gnark)
- [Constantine](https://github.com/mratsim/constantine)
- [Plonky3](https://github.com/Plonky3/Plonky3)

# Security

We take security seriously. If you discover a vulnerability in this project, please report it responsibly.

- You can report vulnerabilities directly via the **[GitHub "Report a Vulnerability" feature](../../security/advisories/new)**.
- Alternatively, send an email to **[security@lambdaclass.com](mailto:security@lambdaclass.com)**.

For more details, please refer to our [Security Policy](./.github/SECURITY.md).
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
4 changes: 4 additions & 0 deletions examples/baby-snark/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Proof {
#[derive(Debug)]
pub enum Error {
WrongWitness,
FirstInputElementIsNotOne,
}

pub struct Prover;
Expand All @@ -19,6 +20,9 @@ impl Prover {
ssp: &SquareSpanProgram,
pk: &ProvingKey,
) -> Result<Proof, Error> {
if inputs[0].ne(&FrElement::one()) {
return Err(Error::FirstInputElementIsNotOne);
}
if !ssp.check_valid(inputs) {
return Err(Error::WrongWitness);
}
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
21 changes: 18 additions & 3 deletions math/benches/criterion_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ mod fields;
use fields::mersenne31::{mersenne31_extension_ops_benchmarks, mersenne31_ops_benchmarks};
use fields::mersenne31_montgomery::mersenne31_mont_ops_benchmarks;
use fields::{
baby_bear::{babybear_ops_benchmarks, babybear_ops_benchmarks_f64, babybear_p3_ops_benchmarks},
baby_bear::{
babybear_extension_ops_benchmarks_p3, babybear_p3_ops_benchmarks,
babybear_u32_extension_ops_benchmarks, babybear_u32_ops_benchmarks,
babybear_u64_extension_ops_benchmarks, babybear_u64_ops_benchmarks,
},
stark252::starkfield_ops_benchmarks,
u64_goldilocks::u64_goldilocks_ops_benchmarks,
u64_goldilocks_montgomery::u64_goldilocks_montgomery_ops_benchmarks,
Expand All @@ -14,7 +18,18 @@ use fields::{
criterion_group!(
name = field_benches;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets =babybear_ops_benchmarks,babybear_ops_benchmarks_f64, babybear_p3_ops_benchmarks,mersenne31_extension_ops_benchmarks,mersenne31_ops_benchmarks,
starkfield_ops_benchmarks,u64_goldilocks_ops_benchmarks,u64_goldilocks_montgomery_ops_benchmarks,mersenne31_mont_ops_benchmarks

targets = babybear_u32_ops_benchmarks,
babybear_u32_extension_ops_benchmarks,
babybear_u64_ops_benchmarks,
babybear_u64_extension_ops_benchmarks,
babybear_p3_ops_benchmarks,
babybear_extension_ops_benchmarks_p3,
mersenne31_ops_benchmarks,
mersenne31_extension_ops_benchmarks,
mersenne31_mont_ops_benchmarks,
starkfield_ops_benchmarks,
u64_goldilocks_ops_benchmarks,
u64_goldilocks_montgomery_ops_benchmarks,
);
criterion_main!(field_benches);
Loading

0 comments on commit 0fcc8c2

Please sign in to comment.