Make Pcd::decrypt_fields() replace encrypted by commitments
This commit is contained in:
parent
7a8f3c056a
commit
ec447ca409
11
src/pcd.rs
11
src/pcd.rs
@ -185,6 +185,7 @@ pub trait Pcd<'a>: Serialize + Deserialize<'a> {
|
||||
|
||||
fn decrypt_fields(
|
||||
&self,
|
||||
fields2commit: &Map<String, Value>,
|
||||
fields2keys: &Map<String, Value>,
|
||||
fields2plain: &mut Map<String, Value>,
|
||||
) -> Result<()> {
|
||||
@ -222,8 +223,14 @@ pub trait Pcd<'a>: Serialize + Deserialize<'a> {
|
||||
|
||||
fields2plain.insert(field.to_owned(), Value::String(decrypted_value));
|
||||
} else {
|
||||
// We keep the original value, that allows us to have fields that are always left unencrypted
|
||||
fields2plain.insert(field.to_owned(), encrypted_value.clone());
|
||||
// We put the commitment instead of the encrypted value
|
||||
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