Class NTRUEncryptionKeyGenerationParameters

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class NTRUEncryptionKeyGenerationParameters
    extends KeyGenerationParameters
    implements java.lang.Cloneable
    A set of parameters for NtruEncrypt. Several predefined parameter sets are available and new ones can be created as well.
    • Constructor Detail

      • NTRUEncryptionKeyGenerationParameters

        public NTRUEncryptionKeyGenerationParameters​(int N,
                                                     int q,
                                                     int df,
                                                     int dm0,
                                                     int db,
                                                     int c,
                                                     int minCallsR,
                                                     int minCallsMask,
                                                     boolean hashSeed,
                                                     byte[] oid,
                                                     boolean sparse,
                                                     boolean fastFp,
                                                     Digest hashAlg,
                                                     java.security.SecureRandom random)
        Constructs a parameter set that uses ternary private keys (i.e. polyType=SIMPLE).
        Parameters:
        N - number of polynomial coefficients
        q - modulus
        df - number of ones in the private polynomial f
        dm0 - minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step
        db - number of random bits to prepend to the message
        c - a parameter for the Index Generation Function (IndexGenerator)
        minCallsR - minimum number of hash calls for the IGF to make
        minCallsMask - minimum number of calls to generate the masking polynomial
        hashSeed - whether to hash the seed in the MGF first (true) or use the seed directly (false)
        oid - three bytes that uniquely identify the parameter set
        sparse - whether to treat ternary polynomials as sparsely populated (SparseTernaryPolynomial vs DenseTernaryPolynomial)
        fastFp - whether f=1+p*F for a ternary F (true) or f is ternary (false)
        hashAlg - a valid identifier for a java.security.MessageDigest instance such as SHA-256. The MessageDigest must support the getDigestLength() method.
        random - entropy source, if null uses CryptoServicesRegistrar.getSecureRandom()
      • NTRUEncryptionKeyGenerationParameters

        public NTRUEncryptionKeyGenerationParameters​(int N,
                                                     int q,
                                                     int df,
                                                     int dm0,
                                                     int db,
                                                     int c,
                                                     int minCallsR,
                                                     int minCallsMask,
                                                     boolean hashSeed,
                                                     byte[] oid,
                                                     boolean sparse,
                                                     boolean fastFp,
                                                     Digest hashAlg)
        Constructs a parameter set that uses ternary private keys (i.e. polyType=SIMPLE).
        Parameters:
        N - number of polynomial coefficients
        q - modulus
        df - number of ones in the private polynomial f
        dm0 - minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step
        db - number of random bits to prepend to the message
        c - a parameter for the Index Generation Function (IndexGenerator)
        minCallsR - minimum number of hash calls for the IGF to make
        minCallsMask - minimum number of calls to generate the masking polynomial
        hashSeed - whether to hash the seed in the MGF first (true) or use the seed directly (false)
        oid - three bytes that uniquely identify the parameter set
        sparse - whether to treat ternary polynomials as sparsely populated (SparseTernaryPolynomial vs DenseTernaryPolynomial)
        fastFp - whether f=1+p*F for a ternary F (true) or f is ternary (false)
        hashAlg - a valid identifier for a java.security.MessageDigest instance such as SHA-256. The MessageDigest must support the getDigestLength() method.
      • NTRUEncryptionKeyGenerationParameters

        public NTRUEncryptionKeyGenerationParameters​(int N,
                                                     int q,
                                                     int df1,
                                                     int df2,
                                                     int df3,
                                                     int dm0,
                                                     int db,
                                                     int c,
                                                     int minCallsR,
                                                     int minCallsMask,
                                                     boolean hashSeed,
                                                     byte[] oid,
                                                     boolean sparse,
                                                     boolean fastFp,
                                                     Digest hashAlg,
                                                     java.security.SecureRandom random)
        Constructs a parameter set that uses product-form private keys (i.e. polyType=PRODUCT).
        Parameters:
        N - number of polynomial coefficients
        q - modulus
        df1 - number of ones in the private polynomial f1
        df2 - number of ones in the private polynomial f2
        df3 - number of ones in the private polynomial f3
        dm0 - minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step
        db - number of random bits to prepend to the message
        c - a parameter for the Index Generation Function (IndexGenerator)
        minCallsR - minimum number of hash calls for the IGF to make
        minCallsMask - minimum number of calls to generate the masking polynomial
        hashSeed - whether to hash the seed in the MGF first (true) or use the seed directly (false)
        oid - three bytes that uniquely identify the parameter set
        sparse - whether to treat ternary polynomials as sparsely populated (SparseTernaryPolynomial vs DenseTernaryPolynomial)
        fastFp - whether f=1+p*F for a ternary F (true) or f is ternary (false)
        hashAlg - a valid identifier for a java.security.MessageDigest instance such as SHA-256
        random - entropy source, if null uses CryptoServicesRegistrar.getSecureRandom()
      • NTRUEncryptionKeyGenerationParameters

        public NTRUEncryptionKeyGenerationParameters​(int N,
                                                     int q,
                                                     int df1,
                                                     int df2,
                                                     int df3,
                                                     int dm0,
                                                     int db,
                                                     int c,
                                                     int minCallsR,
                                                     int minCallsMask,
                                                     boolean hashSeed,
                                                     byte[] oid,
                                                     boolean sparse,
                                                     boolean fastFp,
                                                     Digest hashAlg)
        Constructs a parameter set that uses product-form private keys (i.e. polyType=PRODUCT). Uses CryptoServicesRegistrar.getSecureRandom() as an entropy source.
        Parameters:
        N - number of polynomial coefficients
        q - modulus
        df1 - number of ones in the private polynomial f1
        df2 - number of ones in the private polynomial f2
        df3 - number of ones in the private polynomial f3
        dm0 - minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step
        db - number of random bits to prepend to the message
        c - a parameter for the Index Generation Function (IndexGenerator)
        minCallsR - minimum number of hash calls for the IGF to make
        minCallsMask - minimum number of calls to generate the masking polynomial
        hashSeed - whether to hash the seed in the MGF first (true) or use the seed directly (false)
        oid - three bytes that uniquely identify the parameter set
        sparse - whether to treat ternary polynomials as sparsely populated (SparseTernaryPolynomial vs DenseTernaryPolynomial)
        fastFp - whether f=1+p*F for a ternary F (true) or f is ternary (false)
        hashAlg - a valid identifier for a java.security.MessageDigest instance such as SHA-256
      • NTRUEncryptionKeyGenerationParameters

        public NTRUEncryptionKeyGenerationParameters​(java.io.InputStream is)
                                              throws java.io.IOException
        Reads a parameter set from an input stream.
        Parameters:
        is - an input stream
        Throws:
        java.io.IOException
    • Method Detail

      • getMaxMessageLength

        public int getMaxMessageLength()
        Returns the maximum length a plaintext message can be with this parameter set.
        Returns:
        the maximum length in bytes
      • writeTo

        public void writeTo​(java.io.OutputStream os)
                     throws java.io.IOException
        Writes the parameter set to an output stream
        Parameters:
        os - an output stream
        Throws:
        java.io.IOException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object