core/src/main/java/org/bouncycastle/pqc/crypto/qtesla/QTESLA.java
/************************************************************************************************
     * Description:	Checks Bounds for W = V - EC During Signature Verification.
     * 				Leaks the Position of the Coefficient that Fails the Test.
     * 				The Position of the Coefficient is Independent of the Secret Data.
     * 				Does not Leak the Signature of the Coefficients.
     *
     * @param        V            Parameter to be Checked
     * @param        vOffset        Starting Point of V
     * @param        n            Polynomial Degree
     * @param        d            Number of Rounded Bits
     * @param        q            Modulus
     * @param        rejection    Bound in Checking Error Polynomial
     *
     * @return false        Valid / Accepted
     * 				true		Invalid / Rejected
     *************************************************************************************************/
Checks Bounds for W = V - EC During Signature Verification.
Leaks the Position of the Coefficient that Fails the Test.
The Position of the Coefficient is Independent of the Secret Data.
Does not Leak the Signature of the Coefficients.



@return false        Valid / Accepted
true            Invalid / Rejected
Checks Bounds for W = V - EC During Signature Verification . Leaks the Position of the Coefficient that Fails the Test . The Position of the Coefficient is Independent of the Secret Data . Does not Leak the Signature of the Coefficients . @return false Valid / Accepted true Invalid / Rejected
private static boolean testV(long[] V, int vOffset, int n, int d, int q, int rejection)
    {
        long mask;
        long left;
        long right;
        int rightInteger;
        long test1;
        long test2;
        for (int i = 0; i < n; i++)
        {
            mask = (q / 2 - V[vOffset + i]) >> 63;
            right = ((V[vOffset + i] - q) & mask) | (V[vOffset + i] & (~mask));
            test1 = (~(absolute(right) - (q / 2 - rejection))) >>> 63;
            left = right;
            rightInteger = (int)((right + (1 << (d - 1)) - 1) >> d);
            right = rightInteger;
            right = left - (right << d);
            test2 = (~(absolute(right) - ((1 << (d - 1)) - rejection))) >>> 63;
            /* Two Tests Fail */
            if ((test1 | test2) == 0x1L)
            {
                return true;
            }
        }
        return false;
    }
private static boolean testV ( long [ ] V , int vOffset , int n , int d , int q , int rejection ) { long mask ; long left ; long right ; int rightInteger ; long test1 ; long test2 ; for ( int i = 0 ; i < n ; i ++ ) { mask = ( q / 2 - V [ vOffset + i ] ) >> 63 ; right = ( ( V [ vOffset + i ] - q ) & mask ) | ( V [ vOffset + i ] & ( ~ mask ) ) ; test1 = ( ~ ( absolute ( right ) - ( q / 2 - rejection ) ) ) >>> 63 ; left = right ; rightInteger = ( int ) ( ( right + ( 1 << ( d - 1 ) ) - 1 ) >> d ) ; right = rightInteger ; right = left - ( right << d ) ; test2 = ( ~ ( absolute ( right ) - ( ( 1 << ( d - 1 ) ) - rejection ) ) ) >>> 63 ; /* Two Tests Fail */ if ( ( test1 | test2 ) == 0x1L ) { return true ; } } return false ; }
Description:     Checks Bounds for W = V - EC During Signature Verification.
Description : Checks Bounds for W = V - EC During Signature Verification .