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