pub struct Scalar(/* private fields */);
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 non_secure_erase(&mut self)
pub fn non_secure_erase(&mut self)
Attempts to erase the contents of the underlying array.
Note, however, that the compiler is allowed to freely copy or move the
contents of this array to other places in memory. Preventing this behavior
is very subtle. For more discussion on this, please see the documentation
of the zeroize
crate.
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 for Scalar
impl PartialEq for Scalar
source§impl PartialOrd for Scalar
impl PartialOrd for Scalar
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Scalar
impl Eq for Scalar
impl StructuralPartialEq for Scalar
Auto Trait Implementations§
impl Freeze for Scalar
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)