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 random_custom<R>(rng: R) -> Scalarwhere
R: Rng,
pub fn random_custom<R>(rng: R) -> Scalarwhere
R: Rng,
Generates a random scalar using supplied RNG
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<T> AnySync for T
impl<T> AnySync for T
§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
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)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.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
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
§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
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>
T
in a tonic::Request