Skip to content

Add prover-client prototype#907

Closed
jadnohra wants to merge 1 commit intographite-base/907from
08-30-closed-source-prover-with-serial
Closed

Add prover-client prototype#907
jadnohra wants to merge 1 commit intographite-base/907from
08-30-closed-source-prover-with-serial

Conversation

@jadnohra
Copy link
Copy Markdown
Contributor

@jadnohra jadnohra commented Sep 1, 2025

Implements ENG2-282. Prototype for a FFI-based prover client.

Copy link
Copy Markdown
Contributor Author

jadnohra commented Sep 1, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jadnohra jadnohra force-pushed the 08-30-closed-source-prover-with-serial branch from 08e7cb0 to d9e5fe8 Compare September 1, 2025 22:39
@jadnohra jadnohra changed the title Add prover-interface Add prover-client Sep 1, 2025
@jadnohra jadnohra requested review from GraDKh, fkondej and jimpo September 1, 2025 22:42
@jadnohra jadnohra changed the title Add prover-client Add prover-client prototype Sep 2, 2025
@graphite-app graphite-app bot changed the base branch from dgordon/add_verifier to graphite-base/907 September 2, 2025 07:20
# Core dependencies for serialization
binius-core = { path = "../core" }
binius-utils = { path = "../utils" }
bytes = "1.7"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspace configuration requires all crates to reference dependencies declared in the workspace root Cargo.toml. The dependency bytes = "1.7" should be declared in the workspace root and referenced here as bytes.workspace = true.

Spotted by Diamond (based on custom rule: Irreducible Rust and Cargo)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

priv_witness_bytes.len(),
log_inv_rate,
proof_buf.as_mut_ptr(),
proof_buf.capacity(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Issue: Using proof_buf.capacity() in the FFI call creates a potential buffer overflow vulnerability. While both capacity and length are currently identical (since the vector is initialized with a fixed size), this code would be unsafe if the vector implementation changes.

Replace with proof_buf.len() to correctly represent the actual usable buffer size:

let result = binius_prove(
    // other parameters...
    proof_buf.as_mut_ptr(),
    proof_buf.len(),  // Use len() instead of capacity()
);

This ensures the FFI function never writes beyond the initialized portion of the buffer, preventing potential memory corruption.

Suggested change
proof_buf.capacity(),
proof_buf.len(),

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +37 to +39
let cs_slice = std::slice::from_raw_parts(cs_bytes, cs_len);
let pub_witness_slice = std::slice::from_raw_parts(pub_witness_bytes, pub_witness_len);
let priv_witness_slice = std::slice::from_raw_parts(priv_witness_bytes, priv_witness_len);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slice creation from raw pointers lacks validation for memory safety. Since these slices are created in an unsafe block, there should be additional checks to ensure the provided lengths don't exceed allocated memory regions. Consider adding bounds checking or explicitly documenting in the function's safety documentation that callers must guarantee valid memory regions and accurate lengths. This is particularly important for FFI functions where invalid inputs from external callers could lead to undefined behavior or security vulnerabilities.

Suggested change
let cs_slice = std::slice::from_raw_parts(cs_bytes, cs_len);
let pub_witness_slice = std::slice::from_raw_parts(pub_witness_bytes, pub_witness_len);
let priv_witness_slice = std::slice::from_raw_parts(priv_witness_bytes, priv_witness_len);
// SAFETY: Caller must ensure that:
// - All pointers are valid for reads of their respective lengths
// - All pointers are properly aligned for u8
// - The memory regions won't be mutated for the lifetime of these slices
// - The lengths accurately represent the allocated memory regions
let cs_slice = std::slice::from_raw_parts(cs_bytes, cs_len);
let pub_witness_slice = std::slice::from_raw_parts(pub_witness_bytes, pub_witness_len);
let priv_witness_slice = std::slice::from_raw_parts(priv_witness_bytes, priv_witness_len);

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jadnohra jadnohra closed this Sep 7, 2025
@jimpo jimpo deleted the 08-30-closed-source-prover-with-serial branch November 21, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant