pub struct Scalar(_);
Expand description
Positive 256-bit integer guaranteed to be less than the secp256k1 curve order.
The difference between PrivateKey
and Scalar
is that Scalar
doesn’t guarantee being
securely usable as a private key.
Warning: the operations on this type are NOT constant time! Using this with secret values is not advised.
Implementations§
source§impl Scalar
impl Scalar
sourcepub fn from_be_bytes(value: [u8; 32]) -> Result<Self, OutOfRangeError>
pub fn from_be_bytes(value: [u8; 32]) -> Result<Self, OutOfRangeError>
Tries to deserialize from big endian bytes
Security warning: this function is not constant time! Passing secret data is not recommended.
Errors
Returns error when the value is above the curve order.
sourcepub fn from_le_bytes(value: [u8; 32]) -> Result<Self, OutOfRangeError>
pub fn from_le_bytes(value: [u8; 32]) -> Result<Self, OutOfRangeError>
Tries to deserialize from little endian bytes
Security warning: this function is not constant time! Passing secret data is not recommended.
Errors
Returns error when the value is above the curve order.
sourcepub fn to_be_bytes(self) -> [u8; 32]
pub fn to_be_bytes(self) -> [u8; 32]
Serializes to big endian bytes
sourcepub fn to_le_bytes(self) -> [u8; 32]
pub fn to_le_bytes(self) -> [u8; 32]
Serializes to little endian bytes
Trait Implementations§
source§impl Ord for Scalar
impl Ord for Scalar
source§impl PartialEq<Scalar> for Scalar
impl PartialEq<Scalar> for Scalar
source§impl PartialOrd<Scalar> for Scalar
impl PartialOrd<Scalar> for Scalar
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 Scalar
impl Eq for Scalar
impl StructuralEq for Scalar
impl StructuralPartialEq for Scalar
Auto Trait Implementations§
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnwindSafe for Scalar
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