ArticleslgStudy

computer science

NaCl (software)

NaCl (software) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand NaCl (software) rather than just read about it. In short: NaCl (Networking and Cryptography Library, pronounced "salt") is a public domain, high-speed software library for cryptography. NaCl was created by the mathematician and programmer Daniel J.

Key takeaways

  • NaCl (software) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect NaCl (software) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of NaCl (software) from memory before moving on to harder problems.

Reference excerpt

NaCl (Networking and Cryptography Library, pronounced "salt") is a public domain, high-speed software library for cryptography. NaCl was created by the mathematician and programmer Daniel J. Bernstein, who is best known for the creation of qmail and Curve25519. The core team also includes Tanja Lange and Peter Schwabe. The main goal while creating NaCl, according to the team's 2011 paper, was to "avoid various types of cryptographic disasters suffered by previous cryptographic libraries". The team does so by safer designs that avoid issues such as side-channel leakage and loss of randomness, by being performant enough that safety features do not get disabled by the user, and by picking better cryptographic primitives. The high-level "box" API is designed to encourage the use of authenticated encryption.

Functions

Public-key cryptography crypto_box, public-key authenticated encryption. Key agreement happens via X25519; encryption is done by Salsa20-Poly1305. crypto_scalarmult, scalar multiplication on X25519. This function can be used for elliptic-curve Diffie–Hellman. crypto_sign, signatures using Ed25519 and SHA-512.

Secret-key cryptography crypto_secretbox, private-key authenticated encryption using Salsa20-Poly1305. crypto_stream, encryption using Salsa20, XSalsa20, or AES. crypto_auth, authentication using HMAC-SHA-512-256. crypto_onetimeauth, single-message authentication using Poly1305.

Low-level functions crypto_hash, hashing using SHA-512 or SHA-256 crypto_verify, string comparison in constant time.

Implementations The reference implementation is written in C, often incorporating inline assembly routines. C++ support is implemented as a wrapper. A Python wrapper was planned, but is not part of the latest (20110221) release. The home page, last updated in 2016, mentions prototype wrappers. The reference NaCl implementation has a variety of programming language bindings, such as PHP and Tcl.

Libsodium Libsodium is an API-compatible fork of reference NaCl created in 2013. It is "installable and packageable", or in other words can be compiled into a dynamic library and installed as a software package thanks to the addition of build files (NaCl had none). It is also "portable and cross-compilable". As libsodium can be dynamically linked, it serves as the basis for a number of bindings in languages such as Squeak, Pharo, Perl 5, and Python. libsodium also extends the NaCl API with new algorithms (e.g. BLAKE2, ChaCha20-Poly1305, AEGIS) and new classes of functions (e.g. secure memory, random number generation, short-input hashing, password hashing and key derivation).

TweetNaCl In 2013, the NaCl team and three others released TweetNaCl, a condensed implementation of NaCl's 25 functions that fits in the size of 100 tweets (140 symbols each). TweetNaCl has been used as the basis of ports including TweetNaCl.js and TweetNaCl-Java. It has also been rewritten in the SPARK Ada subset as SPARKNaCl, which the authors describe as "(unlike TweetNaCl) readable owing to the large number of explanatory comments and contracts in the code."

Other implementations RustCrypto - a popular set of pure-Rust crypto libraries that includes an NaCl compatibility layer. dryoc — a pure-Rust cryptography library implementing the libsodium/NaCl API with support for protected memory. Monocypher — a rewrite of NaCl in C. Aims to have the speed of reference NaCl and the size of TweetNaCl.

See also The use of the term salt in cryptography Comparison of cryptography libraries List of free and open-source software packages

References

External links Official website

Worked examples

Example 1 — a first encounter with NaCl (software)

Start with the simplest possible case. Write down what NaCl (software) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to NaCl (software) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about NaCl (software) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of NaCl (software)

In research
NaCl (software) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses NaCl (software) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
NaCl (software) is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2008 software, Cryptographic software, Public-domain software, so understanding it makes those chapters shorter.
In everyday life
Look for NaCl (software) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “NaCl (software)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study NaCl (software) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what NaCl (software) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain NaCl (software) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is NaCl (software) in simple terms?

NaCl (Networking and Cryptography Library, pronounced "salt") is a public domain, high-speed software library for cryptography. NaCl was created by the mathematician and programmer Daniel J.

Why does NaCl (software) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study NaCl (software)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on NaCl (software).

Tags

  • 2008 software
  • Cryptographic software
  • Public-domain software

Keep exploring