pub struct Scalar(/* private fields */);Expand description
secp256k1 scalar value for use in elliptic curve operations
Implementations§
Source§impl Scalar
impl Scalar
Sourcepub fn new(data: [u8; 32]) -> Result<Self>
pub fn new(data: [u8; 32]) -> Result<Self>
Create a new scalar from raw bytes.
The value must use the canonical big-endian encoding in 1..n.
Out-of-range inputs are rejected rather than reduced.
Sourcepub fn from_secret_buffer(
buffer: SecretBuffer<K256_SCALAR_SIZE>,
) -> Result<Self>
pub fn from_secret_buffer( buffer: SecretBuffer<K256_SCALAR_SIZE>, ) -> Result<Self>
Create a scalar from a SecretBuffer.
The buffer contents must be a canonical non-zero scalar.
Sourcepub fn as_secret_buffer(&self) -> &SecretBuffer<K256_SCALAR_SIZE>
pub fn as_secret_buffer(&self) -> &SecretBuffer<K256_SCALAR_SIZE>
Get a reference to the underlying SecretBuffer.
Sourcepub fn serialize(&self) -> SecretBuffer<K256_SCALAR_SIZE>
pub fn serialize(&self) -> SecretBuffer<K256_SCALAR_SIZE>
Serialize this scalar to protected exact-size storage.
Sourcepub fn deserialize(bytes: &[u8]) -> Result<Self>
pub fn deserialize(bytes: &[u8]) -> Result<Self>
Deserialize a canonical non-zero scalar.
Trait Implementations§
impl ZeroizeOnDrop 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 UnsafeUnpin 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