pub struct Scalar {
bytes: Bytes,
}
Expand description
The Scalar type used in cryptographic operations.
Fields
bytes: Bytes
Implementations
pub fn new() -> Self
pub fn new() -> Self
Returns a new, uninitialized Scalar.
Returns
- [Scalar] - The new Scalar.
Examples
use std::scalar::Scalar;
fn foo() {
let new_scalar = Scalar::new();
}
pub fn zero() -> Self
pub fn zero() -> Self
Returns a zeroed Scalar.
Returns
- [Scalar] - The new zeroed Scalar.
Examples
use std::scalar::Scalar;
fn foo() {
let zero_scalar = Scalar::zero();
assert(b256::try_from(new_scalar.bytes()).unwrap() == b256::zero());
}
pub fn min() -> Self
pub fn min() -> Self
Returns the minimum scalar.
Returns
- [Scalar] - The new minimum Scalar.
Examples
use std::scalar::Scalar;
fn foo() {
let zero_scalar = Scalar::zero();
assert(b256::try_from(new_scalar.bytes()).unwrap() == b256::zero());
}
pub fn is_zero(self) -> bool
pub fn is_zero(self) -> bool
Returns true if the scalar is zero, otherwise false.
Returns
Examples
use std::scalar::Scalar;
fn foo() {
let zero_scalar = Scalar::zero();
assert(zero_scalar.is_zero());
}
pub fn bytes(self) -> Bytes
pub fn bytes(self) -> Bytes
Returns the underlying bytes of the scalar.
Returns
- [Bytes] - The scalar represented as bytes.
Examples
use std::scalar::Scalar;
fn foo(scalar: Scalar) {
let bytes = scalar.bytes();
assert(bytes.len() != 0);
}
Trait Implementations
impl AbiEncode for Scalar
impl AbiEncode for Scalar
pub fn abi_encode(self, buffer: Buffer) -> Buffer
impl AbiDecode for Scalar
impl AbiDecode for Scalar
pub fn abi_decode(refmut buffer: BufferReader) -> Self
impl Eq for Scalar
impl Eq for Scalar
pub fn eq(self, other: Self) -> bool
pub fn neq(self, other: Self) -> bool
pub fn neq(self, other: Self) -> bool
Evaluates if two values of the same type are not equal.
Additional Information
This function is inherited when eq()
is implemented.
Arguments
other
: [Self] - The value of the same type.
Returns
- [bool] -
true
if the two values are not equal, otherwisefalse
.
Examples
struct MyStruct {
val: u64,
}
impl Eq for MyStruct {
fn eq(self, other: Self) -> bool {
self.val == other.val
}
}
fn foo() {
let struct1 = MyStruct { val: 10 };
let struct2 = MyStruct { val: 2 };
let result = struct1 != struct2;
assert(result);
}