Allow literals in statement templates (#287)

This PR is a continuation of the work done in #276 
- Fix PodType in MainPod (we were using `MockMain` instead of `Main`)
- Update anchored keys in statement template arguments to only support wildcards in the origin and literal keys as the key.
  - Update the pest grammar accordingly
  - Update the parser accordingly
- Rewrite the eth_dos example in a recursive manner so that we use one recursive pod for every distance increment of 1.
  - I've also used the podlang to define the eth_dos custom predicates.  Currently all predicates are in a single batch (previously `eth_friend` was in a different batch).  With #286 we could define `eth_friend` in a different batch again.
    - I was feeling a bit creative and used a format macro to pass `Value`s from rust to the podlang code.
  - The eth_dos is now written using literals.  This resolves https://github.com/0xPARC/pod2/issues/255
- Remove `StatementArg::WildcardValue` in favor of `StatementArg::Literal`.  The `WildcardValue` was just a way to have some kind of typing for values that would be used as arguments in custom predicates.  Now that we can have literals in any statement this value can be anything, so I just removed the `WildcardValue` and use `Literal` instead.  On the backend it was already the case that both cases were treated the same way (after all, `WildcardValue` and `Literal` were 4 fields in the backend).
  - Added a new type for Value: `PodId` so that we can use it for custom predicates that take a pod id to be used in a wildcard
- Add a mock vd_set that is empty for tests that don't use plonky2; this allows running those tests individually without paying for the expensive work of calculating the vd for various circuits.
- rename StatementTmplArg::WildcardValue to StatementTmplArg::Wildcard
This commit is contained in:
Eduard S. 2025-06-16 16:38:38 +02:00 committed by GitHub
parent 7d0d3ad769
commit 3c6930dfe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 659 additions and 1111 deletions

View file

@ -31,9 +31,8 @@ use crate::{
middleware::{
CustomPredicate, CustomPredicateBatch, CustomPredicateRef, NativeOperation,
NativePredicate, OperationType, Params, Predicate, PredicatePrefix, RawValue, StatementArg,
StatementTmpl, StatementTmplArg, StatementTmplArgPrefix, ToFields, Value, WildcardValue,
EMPTY_VALUE, F, HASH_SIZE, OPERATION_ARG_F_LEN, OPERATION_AUX_F_LEN, STATEMENT_ARG_F_LEN,
VALUE_SIZE,
StatementTmpl, StatementTmplArg, StatementTmplArgPrefix, ToFields, Value, EMPTY_VALUE, F,
HASH_SIZE, OPERATION_ARG_F_LEN, OPERATION_AUX_F_LEN, STATEMENT_ARG_F_LEN, VALUE_SIZE,
},
};
@ -597,7 +596,7 @@ impl CustomPredicateVerifyEntryTarget {
// Replace statement templates of batch-self with (id,index)
self.custom_predicate
.set_targets(pw, params, &cpv.custom_predicate)?;
let pad_arg = WildcardValue::None;
let pad_arg = Value::from(0);
for (arg_target, arg) in self.args.iter().zip_eq(
cpv.args
.iter()
@ -1427,11 +1426,8 @@ pub(crate) mod tests {
use super::*;
use crate::{
backends::plonky2::basetypes::C,
examples::custom::{eth_dos_batch, eth_friend_batch},
frontend,
frontend::CustomPredicateBatchBuilder,
middleware::CustomPredicateBatch,
backends::plonky2::basetypes::C, examples::custom::eth_dos_batch, frontend,
frontend::CustomPredicateBatchBuilder, middleware::CustomPredicateBatch,
};
pub(crate) const I64_TEST_PAIRS: [(i64, i64); 36] = [
@ -1481,7 +1477,7 @@ pub(crate) mod tests {
let params = Params::default();
let config = CircuitConfig::standard_recursion_config();
let custom_predicate_batch = eth_friend_batch(&params, false)?;
let custom_predicate_batch = eth_dos_batch(&params, false)?;
for (i, cp) in custom_predicate_batch.predicates().iter().enumerate() {
let mut builder = CircuitBuilder::<F, D>::new(config.clone());
@ -1544,9 +1540,6 @@ pub(crate) mod tests {
helper_custom_predicate_batch_target_id(&params, &custom_predicate_batch).unwrap();
// Some cases from the examples
let custom_predicate_batch = eth_friend_batch(&params, false)?;
helper_custom_predicate_batch_target_id(&params, &custom_predicate_batch).unwrap();
let custom_predicate_batch = eth_dos_batch(&params, false)?;
helper_custom_predicate_batch_target_id(&params, &custom_predicate_batch).unwrap();

View file

@ -41,7 +41,7 @@ use crate::{
middleware::{
AnchoredKey, CustomPredicate, CustomPredicateBatch, CustomPredicateRef, NativeOperation,
NativePredicate, Params, PodType, PredicatePrefix, Statement, StatementArg, ToFields,
Value, ValueRef, WildcardValue, EMPTY_VALUE, F, HASH_SIZE, KEY_TYPE, SELF, VALUE_SIZE,
Value, ValueRef, EMPTY_VALUE, F, HASH_SIZE, KEY_TYPE, SELF, VALUE_SIZE,
},
};
@ -1338,7 +1338,7 @@ impl MainPodVerifyGadget {
&builder.constants(
&Statement::equal(
ValueRef::Key(AnchoredKey::from((SELF, KEY_TYPE))),
ValueRef::Literal(Value::from(PodType::MockMain)),
ValueRef::Literal(Value::from(PodType::Main)),
)
.to_fields(params),
),
@ -1399,7 +1399,7 @@ pub struct MainPodVerifyTarget {
pub struct CustomPredicateVerification {
pub custom_predicate_table_index: usize,
pub custom_predicate: CustomPredicateRef,
pub args: Vec<WildcardValue>,
pub args: Vec<Value>,
pub op_args: Vec<mainpod::Statement>,
}
@ -1612,10 +1612,10 @@ mod tests {
mainpod::{calculate_id, OperationArg, OperationAux},
primitives::merkletree::{MerkleClaimAndProof, MerkleTree},
},
frontend::{self, key, literal, CustomPredicateBatchBuilder, StatementTmplBuilder},
frontend::{self, literal, CustomPredicateBatchBuilder, StatementTmplBuilder},
middleware::{
hash_str, hash_values, Hash, Key, KeyOrWildcard, OperationType, PodId, Predicate,
RawValue, SelfOrWildcard, StatementTmpl, StatementTmplArg, Wildcard, WildcardValue,
hash_str, hash_values, Hash, Key, OperationType, PodId, Predicate, RawValue,
StatementTmpl, StatementTmplArg, Wildcard,
},
};
@ -2558,45 +2558,16 @@ mod tests {
helper_statement_arg_from_template(&params, st_tmpl_arg, args, expected_st_arg)?;
// case: AnchoredKey(id_wildcard, key_literal)
let st_tmpl_arg = StatementTmplArg::AnchoredKey(
SelfOrWildcard::Wildcard(Wildcard::new("a".to_string(), 1)),
KeyOrWildcard::Key(Key::from("foo")),
);
let args = vec![Value::from(1), Value::from(pod_id.0), Value::from(3)];
let st_tmpl_arg =
StatementTmplArg::AnchoredKey(Wildcard::new("a".to_string(), 1), Key::from("foo"));
let args = vec![Value::from(1), Value::from(pod_id), Value::from(3)];
let expected_st_arg = StatementArg::Key(AnchoredKey::new(pod_id, Key::from("foo")));
helper_statement_arg_from_template(&params, st_tmpl_arg, args, expected_st_arg)?;
// case: AnchoredKey(id_wildcard, key_wildcard)
let st_tmpl_arg = StatementTmplArg::AnchoredKey(
SelfOrWildcard::Wildcard(Wildcard::new("a".to_string(), 1)),
KeyOrWildcard::Wildcard(Wildcard::new("b".to_string(), 2)),
);
let args = vec![Value::from(1), Value::from(pod_id.0), Value::from("key")];
let expected_st_arg = StatementArg::Key(AnchoredKey::new(pod_id, Key::from("key")));
helper_statement_arg_from_template(&params, st_tmpl_arg, args, expected_st_arg)?;
// case: AnchoredKey(SELF, key_literal)
let st_tmpl_arg = StatementTmplArg::AnchoredKey(
SelfOrWildcard::SELF,
KeyOrWildcard::Key(Key::from("foo")),
);
let args = vec![Value::from(1), Value::from(pod_id.0), Value::from(3)];
let expected_st_arg = StatementArg::Key(AnchoredKey::new(SELF, Key::from("foo")));
helper_statement_arg_from_template(&params, st_tmpl_arg, args, expected_st_arg)?;
// case: AnchoredKey(SELF, key_wildcard)
let st_tmpl_arg = StatementTmplArg::AnchoredKey(
SelfOrWildcard::SELF,
KeyOrWildcard::Wildcard(Wildcard::new("b".to_string(), 2)),
);
let args = vec![Value::from(1), Value::from(pod_id.0), Value::from("key")];
let expected_st_arg = StatementArg::Key(AnchoredKey::new(SELF, Key::from("key")));
helper_statement_arg_from_template(&params, st_tmpl_arg, args, expected_st_arg)?;
// case: WildcardLiteral(wildcard)
let st_tmpl_arg = StatementTmplArg::WildcardLiteral(Wildcard::new("a".to_string(), 1));
let st_tmpl_arg = StatementTmplArg::Wildcard(Wildcard::new("a".to_string(), 1));
let args = vec![Value::from(1), Value::from("key"), Value::from(3)];
let expected_st_arg = StatementArg::WildcardLiteral(WildcardValue::Key(Key::from("key")));
let expected_st_arg = StatementArg::Literal(Value::from("key"));
helper_statement_arg_from_template(&params, st_tmpl_arg, args, expected_st_arg)?;
Ok(())
@ -2648,10 +2619,7 @@ mod tests {
let st_tmpl = StatementTmpl {
pred: Predicate::Native(NativePredicate::Equal),
args: vec![
StatementTmplArg::AnchoredKey(
SelfOrWildcard::Wildcard(Wildcard::new("a".to_string(), 1)),
KeyOrWildcard::Key(Key::from("key")),
),
StatementTmplArg::AnchoredKey(Wildcard::new("a".to_string(), 1), Key::from("key")),
StatementTmplArg::Literal(Value::from("value")),
],
};
@ -2669,7 +2637,7 @@ mod tests {
params: &Params,
custom_predicate: CustomPredicateRef,
op_args: Vec<Statement>,
args: Vec<WildcardValue>,
args: Vec<Value>,
expected_st: Option<Statement>,
) -> Result<()> {
let config = CircuitConfig::standard_recursion_config();
@ -2732,19 +2700,15 @@ mod tests {
use NativePredicate as NP;
use StatementTmplBuilder as STB;
let mut builder = CustomPredicateBatchBuilder::new(params.clone(), "batch".into());
let stb0 = STB::new(NP::Equal)
.arg(("id", key("score")))
.arg(literal(42));
let stb1 = STB::new(NP::Equal)
.arg(("id", "secret_key"))
.arg(literal(1234));
let stb0 = STB::new(NP::Equal).arg(("id", "score")).arg(literal(42));
let stb1 = STB::new(NP::Equal).arg(("id", "key")).arg("secret");
let _ = builder.predicate_and(
"pred_and",
&["id"],
&["secret_key"],
&["secret"],
&[stb0.clone(), stb1.clone()],
)?;
let _ = builder.predicate_or("pred_or", &["id"], &["secret_key"], &[stb0, stb1])?;
let _ = builder.predicate_or("pred_or", &["id"], &["secret"], &[stb0, stb1])?;
let batch = builder.finish();
let pod_id = PodId(hash_str("pod_id"));
@ -2757,17 +2721,14 @@ mod tests {
Value::from(42),
),
Statement::equal(
AnchoredKey::new(pod_id, Key::from("foo")),
AnchoredKey::new(pod_id, Key::from("key")),
Value::from(1234),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(1234)];
let expected_st = Statement::Custom(
custom_predicate.clone(),
vec![args[0].clone(), WildcardValue::None],
vec![args[0].clone(), Value::from(0)],
);
helper_custom_operation_verify_gadget(
@ -2788,10 +2749,10 @@ mod tests {
),
Statement::None,
];
let args = vec![WildcardValue::PodId(pod_id), WildcardValue::None];
let args = vec![Value::from(pod_id), Value::from(0)];
let expected_st = Statement::Custom(
custom_predicate.clone(),
vec![args[0].clone(), WildcardValue::None],
vec![args[0].clone(), Value::from(0)],
);
helper_custom_operation_verify_gadget(
@ -2808,17 +2769,14 @@ mod tests {
let op_args = vec![
Statement::None,
Statement::equal(
AnchoredKey::new(pod_id, Key::from("foo")),
AnchoredKey::new(pod_id, Key::from("key")),
Value::from(1234),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(1234)];
let expected_st = Statement::Custom(
custom_predicate.clone(),
vec![args[0].clone(), WildcardValue::None],
vec![args[0].clone(), Value::from(0)],
);
helper_custom_operation_verify_gadget(
@ -2848,22 +2806,21 @@ mod tests {
use NativePredicate as NP;
use StatementTmplBuilder as STB;
let mut builder = CustomPredicateBatchBuilder::new(params.clone(), "batch".into());
let stb0 = STB::new(NP::Equal)
.arg(("id", key("score")))
.arg(literal(42));
let stb0 = STB::new(NP::Equal).arg(("id", "score")).arg(literal(42));
let stb1 = STB::new(NP::Equal)
.arg(("id", "secret_key"))
.arg(("id", key("score")));
.arg(("secret_id", "key"))
.arg(("id", "score"));
let _ = builder.predicate_and(
"pred_and",
&["id"],
&["secret_key"],
&["secret_id"],
&[stb0.clone(), stb1.clone()],
)?;
let _ = builder.predicate_or("pred_or", &["id"], &["secret_key"], &[stb0, stb1])?;
let _ = builder.predicate_or("pred_or", &["id"], &["secret_id"], &[stb0, stb1])?;
let batch = builder.finish();
let pod_id = PodId(hash_str("pod_id"));
let secret_pod_id = PodId(hash_str("secret_pod_id"));
// AND (0) Sanity check with correct values
let custom_predicate = CustomPredicateRef::new(batch.clone(), 0);
@ -2873,17 +2830,14 @@ mod tests {
Value::from(42),
),
Statement::equal(
AnchoredKey::new(pod_id, Key::from("foo")),
AnchoredKey::new(secret_pod_id, Key::from("key")),
AnchoredKey::new(pod_id, Key::from("score")),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(secret_pod_id)];
let expected_st = Statement::Custom(
custom_predicate.clone(),
vec![args[0].clone(), WildcardValue::None],
vec![args[0].clone(), Value::from(0)],
);
helper_custom_operation_verify_gadget(
@ -2903,14 +2857,11 @@ mod tests {
Value::from(42),
),
Statement::equal(
AnchoredKey::new(PodId(hash_str("BAD")), Key::from("foo")),
AnchoredKey::new(pod_id, Key::from("score")),
AnchoredKey::new(secret_pod_id, Key::from("key")),
AnchoredKey::new(PodId(hash_str("BAD")), Key::from("score")),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(secret_pod_id)];
assert!(helper_custom_operation_verify_gadget(
&params,
@ -2926,14 +2877,11 @@ mod tests {
let op_args = vec![
Statement::equal(AnchoredKey::new(pod_id, Key::from("BAD")), Value::from(42)),
Statement::equal(
AnchoredKey::new(pod_id, Key::from("foo")),
AnchoredKey::new(secret_pod_id, Key::from("key")),
AnchoredKey::new(pod_id, Key::from("score")),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(secret_pod_id)];
assert!(helper_custom_operation_verify_gadget(
&params,
@ -2952,14 +2900,11 @@ mod tests {
Value::from(0xbad),
),
Statement::equal(
AnchoredKey::new(pod_id, Key::from("foo")),
AnchoredKey::new(secret_pod_id, Key::from("key")),
AnchoredKey::new(pod_id, Key::from("score")),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(secret_pod_id)];
assert!(helper_custom_operation_verify_gadget(
&params,
@ -2978,14 +2923,11 @@ mod tests {
Value::from(42),
),
Statement::not_equal(
AnchoredKey::new(pod_id, Key::from("foo")),
AnchoredKey::new(secret_pod_id, Key::from("key")),
AnchoredKey::new(pod_id, Key::from("score")),
),
];
let args = vec![
WildcardValue::PodId(pod_id),
WildcardValue::Key(Key::from("foo")),
];
let args = vec![Value::from(pod_id), Value::from(secret_pod_id)];
assert!(helper_custom_operation_verify_gadget(
&params,
@ -2999,7 +2941,7 @@ mod tests {
// OR (1) Two Nones
let custom_predicate = CustomPredicateRef::new(batch.clone(), 1);
let op_args = vec![Statement::None, Statement::None];
let args = vec![WildcardValue::PodId(pod_id), WildcardValue::None];
let args = vec![Value::from(pod_id), Value::from(0)];
assert!(helper_custom_operation_verify_gadget(
&params,

View file

@ -315,7 +315,12 @@ pub(crate) fn layout_statements(
}
// Input statements
assert!(inputs.statements.len() <= params.max_priv_statements());
assert!(
inputs.statements.len() <= params.max_priv_statements(),
"inputs.statements.len={} > params.max_priv_statements={}",
inputs.statements.len(),
params.max_priv_statements()
);
for i in 0..params.max_priv_statements() {
let mut st = inputs
.statements
@ -329,9 +334,14 @@ pub(crate) fn layout_statements(
// Public statements
assert!(inputs.public_statements.len() < params.max_public_statements);
let pod_type = if mock {
PodType::MockMain
} else {
PodType::Main
};
let mut type_st = middleware::Statement::Equal(
AnchoredKey::from((SELF, KEY_TYPE)).into(),
middleware::Value::from(PodType::MockMain).into(),
middleware::Value::from(pod_type).into(),
)
.into();
pad_statement(params, &mut type_st);
@ -709,16 +719,13 @@ pub mod tests {
primitives::ec::schnorr::SecretKey,
signedpod::Signer,
},
examples::{
eth_dos_pod_builder, eth_friend_signed_pod_builder, zu_kyc_pod_builder,
zu_kyc_sign_pod_builders,
},
examples::{attest_eth_friend, zu_kyc_pod_builder, zu_kyc_sign_pod_builders, EthDosHelper},
frontend::{
key, literal, CustomPredicateBatchBuilder, MainPodBuilder, StatementTmplBuilder as STB,
literal, CustomPredicateBatchBuilder, MainPodBuilder, StatementTmplBuilder as STB,
{self},
},
middleware,
middleware::{CustomPredicateRef, NativePredicate as NP, DEFAULT_VD_SET},
middleware::{CustomPredicateRef, NativePredicate as NP, Value, DEFAULT_VD_SET},
op,
};
@ -847,52 +854,31 @@ pub mod tests {
#[test]
fn test_main_ethdos() -> frontend::Result<()> {
let params = Params {
max_input_signed_pods: 2,
max_input_recursive_pods: 1,
max_statements: 26,
max_public_statements: 5,
max_signed_pod_values: 8,
max_operation_args: 5,
max_custom_predicate_wildcards: 6,
max_custom_predicate_verifications: 8,
..Default::default()
};
let params = Params::default();
println!("{:#?}", params);
let vd_set = &*DEFAULT_VD_SET;
let mut alice = Signer(SecretKey(1u32.into()));
let bob = Signer(SecretKey(2u32.into()));
let mut charlie = Signer(SecretKey(3u32.into()));
let mut bob = Signer(SecretKey(2u32.into()));
let charlie = Signer(SecretKey(3u32.into()));
// Alice attests that she is ETH friends with Charlie and Charlie
// attests that he is ETH friends with Bob.
// Alice attests that she is ETH friends with Bob and Bob
// attests that he is ETH friends with Charlie.
let alice_attestation =
eth_friend_signed_pod_builder(&params, charlie.public_key().into()).sign(&mut alice)?;
let charlie_attestation =
eth_friend_signed_pod_builder(&params, bob.public_key().into()).sign(&mut charlie)?;
let alice_bob_ethdos_builder = eth_dos_pod_builder(
&params,
&vd_set,
false,
&alice_attestation,
&charlie_attestation,
bob.public_key().into(),
)?;
let mut prover = MockProver {};
let pod = alice_bob_ethdos_builder.prove(&mut prover, &params)?;
assert!(pod.pod.verify().is_ok());
attest_eth_friend(&params, &mut alice, Value::from(bob.public_key()));
let bob_attestation =
attest_eth_friend(&params, &mut bob, Value::from(charlie.public_key()));
let helper = EthDosHelper::new(&params, vd_set, false, Value::from(alice.public_key()))?;
let mut prover = Prover {};
let alice_bob_ethdos = alice_bob_ethdos_builder.prove(&mut prover, &params)?;
crate::measure_gates_print!();
let pod = (alice_bob_ethdos.pod as Box<dyn Any>)
.downcast::<MainPod>()
.unwrap();
Ok(pod.verify()?)
let dist_1 = helper
.dist_1(&alice_attestation)?
.prove(&mut prover, &params)?;
dist_1.pod.verify()?;
let dist_2 = helper
.dist_n_plus_1(&dist_1, &bob_attestation)?
.prove(&mut prover, &params)?;
Ok(dist_2.pod.verify()?)
}
#[test]
@ -914,19 +900,17 @@ pub mod tests {
let vd_set = &*DEFAULT_VD_SET;
let mut cpb_builder = CustomPredicateBatchBuilder::new(params.clone(), "cpb".into());
let stb0 = STB::new(NP::Equal)
.arg(("id", key("score")))
.arg(literal(42));
let stb0 = STB::new(NP::Equal).arg(("id", "score")).arg(literal(42));
let stb1 = STB::new(NP::Equal)
.arg(("id", "secret_key"))
.arg(("id", key("score")));
.arg(("secret_id", "key"))
.arg(("id", "score"));
let _ = cpb_builder.predicate_and(
"pred_and",
&["id"],
&["secret_key"],
&["secret_id"],
&[stb0.clone(), stb1.clone()],
)?;
let _ = cpb_builder.predicate_or("pred_or", &["id"], &["secret_key"], &[stb0, stb1])?;
let _ = cpb_builder.predicate_or("pred_or", &["id"], &["secret_id"], &[stb0, stb1])?;
let cpb = cpb_builder.finish();
let cpb_and = CustomPredicateRef::new(cpb.clone(), 0);
@ -934,8 +918,8 @@ pub mod tests {
let mut pod_builder = MainPodBuilder::new(&params, &vd_set);
let st0 = pod_builder.priv_op(op!(new_entry, ("score", 42)))?;
let st1 = pod_builder.priv_op(op!(new_entry, ("foo", 42)))?;
let st0 = pod_builder.priv_op(op!(new_entry, "score", 42))?;
let st1 = pod_builder.priv_op(op!(new_entry, "key", 42))?;
let st2 = pod_builder.priv_op(op!(eq, st1.clone(), st0.clone()))?;
let _st3 = pod_builder.priv_op(op!(custom, cpb_and.clone(), st0, st2))?;

View file

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use crate::{
backends::plonky2::error::{Error, Result},
middleware::{self, NativePredicate, Params, Predicate, StatementArg, ToFields, WildcardValue},
middleware::{self, NativePredicate, Params, Predicate, StatementArg, ToFields, Value},
};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -74,11 +74,11 @@ impl TryFrom<Statement> for middleware::Statement {
)))?,
},
Predicate::Custom(cpr) => {
let vs: Vec<WildcardValue> = proper_args
let vs: Vec<Value> = proper_args
.into_iter()
.filter_map(|arg| match arg {
SA::None => None,
SA::WildcardLiteral(v) => Some(v),
SA::Literal(v) => Some(v),
_ => unreachable!(),
})
.collect();

View file

@ -10,9 +10,9 @@ use crate::{
},
constants::MAX_DEPTH,
middleware::{
containers::Dictionary, hash_str, serialization::ordered_map, AnchoredKey, DynError, Hash,
Key, Params, Pod, PodId, PodSigner, PodType, RawValue, Statement, Value, KEY_SIGNER,
KEY_TYPE, SELF,
containers::Dictionary, hash_str, serialization::ordered_map, AnchoredKey, DynError, Key,
Params, Pod, PodId, PodSigner, PodType, RawValue, Statement, Value, KEY_SIGNER, KEY_TYPE,
SELF,
},
};
@ -21,8 +21,8 @@ pub struct MockSigner {
}
impl MockSigner {
pub fn public_key(&self) -> Hash {
hash_str(&self.pk)
pub fn public_key(&self) -> Value {
Value::from(hash_str(&self.pk))
}
}
@ -30,7 +30,7 @@ impl MockSigner {
fn _sign(&mut self, params: &Params, kvs: &HashMap<Key, Value>) -> Result<MockSignedPod> {
let mut kvs = kvs.clone();
let pubkey = self.public_key();
kvs.insert(Key::from(KEY_SIGNER), Value::from(pubkey));
kvs.insert(Key::from(KEY_SIGNER), pubkey.clone());
kvs.insert(Key::from(KEY_TYPE), Value::from(PodType::MockSigned));
let dict = Dictionary::new(params.max_depth_mt_containers, kvs.clone())?;