No Pod IDs (#394)
- middleware:
- Add `Statement::Intro`
- Add `SignedBy` native predicate and operation. The signature is auxiliary data to the operation
- Rename `PodSigner` to `Signer` with a new API (just for signing `RawValue`)
- Removed `NewEntry` operation. Use `ContainsFromEntries` instead
- Remove `KEY_SIGNER` and `KEY_TYPE` which are no longer used
- Merge `RecursivePod` and `Pod` traits
- Change the `Pod::deserialize_data` method to use `Self` instead of `Box<dyn Pod>`
- Extend `Pod` trait with these methods:
- `is_main`: when the pod is Main, in a (recursive) verification its vk will be checked to exist in the vd_set but not if it's intro pod
- `is_mock`: skip some verifications in the recursive mock MainPod verification
- `verifier_data_hash`
- `pod_id` renamed to `statements_hash`
- AnchoredKeys are now a pair of dictionary root and key
- Entry statements are now defined as Contains with literal arguments
- Operations that take Entries now use Contains statements with literal arguments
- frontend:
- Rename `SignedPod` to `SignedDict` (which now contains the dict, public key and signature, and can still `verify(self)`ed)
- The `SignedDict` keeps the method `get_statement` for convenience but now it returns a `Contains` statement that proves the existence of the key in the dict
- The `MainPodBuilder` automatically inserts a `Contains` statement when an operation is added that uses an entry as argument that was not yet "opened".
- Removed the `literal` methods from the `MainPodBuilder` that were loading literals to anchored keys: that was no longer needed after we introduced literal arguments
- backend
- Only verify inclusion of the verifying key into the vd_set if the pod is MainPod. A pod is not MainPod if the first statement is Intro.
- Reject intro pods that have non-intro statements
- Empty pod now returns an intro statement
- Don't insert a type statement automatically in MainPod and MockMainPod. We get rid of the type entry.
- Implement `SignedBy` operation, which uses the muxed table to store signature verifications
- Rename `PodId` to `statements_hash` or `sts_hash` for short. Now this is only used as a hash of the statements for the circuits public inputs.
- Refactor normalization of `self` statements:
- Before: replace values that contain `SELF` by the given pod_id
- After: place the verifying key hash into the Intro predicates
This commit is contained in:
parent
122f9c3cac
commit
0e2f7b756e
39 changed files with 2127 additions and 3064 deletions
|
|
@ -3,14 +3,14 @@ use std::{
|
|||
sync::{LazyLock, Mutex},
|
||||
};
|
||||
|
||||
use crate::middleware::{BackendError, Params, Pod, PodId, PodType, RecursivePod, Result, VDSet};
|
||||
use crate::middleware::{BackendError, Hash, Params, Pod, PodType, Result, VDSet};
|
||||
|
||||
type DeserializeFn = fn(
|
||||
params: Params,
|
||||
data: serde_json::Value,
|
||||
vd_set: VDSet,
|
||||
id: PodId,
|
||||
) -> Result<Box<dyn RecursivePod>, BackendError>;
|
||||
id: Hash,
|
||||
) -> Result<Box<dyn Pod>, BackendError>;
|
||||
|
||||
static DESERIALIZERS: LazyLock<Mutex<HashMap<usize, DeserializeFn>>> =
|
||||
LazyLock::new(backend::deserializers_default);
|
||||
|
|
@ -25,10 +25,10 @@ pub fn register_pod_deserializer(pod_type: usize, deserialize_fn: DeserializeFn)
|
|||
pub fn deserialize_pod(
|
||||
pod_type: usize,
|
||||
params: Params,
|
||||
id: PodId,
|
||||
id: Hash,
|
||||
vd_set: VDSet,
|
||||
data: serde_json::Value,
|
||||
) -> Result<Box<dyn RecursivePod>, BackendError> {
|
||||
) -> Result<Box<dyn Pod>, BackendError> {
|
||||
let deserialize_fn: DeserializeFn =
|
||||
*DESERIALIZERS
|
||||
.lock()
|
||||
|
|
@ -42,14 +42,6 @@ pub fn deserialize_pod(
|
|||
deserialize_fn(params, data, vd_set, id)
|
||||
}
|
||||
|
||||
pub fn deserialize_signed_pod(
|
||||
pod_type: usize,
|
||||
id: PodId,
|
||||
data: serde_json::Value,
|
||||
) -> Result<Box<dyn Pod>, BackendError> {
|
||||
backend::deserialize_signed_pod(pod_type, id, data)
|
||||
}
|
||||
|
||||
#[cfg(feature = "backend_plonky2")]
|
||||
mod backend {
|
||||
use super::*;
|
||||
|
|
@ -57,30 +49,26 @@ mod backend {
|
|||
emptypod::EmptyPod,
|
||||
mainpod::MainPod,
|
||||
mock::{emptypod::MockEmptyPod, mainpod::MockMainPod},
|
||||
signedpod::SignedPod,
|
||||
};
|
||||
|
||||
pub(super) fn deserializers_default() -> Mutex<HashMap<usize, DeserializeFn>> {
|
||||
fn deserialize_data<P: Pod>(
|
||||
params: Params,
|
||||
data: serde_json::Value,
|
||||
vd_set: VDSet,
|
||||
id: Hash,
|
||||
) -> Result<Box<dyn Pod>, BackendError> {
|
||||
Ok(Box::new(P::deserialize_data(params, data, vd_set, id)?))
|
||||
}
|
||||
|
||||
let mut map: HashMap<usize, DeserializeFn> = HashMap::new();
|
||||
map.insert(PodType::Empty as usize, EmptyPod::deserialize_data);
|
||||
map.insert(PodType::Main as usize, MainPod::deserialize_data);
|
||||
map.insert(PodType::MockEmpty as usize, MockEmptyPod::deserialize_data);
|
||||
map.insert(PodType::MockMain as usize, MockMainPod::deserialize_data);
|
||||
map.insert(PodType::Empty as usize, deserialize_data::<EmptyPod>);
|
||||
map.insert(PodType::Main as usize, deserialize_data::<MainPod>);
|
||||
map.insert(
|
||||
PodType::MockEmpty as usize,
|
||||
deserialize_data::<MockEmptyPod>,
|
||||
);
|
||||
map.insert(PodType::MockMain as usize, deserialize_data::<MockMainPod>);
|
||||
Mutex::new(map)
|
||||
}
|
||||
|
||||
pub(super) fn deserialize_signed_pod(
|
||||
pod_type: usize,
|
||||
id: PodId,
|
||||
data: serde_json::Value,
|
||||
) -> Result<Box<dyn Pod>, BackendError> {
|
||||
if pod_type == PodType::Signed as usize {
|
||||
SignedPod::deserialize(id, data)
|
||||
} else {
|
||||
Err(BackendError::custom(format!(
|
||||
"unexpected pod_type={} for deserialize_signed_pod",
|
||||
pod_type
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue