Use id as public inputs in MainPod verify (#233)
This commit is contained in:
parent
024ed8bd04
commit
cd40219ba6
1 changed files with 12 additions and 7 deletions
|
|
@ -8,8 +8,10 @@ use plonky2::{
|
||||||
hash::poseidon::PoseidonHash,
|
hash::poseidon::PoseidonHash,
|
||||||
iop::witness::PartialWitness,
|
iop::witness::PartialWitness,
|
||||||
plonk::{
|
plonk::{
|
||||||
circuit_builder::CircuitBuilder, circuit_data::CircuitConfig, config::Hasher,
|
circuit_builder::CircuitBuilder,
|
||||||
proof::ProofWithPublicInputs,
|
circuit_data::CircuitConfig,
|
||||||
|
config::Hasher,
|
||||||
|
proof::{Proof, ProofWithPublicInputs},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
pub use statement::*;
|
pub use statement::*;
|
||||||
|
|
@ -423,13 +425,13 @@ impl Prover {
|
||||||
|
|
||||||
// generate & verify proof
|
// generate & verify proof
|
||||||
let data = builder.build::<C>();
|
let data = builder.build::<C>();
|
||||||
let proof = data.prove(pw)?;
|
let proof_with_pis = data.prove(pw)?;
|
||||||
|
|
||||||
Ok(MainPod {
|
Ok(MainPod {
|
||||||
params: params.clone(),
|
params: params.clone(),
|
||||||
id,
|
id,
|
||||||
public_statements,
|
public_statements,
|
||||||
proof,
|
proof: proof_with_pis.proof,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -449,7 +451,7 @@ pub struct MainPod {
|
||||||
params: Params,
|
params: Params,
|
||||||
id: PodId,
|
id: PodId,
|
||||||
public_statements: Vec<Statement>,
|
public_statements: Vec<Statement>,
|
||||||
proof: ProofWithPublicInputs<F, C, D>,
|
proof: Proof<F, C, D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a Statement into middleware::Statement and replace references to SELF by `self_id`.
|
/// Convert a Statement into middleware::Statement and replace references to SELF by `self_id`.
|
||||||
|
|
@ -489,7 +491,10 @@ impl MainPod {
|
||||||
.eval(&mut builder)?;
|
.eval(&mut builder)?;
|
||||||
|
|
||||||
let data = builder.build::<C>();
|
let data = builder.build::<C>();
|
||||||
data.verify(self.proof.clone())
|
data.verify(ProofWithPublicInputs {
|
||||||
|
proof: self.proof.clone(),
|
||||||
|
public_inputs: id.to_fields(&self.params),
|
||||||
|
})
|
||||||
.map_err(|e| Error::custom(format!("MainPod proof verification failure: {:?}", e)))
|
.map_err(|e| Error::custom(format!("MainPod proof verification failure: {:?}", e)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue