Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda