use of com.icodici.crypto.EncryptionError in project universa by UniversaBlockchain.
the class KeyRecord method setupKey.
private void setupKey() {
try {
Object x = getOrThrow("key");
remove("key");
if (x instanceof PublicKey) {
publicKey = (PublicKey) x;
} else if (x instanceof PrivateKey) {
publicKey = ((PrivateKey) x).getPublicKey();
} else if (x instanceof String) {
publicKey = new PublicKey(Base64u.decodeCompactString((String) x));
} else {
if (x instanceof Bytes)
x = ((Bytes) x).toArray();
if (x instanceof byte[]) {
publicKey = new PublicKey((byte[]) x);
} else {
throw new IllegalArgumentException("unsupported key object: " + x.getClass().getName());
}
}
put("key", publicKey);
} catch (EncryptionError e) {
throw new IllegalArgumentException("unsupported key, failed to construct", e);
}
}
Aggregations