TezosRio / TezosJ_plainJava

Java Software Development Kit for Tezos blockchain
MIT License
32 stars 7 forks source link

Signed message verification #11

Open dmytronasyrov opened 3 years ago

dmytronasyrov commented 3 years ago

I'm looking for a solution to verify signed by Beacon wallet (JS) RAW or MICHELINE message. Looked through the source code of many repos but no luck yet. The closest solution for RAW (from my perspective) is

byte[] walletAddress = "PKH".getBytes(StandardCharsets.US_ASCII);
byte[] signature = "edsigu53AaPtjGhGtPKb3aM2AB8kGmikyhFtyjTP6QKv3VisAuVbtak8DJzEJn5kNB3hsNwEUP9FFfxuRZaPGUs5dmeSkT7pG2s".getBytes(StandardCharsets.US_ASCII);
byte[] msg = "abc".getBytes(StandardCharsets.US_ASCII);
final boolean verify = Ed25519.verify(signature, 0, walletAddress, 0, msg, 0, msg.length);

Message was signed with:

const payload = {
      signingType: SigningType.RAW,
      payload: "abc",
      sourceAddress: PKH
};

const signedPayload = await wallet.client.requestSignPayload(payload);
const {signature} = signedPayload;

Any idea how to make verification works?