Skip to main content

RegisterWriter

Enum RegisterWriter 

Source
pub(crate) enum RegisterWriter {
    None,
    Mul(RegisterId),
    UMulH(u32),
    SMulH(u32),
    AddSub(RegisterId),
    AddConst,
    Xor(RegisterId),
    XorConst,
    Rotate,
}
Expand description

Information about the instruction that writes to a register, from the perspective of our particular constraints here

This is conceptually similar to storing the last super::Instruction that wrote to a register, but HashX sometimes needs information for constraints which won’t end up in the final Instruction.

We’ve chosen the encoding to minimize the code size in writer_pair_allowed. Most pairwise comparisons can just be a register equality test.

The instructions here fall into three categories which use their own format for encoding arguments:

  • Wide Multiply, extra u32

    UMulH and SMulH use an additional otherwise unused 32-bit value from the Rng when considering writer collisions.

    As far as I can tell this is a bug in the original implementation but we can’t change the behavior without breaking compatibility.

    The collisions are rare enough not to be a worthwhile addition to ASIC-resistance. It seems like this was a vestigial feature left over from immediate value matching features which were removed during the development of HashX, but I can’t be sure.

  • Constant source

    Only considers the opcode itself, not the specific immediate value.

  • Register source

    Considers the source register, collapses add/subtract into one op.

Variants§

§

None

Register not written yet

§

Mul(RegisterId)

Register source writer for super::Instruction::Mul

§

UMulH(u32)

Wide multiply writer for super::Instruction::UMulH

§

SMulH(u32)

Wide multiply writer for super::Instruction::SMulH

§

AddSub(RegisterId)

§

AddConst

Constant source writer for super::Instruction::AddConst

§

Xor(RegisterId)

Register source writer for super::Instruction::Xor

§

XorConst

Constant source writer for super::Instruction::XorConst

§

Rotate

Constant source writer for super::Instruction::Rotate

Trait Implementations§

Source§

impl Clone for RegisterWriter

Source§

fn clone(&self) -> RegisterWriter

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 RegisterWriter

Source§

impl Debug for RegisterWriter

Source§

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

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

impl Default for RegisterWriter

Source§

fn default() -> RegisterWriter

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

impl Eq for RegisterWriter

Source§

impl PartialEq for RegisterWriter

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RegisterWriter

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.