pub struct Signature(pub Signature);
Expand description
The Signature
object is a wrapper around a raw bytes signature, typically
returned by :meth:~solders.keypair.Keypair.sign_message
or other similar methods.
Args: signature_bytes (bytes): The raw signature bytes.
Tuple Fields§
§0: Signature
Implementations§
Source§impl Signature
impl Signature
pub const LENGTH: usize = 64usize
pub fn new(signature_bytes: [u8; 64]) -> Self
Sourcepub fn new_unique() -> Self
pub fn new_unique() -> Self
Create a random siganture.
Returns: Signature: The random signature.
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new default signature object.
Returns: Signature: The default signature.
Example: >>> from solders.signature import Signature >>> Signature.default() Signature( 1111111111111111111111111111111111111111111111111111111111111111, )
Sourcepub fn new_from_str(s: &str) -> PyResult<Self>
pub fn new_from_str(s: &str) -> PyResult<Self>
Retrieve a signature from a base58-encoded string.
Args: s (str): base58-encoded signature.
Returns: Signature: The decoded signature.
Example: >>> from solders.signature import Signature >>> from solders.keypair import Keypair >>> sig = Keypair().sign_message(bytes([0])) >>> assert Signature.from_string(str(sig)) == sig
Sourcepub fn verify(&self, pubkey: Pubkey, message_bytes: &[u8]) -> bool
pub fn verify(&self, pubkey: Pubkey, message_bytes: &[u8]) -> bool
Check if the signature is a valid signature created by the given pubkey on the given message.
Args: pubkey: The pubkey that is supposed to have signed the message. message (bytes): The message in bytes.
Returns: bool: True if verfiication is successful.
Example: >>> from solders.keypair import Keypair >>> from solders.signature import Signature >>> kp = Keypair() >>> msg = b“macaroni“ >>> sig = kp.sign_message(msg) >>> sig.verify(kp.pubkey(), msg) True
Sourcepub fn to_bytes_array(&self) -> [u8; 64]
pub fn to_bytes_array(&self) -> [u8; 64]
Returns this signature as a byte array.
Returns: list[int]: the signature as a list of 64 u8 ints.
Example: >>> from solders.signature import Signature >>> assert Signature.default().to_bytes_array() == [0] * 64
Sourcepub fn from_bytes(raw_bytes: [u8; 64]) -> PyResult<Self>
pub fn from_bytes(raw_bytes: [u8; 64]) -> PyResult<Self>
Construct from bytes
. Equivalent to Signature.__init__
but included for the sake of consistency.
Args: raw_bytes (bytes): the signature bytes.
Returns:
Signature: a Signature
object.
pub fn __hash__(&self) -> u64
pub fn __richcmp__(&self, other: &Self, op: CompareOp) -> bool
pub fn __bytes__<'a>(&self, py: Python<'a>) -> &'a PyBytes
pub fn __str__(&self) -> String
pub fn __repr__(&self) -> String
pub fn __reduce__(&self) -> PyResult<(PyObject, PyObject)>
Trait Implementations§
Source§impl AsRef<Signature> for Signature
impl AsRef<Signature> for Signature
Source§fn as_ref(&self) -> &SignatureOriginal
fn as_ref(&self) -> &SignatureOriginal
Source§impl CommonMethods<'_> for Signature
impl CommonMethods<'_> for Signature
fn py_to_json(&self) -> String
fn py_from_json(raw: &'a str) -> Result<Self, PyErr>
Source§impl CommonMethodsCore for Signature
impl CommonMethodsCore for Signature
Source§impl<'de> Deserialize<'de> for Signature
impl<'de> Deserialize<'de> for Signature
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 From<Signature> for Signature
impl From<Signature> for Signature
Source§fn from(original: SignatureOriginal) -> Signature
fn from(original: SignatureOriginal) -> Signature
Source§impl Ord for Signature
impl Ord for Signature
Source§impl PartialOrd for Signature
impl PartialOrd for Signature
Source§impl PyBytesGeneral for Signature
impl PyBytesGeneral for Signature
fn pybytes_general<'a>(&self, py: Python<'a>) -> &'a PyBytes
Source§impl PyBytesSlice for Signature
impl PyBytesSlice for Signature
fn pybytes_slice<'a>(&self, py: Python<'a>) -> &'a PyBytes
Source§impl PyClassImpl for Signature
impl PyClassImpl for Signature
Source§const IS_BASETYPE: bool = true
const IS_BASETYPE: bool = true
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<Signature>
type ThreadChecker = SendablePyClass<Signature>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<Signature> for PyClassImplCollector<Signature>
impl PyClassNewTextSignature<Signature> for PyClassImplCollector<Signature>
fn new_text_signature(self) -> Option<&'static str>
Source§impl PyFromBytesGeneral for Signature
impl PyFromBytesGeneral for Signature
fn py_from_bytes_general(raw: &[u8]) -> PyResult<Self>
Source§impl PyMethods<Signature> for PyClassImplCollector<Signature>
impl PyMethods<Signature> for PyClassImplCollector<Signature>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Signature
impl PyTypeInfo for Signature
Source§type AsRefTarget = PyCell<Signature>
type AsRefTarget = PyCell<Signature>
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
Source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
object
is an instance of this type or a subclass of this type.Source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
object
is an instance of this type.impl Copy for Signature
impl Eq for Signature
impl StructuralPartialEq for Signature
Auto Trait Implementations§
impl Freeze for Signature
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnwindSafe for Signature
Blanket Implementations§
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<'a, T> FromPyObject<'a> for T
impl<'a, T> FromPyObject<'a> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more