Check if we don't have the roles already in clear when validating a state

This commit is contained in:
NicolasCantu 2024-12-19 14:06:38 +01:00 committed by Nicolas Cantu
parent 401cc35fe7
commit 5716dabbd9

View File

@ -157,12 +157,18 @@ impl ProcessState {
return Err(anyhow::anyhow!("State is identical to the previous state"));
}
let mut fields2plains = Map::new();
let fields2commit = self.pcd_commitment.as_object().ok_or(anyhow::Error::msg("pcd_commitment is not an object"))?;
self.encrypted_pcd
.decrypt_all(self.commited_in, &fields2commit, &self.keys, &mut fields2plains)?;
let roles2rules = match self.encrypted_pcd.extract_roles() {
Ok(roles) => roles,
Err(_) => {
let mut fields2plains = Map::new();
let fields2commit = self.pcd_commitment.as_object().ok_or(anyhow::Error::msg("pcd_commitment is not an object"))?;
self.encrypted_pcd
.decrypt_all(self.commited_in, &fields2commit, &self.keys, &mut fields2plains)?;
Value::Object(fields2plains).extract_roles()?
}
};
let roles2rules = Value::Object(fields2plains).extract_roles()?;
// Check if each modified field satisfies at least one applicable rule across all roles
let all_fields_validated = modified_fields.iter().all(|field| {