pub fn secp256k1_ecdsa_recover(sig: &[u8; 65], msg: &[u8; 32]) -> Result<[u8; 64], EcdsaVerifyError> {
	let rs = secp256k1::Signature::parse_slice(&sig[0..64]).map_err(|_| EcdsaVerifyError::BadRS)?;
	let v = secp256k1::RecoveryId::parse(if sig[64] > 26 { sig[64] - 27 } else { sig[64] } as u8).map_err(|_| EcdsaVerifyError::BadV)?;
	let pubkey = secp256k1::recover(&secp256k1::Message::parse(msg), &rs, &v).map_err(|_| EcdsaVerifyError::BadSignature)?;
	let mut res = [0u8; 64];
	res.copy_from_slice(&pubkey.serialize()[1..65]);
	Ok(res)
}
/// Verify and recover a SECP256k1 ECDSA signature.
/// - `sig` is passed in RSV format. V should be either 0/1 or 27/28.
/// - returns `Err` if the signature is bad, otherwise the 64-byte pubkey (doesn't include the 0x04 prefix).
Verify and recover a SECP256k1 ECDSA signature.
`sig` is passed in RSV format. V should be either 0/1 or 27/28.
returns `Err` if the signature is bad, otherwise the 64-byte pubkey (doesn't include the 0x04 prefix).
Verify and recover a SECP256k1 ECDSA signature . ` sig ` is passed in RSV format . V should be either 0 / 1 or 27 / 28 . returns ` Err ` if the signature is bad otherwise the 64 - byte pubkey ( doesn ' t include the 0x04 prefix ) .
pub fn secp256k1_ecdsa_recover(sig: &[u8; 65], msg: &[u8; 32]) -> Result<[u8; 64], EcdsaVerifyError> {
	let rs = secp256k1::Signature::parse_slice(&sig[0..64]).map_err(|_| EcdsaVerifyError::BadRS)?;
	let v = secp256k1::RecoveryId::parse(if sig[64] > 26 { sig[64] - 27 } else { sig[64] } as u8).map_err(|_| EcdsaVerifyError::BadV)?;
	let pubkey = secp256k1::recover(&secp256k1::Message::parse(msg), &rs, &v).map_err(|_| EcdsaVerifyError::BadSignature)?;
	let mut res = [0u8; 64];
	res.copy_from_slice(&pubkey.serialize()[1..65]);
	Ok(res)
}
pub fn secp256k1_ecdsa_recover ( sig : & [ u8 ; 65 ] , msg : & [ u8 ; 32 ] ) -> Result < [ u8 ; 64 ] , EcdsaVerifyError > { let rs = secp256k1 :: Signature :: parse_slice ( & sig [ 0 .. 64 ] ) . map_err ( | _ | EcdsaVerifyError :: BadRS ) ? ; let v = secp256k1 :: RecoveryId :: parse ( if sig [ 64 ] > 26 { sig [ 64 ] - 27 } else { sig [ 64 ] } as u8 ) . map_err ( | _ | EcdsaVerifyError :: BadV ) ? ; let pubkey = secp256k1 :: recover ( & secp256k1 :: Message :: parse ( msg ) , & rs , & v ) . map_err ( | _ | EcdsaVerifyError :: BadSignature ) ? ; let mut res = [ 0u8 ; 64 ] ; res . copy_from_slice ( & pubkey . serialize ( ) [ 1 .. 65 ] ) ; Ok ( res ) }
Verify and recover a SECP256k1 ECDSA signature.
Verify and recover a SECP256k1 ECDSA signature .
sig
&[u8; 65]
msg
&[u8; 32]
sig
&[u8; 65]
msg
&[u8; 32]