snarkvm_console_types_scalar/
lib.rs#![cfg_attr(test, allow(clippy::assertions_on_result_states))]
#![warn(clippy::cast_possible_truncation)]
mod arithmetic;
mod bitwise;
mod bytes;
mod compare;
mod from_bits;
mod from_field;
mod from_field_lossy;
mod one;
mod parse;
mod random;
mod serialize;
mod size_in_bits;
mod size_in_bytes;
mod to_bits;
mod to_field;
mod zero;
pub use snarkvm_console_network_environment::prelude::*;
pub use snarkvm_console_types_boolean::Boolean;
pub use snarkvm_console_types_field::Field;
use zeroize::Zeroize;
#[derive(Copy, Clone, PartialEq, Eq, Hash, Zeroize)]
pub struct Scalar<E: Environment> {
scalar: E::Scalar,
}
impl<E: Environment> ScalarTrait for Scalar<E> {}
impl<E: Environment> Scalar<E> {
pub const SIZE_IN_BITS: usize = E::Scalar::SIZE_IN_BITS;
pub const SIZE_IN_BYTES: usize = (E::Scalar::SIZE_IN_BITS + 7) / 8;
pub const SIZE_IN_DATA_BITS: usize = E::Scalar::SIZE_IN_DATA_BITS;
pub const fn new(scalar: E::Scalar) -> Self {
Self { scalar }
}
}
impl<E: Environment> TypeName for Scalar<E> {
#[inline]
fn type_name() -> &'static str {
"scalar"
}
}
impl<E: Environment> Deref for Scalar<E> {
type Target = E::Scalar;
#[inline]
fn deref(&self) -> &Self::Target {
&self.scalar
}
}