Struct mostinefficientsha::u::U [] [src]

pub struct U {
    pub bits: ArrayVec<[RTerm; 32]>,
}

This type represents a u32, an unsigned number made of 32 bits. The bits are not boolean, but represented by a lazily evaluated tree of Terms.

This type implements some arithmetic operations on u32s that translate into bit operations under the hood. For example the + operation is translated into half adders and full adders, that themselves consist of bit operations like and and or.

This type implements all operations needed to calculate a sha256 hash: rotate_right, shift_right >>, Addition + and the bitwise operations and &, xor ^ and not !. Use the member functions or the implemented operators. See sha.rs for example use.

This U can be constructed from a u32 constant number. The bits of that number will translate into Terms of type Constant.

It can be constructed by creating 32 new symbolic Terms.

It can also be constructed by using operations like >>.

After construction, the bits can be manipulated using the bits field of this struct.

Fields

The LSBit is bits[0], the MSBit is bits[31]. The byte order is big endian. Push LSB first.

Methods

impl U
[src]

Create a new U with 32 Terms of type Symbol. Do not forget to set the value of each symbol afterwards. You can set the value of each bit by using my_u.bits[22].set(0.3f64). Or set 8 bits of this U with my_u.set_byte('e', 2).

Create a new U with 32 Terms of type Constant.

Sets the bits of one byte of this u32 to their min/max values 1.0 and 0.0 depending on set_value. bytenum must be one of 0, 1, 2, 3. Byte 0 is the most significant byte of the four byte representation of this u32.

Panics if the relevant bits/Terms of this U are not of type Symbol.

Sets all bits of this U to a value dependend on bytes. See set_byte() for details.

Panics if any bit/Term of this U is not of type Symbol.

Recursively resets the cache of this self's bits/Terms and the Terms self's Terms depend on.

This need to be called after and before using nr_of_terms(), nr_of_terms_flattened() and max_logic_depth_and_max_stack_size().

It also needs to be called before evaluate() and eval_to_u32(), but only if a symbolic Term has been modified.

Evaluates all bits to a f64 value. Push these values to out. Pushes the MSBit first.

Evaluate all bits to a f64 value, then round that value to 0 or 1 and assemble a u32 with these bits.

Max stack size needed when evaluating each bit of this U recursively.

It also returns the maximum logic depth.

Returns: (max_logic_depth, max_stacksize)

Note: manually call reset() before using this function.

Returns the number of RTerms that contribute to the evaluation of this U.

Note: manually call reset() before using this function.

Returns the number of Terms that contribute to the evaluation of this U if the tree would have been flattened for each bit and subtree.

Note: manually call reset() before using this function.

Returns a new U that evaluates to selfs value, but bitrotated by x to the right. Rotation happens without any carry bit. x must be less or equal 32.

Returns a new U that evaluates to selfs value, but bitshifted by x to the right. x must be less than 32.

Returns a new U that evaluates to the bitwise xor with rhs.

Returns a new U that evaluates to the bitwise and with rhs.

Returns a new U that evaluates to the bitwise not with rhs.

Returns a new U that evaluates to the arithmethic addition with rhs.

Trait Implementations

impl Clone for U
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl From<u32> for U
[src]

Performs the conversion.

impl Debug for U
[src]

Debug: MSB...LSB

impl Shr<usize> for U
[src]

The resulting type after applying the >> operator

The method for the >> operator

impl<'a> Shr<usize> for &'a U
[src]

The resulting type after applying the >> operator

The method for the >> operator

impl Add<U> for U
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a> Add<U> for &'a U
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a> Add<&'a U> for U
[src]

The resulting type after applying the + operator

The method for the + operator

impl<'a, 'b> Add<&'a U> for &'b U
[src]

The resulting type after applying the + operator

The method for the + operator

impl Not for U
[src]

The resulting type after applying the ! operator

The method for the unary ! operator

impl<'a> Not for &'a U
[src]

The resulting type after applying the ! operator

The method for the unary ! operator

impl BitXor<U> for U
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a> BitXor<U> for &'a U
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a> BitXor<&'a U> for U
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl<'a, 'b> BitXor<&'a U> for &'b U
[src]

The resulting type after applying the ^ operator

The method for the ^ operator

impl BitAnd<U> for U
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a> BitAnd<U> for &'a U
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a> BitAnd<&'a U> for U
[src]

The resulting type after applying the & operator

The method for the & operator

impl<'a, 'b> BitAnd<&'a U> for &'b U
[src]

The resulting type after applying the & operator

The method for the & operator