pub struct Message(_);Expand description
A (hashed) message input to an ECDSA signature.
Implementations§
§impl Message
impl Message
pub fn from_slice(data: &[u8]) -> Result<Message, Error>
pub fn from_slice(data: &[u8]) -> Result<Message, Error>
If you just want to sign an arbitrary message use Message::from_hashed_data instead.
Converts a MESSAGE_SIZE-byte slice to a message object. WARNING: the slice has to be a
cryptographically secure hash of the actual message that’s going to be signed. Otherwise
the result of signing isn’t a
secure signature.
pub fn from_hashed_data<H>(data: &[u8]) -> Messagewhere
H: ThirtyTwoByteHash + Hash,
pub fn from_hashed_data<H>(data: &[u8]) -> Messagewhere H: ThirtyTwoByteHash + Hash,
Constructs a Message by hashing data with hash algorithm H.
Requires the feature bitcoin-hashes to be enabled.
Examples
use secp256k1::hashes::{sha256, Hash};
use secp256k1::Message;
let m1 = Message::from_hashed_data::<sha256::Hash>("Hello world!".as_bytes());
// is equivalent to
let m2 = Message::from(sha256::Hash::hash("Hello world!".as_bytes()));
assert_eq!(m1, m2);Trait Implementations§
§impl<T> From<T> for Messagewhere
T: ThirtyTwoByteHash,
impl<T> From<T> for Messagewhere T: ThirtyTwoByteHash,
§impl Ord for Message
impl Ord for Message
§impl PartialOrd<Message> for Message
impl PartialOrd<Message> for Message
§fn partial_cmp(&self, other: &Message) -> Option<Ordering>
fn partial_cmp(&self, other: &Message) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for Message
impl Eq for Message
Auto Trait Implementations§
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.