core/src/main/java/org/bouncycastle/pqc/crypto/qtesla/QTESLA.java
/*****************************************************************************************************************************************************************************
     * Description:	Hash Function to Generate C' for Provably-Secure qTESLA Security Category-1 and Category-3
     *****************************************************************************************************************************************************************************/
Hash Function to Generate C' for Provably-Secure qTESLA Security Category-1 and Category-3
Hash Function to Generate C ' for Provably - Secure qTESLA Security Category - 1 and Category - 3
private static void hashFunction(byte[] output, int outputOffset, long[] V, final byte[] message, int messageOffset, int messageLength, int n, int k, int d, int q)
    {
        int index;
        long mask;
        long cL;
        long temporary;
        byte[] T = new byte[n * k + messageLength];
        for (int j = 0; j < k; j++)
        {
            index = n * j;
            for (int i = 0; i < n; i++)
            {
                temporary = V[index];
                mask = (q / 2 - temporary) >> 63;
                temporary = ((temporary - q) & mask) | (temporary & (~mask));
                cL = temporary & ((1 << d) - 1);
                mask = ((1 << (d - 1)) - cL) >> 63;
                cL = ((cL - (1 << d)) & mask) | (cL & (~mask));
                T[index++] = (byte)((temporary - cL) >> d);
            }
        }
        System.arraycopy(message, messageOffset, T, n * k, messageLength);
        if (q == Parameter.Q_I_P)
        {
            HashUtils.secureHashAlgorithmKECCAK128(output, outputOffset, Polynomial.HASH, T, 0, messageLength + n * k);
        }
        if (q == Parameter.Q_III_P)
        {
            HashUtils.secureHashAlgorithmKECCAK256(output, outputOffset, Polynomial.HASH, T, 0, messageLength + n * k);
        }
    }
private static void hashFunction ( byte [ ] output , int outputOffset , long [ ] V , final byte [ ] message , int messageOffset , int messageLength , int n , int k , int d , int q ) { int index ; long mask ; long cL ; long temporary ; byte [ ] T = new byte [ n * k + messageLength ] ; for ( int j = 0 ; j < k ; j ++ ) { index = n * j ; for ( int i = 0 ; i < n ; i ++ ) { temporary = V [ index ] ; mask = ( q / 2 - temporary ) >> 63 ; temporary = ( ( temporary - q ) & mask ) | ( temporary & ( ~ mask ) ) ; cL = temporary & ( ( 1 << d ) - 1 ) ; mask = ( ( 1 << ( d - 1 ) ) - cL ) >> 63 ; cL = ( ( cL - ( 1 << d ) ) & mask ) | ( cL & ( ~ mask ) ) ; T [ index ++ ] = ( byte ) ( ( temporary - cL ) >> d ) ; } } System . arraycopy ( message , messageOffset , T , n * k , messageLength ) ; if ( q == Parameter . Q_I_P ) { HashUtils . secureHashAlgorithmKECCAK128 ( output , outputOffset , Polynomial . HASH , T , 0 , messageLength + n * k ) ; } if ( q == Parameter . Q_III_P ) { HashUtils . secureHashAlgorithmKECCAK256 ( output , outputOffset , Polynomial . HASH , T , 0 , messageLength + n * k ) ; } }
Description:     Hash Function to Generate C' for Provably-Secure qTESLA Security Category-1 and Category-3
Description : Hash Function to Generate C ' for Provably - Secure qTESLA Security Category - 1 and Category - 3