我有下面的代码,使用ed25519签名算法在javascript中对一些有效载荷进行签名
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')))
但是当我尝试使用net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec
验证kotlin / java内部的签名时,它说我的密钥规格不受支持。
有什么办法在javascript中对软件包进行签名并在java / kotlin中进行验证?