Trait lucky_commit::GitHashFn
source · pub trait GitHashFn: Sealed + Debug + Send + Clone + Eq + 'static {
type State: AsRef<[u32]> + AsMut<[u32]> + Clone + Copy + Debug + Default + Eq + Send;
type Block: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug;
const INITIAL_STATE: Self::State;
const KERNEL: &'static str;
// Required method
fn compress(state: &mut Self::State, blocks: &[Self::Block]);
}
Expand description
A hash function used by git. This is a sealed trait implemented by Sha1
and Sha256
.
The fields and methods on this trait are subject to change. Consumers should pretend that
the types implementing the trait are opaque.
Required Associated Types§
sourcetype State: AsRef<[u32]> + AsMut<[u32]> + Clone + Copy + Debug + Default + Eq + Send
type State: AsRef<[u32]> + AsMut<[u32]> + Clone + Copy + Debug + Default + Eq + Send
The type of the output and intermediate state of this hash function.
For sha1 and sha256, this is [u32; N] for some N. Ideally this trait would just
have an associated const for the length of the state vector, and then
State
would be defined as [u32; N]
, but this isn’t possible due
to https://github.com/rust-lang/rust/issues/60551.
Required Associated Constants§
sourceconst INITIAL_STATE: Self::State
const INITIAL_STATE: Self::State
The initial value of the state vector for the given algorithm
sourceconst KERNEL: &'static str
const KERNEL: &'static str
Source code of an OpenCL shader kernel finding hash matches for the given
algorithm. The kernel should have a function scatter_padding_and_find_match
, which
accepts the following parameters:
- A pointer to the
data
in the desired hash spec (pointing to the appropriate number of bytes for the given hash algorithm) - A pointer to the
mask
of the desired hash spec - The “base padding specifier” for the current run, which determines which padding will be attempted. The padding specifier used by any given thread is equal to the base specifier plus that thread’s ID.
- A pointer to the intermediate state after all static blocks have been hashed
- A pointer to the dynamic blocks, encoded as big-endian 32-bit integers
- The number of dynamic blocks that are present
- A writeable pointer where the shader should write a thread ID if it finds an appropriate match.