Partial implementation of the MockMainPod (#33)

* wip

* wip

* feat: handle public statements

* fix: remove old backend module
This commit is contained in:
Eduard S. 2025-02-05 16:50:00 +01:00 committed by GitHub
parent e074d34078
commit 8945d7f8a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 555 additions and 268 deletions

View file

@ -171,6 +171,7 @@ pub struct Params {
pub max_signed_pod_values: usize,
pub max_public_statements: usize,
pub max_statement_args: usize,
pub max_operation_args: usize,
}
impl Params {
@ -188,6 +189,7 @@ impl Default for Params {
max_signed_pod_values: 8,
max_public_statements: 10,
max_statement_args: 5,
max_operation_args: 5,
}
}
}
@ -220,6 +222,29 @@ pub trait SignedPod: fmt::Debug + DynClone {
// impl Clone for Box<dyn SignedPod>
dyn_clone::clone_trait_object!(SignedPod);
/// This is a filler type that fulfills the SignedPod trait and always verifies. It's empty. This
/// can be used to simulate padding in a circuit.
#[derive(Debug, Clone)]
pub struct NoneSignedPod {}
impl SignedPod for NoneSignedPod {
fn verify(&self) -> bool {
true
}
fn id(&self) -> PodId {
PodId(NULL)
}
fn kvs(&self) -> HashMap<Hash, Value> {
HashMap::new()
}
fn pub_statements(&self) -> Vec<Statement> {
Vec::new()
}
fn into_any(self: Box<Self>) -> Box<dyn Any> {
self
}
}
pub trait PodSigner {
fn sign(&mut self, params: &Params, kvs: &HashMap<Hash, Value>) -> Result<Box<dyn SignedPod>>;
}
@ -305,12 +330,38 @@ pub trait MainPod: fmt::Debug + DynClone {
// impl Clone for Box<dyn SignedPod>
dyn_clone::clone_trait_object!(MainPod);
/// This is a filler type that fulfills the MainPod trait and always verifies. It's empty. This
/// can be used to simulate padding in a circuit.
#[derive(Debug, Clone)]
pub struct NoneMainPod {}
impl MainPod for NoneMainPod {
fn verify(&self) -> bool {
true
}
fn id(&self) -> PodId {
PodId(NULL)
}
fn pub_statements(&self) -> Vec<Statement> {
Vec::new()
}
fn into_any(self: Box<Self>) -> Box<dyn Any> {
self
}
}
// TODO: Figure out a way to signal which signed_pods entries and which main_pods statements need
// to be made public. Idea: introduce an operation called reveal, which the backend translates to
// CopyOf but moves copies that statement to a public slot?
#[derive(Debug)]
pub struct MainPodInputs<'a> {
pub signed_pods: &'a [&'a dyn SignedPod],
pub main_pods: &'a [&'a dyn MainPod],
pub signed_pods: &'a [&'a Box<dyn SignedPod>],
pub main_pods: &'a [&'a Box<dyn MainPod>],
pub statements: &'a [Statement],
pub operations: &'a [Operation],
/// Statements that need to be made public (they can come from input pods or input
/// statements)
pub public_statements: &'a [Statement],
}
pub trait PodProver {