private static void doubleXYZ(PartialXYZT partialXYZT, XYZ p) {
    long[] t0 = new long[Field25519.LIMB_CNT];

    // XX = X1^2
    Field25519.square(partialXYZT.xyz.x, p.x);

    // YY = Y1^2
    Field25519.square(partialXYZT.xyz.z, p.y);

    // B' = Z1^2
    Field25519.square(partialXYZT.t, p.z);

    // B = 2 * B'
    Field25519.sum(partialXYZT.t, partialXYZT.t, partialXYZT.t);

    // A = X1 + Y1
    Field25519.sum(partialXYZT.xyz.y, p.x, p.y);

    // AA = A^2
    Field25519.square(t0, partialXYZT.xyz.y);

    // Y3 = YY + XX
    Field25519.sum(partialXYZT.xyz.y, partialXYZT.xyz.z, partialXYZT.xyz.x);

    // Z3 = YY - XX
    Field25519.sub(partialXYZT.xyz.z, partialXYZT.xyz.z, partialXYZT.xyz.x);

    // X3 = AA - Y3
    Field25519.sub(partialXYZT.xyz.x, t0, partialXYZT.xyz.y);

    // T3 = B - Z3
    Field25519.sub(partialXYZT.t, partialXYZT.t, partialXYZT.xyz.z);
  }
Doubles {@code p} and puts the result into this PartialXYZT.

This is based on the addition defined in formula 7 in Section 3.3 of
Hisil H., Wong K.KH., Carter G., Dawson E. (2008) Twisted Edwards Curves Revisited.

Please note that this is a partial of the operation listed there leaving out the final
conversion from PartialXYZT to XYZT and also this fixes a typo in calculation of Y3 and T3 in
the paper, H should be replaced with A+B.
java_src/src/main/java/com/google/crypto/tink/internal/Ed25519.java