Struct std::b512::B512

pub struct B512 {
    /// The two `b256`s that make up the `B512`.
    bits: [b256; 2],
}
Expand description

Stores two b256s in contiguous memory.
Guaranteed to be contiguous for use with ec-recover: std::ecr::ec_recover.

Fields

bits: [b256; 2]

The two b256s that make up the B512.

Implementations

fn new() -> Self

Initializes a new, zeroed B512.

Returns

  • [B512] - A zero value B512.

Examples

use std::b512::B512;

fn foo() {
    let zero = B512::new();
}

fn bits(self) -> [b256; 2]

Returns the underlying bits for the B512 type.

Returns

  • [[b256; 2]] - The two b256s that make up the B512.

Examples

use std::b512::B512;

fn foo() {
    let zero = B512::new();
    assert(zero.bits() == [b256::zero(), b256::zero()]);
}

fn zero() -> Self

Returns the zero value for the B512 type.

Returns

  • [B512] -> The zero value for the B512 type.

Examples

use std::b512::B512;

fn foo() {
    let zero_b512 = B512::zero();
    assert(zero_b512 == B512::from((b256::zero(), b256::zero())));
}

fn is_zero(self) -> bool

Returns whether a B512 is set to zero.

Returns

  • [bool] -> True if the B512 is zero, otherwise false.

Examples

use std::b512::B512;

fn foo() {
    let zero_b512 = B512::zero();
    assert(zero_b512.is_zero());
}

Trait Implementations

fn eq(self, other: Self) -> bool

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, otherwise false.

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);
}

fn from(components: (b256, b256)) -> Self

Converts from a b256 tuple to a B512.

Arguments

  • components: [(b256, b256)] - The (b256, b256) tuple to convert to a B512.

Returns

  • [B512] - The newly created B512.

Examples

use std::b512::B512;

fn foo() {
    let tuple: (b256, b256) = (b256::zero(), b256::zero());
    let b512 = B512::from(tuple);
}