Skip to content

Commit

Permalink
add code to specify behaviour in case of short messages input to issu…
Browse files Browse the repository at this point in the history
…ance authorization signature function
  • Loading branch information
vivek-arte committed Jan 22, 2024
1 parent 7e44bbb commit a76a074
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ impl IssuanceAuthorizingKey {
}

/// Sign the provided message using the `IssuanceAuthorizingKey`.
/// Only supports signing of messages longer than 32 bytes, using prehashing, as described in [BIP 340][bip340]
///
/// [bip340]: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#messages-of-arbitrary-size
pub fn sign(&self, msg: &[u8]) -> Signature {
assert!(msg.len() >= 32);
schnorr::SigningKey::from(self.0).sign(msg)
}
}
Expand Down Expand Up @@ -1196,6 +1200,14 @@ mod tests {
assert!(isk.is_none());
}

#[test]
#[should_panic]
fn cannot_generate_issuance_authorization_signature_for_short_messages() {
let isk = IssuanceAuthorizingKey::random();
let msg = [0u8; 16];
let _ = isk.sign(&msg);
}

#[test]
fn issuance_authorizing_key_from_bytes_to_bytes_roundtrip() {
let isk = IssuanceAuthorizingKey::random();
Expand Down

0 comments on commit a76a074

Please sign in to comment.