pub struct ScalarBytes<C: Curve> { /* private fields */ }Expand description
Scalar bytes: wrapper for FieldBytes which guarantees that the the
inner byte value is within range of the Curve::ORDER.
Does not require an arithmetic implementation.
Implementations§
Source§impl<C> ScalarBytes<C>where
C: Curve,
impl<C> ScalarBytes<C>where
C: Curve,
Sourcepub fn new(bytes: FieldBytes<C>) -> CtOption<Self>
pub fn new(bytes: FieldBytes<C>) -> CtOption<Self>
Create new ScalarBytes, checking that the given input is within
range of the Curve::ORDER.
Sourcepub fn from_uint(uint: &C::UInt) -> CtOption<Self>
pub fn from_uint(uint: &C::UInt) -> CtOption<Self>
Create ScalarBytes from the provided C::UInt.
Sourcepub fn from_scalar(scalar: &Scalar<C>) -> Selfwhere
C: ProjectiveArithmetic,
pub fn from_scalar(scalar: &Scalar<C>) -> Selfwhere
C: ProjectiveArithmetic,
Convert from a Scalar type for this curve.
Sourcepub fn to_scalar(&self) -> Scalar<C>where
C: ProjectiveArithmetic,
pub fn to_scalar(&self) -> Scalar<C>where
C: ProjectiveArithmetic,
Convert to a Scalar type for this curve.
Sourcepub fn into_scalar(self) -> Scalar<C>where
C: ProjectiveArithmetic,
pub fn into_scalar(self) -> Scalar<C>where
C: ProjectiveArithmetic,
Convert into a Scalar type for this curve.
Sourcepub fn as_bytes(&self) -> &FieldBytes<C>
pub fn as_bytes(&self) -> &FieldBytes<C>
Borrow the inner FieldBytes
Sourcepub fn into_bytes(self) -> FieldBytes<C>
pub fn into_bytes(self) -> FieldBytes<C>
Convert into FieldBytes
Sourcepub fn zero() -> Self
pub fn zero() -> Self
Create ScalarBytes representing a value of zero.
Sourcepub fn is_zero(&self) -> Choice
pub fn is_zero(&self) -> Choice
Is this ScalarBytes value all zeroes?
Trait Implementations§
Source§impl<C> AsRef<GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>> for ScalarBytes<C>where
C: Curve,
impl<C> AsRef<GenericArray<u8, <<C as Curve>::UInt as ArrayEncoding>::ByteSize>> for ScalarBytes<C>where
C: Curve,
Source§fn as_ref(&self) -> &FieldBytes<C>
fn as_ref(&self) -> &FieldBytes<C>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<C> ConditionallySelectable for ScalarBytes<C>
impl<C> ConditionallySelectable for ScalarBytes<C>
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
Conditionally swap
self and other if choice == 1; otherwise,
reassign both unto themselves. Read moreSource§impl<C> ConstantTimeEq for ScalarBytes<C>where
C: Curve,
impl<C> ConstantTimeEq for ScalarBytes<C>where
C: Curve,
impl<C> Copy for ScalarBytes<C>
Source§impl<C> Default for ScalarBytes<C>where
C: Curve,
impl<C> Default for ScalarBytes<C>where
C: Curve,
impl<C: Eq + Curve> Eq for ScalarBytes<C>
Source§impl<C> From<&NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<&NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
arithmetic only.Source§fn from(scalar: &NonZeroScalar<C>) -> ScalarBytes<C>
fn from(scalar: &NonZeroScalar<C>) -> ScalarBytes<C>
Converts to this type from the input type.
Source§impl<C> From<&ScalarBytes<C>> for FieldBytes<C>where
C: Curve,
impl<C> From<&ScalarBytes<C>> for FieldBytes<C>where
C: Curve,
Source§fn from(scalar_bytes: &ScalarBytes<C>) -> FieldBytes<C>
fn from(scalar_bytes: &ScalarBytes<C>) -> FieldBytes<C>
Converts to this type from the input type.
Source§impl<C> From<NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> From<NonZeroScalar<C>> for ScalarBytes<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
arithmetic only.Source§fn from(scalar: NonZeroScalar<C>) -> ScalarBytes<C>
fn from(scalar: NonZeroScalar<C>) -> ScalarBytes<C>
Converts to this type from the input type.
Source§impl<C> From<ScalarBytes<C>> for FieldBytes<C>where
C: Curve,
impl<C> From<ScalarBytes<C>> for FieldBytes<C>where
C: Curve,
Source§fn from(scalar_bytes: ScalarBytes<C>) -> FieldBytes<C>
fn from(scalar_bytes: ScalarBytes<C>) -> FieldBytes<C>
Converts to this type from the input type.
Source§impl<C> PartialEq for ScalarBytes<C>where
C: Curve,
impl<C> PartialEq for ScalarBytes<C>where
C: Curve,
Source§impl<C> TryFrom<ScalarBytes<C>> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature arithmetic only.
impl<C> TryFrom<ScalarBytes<C>> for NonZeroScalar<C>where
C: Curve + ProjectiveArithmetic,
Available on crate feature
arithmetic only.Source§fn try_from(bytes: ScalarBytes<C>) -> Result<NonZeroScalar<C>>
fn try_from(bytes: ScalarBytes<C>) -> Result<NonZeroScalar<C>>
Performs the conversion.
Auto Trait Implementations§
impl<C> Freeze for ScalarBytes<C>
impl<C> RefUnwindSafe for ScalarBytes<C>where
<<<C as Curve>::UInt as ArrayEncoding>::ByteSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<C> Send for ScalarBytes<C>
impl<C> Sync for ScalarBytes<C>
impl<C> Unpin for ScalarBytes<C>
impl<C> UnsafeUnpin for ScalarBytes<C>
impl<C> UnwindSafe for ScalarBytes<C>
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