Check if message in slate comes with signature (#2284)

Fixes #2281
This commit is contained in:
hashmap 2019-01-03 13:05:23 +01:00 committed by GitHub
parent 939f42ea56
commit 3b4492495f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -351,12 +351,22 @@ impl Slate {
/// Verifies any messages in the slate's participant data match their signatures /// Verifies any messages in the slate's participant data match their signatures
pub fn verify_messages(&self, secp: &secp::Secp256k1) -> Result<(), Error> { pub fn verify_messages(&self, secp: &secp::Secp256k1) -> Result<(), Error> {
for p in self.participant_data.iter() { for p in self.participant_data.iter() {
if let Some(msg) = p.message.clone() { if let Some(msg) = &p.message {
let hashed = blake2b(secp::constants::MESSAGE_SIZE, &[], &msg.as_bytes()[..]); let hashed = blake2b(secp::constants::MESSAGE_SIZE, &[], &msg.as_bytes()[..]);
let m = secp::Message::from_slice(&hashed.as_bytes())?; let m = secp::Message::from_slice(&hashed.as_bytes())?;
let signature = match p.message_sig {
None => {
error!("verify_messages - participant message doesn't have signature. Message: \"{}\"",
String::from_utf8_lossy(&msg.as_bytes()[..]));
return Err(ErrorKind::Signature(
"Optional participant messages doesn't have signature".to_owned(),
))?;
}
Some(s) => s,
};
if !aggsig::verify_single( if !aggsig::verify_single(
secp, secp,
&p.message_sig.as_ref().unwrap(), &signature,
&m, &m,
None, None,
&p.public_blind_excess, &p.public_blind_excess,