本文整理汇总了Java中org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial类的典型用法代码示例。如果您正苦于以下问题:Java ProductFormPolynomial类的具体用法?Java ProductFormPolynomial怎么用?Java ProductFormPolynomial使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProductFormPolynomial类属于org.bouncycastle.pqc.math.ntru.polynomial包,在下文中一共展示了ProductFormPolynomial类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:NTRUEncryptionPrivateKeyParameters.java
示例2: getEncoded
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入依赖的package包/类
/**
* Converts the key to a byte array
*
* @return the encoded key
* @see #NTRUEncryptionPrivateKeyParameters(byte[], NTRUEncryptionParameters)
*/
public byte[] getEncoded()
{
byte[] hBytes = h.toBinary(params.q);
byte[] tBytes;
if (t instanceof ProductFormPolynomial)
{
tBytes = ((ProductFormPolynomial)t).toBinary();
}
else
{
tBytes = t.toIntegerPolynomial().toBinary3Tight();
}
byte[] res = new byte[hBytes.length + tBytes.length];
System.arraycopy(hBytes, 0, res, 0, hBytes.length);
System.arraycopy(tBytes, 0, res, hBytes.length, tBytes.length);
return res;
}
开发者ID:Appdome,项目名称:ipack,代码行数:28,代码来源:NTRUEncryptionPrivateKeyParameters.java
示例3: getEncoded
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入依赖的package包/类
private byte[] getEncoded(Polynomial p)
{
if (p instanceof ProductFormPolynomial)
{
return ((ProductFormPolynomial)p).toBinary();
}
else
{
return p.toIntegerPolynomial().toBinary3Tight();
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:NTRUSigningPrivateKeyParameters.java
示例4: generateBlindingPoly
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入依赖的package包/类
/**
* Deterministically generates a blinding polynomial from a seed and a message representative.
*
* @param seed
* @param M message representative
* @return a blinding polynomial
*/
private Polynomial generateBlindingPoly(byte[] seed, byte[] M)
{
IndexGenerator ig = new IndexGenerator(seed, params);
if (params.polyType == NTRUParameters.TERNARY_POLYNOMIAL_TYPE_PRODUCT)
{
SparseTernaryPolynomial r1 = new SparseTernaryPolynomial(generateBlindingCoeffs(ig, params.dr1));
SparseTernaryPolynomial r2 = new SparseTernaryPolynomial(generateBlindingCoeffs(ig, params.dr2));
SparseTernaryPolynomial r3 = new SparseTernaryPolynomial(generateBlindingCoeffs(ig, params.dr3));
return new ProductFormPolynomial(r1, r2, r3);
}
else
{
int dr = params.dr;
boolean sparse = params.sparse;
int[] r = generateBlindingCoeffs(ig, dr);
if (sparse)
{
return new SparseTernaryPolynomial(r);
}
else
{
return new DenseTernaryPolynomial(r);
}
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:NTRUEngine.java
示例5: 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);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:ProductFormPolynomialTest.java
示例6: testMult
import org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial; //导入依赖的package包/类
public void testMult()
{
ProductFormPolynomial p1 = ProductFormPolynomial.generateRandom(N, df1, df2, df3, df3 - 1, new SecureRandom());
IntegerPolynomial p2 = PolynomialGenerator.generateRandom(N, q);
IntegerPolynomial p3 = p1.mult(p2);
IntegerPolynomial p4 = p1.toIntegerPolynomial().mult(p2);
assertEquals(p3, p4);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:ProductFormPolynomialTest.java
示例7: 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);
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:52,代码来源:NTRUSigningPrivateKeyParameters.java
注:本文中的org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论