Update create_update_message
This commit is contained in:
parent
cc8d64f6ce
commit
76ce2c0672
18
src/api.rs
18
src/api.rs
@ -1303,13 +1303,13 @@ pub fn create_update_message(
|
||||
|
||||
let mut all_members: HashMap<Member, HashSet<String>> = HashMap::new();
|
||||
let shared_secrets = lock_shared_secrets()?;
|
||||
for (name, role) in roles {
|
||||
for (name, role) in &roles {
|
||||
let fields: Vec<String> = role
|
||||
.validation_rules
|
||||
.iter()
|
||||
.flat_map(|rule| rule.fields.clone())
|
||||
.collect();
|
||||
for member in role.members {
|
||||
for member in &role.members {
|
||||
// Check that we have a shared_secret with all members
|
||||
if let Some(no_secret_address) = member.get_addresses().iter()
|
||||
.find(|a| shared_secrets.get_secret_for_address(a.as_str().try_into().unwrap()).is_none())
|
||||
@ -1330,15 +1330,10 @@ pub fn create_update_message(
|
||||
let sender: Member = local_device
|
||||
.to_member();
|
||||
|
||||
// To allow the recipient to identify the pcd that contains only encrypted values, we compute the merkle tree of the encrypted pcd
|
||||
// we then put the root in the payload of the prd update
|
||||
let encrypted_pcd_hash = update_state.encrypted_pcd.hash_all_fields(OutPoint::null())?;
|
||||
let encrypted_pcd_merkle_root = <Value as Pcd>::create_merkle_tree(&Value::Object(encrypted_pcd_hash))?.root().unwrap();
|
||||
|
||||
let full_prd = Prd::new_update(
|
||||
outpoint,
|
||||
serde_json::to_string(&sender)?,
|
||||
serialize(&encrypted_pcd_merkle_root).to_lower_hex_string(),
|
||||
roles,
|
||||
update_state.keys.clone(),
|
||||
update_state.pcd_commitment.clone(),
|
||||
);
|
||||
@ -1368,14 +1363,7 @@ pub fn create_update_message(
|
||||
return Err(ApiError::new("Empty ciphers list".to_owned()));
|
||||
}
|
||||
|
||||
let updated_process = UpdatedProcess {
|
||||
commitment_tx: outpoint,
|
||||
current_process: process.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
Ok(ApiReturn {
|
||||
updated_process: Some(updated_process),
|
||||
ciphers_to_send: ciphers,
|
||||
..Default::default()
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user