本文整理汇总了Java中org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial.fromBinary方法的典型用法代码示例。如果您正苦于以下问题:Java ProductFormPolynomial.fromBinary方法的具体用法?Java ProductFormPolynomial.fromBinary怎么用?Java ProductFormPolynomial.fromBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial
的用法示例。
在下文中一共展示了ProductFormPolynomial.fromBinary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NTRUEncryptionPrivateKeyParameters
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入方法依赖的package包/类
/**
* Reads a polynomial <code>f</code> from an input stream and constructs a new private key
*
* @param is an input stream
* @param params the NtruEncrypt parameters to use
* @see #writeTo(OutputStream)
*/
public NTRUEncryptionPrivateKeyParameters(InputStream is, NTRUEncryptionParameters params)
throws IOException
{
super(true, params);
if (params.polyType == NTRUParameters.TERNARY_POLYNOMIAL_TYPE_PRODUCT)
{
int N = params.N;
int df1 = params.df1;
int df2 = params.df2;
int df3Ones = params.df3;
int df3NegOnes = params.fastFp ? params.df3 : params.df3 - 1;
h = IntegerPolynomial.fromBinary(is, params.N, params.q);
t = ProductFormPolynomial.fromBinary(is, N, df1, df2, df3Ones, df3NegOnes);
}
else
{
h = IntegerPolynomial.fromBinary(is, params.N, params.q);
IntegerPolynomial fInt = IntegerPolynomial.fromBinary3Tight(is, params.N);
t = params.sparse ? new SparseTernaryPolynomial(fInt) : new DenseTernaryPolynomial(fInt);
}
init();
}
示例2: testFromToBinary
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入方法依赖的package包/类
public void testFromToBinary()
throws Exception
{
ProductFormPolynomial p1 = ProductFormPolynomial.generateRandom(N, df1, df2, df3, df3 - 1, new SecureRandom());
byte[] bin1 = p1.toBinary();
ProductFormPolynomial p2 = ProductFormPolynomial.fromBinary(bin1, N, df1, df2, df3, df3 - 1);
assertEquals(p1, p2);
}
示例3: Basis
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入方法依赖的package包/类
/**
* Reads a basis from an input stream and constructs a new basis.
*
* @param is an input stream
* @param params NtruSign parameters
* @param include_h whether to read the polynomial <code>h</code> (<code>true</code>) or only <code>f</code> and <code>f'</code> (<code>false</code>)
*/
Basis(InputStream is, NTRUSigningKeyGenerationParameters params, boolean include_h)
throws IOException
{
int N = params.N;
int q = params.q;
int d1 = params.d1;
int d2 = params.d2;
int d3 = params.d3;
boolean sparse = params.sparse;
this.params = params;
if (params.polyType == NTRUParameters.TERNARY_POLYNOMIAL_TYPE_PRODUCT)
{
f = ProductFormPolynomial.fromBinary(is, N, d1, d2, d3 + 1, d3);
}
else
{
IntegerPolynomial fInt = IntegerPolynomial.fromBinary3Tight(is, N);
f = sparse ? new SparseTernaryPolynomial(fInt) : new DenseTernaryPolynomial(fInt);
}
if (params.basisType == NTRUSigningKeyGenerationParameters.BASIS_TYPE_STANDARD)
{
IntegerPolynomial fPrimeInt = IntegerPolynomial.fromBinary(is, N, q);
for (int i = 0; i < fPrimeInt.coeffs.length; i++)
{
fPrimeInt.coeffs[i] -= q / 2;
}
fPrime = fPrimeInt;
}
else if (params.polyType == NTRUParameters.TERNARY_POLYNOMIAL_TYPE_PRODUCT)
{
fPrime = ProductFormPolynomial.fromBinary(is, N, d1, d2, d3 + 1, d3);
}
else
{
fPrime = IntegerPolynomial.fromBinary3Tight(is, N);
}
if (include_h)
{
h = IntegerPolynomial.fromBinary(is, N, q);
}
}