pub struct ChainSignature<E>(/* private fields */);Expand description
Represents an ECDSA signature based on the secp256k1 curve with a recoverable public key. The signature uses Keccak256 as the hash function.
This signature encodes the 2-bit recovery information into the
uppermost bits from MSB of the S value, which are never used by this ECDSA
instantiation over secp256k1.
The instance holds the byte array consisting of R and S values with the recovery bit
already embedded in S.
See EIP-2098 for details.
Implementations§
Source§impl<E: EcdsaEngine> ChainSignature<E>
impl<E: EcdsaEngine> ChainSignature<E>
Sourcepub fn raw_signature(&self) -> ([u8; 64], u8)
pub fn raw_signature(&self) -> ([u8; 64], u8)
Returns the raw signature, without the encoded public key recovery bit and the recovery parity bit as a separate value.
Sourcepub fn sign_message(message: &[u8], chain_keypair: &ChainKeypair) -> Self
pub fn sign_message(message: &[u8], chain_keypair: &ChainKeypair) -> Self
Signs the given message using the chain private key.
Sourcepub fn sign_hash(hash: &Hash, chain_keypair: &ChainKeypair) -> Self
pub fn sign_hash(hash: &Hash, chain_keypair: &ChainKeypair) -> Self
Signs the given hash using the raw private key.
Sourcepub fn verify_message(
&self,
message: &[u8],
public_key: &PublicKey,
) -> Result<bool>
pub fn verify_message( &self, message: &[u8], public_key: &PublicKey, ) -> Result<bool>
Verifies this signature against the given message and a public key object
Sourcepub fn verify_hash(&self, hash: &Hash, public_key: &PublicKey) -> Result<bool>
pub fn verify_hash(&self, hash: &Hash, public_key: &PublicKey) -> Result<bool>
Verifies this signature against the given hash and a public key object
Sourcepub fn recover_from_msg(&self, msg: &[u8]) -> Result<PublicKey>
pub fn recover_from_msg(&self, msg: &[u8]) -> Result<PublicKey>
Recovers signer public key if this signature is a valid signature of the given msg.
Sourcepub fn recover_from_hash(&self, hash: &Hash) -> Result<PublicKey>
pub fn recover_from_hash(&self, hash: &Hash) -> Result<PublicKey>
Recovers signer public key if this signature is a valid signature of the given hash.
Trait Implementations§
Source§impl<E> AsRef<[u8]> for ChainSignature<E>
impl<E> AsRef<[u8]> for ChainSignature<E>
Source§impl<E> BytesRepresentable for ChainSignature<E>
impl<E> BytesRepresentable for ChainSignature<E>
Source§impl<E: Clone> Clone for ChainSignature<E>
impl<E: Clone> Clone for ChainSignature<E>
Source§fn clone(&self) -> ChainSignature<E>
fn clone(&self) -> ChainSignature<E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E: Debug> Debug for ChainSignature<E>
impl<E: Debug> Debug for ChainSignature<E>
Source§impl<'de, E> Deserialize<'de> for ChainSignature<E>
impl<'de, E> Deserialize<'de> for ChainSignature<E>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<E: PartialEq> PartialEq for ChainSignature<E>
impl<E: PartialEq> PartialEq for ChainSignature<E>
Source§impl<E> Serialize for ChainSignature<E>
impl<E> Serialize for ChainSignature<E>
Source§impl<E> TryFrom<&[u8]> for ChainSignature<E>
impl<E> TryFrom<&[u8]> for ChainSignature<E>
impl<E: Copy> Copy for ChainSignature<E>
impl<E: Eq> Eq for ChainSignature<E>
impl<E> StructuralPartialEq for ChainSignature<E>
Auto Trait Implementations§
impl<E> Freeze for ChainSignature<E>
impl<E> RefUnwindSafe for ChainSignature<E>where
E: RefUnwindSafe,
impl<E> Send for ChainSignature<E>where
E: Send,
impl<E> Sync for ChainSignature<E>where
E: Sync,
impl<E> Unpin for ChainSignature<E>where
E: Unpin,
impl<E> UnwindSafe for ChainSignature<E>where
E: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> ToHex for Twhere
T: BytesRepresentable,
impl<T> ToHex for Twhere
T: BytesRepresentable,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self into the result. Upper case
letters are used (e.g. F9B4CA)