Package org.bouncycastle.pqc.crypto.ntru
Class NTRUEncryptionParameters
- java.lang.Object
-
- org.bouncycastle.pqc.crypto.ntru.NTRUEncryptionParameters
-
- All Implemented Interfaces:
java.lang.Cloneable
public class NTRUEncryptionParameters extends java.lang.Object implements java.lang.Cloneable
A set of parameters for NtruEncrypt. Several predefined parameter sets are available and new ones can be created as well.
-
-
Field Summary
Fields Modifier and Type Field Description int
bufferLenBits
int
c
int
db
int
df
int
df1
int
df2
int
df3
int
dg
int
dm0
int
dr
int
dr1
int
dr2
int
dr3
boolean
fastFp
Digest
hashAlg
boolean
hashSeed
int
maxMsgLenBytes
int
minCallsMask
int
minCallsR
int
N
byte[]
oid
int
pkLen
int
polyType
int
q
boolean
sparse
-
Constructor Summary
Constructors Constructor Description 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.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.NTRUEncryptionParameters(java.io.InputStream is)
Reads a parameter set from an input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NTRUEncryptionParameters
clone()
boolean
equals(java.lang.Object obj)
int
getMaxMessageLength()
Returns the maximum length a plaintext message can be with this parameter set.int
hashCode()
java.lang.String
toString()
void
writeTo(java.io.OutputStream os)
Writes the parameter set to an output stream
-
-
-
Field Detail
-
N
public int N
-
q
public int q
-
df
public int df
-
df1
public int df1
-
df2
public int df2
-
df3
public int df3
-
dr
public int dr
-
dr1
public int dr1
-
dr2
public int dr2
-
dr3
public int dr3
-
dg
public int dg
-
maxMsgLenBytes
public int maxMsgLenBytes
-
db
public int db
-
bufferLenBits
public int bufferLenBits
-
dm0
public int dm0
-
pkLen
public int pkLen
-
c
public int c
-
minCallsR
public int minCallsR
-
minCallsMask
public int minCallsMask
-
hashSeed
public boolean hashSeed
-
oid
public byte[] oid
-
sparse
public boolean sparse
-
fastFp
public boolean fastFp
-
polyType
public int polyType
-
hashAlg
public Digest hashAlg
-
-
Constructor Detail
-
NTRUEncryptionParameters
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
- number of polynomial coefficientsq
- modulusdf
- number of ones in the private polynomialf
dm0
- minimum acceptable number of -1's, 0's, and 1's in the polynomialm'
in the last encryption stepdb
- number of random bits to prepend to the messagec
- a parameter for the Index Generation Function (IndexGenerator
)minCallsR
- minimum number of hash calls for the IGF to makeminCallsMask
- minimum number of calls to generate the masking polynomialhashSeed
- whether to hash the seed in the MGF first (true) or use the seed directly (false)oid
- three bytes that uniquely identify the parameter setsparse
- whether to treat ternary polynomials as sparsely populated (SparseTernaryPolynomial
vsDenseTernaryPolynomial
)fastFp
- whetherf=1+p*F
for a ternaryF
(true) orf
is ternary (false)hashAlg
- a valid identifier for ajava.security.MessageDigest
instance such asSHA-256
. TheMessageDigest
must support thegetDigestLength()
method.
-
NTRUEncryptionParameters
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
- number of polynomial coefficientsq
- modulusdf1
- number of ones in the private polynomialf1
df2
- number of ones in the private polynomialf2
df3
- number of ones in the private polynomialf3
dm0
- minimum acceptable number of -1's, 0's, and 1's in the polynomialm'
in the last encryption stepdb
- number of random bits to prepend to the messagec
- a parameter for the Index Generation Function (IndexGenerator
)minCallsR
- minimum number of hash calls for the IGF to makeminCallsMask
- minimum number of calls to generate the masking polynomialhashSeed
- whether to hash the seed in the MGF first (true) or use the seed directly (false)oid
- three bytes that uniquely identify the parameter setsparse
- whether to treat ternary polynomials as sparsely populated (SparseTernaryPolynomial
vsDenseTernaryPolynomial
)fastFp
- whetherf=1+p*F
for a ternaryF
(true) orf
is ternary (false)hashAlg
- a valid identifier for ajava.security.MessageDigest
instance such asSHA-256
-
NTRUEncryptionParameters
public NTRUEncryptionParameters(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
-
clone
public NTRUEncryptionParameters clone()
- Overrides:
clone
in classjava.lang.Object
-
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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-