crypto: Use the chain method to get the sha hash of the content

master
Damir Jelić 2021-01-14 13:34:12 +01:00
parent 3f3ae794a4
commit 43ea9a16a0
1 changed files with 3 additions and 1 deletions

View File

@ -63,10 +63,12 @@ pub struct SasIds {
/// interactive verification process. /// interactive verification process.
pub fn calculate_commitment(public_key: &str, content: impl Into<StartContent>) -> String { pub fn calculate_commitment(public_key: &str, content: impl Into<StartContent>) -> String {
let content = content.into().canonical_json(); let content = content.into().canonical_json();
let content_string = content.to_string();
encode( encode(
Sha256::new() Sha256::new()
.chain(&format!("{}{}", public_key, content)) .chain(&public_key)
.chain(&content_string)
.finalize(), .finalize(),
) )
} }