Make Pcd::decrypt_fields() replace encrypted by commitments
This commit is contained in:
parent
64908496eb
commit
b38189beca
11
src/pcd.rs
11
src/pcd.rs
@ -185,6 +185,7 @@ pub trait Pcd<'a>: Serialize + Deserialize<'a> {
|
|||||||
|
|
||||||
fn decrypt_fields(
|
fn decrypt_fields(
|
||||||
&self,
|
&self,
|
||||||
|
fields2commit: &Map<String, Value>,
|
||||||
fields2keys: &Map<String, Value>,
|
fields2keys: &Map<String, Value>,
|
||||||
fields2plain: &mut Map<String, Value>,
|
fields2plain: &mut Map<String, Value>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
@ -222,8 +223,14 @@ pub trait Pcd<'a>: Serialize + Deserialize<'a> {
|
|||||||
|
|
||||||
fields2plain.insert(field.to_owned(), Value::String(decrypted_value));
|
fields2plain.insert(field.to_owned(), Value::String(decrypted_value));
|
||||||
} else {
|
} else {
|
||||||
// We keep the original value, that allows us to have fields that are always left unencrypted
|
// We put the commitment instead of the encrypted value
|
||||||
fields2plain.insert(field.to_owned(), encrypted_value.clone());
|
let commitment = fields2commit.get(field);
|
||||||
|
match commitment {
|
||||||
|
Some(hash) => {
|
||||||
|
fields2plain.insert(field.to_owned(), hash.clone());
|
||||||
|
},
|
||||||
|
None => return Err(Error::msg(format!("Missing commitment for field {}", field)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user