@Test public void testGeneratePrivateKeyReturnsIntentionallyMalformedKeys() { byte[] privateKey = X25519.generatePrivateKey(); assertEquals(7, privateKey[0] & 7); assertEquals(128, privateKey[31] & 192); }
@SuppressWarnings("NarrowingCompoundAssignment") public static byte[] generatePrivateKey() { byte[] privateKey = Random.randBytes(Field25519.FIELD_LEN); privateKey[0] |= 7; privateKey[31] &= 63; privateKey[31] |= 128; return privateKey; }
X25519 { @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] generatePrivateKey() { byte[] privateKey = Random.randBytes(Field25519.FIELD_LEN); privateKey[0] |= 7; privateKey[31] &= 63; privateKey[31] |= 128; return privateKey; } }
X25519 { @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] generatePrivateKey() { byte[] privateKey = Random.randBytes(Field25519.FIELD_LEN); privateKey[0] |= 7; privateKey[31] &= 63; privateKey[31] |= 128; return privateKey; }  }
X25519 { @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] generatePrivateKey() { byte[] privateKey = Random.randBytes(Field25519.FIELD_LEN); privateKey[0] |= 7; privateKey[31] &= 63; privateKey[31] |= 128; return privateKey; }  @SuppressWarnings("NarrowingCompoundAssignment") static byte[] generatePrivateKey(); @SuppressWarnings("NarrowingCompoundAssignment") static byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue); static byte[] publicFromPrivate(byte[] privateKey); }
X25519 { @SuppressWarnings("NarrowingCompoundAssignment") public static byte[] generatePrivateKey() { byte[] privateKey = Random.randBytes(Field25519.FIELD_LEN); privateKey[0] |= 7; privateKey[31] &= 63; privateKey[31] |= 128; return privateKey; }  @SuppressWarnings("NarrowingCompoundAssignment") static byte[] generatePrivateKey(); @SuppressWarnings("NarrowingCompoundAssignment") static byte[] computeSharedSecret(byte[] privateKey, byte[] peersPublicValue); static byte[] publicFromPrivate(byte[] privateKey);  }