protected byte[] truncate(byte[] bs) { if (bs.length <= macLength) { return bs; } return Arrays.copyOf(bs, macLength); } }
protected byte[] truncate(byte[] bs) { if (bs.length <= macSize) { return bs; } return Arrays.copyOf(bs, macSize); } }
public BigInteger[] getKnowledgeProofForX2s() { return Arrays.copyOf(knowledgeProofForX2s, knowledgeProofForX2s.length); }
public BigInteger[] getKnowledgeProofForX2() { return Arrays.copyOf(knowledgeProofForX2, knowledgeProofForX2.length); }
byte[] toTruncatedByteArray(int payloadLength) { /* * RFC 6520 4. The padding_length MUST be at least 16. */ int minimumCount = payloadLength + 16; if (count < minimumCount) { return null; } return Arrays.copyOf(buf, payloadLength); } }
public BigInteger[] getKnowledgeProofForX1() { return Arrays.copyOf(knowledgeProofForX1, knowledgeProofForX1.length); }
byte[] toTruncatedByteArray(int payloadLength) { /* * RFC 6520 4. The padding_length MUST be at least 16. */ int minimumCount = payloadLength + 16; if (count < minimumCount) { return null; } return Arrays.copyOf(buf, payloadLength); } }
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); }
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); }
public int[] getOnes() { int N = coeffs.length; int[] ones = new int[N]; int onesIdx = 0; for (int i = 0; i < N; i++) { int c = coeffs[i]; if (c == 1) { ones[onesIdx++] = i; } } return Arrays.copyOf(ones, onesIdx); }
/** * 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; } }
/** * 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; } }
public int[] getOnes() { int N = coeffs.length; int[] ones = new int[N]; int onesIdx = 0; for (int i = 0; i < N; i++) { int c = coeffs[i]; if (c == 1) { ones[onesIdx++] = i; } } return Arrays.copyOf(ones, onesIdx); }
/** * 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]; } }
/** * 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]; } }
/** * 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; }
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; }
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; }
/** * 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; }
public JPAKERound2Payload( String participantId, BigInteger a, BigInteger[] knowledgeProofForX2s) { JPAKEUtil.validateNotNull(participantId, "participantId"); JPAKEUtil.validateNotNull(a, "a"); JPAKEUtil.validateNotNull(knowledgeProofForX2s, "knowledgeProofForX2s"); this.participantId = participantId; this.a = a; this.knowledgeProofForX2s = Arrays.copyOf(knowledgeProofForX2s, knowledgeProofForX2s.length); }