I have the code below which I am using to sign some payload in javascript using ed25519 signature algorithm
var nacl=require("tweetnacl")
var keys=nacl.sign.keyPair()
var TextEncoder= require('util').TextEncoder;
var documentId = "77ccbf5e-4ddd-4092-b813-ac06084a3eb0"
const bs58 = require('bs58')
var bufferOutput=buf2hex(keys.publicKey.buffer)
const bytes = Buffer.from(bufferOutput, 'hex')
const pub = bs58.encode(bytes)
console.log("public key",pub)
var uri = "77ccbf5e-4ddd-4092-b813-ac06084a3eb0#keys-1"
var document = {
"id": documentId,
"publicKey": [
{
"id": uri,
"type": "Ed25519VerificationKey2018",
"controller": documentId,
"publicKeyBase58": pub
}
]
}
var uint8array = new TextEncoder("utf-8").encode(document);
var signature=nacl.sign(uint8array, keys.secretKey)
console.log("signature",bs58.encode(Buffer.from(buf2hex(signature),'hex')))
But when I try to verify the signature inside kotlin/java using net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec it says that my keyspec is unsupported.
Is there any way to sign a package in javascript and verify in java/kotlin?