use of com.github.dedis.popstellar.model.objects.security.Base64URLData in project popstellar by dedis.
the class KeyManagerTest method keyPairIsRight.
@Test
public void keyPairIsRight() throws GeneralSecurityException {
KeyManager keyManager = new KeyManager(androidKeysetManager, wallet);
KeyPair mainKeyPair = keyManager.getMainKeyPair();
PublicKey mainKey = keyManager.getMainPublicKey();
assertEquals(mainKey, mainKeyPair.getPublicKey());
// We cannot extract the public key from the keyset handle
// But we can make sure both signatures are equals and the key manager keypair can verify it
PublicKeySign signer = androidKeysetManager.getKeysetHandle().getPrimitive(PublicKeySign.class);
// Generate any data, here a message id
Base64URLData data = Base64DataUtils.generateMessageID();
Signature signature = mainKeyPair.sign(data);
assertArrayEquals(signer.sign(data.getData()), signature.getData());
assertTrue(mainKey.verify(signature, data));
}
Aggregations