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


Java Arrays.copyOf方法代码示例

本文整理汇总了Java中org.bouncycastle.util.Arrays.copyOf方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.copyOf方法的具体用法?Java Arrays.copyOf怎么用?Java Arrays.copyOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.util.Arrays的用法示例。


在下文中一共展示了Arrays.copyOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sub

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Subtracts another polynomial which can have a different number of coefficients.
 *
 * @param b another polynomial
 */
public void sub(BigIntPolynomial b)
{
    if (b.coeffs.length > coeffs.length)
    {
        int N = coeffs.length;
        coeffs = Arrays.copyOf(coeffs, b.coeffs.length);
        for (int i = N; i < coeffs.length; i++)
        {
            coeffs[i] = Constants.BIGINT_ZERO;
        }
    }
    for (int i = 0; i < b.coeffs.length; i++)
    {
        coeffs[i] = coeffs[i].subtract(b.coeffs[i]);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:BigIntPolynomial.java

示例2: unpadBody

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public static byte[] unpadBody(byte[] body) {
    int ind = body.length - 1;
    while (body[ind] == (byte) 0xFF && ind > 0) {
        ind--;
    }

    if (body[ind] == (byte) 0x7F) {
        return Arrays.copyOf(body, ind);
    } else {
        return new byte[0];
    }
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:13,代码来源:SphinxClient.java

示例3: getAesKey

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public byte[] getAesKey(ECPoint s) {
    return Arrays.copyOf(
            sha256.digest(
                    Arrays.concatenate(
                            "aes_key:".getBytes(Charset.forName("UTF-8")),
                            group.printable(s)
                    )
            ), this.k);
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:10,代码来源:SphinxParams.java

示例4: SparseTernaryPolynomial

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Constructs a new <code>SparseTernaryPolynomial</code> with a given set of coefficients.
 *
 * @param coeffs the coefficients
 */
public SparseTernaryPolynomial(int[] coeffs)
{
    N = coeffs.length;
    ones = new int[N];
    negOnes = new int[N];
    int onesIdx = 0;
    int negOnesIdx = 0;
    for (int i = 0; i < N; i++)
    {
        int c = coeffs[i];
        switch (c)
        {
        case 1:
            ones[onesIdx++] = i;
            break;
        case -1:
            negOnes[negOnesIdx++] = i;
            break;
        case 0:
            break;
        default:
            throw new IllegalArgumentException("Illegal value: " + c + ", must be one of {-1, 0, 1}");
        }
    }
    ones = Arrays.copyOf(ones, onesIdx);
    negOnes = Arrays.copyOf(negOnes, negOnesIdx);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:33,代码来源:SparseTernaryPolynomial.java

示例5: toBinary

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Encodes the polynomial to a byte array writing <code>BITS_PER_INDEX</code> bits for each coefficient.
 *
 * @return the encoded polynomial
 */
public byte[] toBinary()
{
    int maxIndex = 1 << BITS_PER_INDEX;
    byte[] bin1 = ArrayEncoder.encodeModQ(ones, maxIndex);
    byte[] bin2 = ArrayEncoder.encodeModQ(negOnes, maxIndex);

    byte[] bin = Arrays.copyOf(bin1, bin1.length + bin2.length);
    System.arraycopy(bin2, 0, bin, bin1.length, bin2.length);
    return bin;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:SparseTernaryPolynomial.java

示例6: getNegOnes

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public int[] getNegOnes()
{
    int N = coeffs.length;
    int[] negOnes = new int[N];
    int negOnesIdx = 0;
    for (int i = 0; i < N; i++)
    {
        int c = coeffs[i];
        if (c == -1)
        {
            negOnes[negOnesIdx++] = i;
        }
    }
    return Arrays.copyOf(negOnes, negOnesIdx);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:DenseTernaryPolynomial.java

示例7: add

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Adds another polynomial which can have a different number of coefficients.
 *
 * @param b another polynomial
 */
public void add(IntegerPolynomial b)
{
    if (b.coeffs.length > coeffs.length)
    {
        coeffs = Arrays.copyOf(coeffs, b.coeffs.length);
    }
    for (int i = 0; i < b.coeffs.length; i++)
    {
        coeffs[i] += b.coeffs[i];
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:IntegerPolynomial.java

示例8: sub

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Subtracts another polynomial which can have a different number of coefficients.
 *
 * @param b another polynomial
 */
public void sub(IntegerPolynomial b)
{
    if (b.coeffs.length > coeffs.length)
    {
        coeffs = Arrays.copyOf(coeffs, b.coeffs.length);
    }
    for (int i = 0; i < b.coeffs.length; i++)
    {
        coeffs[i] -= b.coeffs[i];
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:IntegerPolynomial.java

示例9: mult

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Multiplies the polynomial with another, taking the indices mod N and the values mod 2048.
 */
public LongPolynomial2 mult(LongPolynomial2 poly2)
{
    int N = coeffs.length;
    if (poly2.coeffs.length != N || numCoeffs != poly2.numCoeffs)
    {
        throw new IllegalArgumentException("Number of coefficients must be the same");
    }

    LongPolynomial2 c = multRecursive(poly2);

    if (c.coeffs.length > N)
    {
        if (numCoeffs % 2 == 0)
        {
            for (int k = N; k < c.coeffs.length; k++)
            {
                c.coeffs[k - N] = (c.coeffs[k - N] + c.coeffs[k]) & 0x7FF0007FFL;
            }
            c.coeffs = Arrays.copyOf(c.coeffs, N);
        }
        else
        {
            for (int k = N; k < c.coeffs.length; k++)
            {
                c.coeffs[k - N] = c.coeffs[k - N] + (c.coeffs[k - 1] >> 24);
                c.coeffs[k - N] = c.coeffs[k - N] + ((c.coeffs[k] & 2047) << 24);
                c.coeffs[k - N] &= 0x7FF0007FFL;
            }
            c.coeffs = Arrays.copyOf(c.coeffs, N);
            c.coeffs[c.coeffs.length - 1] &= 2047;
        }
    }

    c = new LongPolynomial2(c.coeffs);
    c.numCoeffs = numCoeffs;
    return c;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:41,代码来源:LongPolynomial2.java

示例10: add

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Adds another polynomial which can have a different number of coefficients.
 *
 * @param b another polynomial
 */
private void add(LongPolynomial2 b)
{
    if (b.coeffs.length > coeffs.length)
    {
        coeffs = Arrays.copyOf(coeffs, b.coeffs.length);
    }
    for (int i = 0; i < b.coeffs.length; i++)
    {
        coeffs[i] = (coeffs[i] + b.coeffs[i]) & 0x7FF0007FFL;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:LongPolynomial2.java

示例11: sub

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Subtracts another polynomial which can have a different number of coefficients.
 *
 * @param b another polynomial
 */
private void sub(LongPolynomial2 b)
{
    if (b.coeffs.length > coeffs.length)
    {
        coeffs = Arrays.copyOf(coeffs, b.coeffs.length);
    }
    for (int i = 0; i < b.coeffs.length; i++)
    {
        coeffs[i] = (0x0800000800000L + coeffs[i] - b.coeffs[i]) & 0x7FF0007FFL;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:LongPolynomial2.java

示例12: toBinary

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public byte[] toBinary()
{
    byte[] f1Bin = f1.toBinary();
    byte[] f2Bin = f2.toBinary();
    byte[] f3Bin = f3.toBinary();

    byte[] all = Arrays.copyOf(f1Bin, f1Bin.length + f2Bin.length + f3Bin.length);
    System.arraycopy(f2Bin, 0, all, f1Bin.length, f2Bin.length);
    System.arraycopy(f3Bin, 0, all, f1Bin.length + f2Bin.length, f3Bin.length);
    return all;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:ProductFormPolynomial.java

示例13: getKnowledgeProofForX2s

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public BigInteger[] getKnowledgeProofForX2s()
{
    return Arrays.copyOf(knowledgeProofForX2s, knowledgeProofForX2s.length);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:JPAKERound2Payload.java

示例14: keyValue

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
public byte[] keyValue() {
    return Arrays.copyOf(keyValue, keyValue.length);
}
 
开发者ID:xipki,项目名称:xitk,代码行数:4,代码来源:Asn1CreateSecretKeyParams.java

示例15: invertFq

import org.bouncycastle.util.Arrays; //导入方法依赖的package包/类
/**
 * Computes the inverse mod <code>q; q</code> must be a power of 2.<br/>
 * Returns <code>null</code> if the polynomial is not invertible.
 *
 * @param q the modulus
 * @return a new polynomial
 */
public IntegerPolynomial invertFq(int q)
{
    int N = coeffs.length;
    int k = 0;
    IntegerPolynomial b = new IntegerPolynomial(N + 1);
    b.coeffs[0] = 1;
    IntegerPolynomial c = new IntegerPolynomial(N + 1);
    IntegerPolynomial f = new IntegerPolynomial(N + 1);
    f.coeffs = Arrays.copyOf(coeffs, N + 1);
    f.modPositive(2);
    // set g(x) = x^N − 1
    IntegerPolynomial g = new IntegerPolynomial(N + 1);
    g.coeffs[0] = 1;
    g.coeffs[N] = 1;
    while (true)
    {
        while (f.coeffs[0] == 0)
        {
            for (int i = 1; i <= N; i++)
            {
                f.coeffs[i - 1] = f.coeffs[i];   // f(x) = f(x) / x
                c.coeffs[N + 1 - i] = c.coeffs[N - i];   // c(x) = c(x) * x
            }
            f.coeffs[N] = 0;
            c.coeffs[0] = 0;
            k++;
            if (f.equalsZero())
            {
                return null;   // not invertible
            }
        }
        if (f.equalsOne())
        {
            break;
        }
        if (f.degree() < g.degree())
        {
            // exchange f and g
            IntegerPolynomial temp = f;
            f = g;
            g = temp;
            // exchange b and c
            temp = b;
            b = c;
            c = temp;
        }
        f.add(g, 2);
        b.add(c, 2);
    }

    if (b.coeffs[N] != 0)
    {
        return null;
    }
    // Fq(x) = x^(N-k) * b(x)
    IntegerPolynomial Fq = new IntegerPolynomial(N);
    int j = 0;
    k %= N;
    for (int i = N - 1; i >= 0; i--)
    {
        j = i - k;
        if (j < 0)
        {
            j += N;
        }
        Fq.coeffs[j] = b.coeffs[i];
    }

    return mod2ToModq(Fq, q);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:78,代码来源:IntegerPolynomial.java


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