/** * @return name of the algorithm */ public final String getAlgorithm() { return QTESLASecurityCategory.getName(keyParams.getSecurityCategory()); }
/** * @return name of the algorithm */ public final String getAlgorithm() { return QTESLASecurityCategory.getName(keyParams.getSecurityCategory()); }
/** * Base constructor - provide the qTESLA security category and a source of randomness. * * @param securityCategory the security category to generate the parameters for. * @param random the random byte source. */ public QTESLAKeyGenerationParameters(int securityCategory, SecureRandom random) { super(random, -1); QTESLASecurityCategory.getPrivateSize(securityCategory); // check the category is valid this.securityCategory = securityCategory; }
public HeuristicI() { super(QTESLASecurityCategory.getName(QTESLASecurityCategory.HEURISTIC_I), new NullDigest(), new QTESLASigner()); } }
/** * Initialize the generator with a security category and a source of randomness. * * @param param a {@link QTESLAKeyGenerationParameters} object. */ public void init( KeyGenerationParameters param) { QTESLAKeyGenerationParameters parameters = (QTESLAKeyGenerationParameters)param; this.secureRandom = parameters.getRandom(); this.securityCategory = parameters.getSecurityCategory(); }
public int hashCode() { return keyParams.getSecurityCategory() + 37 * Arrays.hashCode(keyParams.getPublicData()); }
public int hashCode() { return keyParams.getSecurityCategory() + 37 * Arrays.hashCode(keyParams.getSecret()); }
/**************************************************************************************************************************************************************** * Description: Generates A Pair of Public Key and Private Key for qTESLA Signature Scheme for Provably-Secure qTESLA Security Category-3 * * @param publicKey Contains Public Key * @param privateKey Contains Private Key * @param secureRandom Source of Randomness * * @return 0 Successful Execution ****************************************************************************************************************************************************************/ public static int generateKeyPairIIIP(byte[] publicKey, byte[] privateKey, SecureRandom secureRandom) { return generateKeyPair( publicKey, privateKey, secureRandom, Parameter.N_III_P, Parameter.K_III_P, Parameter.H_III_P, Parameter.Q_III_P, Parameter.Q_INVERSE_III_P, Parameter.Q_LOGARITHM_III_P, Parameter.GENERATOR_A_III_P, Parameter.INVERSE_NUMBER_THEORETIC_TRANSFORM_III_P, Parameter.XI_III_P, PolynomialProvablySecure.ZETA_III_P, Parameter.KEY_GENERATOR_BOUND_E_III_P, Parameter.KEY_GENERATOR_BOUND_S_III_P ); }
private byte[] allocatePublic(int securityCategory) { return new byte[QTESLASecurityCategory.getPublicSize(securityCategory)]; } }
/***************************************************************************************************************** * Description: Samples A Bit from Bernoulli with Restriction of 20-Bit Exponent *****************************************************************************************************************/ private static int bernoulli(long result, long fractionOfExponent, double[][] exponentialDistribution) { /* * * Computes the Actual Bernoulli Parameter = exp (-t / f) * Yields A Fraction of 2^62, to Keep Only 62 Bits of Precision in This Implementation * */ double bernoulliParameter = 4611686018427387904.0; for (long i = 0, j = fractionOfExponent; i < 3; i++, j >>= 5) { bernoulliParameter *= exponentialDistribution[(int)i][(int)(j & 31)]; } /* Sample from Bernoulli of bernoulliParameter */ return (int)(((result & 0x3FFFFFFFFFFFFFFFL) - round(bernoulliParameter)) >>> 63); }
/**************************************************************************************************************************************************** * Description: Component Wise Polynomial Multiplication for Heuristic qTESLA Security Category-1 and Security Category-3 (Option for Size and Speed) * * @param product Product = Multiplicand (*) Multiplier * @param multiplicand Multiplicand Array * @param multiplier Multiplier Array * @param n Polynomial Degree * @param q Modulus * @param qInverse * * @return none ****************************************************************************************************************************************************/ private static void componentWisePolynomialMultiplication(int[] product, int[] multiplicand, int[] multiplier, int n, int q, long qInverse) { for (int i = 0; i < n; i++) { product[i] = montgomery((long)multiplicand[i] * multiplier[i], q, qInverse); } }
/****************************************************************************************************************************************************************************************************************** * Description: Component Wise Polynomial Multiplication for Provably-Secure qTESLA Security Category-1 and Security Category-3 * * @param product Product = Multiplicand (*) Multiplier * @param productOffset Starting Point of the Product Array * @param multiplicand Multiplicand Array * @param multiplicandOffset Starting Point of the Multiplicand Array * @param multiplier Multiplier Array * @param multiplierOffset Starting Point of the Multiplier Array * @param n Polynomial Degree * @param q Modulus * @param qInverse * * @return none ******************************************************************************************************************************************************************************************************************/ private static void componentWisePolynomialMultiplication(long[] product, int productOffset, long[] multiplicand, int multiplicandOffset, long[] multiplier, int multiplierOffset, int n, int q, long qInverse) { for (int i = 0; i < n; i++) { product[productOffset + i] = montgomeryP(multiplicand[multiplicandOffset + i] * multiplier[multiplierOffset + i], q, qInverse); } }
protected boolean engineVerify(byte[] sigBytes) throws SignatureException { byte[] hash = DigestUtil.getDigestResult(digest); return signer.verifySignature(hash, sigBytes); }
public qTESLA() { super("qTESLA", new NullDigest(), new QTESLASigner()); } }
public HeuristicIIISize() { super(QTESLASecurityCategory.getName(QTESLASecurityCategory.HEURISTIC_III_SIZE), new NullDigest(), new QTESLASigner()); } }
private byte[] allocatePrivate(int securityCategory) { return new byte[QTESLASecurityCategory.getPrivateSize(securityCategory)]; }
/**************************************************************************************************************************************************************** * Description: Generates A Pair of Public Key and Private Key for qTESLA Signature Scheme for Heuristic qTESLA Security Category-3 (Option for Size) * * @param publicKey Contains Public Key * @param privateKey Contains Private Key * @param secureRandom Source of Randomness * * @return 0 Successful Execution ****************************************************************************************************************************************************************/ public static int generateKeyPairIIISize(byte[] publicKey, byte[] privateKey, SecureRandom secureRandom) { return generateKeyPair( publicKey, privateKey, secureRandom, Parameter.N_III_SIZE, Parameter.H_III_SIZE, Parameter.Q_III_SIZE, Parameter.Q_INVERSE_III_SIZE, Parameter.Q_LOGARITHM_III_SIZE, Parameter.GENERATOR_A_III_SIZE, Parameter.INVERSE_NUMBER_THEORETIC_TRANSFORM_III_SIZE, Parameter.XI_III_SIZE, PolynomialHeuristic.ZETA_III_SIZE, Parameter.KEY_GENERATOR_BOUND_E_III_SIZE, Parameter.KEY_GENERATOR_BOUND_S_III_SIZE ); }
public HeuristicIIISpeed() { super(QTESLASecurityCategory.getName(QTESLASecurityCategory.HEURISTIC_III_SPEED), new NullDigest(), new QTESLASigner()); } }
public ProvablySecureI() { super(QTESLASecurityCategory.getName(QTESLASecurityCategory.PROVABLY_SECURE_I), new NullDigest(), new QTESLASigner()); } }
public ProvablySecureIII() { super(QTESLASecurityCategory.getName(QTESLASecurityCategory.PROVABLY_SECURE_III), new NullDigest(), new QTESLASigner()); } }