Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.crypto.ntru

public Class NTRUEncryptionParameters

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.io.DataInputStream, .DataOutputStream, .IOException, .InputStream, .OutputStream, java.util.Arrays, org.bouncycastle.crypto.Digest, org.bouncycastle.crypto.digests.SHA256Digest, .SHA512Digest, org.bouncycastle.crypto.util.DigestFactory

A set of parameters for NtruEncrypt. Several predefined parameter sets are available and new ones can be created as well.

Field Summary

Modifier and TypeField and Description
public int
pack-priv int
public int
c

public int
public int
public int
public int
public int
public int
public int
public int
public int
public int
public int
public boolean
public Digest
public boolean
pack-priv int
public int
public int
public int
public int
N

public byte[]
public int
public int
public int
q

public boolean

Constructor Summary

AccessConstructor and Description
public
NTRUEncryptionParameters(int
number of polynomial coefficients
N
,
int
modulus
q
,
int
number of ones in the private polynomial f
df
,
int
minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step
dm0
,
int
number of random bits to prepend to the message
db
,
int
a parameter for the Index Generation Function (org.bouncycastle.pqc.legacy.crypto.ntru.IndexGenerator)
c
,
int
minimum number of hash calls for the IGF to make
minCallsR
,
int
minimum number of calls to generate the masking polynomial
minCallsMask
,
boolean
whether to hash the seed in the MGF first (true) or use the seed directly (false)
hashSeed
,
byte[]
three bytes that uniquely identify the parameter set
oid
,
boolean sparse, boolean
whether f=1+p*F for a ternary F (true) or f is ternary (false)
fastFp
,
Digest
a valid identifier for a java.security.MessageDigest instance such as SHA-256. The MessageDigest must support the getDigestLength() method.
hashAlg
)

Constructs a parameter set that uses ternary private keys (i.e. polyType=SIMPLE).

public
NTRUEncryptionParameters(int
number of polynomial coefficients
N
,
int
modulus
q
,
int
number of ones in the private polynomial f1
df1
,
int
number of ones in the private polynomial f2
df2
,
int
number of ones in the private polynomial f3
df3
,
int
minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step
dm0
,
int
number of random bits to prepend to the message
db
,
int
a parameter for the Index Generation Function (org.bouncycastle.pqc.legacy.crypto.ntru.IndexGenerator)
c
,
int
minimum number of hash calls for the IGF to make
minCallsR
,
int
minimum number of calls to generate the masking polynomial
minCallsMask
,
boolean
whether to hash the seed in the MGF first (true) or use the seed directly (false)
hashSeed
,
byte[]
three bytes that uniquely identify the parameter set
oid
,
boolean sparse, boolean
whether f=1+p*F for a ternary F (true) or f is ternary (false)
fastFp
,
Digest
a valid identifier for a java.security.MessageDigest instance such as SHA-256
hashAlg
)

Constructs a parameter set that uses product-form private keys (i.e. polyType=PRODUCT).

public
NTRUEncryptionParameters(InputStream
an input stream
is
)

Reads a parameter set from an input stream.

Method Summary

Modifier and TypeMethod and Description
public NTRUEncryptionParameters
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int

Returns:

the maximum length in bytes
getMaxMessageLength
()

Returns the maximum length a plaintext message can be with this parameter set.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private void
init()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
writeTo(OutputStream
an output stream
os
)

Writes the parameter set to an output stream

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

bufferLenBitsback to summary
public int bufferLenBits
bufferLenTritsback to summary
pack-priv int bufferLenTrits
cback to summary
public int c
dbback to summary
public int db
dfback to summary
public int df
df1back to summary
public int df1
df2back to summary
public int df2
df3back to summary
public int df3
dgback to summary
public int dg
dm0back to summary
public int dm0
drback to summary
public int dr
dr1back to summary
public int dr1
dr2back to summary
public int dr2
dr3back to summary
public int dr3
fastFpback to summary
public boolean fastFp
hashAlgback to summary
public Digest hashAlg
hashSeedback to summary
public boolean hashSeed
llenback to summary
pack-priv int llen
maxMsgLenBytesback to summary
public int maxMsgLenBytes
minCallsMaskback to summary
public int minCallsMask
minCallsRback to summary
public int minCallsR
Nback to summary
public int N
oidback to summary
public byte[] oid
pkLenback to summary
public int pkLen
polyTypeback to summary
public int polyType
qback to summary
public int q
sparseback to summary
public boolean sparse

Constructor Detail

NTRUEncryptionParametersback to summary
public NTRUEncryptionParameters(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:int

number of polynomial coefficients

q:int

modulus

df:int

number of ones in the private polynomial f

dm0:int

minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step

db:int

number of random bits to prepend to the message

c:int

a parameter for the Index Generation Function (org.bouncycastle.pqc.legacy.crypto.ntru.IndexGenerator)

minCallsR:int

minimum number of hash calls for the IGF to make

minCallsMask:int

minimum number of calls to generate the masking polynomial

hashSeed:boolean

whether to hash the seed in the MGF first (true) or use the seed directly (false)

oid:byte[]

three bytes that uniquely identify the parameter set

sparse:boolean

whether to treat ternary polynomials as sparsely populated (org.bouncycastle.pqc.legacy.math.ntru.polynomial.SparseTernaryPolynomial vs org.bouncycastle.pqc.legacy.math.ntru.polynomial.DenseTernaryPolynomial)

fastFp:boolean

whether f=1+p*F for a ternary F (true) or f is ternary (false)

hashAlg:Digest

a valid identifier for a java.security.MessageDigest instance such as SHA-256. The MessageDigest must support the getDigestLength() method.

NTRUEncryptionParametersback to summary
public NTRUEncryptionParameters(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).

Parameters
N:int

number of polynomial coefficients

q:int

modulus

df1:int

number of ones in the private polynomial f1

df2:int

number of ones in the private polynomial f2

df3:int

number of ones in the private polynomial f3

dm0:int

minimum acceptable number of -1's, 0's, and 1's in the polynomial m' in the last encryption step

db:int

number of random bits to prepend to the message

c:int

a parameter for the Index Generation Function (org.bouncycastle.pqc.legacy.crypto.ntru.IndexGenerator)

minCallsR:int

minimum number of hash calls for the IGF to make

minCallsMask:int

minimum number of calls to generate the masking polynomial

hashSeed:boolean

whether to hash the seed in the MGF first (true) or use the seed directly (false)

oid:byte[]

three bytes that uniquely identify the parameter set

sparse:boolean

whether to treat ternary polynomials as sparsely populated (org.bouncycastle.pqc.legacy.math.ntru.polynomial.SparseTernaryPolynomial vs org.bouncycastle.pqc.legacy.math.ntru.polynomial.DenseTernaryPolynomial)

fastFp:boolean

whether f=1+p*F for a ternary F (true) or f is ternary (false)

hashAlg:Digest

a valid identifier for a java.security.MessageDigest instance such as SHA-256

NTRUEncryptionParametersback to summary
public NTRUEncryptionParameters(InputStream is) throws IOException

Reads a parameter set from an input stream.

Parameters
is:InputStream

an input stream

Method Detail

cloneback to summary
public NTRUEncryptionParameters clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:NTRUEncryptionParameters

a clone of this instance.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getMaxMessageLengthback to summary
public int getMaxMessageLength()

Returns the maximum length a plaintext message can be with this parameter set.

Returns:int

the maximum length in bytes

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

initback to summary
private void init()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

writeToback to summary
public void writeTo(OutputStream os) throws IOException

Writes the parameter set to an output stream

Parameters
os:OutputStream

an output stream