Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:37:05+00:00 2026-06-15T09:37:05+00:00

I was looking for libraries to implement an encryption system and was interested in

  • 0

I was looking for libraries to implement an encryption system and was interested in using the NaCl: Networking and Cryptography library specifically the box function. Obviously, it uses symmetric encryption XSalsa20, Curve25519 for public-private cryptography and Poly1305 for authentication as the primitives for it.

However, the documentation looks to be insufficient in the way that they’ve been used. For example, it mentions that to compute the key it uses the sender’s private key and the receiver’s public key to compute the secret key. But it doesn’t explain how. Can anyone shed any light on it?

If I were to use the same public and private keys, I wouldn’t want the same output to be generated on the next attempt as it would be disastrous. Does anyone know of the explanation behind it or hook me up with some more documentation on how the functions work rather than how the functions can be used?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:37:06+00:00Added an answer on June 15, 2026 at 9:37 am

    How does crypto_box work?

    box uses a Diffie-Hellman key exchange on the two keys and hashes the result. Then it uses that as the key for secret_box.

    • crypto_box is equivalent to crypto_box_beforenm followed by crypto_box_afternm.

    • crypto_box_beforenm is the hashed key-exchange which works as described in the Curve25519 paper, using elliptic curve Diffie-Hellman key exchange on Curve25519 hashing the result with HSalsa. This yields a 32 byte shared key.

      k = Hash(Curve25519(b, A)) = Hash(Curve25519(a, B))

    • crypto_box_afternm is identical to crypto_secret_box. It takes a 24 byte nonce and a 32 byte key. It’s an authenticated stream cipher using XSalsa20 for encryption and Poly1305 as MAC. The first 32 bytes of the output of XSalsa20 are used for the MAC, the rest are xored into the plaintext to encrypt it.

    What happens if you use it multiple times?

    If you take two fixed key-pairs, the result of the key exchange will always be the same.

    But the symmetric part secret_box is secure even when you use a key several times, as long as you never reuse a nonce for that key, i.e. the (key, nonce) pair must be unique.

    This property is pretty much the same for all modern authenticated stream ciphers, such as AES-GCM or XSalsa20-Poly1305.

    Common ways to create a unique nonce are:

    • Use an 8 byte prefix and a random 16 byte value (stateless, random 16 bytes are most likely unique)
    • Use a 16 byte prefix and a 8 byte counter (stateful, useful in a connection where you increment for each packet)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What libraries do exist that implement strict data structures? Specifically, I am looking for
I have been looking into libraries for a file system that will allow path
I'm looking for SOAP libraries that implement WS-ReliableMessaging. So far I've come across Apache's
I am looking for an native function from the C libraries or code example
I am looking for open source JCE libraries that implement some of the more
I'm looking for ways to traverse an arbitrary object hierarchy in Java. Obviously, using
i'm looking for implement datagrid with CI, better if using ajax. Searching on Google
I am looking for any libraries in java that can parse an address out
I've been looking around JQuery libraries for the URL hash, but found none that
Looking at examples and tutorials for some MVC libraries for web development on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.