PublicKey grantToProjectPublicKey = grantToProject.getPublicKey();
byte[] newSecretData;
try {
SecretStore store = new SecretStore(onProject.secretData);
Writer writer = store.buildWriter();
writer.writeAsymetricProjectKey(projectSecretData, grantToProject.id, grantToProjectPublicKey);
writer.close();
store.appendContents(writer);
newSecretData = store.getEncoded();
} catch (IOException e) {
throw new RepositoryException("Error writing secrets", e);