当前位置: 首页>>代码示例>>Java>>正文


Java ProductFormPolynomial.fromBinary方法代码示例

本文整理汇总了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();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:NTRUEncryptionPrivateKeyParameters.java

示例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);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:9,代码来源:ProductFormPolynomialTest.java

示例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);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:52,代码来源:NTRUSigningPrivateKeyParameters.java


注:本文中的org.bouncycastle.pqc.math.ntru.polynomial.ProductFormPolynomial.fromBinary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。