Skip to content

Commit 2753b9e

Browse files
committed
Merge #711: Improve from digest comment
72e09c1 Improve the comment on `Message::from_digest` (Martin Habovstiak) Pull request description: Minor improvement on top of #712 ACKs for top commit: apoelstra: ACK 72e09c1 Tree-SHA512: 06e8e706bb9732ea46ef3488ed33f7c7c84ea5afa5b1b2bca03cd2641524ff61156133436c1dd62df62769c8544644e1a4453fbacf4413fece73282ae154a387
2 parents 3f067d5 + 72e09c1 commit 2753b9e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@
6666
//! ```rust
6767
//! # #[cfg(feature = "alloc")] {
6868
//! use secp256k1::{Secp256k1, Message, SecretKey, PublicKey};
69+
//! # fn compute_hash(_: &[u8]) -> [u8; 32] { [0xab; 32] }
6970
//!
7071
//! let secp = Secp256k1::new();
7172
//! let secret_key = SecretKey::from_slice(&[0xcd; 32]).expect("32 bytes, within curve order");
7273
//! let public_key = PublicKey::from_secret_key(&secp, &secret_key);
73-
//! // This is unsafe unless the supplied byte slice is the output of a cryptographic hash function.
74-
//! let message = Message::from_digest([0xab; 32]);
74+
//! // If the supplied byte slice was *not* the output of a cryptographic hash function this would
75+
//! // be cryptographically broken. It has been trivially used in the past to execute attacks.
76+
//! let message = Message::from_digest(compute_hash(b"CSW is not Satoshi"));
7577
//!
7678
//! let sig = secp.sign_ecdsa(&message, &secret_key);
7779
//! assert!(secp.verify_ecdsa(&message, &sig, &public_key).is_ok());

0 commit comments

Comments
 (0)