Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
TweetNaCl.js Public-key signatures example err

I want to use ed25519 to sign my message. And I found TweetNaCl.js which has the Signatures method to achieve my goal.

By referencing TweetNaCl.js minimal Public-key signatures example and official document-Signatures, here is my test code codesandbox.

  const keyPair = nacl.sign.keyPair();
  const secretKey = keyPair.secretKey;
  const publicKey = keyPair.publicKey;
  const secretKeyB64 = encodeBase64(secretKey);
  const publicKeyB64 = encodeBase64(publicKey);
  console.log("secretKeyB64", secretKeyB64);
  console.log("publicKeyB64", publicKeyB64);

  const msgStr = "My unencrypted message";
  const msg = decodeUTF8(msgStr);
  const signature = nacl.sign(msg, secretKey);
  const signatureB64 = encodeBase64(signature);
  console.log("signatureB64", signatureB64);
  const verifiedMsg = nacl.sign.open(signature, publicKey);
  console.log(encodeUTF8(verifiedMsg));

The encodeUTF8(verifiedMsg)'s console log seems no problem and is as same as msgStr.

But I notice that when I put the publicKeyB64, signatureB64, and msgStr to the tweetnacl.js' example page(Public-key signatures) to verify it, it responds error Bad signature length: must be 64 bytes.

If I put the secretKeyB64 into the example sign page, and click "Sign", the Signature seems shorter than what I created from Codesandbox's code.

Is there anything that I missed?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I figure out this problem 20 minutes later... Thanks for the StackOverflow ?!!

I console log the signature and find its length is over 64. After I reviewed the Signatures, I found another method nacl.sign.detached(message, secretKey) and its length was 64!!!

After encodeBase64 and put it to the tweetnacl.js' example page(Public-key signatures) to verify it, it works!!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda