/**
   * Test public key encryption.
   *
   * @throws Exception When test fails.
   */
  @Test
  public void testActivationGenerate() throws Exception {
    String activationOTP = "CKZ2O-OE544";
    String activationIdShort = "IFA6F-3NPAZ";
    byte[] activationNonce = BaseEncoding.base64().decode("grDwkvXrgfUdKBsqg0xYYw==");
    byte[] publicKeyBytes =
        BaseEncoding.base64()
            .decode(
                "BJXfJMCANX+T9FzsG6Hi0KTYPN64i7HxMiWoMYPd17DYfBR+IwzOesTh/jj/B3trL9m3O1oODYil+8ssJzDt/QA=");
    byte[] ephemeralPrivateKeyBytes =
        BaseEncoding.base64().decode("AKeMTtivK/XRiQPhfJYxAw1L62ah4lGTQ4JKqRrr0fnC");
    byte[] masterPublicKey =
        BaseEncoding.base64()
            .decode(
                "BFOqvpLNi15eHDt8fkFxFe034Buw/i8gR3ax4fKiIQynt5K858oBBYhqLVH8FhNmMnlysnRd2UsPJSQxzoPhEn8=");

    CryptoProviderUtil keyConvertor = PowerAuthConfiguration.INSTANCE.getKeyConvertor();
    PrivateKey eph = keyConvertor.convertBytesToPrivateKey(ephemeralPrivateKeyBytes);
    PublicKey mpk = keyConvertor.convertBytesToPublicKey(masterPublicKey);

    PublicKey publicKey =
        PowerAuthConfiguration.INSTANCE.getKeyConvertor().convertBytesToPublicKey(publicKeyBytes);
    PowerAuthClientActivation activation = new PowerAuthClientActivation();

    byte[] cDevicePublicKey =
        activation.encryptDevicePublicKey(
            publicKey, eph, mpk, activationOTP, activationIdShort, activationNonce);
    assertArrayEquals(
        cDevicePublicKey,
        BaseEncoding.base64()
            .decode(
                "tnAyB0C5I9xblLlFCPONUT4GtABvutPkRvvx2oTeGIuUMAmUYTqJluKn/Zge+vbq+VArIVNYVTd+0yuBZGVtkkd1mTcc2eTDhqZSQJS6mMgmKeCqv64c6E4dm4INOkxh"));
  }
 /**
  * Test that the keys are correctly generated.
  *
  * @throws Exception When test fails.
  */
 @Test
 public void testGenerateKeys() throws Exception {
   CryptoProviderUtil keyConvertor = PowerAuthConfiguration.INSTANCE.getKeyConvertor();
   KeyGenerator keyGenerator = new KeyGenerator();
   KeyPair kp = keyGenerator.generateKeyPair();
   System.out.println(
       "Private Key: "
           + BaseEncoding.base64().encode(keyConvertor.convertPrivateKeyToBytes(kp.getPrivate())));
   System.out.println(
       "Public Key: "
           + BaseEncoding.base64().encode(keyConvertor.convertPublicKeyToBytes(kp.getPublic())));
 }