Refactor decrypt_pcd()
This commit is contained in:
parent
43459fa0bb
commit
391ca02186
@ -24,11 +24,20 @@ pub struct ProcessState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ProcessState {
|
impl ProcessState {
|
||||||
pub fn decrypt_pcd(&self) -> Value {
|
pub fn decrypt_pcd(&self) -> anyhow::Result<Value> {
|
||||||
// TODO add real error management
|
|
||||||
let mut fields2plain = Map::new();
|
let mut fields2plain = Map::new();
|
||||||
let _ = self.encrypted_pcd.decrypt_fields(&self.keys, &mut fields2plain);
|
let fields2commit = self.pcd_commitment.to_value_object()?;
|
||||||
Value::Object(fields2plain)
|
self.encrypted_pcd.decrypt_fields(&fields2commit, &self.keys, &mut fields2plain)?;
|
||||||
|
Ok(Value::Object(fields2plain))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_message_hash(&self, approval: bool) -> anyhow::Result<AnkHash> {
|
||||||
|
let merkle_root = <Value as Pcd>::create_merkle_tree(&self.pcd_commitment)?.root().unwrap();
|
||||||
|
if approval {
|
||||||
|
Ok(AnkHash::ValidationYes(AnkValidationYesHash::from_byte_array(merkle_root)))
|
||||||
|
} else {
|
||||||
|
Ok(AnkHash::ValidationNo(AnkValidationNoHash::from_byte_array(merkle_root)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_modified_fields(&self, previous_state: Option<&ProcessState>) -> Vec<String> {
|
fn list_modified_fields(&self, previous_state: Option<&ProcessState>) -> Vec<String> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user