keccak docs (#508)

This PR adds keccak docs

---------

Co-authored-by: Leon Hibnik <107353745+LeonHibnik@users.noreply.github.com>
This commit is contained in:
nonam3e
2024-05-09 03:18:59 +07:00
committed by GitHub
parent 2905d2a469
commit c30e333819
6 changed files with 237 additions and 5 deletions

View File

@@ -16,16 +16,16 @@ pub struct KeccakConfig<'a> {
pub ctx: DeviceContext<'a>,
/// True if inputs are on device and false if they're on host. Default value: false.
are_inputs_on_device: bool,
pub are_inputs_on_device: bool,
/// If true, output is preserved on device, otherwise on host. Default value: false.
are_outputs_on_device: bool,
pub are_outputs_on_device: bool,
/// Whether to run the Keccak asynchronously. If set to `true`, the keccak_hash function will be
/// non-blocking and you'd need to synchronize it explicitly by running
/// `cudaStreamSynchronize` or `cudaDeviceSynchronize`. If set to false, keccak_hash
/// function will block the current CPU thread.
is_async: bool,
pub is_async: bool,
}
impl<'a> Default for KeccakConfig<'a> {
@@ -68,8 +68,10 @@ pub fn keccak256(
input_block_size: i32,
number_of_blocks: i32,
output: &mut (impl HostOrDeviceSlice<u8> + ?Sized),
config: &KeccakConfig,
config: &mut KeccakConfig,
) -> IcicleResult<()> {
config.are_inputs_on_device = input.is_on_device();
config.are_outputs_on_device = output.is_on_device();
unsafe {
keccak256_cuda(
input.as_ptr(),
@@ -87,8 +89,10 @@ pub fn keccak512(
input_block_size: i32,
number_of_blocks: i32,
output: &mut (impl HostOrDeviceSlice<u8> + ?Sized),
config: &KeccakConfig,
config: &mut KeccakConfig,
) -> IcicleResult<()> {
config.are_inputs_on_device = input.is_on_device();
config.are_outputs_on_device = output.is_on_device();
unsafe {
keccak512_cuda(
input.as_ptr(),