Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature-gated partial prove interface #281

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ parallel = [
prover_hypernova = ["dep:nexus-nova", "dep:spartan"]
prover_nova = ["dep:nexus-nova", "dep:spartan"]
prover_jolt = ["dep:nexus-jolt"]

partial_prove = []
25 changes: 25 additions & 0 deletions core/src/prover/hypernova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ pub fn init_circuit_trace(trace: Trace) -> Result<SC, ProofError> {
super::nova::init_circuit_trace(trace).map_err(ProofError::from)
}

// nb: feature-gated as only relevant for testing
#[cfg(feature = "partial_prove")]
pub fn prove_partial_seq(
pp: &PP,
trace: Trace,
start: usize,
len: usize,
) -> Result<IVCProof, ProofError> {
let tr = init_circuit_trace(trace)?;

let end = start + len;
if end >= tr.steps() {
return Err(ProofError::InvalidIndex(tr.steps()));
}

let z_st = tr.input(start)?;
let mut proof = IVCProof::new(&z_st);

for _ in start..end {
proof = prove_seq_step(Some(proof), pp, &tr)?;
}

Ok(proof)
}

pub fn prove_seq(pp: &PP, trace: Trace) -> Result<IVCProof, ProofError> {
let tr = init_circuit_trace(trace)?;

Expand Down
25 changes: 25 additions & 0 deletions core/src/prover/nova/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,31 @@ pub fn init_circuit_trace(trace: Trace) -> Result<SC, ProofError> {
Ok(tr)
}

// nb: feature-gated as only relevant for testing
#[cfg(feature = "partial_prove")]
pub fn prove_partial_seq(
pp: &SeqPP,
trace: Trace,
start: usize,
len: usize,
) -> Result<IVCProof, ProofError> {
let tr = init_circuit_trace(trace)?;

let end = start + len;
if end >= tr.steps() {
return Err(ProofError::InvalidIndex(tr.steps()));
}

let z_st = tr.input(start)?;
let mut proof = IVCProof::new(&z_st);

for _ in start..end {
proof = prove_seq_step(Some(proof), pp, &tr)?;
}

Ok(proof)
}

pub fn prove_seq(pp: &SeqPP, trace: Trace) -> Result<IVCProof, ProofError> {
let tr = init_circuit_trace(trace)?;

Expand Down