Questions tagged [nacl-cryptography]

NaCl (pronounced "salt") is a high-speed software library for network communication, encryption, decryption, signatures, and more. Not to be confused with [google-nativeclient].

Sources & Resources:

54 questions
2
votes
1 answer

Sign and verify using ed25519 in near protocol

I am trying to sign the message in javascript using signMessage and verify it with python for implementing jwt authentication. This is the code for signing message in javascript using near-api-js window.signer = await new…
2
votes
1 answer

How to encrypt JSON object with JS-NaCl and decrypt with php Libsodium

I managed to find a Libsodium js library (JS-NaCl) for front end encryption and has setup my PHP backend for Libsodium encrypt/decrypt also. When I encrypt a JSON object like below const key = "827ccb0eea8a706c4c34a16891f84e7b"; const nonce =…
CliffTheCoder
  • 394
  • 1
  • 4
  • 24
2
votes
1 answer

Is it possible to sign a message with a base58 secret key with Tweetnacl library?

I've generated a key pair using Tweetnacl.js: const base58KeyPairGenerator = (seed: Uint8Array) => ({ publicKey: keyToPublicIdentityKey(nacl.sign.keyPair.fromSeed(seed).publicKey), secretKey: seedToSecretIdentityKey(seed) }); const…
Mik378
  • 21,881
  • 15
  • 82
  • 180
2
votes
1 answer

TweetNaCl gives wrong encoding when trying to decrypt

I'm trying to get TweetNaCl.js working. My problem is that when I decrypt the data, the output is encoded wrong. Encrypted data: 你好,世界 Decrypted data: ä½ å¥½ï¼ä¸ç Here is my decryption function: Crypto.decrypt = function(key, nonce, ciphertext) { …
2
votes
1 answer

How to generate a SHA256 hash of 32 bytes using nodejs (crypto) in order to avoid bad key size error thrown from tweetnacl.js?

I am using the crypto module of node.js to generate a SHA256 hash like this: const key = crypto.createHmac('sha256', data).digest('hex'); Now, tweetnacl throws the error: bad key size when the key is passed in the secretbox: nacl.secretbox(data,…
Abrar
  • 6,874
  • 9
  • 28
  • 41
2
votes
1 answer

"runtime error: slice bounds out of range" in encrypted chat

Update: thanks to peterSO the error seems to be that random bytes, read as strings will include "\n" which causes a newline and the error. The problem is neither io.Copy(conn,…
2
votes
1 answer

How do I do encryption/decryption without generating keypairs again?

I have been working on a project myself and using this website's codes as a guide. Is there any way, I can put the generation of keys into 1 file and encryption/decryption into another. How do I define bob_box without having to generate another pair…
meh
  • 53
  • 1
  • 7
2
votes
1 answer

Security implications of public nonce

I'm planning to use the crypto_box() functions of Nacl to encrypt messages as part of a client/server protocol. The server has to deal with multiple clients and each message from a client to the server is encrypted using the public key of the server…
dsd
  • 551
  • 5
  • 17
2
votes
1 answer

How to use NaCl with Java under Windows

I recently found the library Libsodium and was glad that there are also Bindings for Java. Unfortunately, the libraries don't appear to work with Windows because they were developed for other systems. How can I use the libraries under Windows (if…
Mattias
2
votes
0 answers

libnacl crypto library - how to recover public key

I use the nacl cryptographic library and need to recover the public key from the secret key. Is this possible? This is my somewhat naive attempt: #include #include //... int main(int argc,…
2
votes
2 answers

Using NaCl/libsodium crypto in Objective-C

I try to find out, what's the right way to use the NaCl library in Objective-C. Keygeneration seems easy: - (void) generateKeypair { unsigned char pk[crypto_box_PUBLICKEYBYTES]; unsigned char sk[crypto_box_SECRETKEYBYTES]; …
max
  • 29,122
  • 12
  • 52
  • 79
1
vote
1 answer

Encryption using libsodium and need to generate public and private keys using crypto_box_keypair

I have been working with the libsodium library to implement Shamir secret sharing and trying to test the implementation done by dark crystal https://gitlab.com/dark-crystal-javascript/key-backup-crypto/-/blob/master/example.js Implementation is…
Vikas
  • 975
  • 1
  • 10
  • 34
1
vote
0 answers

using nacl.Sign and understanding its I/O arguments

In the package golang.org/x/crypto/nacl/sign the Sign function has both an out []byte argument and it returns a byte slice. Reading the source code, i am struggling figuring out how to correctly use them, they are head and tail, though in following…
user4466350
1
vote
0 answers

pynacl crypto_core_hsalsa20 for nuki smartlock 2.0

I need the crypto_core_hsalsa20 function to greate an secret key for my NUKI. Both sides calculate DH Key k using function dh1 a. Key 0DE40B998E0E330376F2D2FC4892A6931E25055FD09F054F99E93FECD9BA611E 8. Both sides derive a long term shared secret…
DanielRadl
  • 101
  • 5
1
vote
1 answer

PyNaCl - Printing PrivateKey raw hex value

I am currently experimenting with elliptic curves and using python for simplicity. I have an instance of this class (NaCl/PrivateKey) which is properly instantiated. However looking at it's public class variables, I can only seem to query the…
Woodstock
  • 22,184
  • 15
  • 80
  • 118