@Override
    public void fromPB(EncryptionKeyPB pb, KeyMgr mgr) {
        super.fromPB(pb, mgr);
        if (pb.algorithm == null) {
            throw new IllegalArgumentException("no algorithm in EncryptionKeyPB for NormalKey id:" + id);
        }
        algorithm = pb.algorithm;
        if (pb.plainKey != null) {
            plainKey = pb.plainKey;
        } else if (pb.encryptedKey != null) {
            encryptedKey = pb.encryptedKey;
        } else {
            throw new IllegalArgumentException("no encryptedKey in EncryptionKeyPB for NormalKey id:" + id);
        }
    }
@Test
    public void testFromPB_NoParent() {
        NormalKey key = new NormalKey();
        EncryptionKeyPB pb = new EncryptionKeyPB();
        pb.parentId = 1L;
        pb.algorithm = EncryptionAlgorithmPB.AES_128;
        pb.encryptedKey = new byte[16];
        KeyMgr mgr = new KeyMgr();
        assertThrows(IllegalArgumentException.class, () -> {
            key.fromPB(pb, mgr);
        });
    }