waltid-identity
waltid-identity copied to clipboard
Java implementation issue with Keys abstract class.
Hi Team, I am experiencing this issue when extending the Keys class (id.walt.crypto.keys) from waltid-crypto-jvm-0.2.0.jar. The issue occurs only with the following methods since the java de-compiler adds a postfix (verifyRaw-0E7RQCE) with a dash character that Java does not support. I would appreciate it if you could check and let me know.
- public abstract Object verifyRaw_0E7RQCE/* $FF was: verifyRaw-0E7RQCE*/(@NotNull byte[] var1, @Nullable byte[] var2, @NotNull Continuation var3);
- public abstract Object verifyJws_gIAlu_s/* $FF was: verifyJws-gIAlu-s*/(@NotNull String var1, @NotNull Continuation var2);
Hi @saujam as you see in the picture, I could reproduce the issue. Due to the "inline" Result class the suffix is produced, which can not be inherited from Java.
To solve this issue, I could think of two options: 1.) Change the result type in the Key interface or 2.) Wrap the Result within a subclass for the JVM, as you see in the next screenshot, which at least works in my PoC:
I will discuss these options with the team an come back to you.
Hi @saujam,
if you want to implement a Key in Java instead of Kotlin, you will have to extend from JavaKey
instead of Key
. There you will not have to handle suspend/coroutines or the kotlin.Result return type.
This is a stub you can utilize:
import id.walt.crypto.keys.JavaKey;
import id.walt.crypto.keys.Key;
import id.walt.crypto.keys.KeyMeta;
import id.walt.crypto.keys.KeyType;
import java.util.Map;
import kotlinx.serialization.json.JsonElement;
import kotlinx.serialization.json.JsonObject;
import org.jetbrains.annotations.NotNull;
public class MyKey extends JavaKey {
private String _xyz;
public MyKey(String xyz) {
this._xyz = xyz;
}
@NotNull
@Override
public KeyMeta javaGetMeta() {
return null;
}
@NotNull
@Override
public byte[] javaGetPublicKeyRepresentation() {
return new byte[0];
}
@NotNull
@Override
public Key javaGetPublicKey() {
return null;
}
@NotNull
@Override
public JsonElement javaVerifyJws() {
return null;
}
@NotNull
@Override
public byte[] javaVerifyRaw() {
return new byte[0];
}
@NotNull
@Override
public String javaSignJws(@NotNull byte[] plaintext, @NotNull Map<String, String> headers) {
return "";
}
@NotNull
@Override
public Object javaSignRaw(@NotNull byte[] plaintext) {
return null;
}
@NotNull
@Override
public String javaExportPEM() {
return "";
}
@NotNull
@Override
public JsonObject javaExportJWKObject() {
return null;
}
@NotNull
@Override
public String javaExportJWK() {
return "";
}
@NotNull
@Override
public String javaGetThumbprint() {
return "";
}
@NotNull
@Override
public String javaGetKeyId() {
return "";
}
@Override
public boolean javaHasPrivateKey() {
return false;
}
@NotNull
@Override
public KeyType javaGetKeyType() {
return null;
}
}
What is the release version for java key implementation.