Struct Scalar
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§
§impl Scalar
impl Scalar
pub fn from_be_bytes(value: [u8; 32]) -> Result<Scalar, OutOfRangeError>
pub fn from_be_bytes(value: [u8; 32]) -> Result<Scalar, 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.
pub fn from_le_bytes(value: [u8; 32]) -> Result<Scalar, OutOfRangeError>
pub fn from_le_bytes(value: [u8; 32]) -> Result<Scalar, 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.
pub fn to_be_bytes(self) -> [u8; 32]
pub fn to_be_bytes(self) -> [u8; 32]
Serializes to big endian bytes
pub fn to_le_bytes(self) -> [u8; 32]
pub fn to_le_bytes(self) -> [u8; 32]
Serializes to little endian bytes
Trait Implementations§
§impl Ord for Scalar
impl Ord for Scalar
§impl PartialOrd for Scalar
impl PartialOrd for Scalar
impl 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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request