Skip to content

Commit

Permalink
fix: kzg-rs + docs (#62)
Browse files Browse the repository at this point in the history
* docs: vkey, bls

* refactor
  • Loading branch information
ratankaliani authored Aug 16, 2024
1 parent 381260f commit 445e5ef
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 68 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"crates/*",
"native-host",
"zkvm-host",
"prover-server",
"op-succinct-proposer",
]
resolver = "2"

Expand Down Expand Up @@ -58,7 +58,7 @@ hex = "0.4.3"
client-utils = { path = "crates/client-utils" }
host-utils = { path = "crates/host-utils" }
zkvm-host = { path = "zkvm-host" }
prover-server = { path = "prover-server" }
op-succinct-proposer = { path = "op-succinct-proposer" }

# ethereum
alloy = { version = "0.2", default-features = false, features = ["full"] }
Expand Down Expand Up @@ -101,4 +101,4 @@ tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "pa
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", branch = "patch-v0.10.8", package = "sha2" }
ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", branch = "patch-ecdsa-v0.16.9" }
bls12_381 = { git = "https://github.com/leruaa/bls12_381", branch = "msm_variable_base" }
bn = { git = "https://github.com/0xWOLAND/bn.git", package = "substrate-bn", default-features = false }
bn = { git = "https://github.com/0xWOLAND/bn.git", package = "substrate-bn" }
35 changes: 12 additions & 23 deletions crates/client-utils/src/oracle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,18 @@ impl InMemoryOracle {
}
}

println!("cycle-tracker-report-start: blob-verification");
let commitments: Vec<Bytes48> = blobs
.keys()
.cloned()
.map(|blob| Bytes48::from_slice(&blob.0).unwrap())
.collect_vec();
let kzg_proofs: Vec<Bytes48> = blobs
.values()
.map(|blob| Bytes48::from_slice(&blob.kzg_proof.0).unwrap())
.collect_vec();
let blob_datas: Vec<KzgRsBlob> = blobs
.values()
.map(|blob| KzgRsBlob::from_slice(&blob.data.0).unwrap())
.collect_vec();
// Verify reconstructed blobs.
kzg_rs::KzgProof::verify_blob_kzg_proof_batch(
blob_datas,
commitments,
kzg_proofs,
&get_kzg_settings(),
)
.map_err(|e| anyhow!("blob verification failed for batch: {:?}", e))?;
println!("cycle-tracker-report-end: blob-verification");
let kzg_settings = get_kzg_settings();
for (commitment, blob) in blobs.iter() {
println!("cycle-tracker-report-start: blob-verification");
kzg_rs::KzgProof::verify_blob_kzg_proof(
KzgRsBlob::from_slice(&blob.data.0).unwrap(),
&Bytes48::from_slice(&commitment.0).unwrap(),
&Bytes48::from_slice(&blob.kzg_proof.0).unwrap(),
&kzg_settings,
)
.map_err(|e| anyhow!("blob verification failed: {:?}", e))?;
println!("cycle-tracker-report-end: blob-verification");
}

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
op-succinct-server:
build:
context: .
dockerfile: Dockerfile.server
dockerfile: ./op-succinct-proposer/Dockerfile.op_proposer
env_file:
- .env.server
restart: unless-stopped
Expand All @@ -14,7 +14,7 @@ services:
op-succinct-proposer:
build:
context: .
dockerfile: Dockerfile.op_proposer
dockerfile: ./op-succinct-proposer/Dockerfile.op_proposer
env_file:
- .env.server
restart: unless-stopped
Expand Down
Binary file modified elf/aggregation-elf
Binary file not shown.
Binary file modified elf/fault-proof-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "prover-server"
name = "op-succinct-proposer"
version = "0.1.0"
edition.workspace = true
license.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get update && apt-get install -y \
COPY --from=optimism-builder /optimism/op-proposer/bin/op-proposer /usr/local/bin/op-proposer

# Set the entrypoint to run op-proposer with environment variables
COPY op_proposer.sh /usr/local/bin/op_proposer.sh
COPY ./op-succinct-proposer/op_proposer.sh /usr/local/bin/op_proposer.sh

# Make the binary and entrypoint executable.
RUN chmod +x /usr/local/bin/op-proposer
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use base64::{engine::general_purpose, Engine as _};
use client_utils::{RawBootInfo, BOOT_INFO_SIZE};
use host_utils::{fetcher::SP1KonaDataFetcher, get_agg_proof_stdin, get_proof_stdin, ProgramType};
use log::info;
use prover_server::run_native_host;
use op_succinct_proposer::run_native_host;
use serde::{Deserialize, Deserializer, Serialize};
use sp1_sdk::{
network::client::NetworkClient,
Expand Down
13 changes: 1 addition & 12 deletions prover-server/bin/vkey.rs → op-succinct-proposer/bin/vkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,11 @@ async fn main() -> Result<()> {

let (_, agg_vk) = prover.setup(AGG_ELF);
info!("Aggregation ELF Verification Key: {}", agg_vk.bytes32());
println!("Aggregation ELF Verification Key: {}", agg_vk.bytes32());
let agg_vk_bytes: [u8; 32] = hex::decode(agg_vk.bytes32().replace("0x", ""))
.unwrap()
.try_into()
.unwrap();

// Check the aggregate vkey against the contract.
let provider = ProviderBuilder::new().on_http(Url::from_str(&args.rpc_url.unwrap()).unwrap());

let contract = L2OutputOracle::new(
Address::from_str(&args.contract_address.unwrap()).unwrap(),
provider,
);
let vkey = contract.vkey().call().await?;

assert_eq!(vkey.vkey, B256::from(agg_vk_bytes));
info!("The verification key matches the contract.");

Ok(())
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 445e5ef

Please sign in to comment.