### Question:
KeyPair { public static KeyPair fromPrivate(final PrivateKey privateKey, final CryptoEngine engine) { PublicKey publicKey = engine.createKeyGenerator().derivePublicKey(privateKey); return new KeyPair(Optional.of(privateKey), publicKey, engine); } private  KeyPair(
      final Optional<PrivateKey> privateKey, final PublicKey publicKey, CryptoEngine engine); static KeyPair random(); static KeyPair random(CryptoEngine engine); static KeyPair fromPrivate(final PrivateKey privateKey, final CryptoEngine engine); static KeyPair onlyPublic(final PublicKey publicKey); static KeyPair onlyPublic(final PublicKey publicKey, final CryptoEngine engine); static KeyPair fromPrivate(final PrivateKey privateKey); PrivateKey getPrivateKey(); PublicKey getPublicKey(); boolean hasPrivateKey();  }### Answer:
@Test void ctorWithPrivateKeyDelegatesToDerivePublicKey() { final KeyPairContext context = new KeyPairContext(); KeyPair.fromPrivate(context.privateKey, context.engine); Mockito.verify(context.generator, Mockito.times(1)).derivePublicKey(context.privateKey); }