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 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 more