Skip to content

Commit

Permalink
fix: README, remove cycle trackers
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOLAND committed Aug 20, 2024
1 parent d5eb7bf commit 0a57a04
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ An endpoint for `verify_kzg_proof` in [c-kzg-4844](https://github.com/ethereum/c

## Cycle Counts in SP1

| Operation | Cycle Count |
| -------------------- | ----------- |
| `verify_kzg_proof` | |
| `load_trusted_setup` | 391 |
| Operation | Cycle Count |
| ----------------------------- | ----------------- |
| `verify_blob_kzg_proof` | 27,166,240 cycles |
| `verify_blob_kzg_proof_batch` | 27,363,307 cycles |
| `verify_kzg_proof` | 9,390,640 cycles |

Checkout the SP1 profile at [0xWOLAND/sp1-revm-kzg-profile](https://github.com/0xWOLAND/sp1-revm-kzg-profile). This crate has been used in a [fork of SP1's patch of `revm`](https://github.com/0xWOLAND/revm/tree/patch-v5.0.0), which passes all tests. Additionally, `kzg-rs` is based on [this](https://github.com/0xWOLAND/bls12_381) slightly modified fork of `bls12_381`. This crate works in `[no_std]` mode.
This crate has been used in a [fork of SP1's patch of `revm`](https://github.com/0xWOLAND/revm/tree/patch-v5.0.0), which passes all tests. `kzg-rs` is based on [this](https://github.com/0xWOLAND/bls12_381) slightly modified fork of `bls12_381`. This crate works in `[no_std]` mode.

## Usage
```
```sh
cargo add kzg-rs
```
And add
Or add
```toml
kzg-rs = { version = "0.1", default-features = false, features=['cache'] optional = true }
kzg-rs = { version = "0.1" }
```

You can rebuild `g1.bin` and `g2.bin` by running
You can rebuild `roots_of_unity.bin`, `g1.bin`, and `g2.bin` by running

```sh
cargo run --bin build_binaries
cargo build
```
Binary file modified src/g1.bin
Binary file not shown.
Binary file modified src/g2.bin
Binary file not shown.
8 changes: 1 addition & 7 deletions src/kzg_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ impl KzgProof {
let evaluation_challenge = compute_challenge(&blob, &commitment)?;
let y =
evaluate_polynomial_in_evaluation_form(polynomial, evaluation_challenge, kzg_settings)?;
let out = verify_kzg_proof_impl(commitment, evaluation_challenge, y, proof, kzg_settings);

out
verify_kzg_proof_impl(commitment, evaluation_challenge, y, proof, kzg_settings)
}

pub fn verify_blob_kzg_proof_batch(
Expand Down Expand Up @@ -512,9 +510,7 @@ pub mod tests {
continue;
};

println!("cycle-tracker-start: test_verify_kzg_proof");
let result = KzgProof::verify_kzg_proof(&commitment, &z, &y, &proof, &kzg_settings);
println!("cycle-tracker-end: test_verify_kzg_proof");
match result {
Ok(result) => {
assert_eq!(result, test.get_output().unwrap_or(false));
Expand Down Expand Up @@ -615,14 +611,12 @@ pub mod tests {
continue;
};

println!("cycle-tracker-start: test_verify_blob_kzg_proof_batch");
let result = KzgProof::verify_blob_kzg_proof_batch(
vec![blobs],
vec![commitments],
vec![proofs],
&kzg_settings,
);
println!("cycle-tracker-end: test_verify_blob_kzg_proof_batch");
match result {
Ok(result) => {
assert_eq!(result, test.get_output().unwrap_or(false));
Expand Down

0 comments on commit 0a57a04

Please sign in to comment.