Skip to content

Commit

Permalink
Add feature-gated partial prove interface (#281)
Browse files Browse the repository at this point in the history
* Add feature-gated partial prove interface.

* Add comment.
  • Loading branch information
sjudson authored Aug 28, 2024
1 parent 2e3fba3 commit 7162d8d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
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

0 comments on commit 7162d8d

Please sign in to comment.