test_class.file: java_src/src/test/java/com/google/crypto/tink/subtle/X25519Test.java
test_class.identifier: X25519Test
test_case.body: @Test
    public void testComputeSharedSecretWithRfcIteration() throws Exception {
      byte[] k = new byte[32];
      k[0] = 9;
      byte[] prevK = k;
      k = X25519.computeSharedSecret(k, prevK);
      assertEquals(
          "422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079", TestUtil.hexEncode(k));
      for (int i = 0; i < 999; i++) {
        byte[] tmp = k;
        k = X25519.computeSharedSecret(k, prevK);
        prevK = tmp;
      }
      assertEquals(
          "684cf59ba83309552800ef566f2f4d3c1c3887c49360e3875f2eb94d99532c51", TestUtil.hexEncode(k));
      // Omitting 1M iteration to limit the test runtime.
    }
test_case.class_method_signature: X25519Test.testComputeSharedSecretWithRfcIteration()
test_case.full_signature: @Test public void testComputeSharedSecretWithRfcIteration()
test_case.identifier: testComputeSharedSecretWithRfcIteration
test_case.invocations: computeSharedSecret assertEquals hexEncode computeSharedSecret assertEquals hexEncode
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testComputeSharedSecretWithRfcIteration()
focal_class.file: java_src/src/main/java/com/google/crypto/tink/subtle/X25519.java
focal_class.identifier: X25519
focal_class.class_method_signature: X25519.generatePrivateKey()
focal_class.full_signature: @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] generatePrivateKey()
focal_class.identifier: generatePrivateKey
focal_class.modifiers: @SuppressWarnings("NarrowingCompoundAssignment") public static
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] generatePrivateKey()
focal_class.class_method_signature: X25519.computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)
focal_class.full_signature: @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)
focal_class.identifier: computeSharedSecret
focal_class.modifiers: @SuppressWarnings("NarrowingCompoundAssignment") public static
focal_class.parameters: (byte[] privateKey, byte[] peersPublicValue)
focal_class.return: byte[]
focal_class.signature: byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)
focal_class.class_method_signature: X25519.publicFromPrivate(byte[] privateKey)
focal_class.full_signature: public static byte[] publicFromPrivate(byte[] privateKey)
focal_class.identifier: publicFromPrivate
focal_class.modifiers: public static
focal_class.parameters: (byte[] privateKey)
focal_class.return: byte[]
focal_class.signature: byte[] publicFromPrivate(byte[] privateKey)
focal_method.body: @SuppressWarnings("NarrowingCompoundAssignment")
    public static byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)
        throws InvalidKeyException {
      if (privateKey.length != Field25519.FIELD_LEN) {
        throw new InvalidKeyException("Private key must have 32 bytes.");
      }
      long[] x = new long[Field25519.LIMB_CNT + 1];
  
      byte[] e = Arrays.copyOf(privateKey, Field25519.FIELD_LEN);
      e[0] &= 248;
      e[31] &= 127;
      e[31] |= 64;
  
      Curve25519.curveMult(x, e, peersPublicValue);
      return Field25519.contract(x);
    }
focal_method.class_method_signature: X25519.computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)
focal_method.full_signature: @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)
focal_method.identifier: computeSharedSecret
focal_method.invocations: copyOf curveMult contract
focal_method.modifiers: @SuppressWarnings("NarrowingCompoundAssignment") public static
focal_method.parameters: (byte[] privateKey, byte[] peersPublicValue)
focal_method.return: byte[]
focal_method.signature: byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue)