LibSWIFFT  1.2.0
Macros | Functions | Variables
swifft.c File Reference

LibSWIFFT public C implementation. More...

#include "libswifft/swifft.h"
#include "libswifft/swifft_avx.h"
#include "libswifft/swifft_avx2.h"
#include "libswifft/swifft_avx512.h"
#include "swifft_ops.inl"
Include dependency graph for swifft.c:

Macros

#define SWIFFT_ISET()   SWIFFT_INSTRUCTION_SET
 
#define SWIFFT_OUTPUT_Z1_SIZE   (SWIFFT_N / SWIFFT_W)
 
#define SWIFFT_COMPACT_TRANSPOSE_SIZE   8
 

Functions

void SWIFFT_fft (const BitSequence *LIBSWIFFT_RESTRICT input, const BitSequence *LIBSWIFFT_RESTRICT sign, int m, int16_t *LIBSWIFFT_RESTRICT fftout)
 Computes the FFT phase of SWIFFT. More...
 
void SWIFFT_fftsum (const int16_t *LIBSWIFFT_RESTRICT ikey, const int16_t *LIBSWIFFT_RESTRICT ifftout, int m, int16_t *LIBSWIFFT_RESTRICT iout)
 Computes the FFT-sum phase of SWIFFT. More...
 
 LIBSWIFFT_STATIC_ASSERT (8 *SWIFFT_W==SWIFFT_N, SWIFFT_N_must_be_8_times_SWIFFT_W)
 
void SWIFFT_Compact (const BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], BitSequence compact[SWIFFT_COMPACT_BLOCK_SIZE])
 Compacts a hash value of SWIFFT. The result is not composable with other compacted hash values. More...
 
void SWIFFT_ConstSet (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const int16_t operand)
 Sets a constant value at each SWIFFT hash value element. More...
 
void SWIFFT_ConstAdd (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const int16_t operand)
 Adds a constant value to each SWIFFT hash value element. More...
 
void SWIFFT_ConstSub (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const int16_t operand)
 Subtracts a constant value from each SWIFFT hash value element. More...
 
void SWIFFT_ConstMul (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const int16_t operand)
 Multiply a constant value into each SWIFFT hash value element. More...
 
void SWIFFT_Set (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const BitSequence operand[SWIFFT_OUTPUT_BLOCK_SIZE])
 Sets a SWIFFT hash value to another, element-wise. More...
 
void SWIFFT_Add (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const BitSequence operand[SWIFFT_OUTPUT_BLOCK_SIZE])
 Adds a SWIFFT hash value to another, element-wise. More...
 
void SWIFFT_Sub (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const BitSequence operand[SWIFFT_OUTPUT_BLOCK_SIZE])
 Subtracts a SWIFFT hash value from another, element-wise. More...
 
void SWIFFT_Mul (BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], const BitSequence operand[SWIFFT_OUTPUT_BLOCK_SIZE])
 Multiplies a SWIFFT hash value from another, element-wise. More...
 
void SWIFFT_Compute (const BitSequence input[SWIFFT_INPUT_BLOCK_SIZE], BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE])
 Computes the result of a SWIFFT operation. The result is composable with other hash values. More...
 
void SWIFFT_ComputeSigned (const BitSequence input[SWIFFT_INPUT_BLOCK_SIZE], const BitSequence sign[SWIFFT_INPUT_BLOCK_SIZE], BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE])
 Computes the result of a SWIFFT operation. The result is composable with other hash values. More...
 
void SWIFFT_fftMultiple (int nblocks, const BitSequence *LIBSWIFFT_RESTRICT input, const BitSequence *LIBSWIFFT_RESTRICT sign, int m, int16_t *LIBSWIFFT_RESTRICT fftout)
 Computes the FFT phase of SWIFFT for multiple blocks. More...
 
void SWIFFT_fftsumMultiple (int nblocks, const int16_t *LIBSWIFFT_RESTRICT ikey, const int16_t *LIBSWIFFT_RESTRICT ifftout, int m, int16_t *LIBSWIFFT_RESTRICT iout)
 Computes the FFT-sum phase of SWIFFT for multiple blocks. More...
 
void SWIFFT_CompactMultiple (int nblocks, const BitSequence output[SWIFFT_OUTPUT_BLOCK_SIZE], BitSequence compact[SWIFFT_COMPACT_BLOCK_SIZE])
 Compacts a hash value of SWIFFT for multiple blocks. The result is not composable with other compacted hash values. More...
 
void SWIFFT_ConstSetMultiple (int nblocks, BitSequence *output, const int16_t *operand)
 Sets a constant value at each SWIFFT hash value element for multiple blocks. More...
 
void SWIFFT_ConstAddMultiple (int nblocks, BitSequence *output, const int16_t *operand)
 Adds a constant value to each SWIFFT hash value element for multiple blocks. More...
 
void SWIFFT_ConstSubMultiple (int nblocks, BitSequence *output, const int16_t *operand)
 Subtracts a constant value from each SWIFFT hash value element for multiple blocks. More...
 
void SWIFFT_ConstMulMultiple (int nblocks, BitSequence *output, const int16_t *operand)
 Multiply a constant value into each SWIFFT hash value element for multiple blocks. More...
 
void SWIFFT_SetMultiple (int nblocks, BitSequence *output, const BitSequence *operand)
 Sets a SWIFFT hash value to another, element-wise, for multiple blocks. More...
 
void SWIFFT_AddMultiple (int nblocks, BitSequence *output, const BitSequence *operand)
 Adds a SWIFFT hash value to another, element-wise, for multiple blocks. More...
 
void SWIFFT_SubMultiple (int nblocks, BitSequence *output, const BitSequence *operand)
 Subtracts a SWIFFT hash value from another, element-wise, for multiple blocks. More...
 
void SWIFFT_MulMultiple (int nblocks, BitSequence *output, const BitSequence *operand)
 Multiplies a SWIFFT hash value from another, element-wise, for multiple blocks. More...
 
void SWIFFT_ComputeMultiple (int nblocks, const BitSequence *input, BitSequence *output)
 Computes the result of multiple SWIFFT operations. The result is composable with other hash values. More...
 
void SWIFFT_ComputeMultipleSigned (int nblocks, const BitSequence *input, const BitSequence *sign, BitSequence *output)
 Computes the result of multiple SWIFFT operations. The result is composable with other hash values. More...
 

Variables

LIBSWIFFT_BEGIN_EXTERN_C SWIFFT_ALIGN const BitSequence SWIFFT_sign0 [SWIFFT_INPUT_BLOCK_SIZE] = {0}
 

Detailed Description

LibSWIFFT public C implementation.

Implementation using the best instruction set available at build time.

Macro Definition Documentation

◆ SWIFFT_COMPACT_TRANSPOSE_SIZE

#define SWIFFT_COMPACT_TRANSPOSE_SIZE   8

◆ SWIFFT_ISET

#define SWIFFT_ISET ( )    SWIFFT_INSTRUCTION_SET

◆ SWIFFT_OUTPUT_Z1_SIZE

#define SWIFFT_OUTPUT_Z1_SIZE   (SWIFFT_N / SWIFFT_W)

Function Documentation

◆ LIBSWIFFT_STATIC_ASSERT()

LIBSWIFFT_STATIC_ASSERT ( 8 *  SWIFFT_W = =SWIFFT_N,
SWIFFT_N_must_be_8_times_SWIFFT_W   
)

◆ SWIFFT_Add()

void SWIFFT_Add ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const BitSequence  operand[SWIFFT_OUTPUT_BLOCK_SIZE] 
)

Adds a SWIFFT hash value to another, element-wise.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe hash value to add.

◆ SWIFFT_AddMultiple()

void SWIFFT_AddMultiple ( int  nblocks,
BitSequence output,
const BitSequence operand 
)

Adds a SWIFFT hash value to another, element-wise, for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe hash value to add, per block.

◆ SWIFFT_Compact()

void SWIFFT_Compact ( const BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
BitSequence  compact[SWIFFT_COMPACT_BLOCK_SIZE] 
)

Compacts a hash value of SWIFFT. The result is not composable with other compacted hash values.

Parameters
[in]outputthe hash value of SWIFFT, of size 128 bytes (1024 bit).
[out]compactthe compacted hash value of SWIFFT, of size 64 bytes (512 bit).

◆ SWIFFT_CompactMultiple()

void SWIFFT_CompactMultiple ( int  nblocks,
const BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
BitSequence  compact[SWIFFT_COMPACT_BLOCK_SIZE] 
)

Compacts a hash value of SWIFFT for multiple blocks. The result is not composable with other compacted hash values.

Parameters
[in]nblocksthe number of blocks to operate on.
[in]outputthe hash value of SWIFFT, of size 128 bytes (1024 bit).
[out]compactthe compacted hash value of SWIFFT, of size 64 bytes (512 bit).

◆ SWIFFT_Compute()

void SWIFFT_Compute ( const BitSequence  input[SWIFFT_INPUT_BLOCK_SIZE],
BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE] 
)

Computes the result of a SWIFFT operation. The result is composable with other hash values.

Parameters
[in]inputthe input of 256 bytes (2048 bit).
[out]outputthe resulting hash value of SWIFFT, of size 128 bytes (1024 bit).

◆ SWIFFT_ComputeMultiple()

void SWIFFT_ComputeMultiple ( int  nblocks,
const BitSequence input,
BitSequence output 
)

Computes the result of multiple SWIFFT operations. The result is composable with other hash values.

Parameters
[in]nblocksthe number of blocks to operate on.
[in]inputthe blocks of input, each of 256 bytes (2048 bit).
[out]outputthe resulting blocks of hash values of SWIFFT, each of size 128 bytes (1024 bit).

◆ SWIFFT_ComputeMultipleSigned()

void SWIFFT_ComputeMultipleSigned ( int  nblocks,
const BitSequence input,
const BitSequence sign,
BitSequence output 
)

Computes the result of multiple SWIFFT operations. The result is composable with other hash values.

Parameters
[in]nblocksthe number of blocks to operate on.
[in]inputthe blocks of input, each of 256 bytes (2048 bit).
[in]signthe blocks of sign bits corresponding to blocks of input of 256 bytes (2048 bit).
[out]outputthe resulting blocks of hash values of SWIFFT, each of size 128 bytes (1024 bit).

◆ SWIFFT_ComputeSigned()

void SWIFFT_ComputeSigned ( const BitSequence  input[SWIFFT_INPUT_BLOCK_SIZE],
const BitSequence  sign[SWIFFT_INPUT_BLOCK_SIZE],
BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE] 
)

Computes the result of a SWIFFT operation. The result is composable with other hash values.

Parameters
[in]inputthe input of 256 bytes (2048 bit).
[in]signthe sign bits corresponding to the input of 256 bytes (2048 bit).
[out]outputthe resulting hash value of SWIFFT, of size 128 bytes (1024 bit).

◆ SWIFFT_ConstAdd()

void SWIFFT_ConstAdd ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const int16_t  operand 
)

Adds a constant value to each SWIFFT hash value element.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe constant value to add.

◆ SWIFFT_ConstAddMultiple()

void SWIFFT_ConstAddMultiple ( int  nblocks,
BitSequence output,
const int16_t *  operand 
)

Adds a constant value to each SWIFFT hash value element for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe constant value to add, per block.

◆ SWIFFT_ConstMul()

void SWIFFT_ConstMul ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const int16_t  operand 
)

Multiply a constant value into each SWIFFT hash value element.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe constant value to multiply by.

◆ SWIFFT_ConstMulMultiple()

void SWIFFT_ConstMulMultiple ( int  nblocks,
BitSequence output,
const int16_t *  operand 
)

Multiply a constant value into each SWIFFT hash value element for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe constant value to multiply by, per block.

◆ SWIFFT_ConstSet()

void SWIFFT_ConstSet ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const int16_t  operand 
)

Sets a constant value at each SWIFFT hash value element.

Parameters
[out]outputthe hash value of SWIFFT to modify.
[in]operandthe constant value to set.

◆ SWIFFT_ConstSetMultiple()

void SWIFFT_ConstSetMultiple ( int  nblocks,
BitSequence output,
const int16_t *  operand 
)

Sets a constant value at each SWIFFT hash value element for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe constant value to set, per block.

◆ SWIFFT_ConstSub()

void SWIFFT_ConstSub ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const int16_t  operand 
)

Subtracts a constant value from each SWIFFT hash value element.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe constant value to subtract.

◆ SWIFFT_ConstSubMultiple()

void SWIFFT_ConstSubMultiple ( int  nblocks,
BitSequence output,
const int16_t *  operand 
)

Subtracts a constant value from each SWIFFT hash value element for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe constant value to subtract, per block.

◆ SWIFFT_fft()

void SWIFFT_fft ( const BitSequence *LIBSWIFFT_RESTRICT  input,
const BitSequence *LIBSWIFFT_RESTRICT  sign,
int  m,
int16_t *LIBSWIFFT_RESTRICT  fftout 
)

Computes the FFT phase of SWIFFT.

Parameters
[in]inputthe blocks of input, each of 256 bytes (2048 bits).
[in]signthe blocks of sign bits corresponding to blocks of input of 256 bytes (2048 bits).
[in]mnumber of 8-elements in the input.
[out]fftoutthe blocks of FFT-output elements, totaling N*m.

◆ SWIFFT_fftMultiple()

void SWIFFT_fftMultiple ( int  nblocks,
const BitSequence *LIBSWIFFT_RESTRICT  input,
const BitSequence *LIBSWIFFT_RESTRICT  sign,
int  m,
int16_t *LIBSWIFFT_RESTRICT  fftout 
)

Computes the FFT phase of SWIFFT for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in]inputthe blocks of input, each of 256 bytes (2048 bits).
[in]signthe blocks of sign bits corresponding to blocks of input of 256 bytes (2048 bits).
[in]mnumber of 8-elements in the input.
[out]fftoutthe blocks of FFT-output elements, totaling N*m.

◆ SWIFFT_fftsum()

void SWIFFT_fftsum ( const int16_t *LIBSWIFFT_RESTRICT  ikey,
const int16_t *LIBSWIFFT_RESTRICT  ifftout,
int  m,
int16_t *LIBSWIFFT_RESTRICT  iout 
)

Computes the FFT-sum phase of SWIFFT.

Parameters
[in]ikeythe SWIFFT key.
[in]ifftoutthe blocks of FFT-output elements, totaling N*m
[in]mnumber of 8-elements in the input.
[out]ioutthe blocks of output elements, each of 64 double-bytes (1024 bits).

◆ SWIFFT_fftsumMultiple()

void SWIFFT_fftsumMultiple ( int  nblocks,
const int16_t *LIBSWIFFT_RESTRICT  ikey,
const int16_t *LIBSWIFFT_RESTRICT  ifftout,
int  m,
int16_t *LIBSWIFFT_RESTRICT  iout 
)

Computes the FFT-sum phase of SWIFFT for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in]ikeythe SWIFFT key.
[in]ifftoutthe blocks of FFT-output elements, totaling N*m
[in]mnumber of 8-elements in the input.
[out]ioutthe blocks of output elements, each of 64 double-bytes (1024 bits).

◆ SWIFFT_Mul()

void SWIFFT_Mul ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const BitSequence  operand[SWIFFT_OUTPUT_BLOCK_SIZE] 
)

Multiplies a SWIFFT hash value from another, element-wise.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe hash value to multiply by.

◆ SWIFFT_MulMultiple()

void SWIFFT_MulMultiple ( int  nblocks,
BitSequence output,
const BitSequence operand 
)

Multiplies a SWIFFT hash value from another, element-wise, for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe hash value to multiply by, per block.

◆ SWIFFT_Set()

void SWIFFT_Set ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const BitSequence  operand[SWIFFT_OUTPUT_BLOCK_SIZE] 
)

Sets a SWIFFT hash value to another, element-wise.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe hash value to set to.

◆ SWIFFT_SetMultiple()

void SWIFFT_SetMultiple ( int  nblocks,
BitSequence output,
const BitSequence operand 
)

Sets a SWIFFT hash value to another, element-wise, for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe hash value to set to, per block.

◆ SWIFFT_Sub()

void SWIFFT_Sub ( BitSequence  output[SWIFFT_OUTPUT_BLOCK_SIZE],
const BitSequence  operand[SWIFFT_OUTPUT_BLOCK_SIZE] 
)

Subtracts a SWIFFT hash value from another, element-wise.

Parameters
[in,out]outputthe hash value of SWIFFT to modify.
[in]operandthe hash value to subtract.

◆ SWIFFT_SubMultiple()

void SWIFFT_SubMultiple ( int  nblocks,
BitSequence output,
const BitSequence operand 
)

Subtracts a SWIFFT hash value from another, element-wise, for multiple blocks.

Parameters
[in]nblocksthe number of blocks to operate on.
[in,out]outputthe hash value of SWIFFT to modify, per block.
[in]operandthe hash value to subtract, per block.

Variable Documentation

◆ SWIFFT_sign0