Skip to main content

Bit

Struct Bit 

Source
pub struct Bit(/* private fields */);
Expand description

GF(2) element; the inner byte is invariantly 0 or 1.

Implementations§

Source§

impl Bit

Source

pub const fn new(val: u8) -> Self

Builds the element from the low bit of val.

Source

pub const fn try_new(val: u8) -> Option<Self>

Returns the element if val is 0 or 1, else None.

Source

pub const fn get(self) -> u8

Returns the value, always 0 or 1.

Trait Implementations§

Source§

impl Add for Bit

Add (XOR) 0+0=0, 0+1=1, 1+0=1, 1+1=0

Source§

type Output = Bit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for Bit

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl CanonicalDeserialize for Bit

Source§

fn deserialize(bytes: &[u8]) -> Result<Self, ()>

Reads an element from the start of bytes; ignores the rest. Read more
Source§

impl CanonicalSerialize for Bit

Source§

fn serialized_size(&self) -> usize

Returns the encoded length in bytes.
Source§

fn serialize(&self, writer: &mut [u8]) -> Result<(), ()>

Writes the encoding to the start of writer; later bytes are left as they are. Read more
Source§

fn to_bytes(&self) -> Vec<u8> ⓘ

Encodes self into a new Vec<u8> of serialized_size() bytes.
Source§

impl Clone for Bit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Bit

Source§

impl Debug for Bit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Bit

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Bit

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Bit

Source§

impl From<Bit> for Block128

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<Bit> for Block16

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<Bit> for Block256

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<Bit> for Block32

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<Bit> for Block64

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<Bit> for Block8

Source§

fn from(val: Bit) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Bit

Source§

fn from(val: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Bit

Source§

fn from(val: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Bit

Source§

fn from(val: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Bit

Source§

fn from(val: u128) -> Self

Converts to this type from the input type.
Source§

impl HardwareField for Bit

Source§

fn to_hardware(self) -> Flat<Self>

Maps self to the flat basis: φ(self).
Source§

fn from_hardware(value: Flat<Self>) -> Self

Maps value back to the tower basis: φ⁻¹(value).
Source§

fn add_hardware(lhs: Flat<Self>, rhs: Flat<Self>) -> Flat<Self>

Adds two flat elements (XOR).
Source§

fn add_hardware_packed( lhs: PackedFlat<Self>, rhs: PackedFlat<Self>, ) -> PackedFlat<Self>

Adds two packed flat vectors lane by lane (XOR).
Source§

fn mul_hardware(lhs: Flat<Self>, rhs: Flat<Self>) -> Flat<Self>

Multiplies two flat elements.
Source§

fn mul_hardware_packed( lhs: PackedFlat<Self>, rhs: PackedFlat<Self>, ) -> PackedFlat<Self>

Multiplies two packed flat vectors lane by lane.
Source§

fn mul_hardware_scalar_packed( lhs: PackedFlat<Self>, rhs: Flat<Self>, ) -> PackedFlat<Self>

Multiplies every lane of lhs by the flat scalar rhs.
Source§

fn tower_bit_from_hardware(value: Flat<Self>, bit_idx: usize) -> u8

Returns bit bit_idx of φ⁻¹(value) without a full conversion; constant time in value. Read more
Source§

impl Mul for Bit

Mul (AND) 00=0, 01=0, 1*1=1

Source§

type Output = Bit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Bit> for PackedBit

Source§

type Output = PackedBit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Bit) -> Self

Performs the * operation. Read more
Source§

impl MulAssign for Bit

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl PackableField for Bit

Source§

const WIDTH: usize = PACKED_WIDTH_BIT

How many elements fit in one packed vector.
Source§

type Packed = PackedBit

The packed form; operators act lane by lane.
Source§

fn pack(chunk: &[Self]) -> Self::Packed

Packs chunk[..WIDTH] into one value; ignores the rest. Read more
Source§

fn unpack(packed: Self::Packed, output: &mut [Self])

Writes the lanes of packed to output[..WIDTH]; the rest of output is left as it is. Read more
Source§

impl PartialEq for Bit

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Bit

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Bit

Source§

impl Sub for Bit

Sub is the same as add

Source§

type Output = Bit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for Bit

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl TowerField for Bit

Source§

const BITS: usize = 1

Degree over GF(2): 2^BITS elements.
Source§

const ZERO: Self

The additive identity.
Source§

const ONE: Self

The multiplicative identity.
Source§

const EXTENSION_TAU: Self

τ of the next level, F[X] / (X^2 + X + τ), for Block8 up. Tr(τ) = 1 makes X^2 + X + τ irreducible.
Source§

fn invert(&self) -> Self

Returns self^-1, or 0 for 0. No branch on the value in the default build.
Source§

fn from_uniform_bytes(bytes: &[u8; 32]) -> Self

Builds the element from the first BITS bits of bytes, little-endian; ignores the rest.
Source§

impl Zeroize for Bit

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl Freeze for Bit

§

impl RefUnwindSafe for Bit

§

impl Send for Bit

§

impl Sync for Bit

§

impl Unpin for Bit

§

impl UnsafeUnpin for Bit

§

impl UnwindSafe for Bit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<F> FlatPromote<F> for F
where F: HardwareField,

Source§

fn promote_flat(val: Flat<F>) -> Flat<F>

Maps a flat FromF element into the flat basis of Self.
Source§

fn promote_flat_batch(input: &[Flat<FromF>], output: &mut [Flat<Self>])

Promotes input[i] into output[i] for every i below the shorter length; the rest of output is left as it is.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.