Rust NACL Wrapper API

Overview

Rust NACL Wrapper API salt

NaCl (pronounced "salt") is a new easy-to-use high-speed software library for network communication, encryption, decryption, signatures, etc. NaCl's goal is to provide all of the core operations needed to build higher-level cryptographic tools. Of course, other libraries already exist for these core operations. NaCl advances the state of the art by improving security, by improving usability, and by improving speed.

This library doesn't provides a hexadecimal encoder. Users can encode the hashes and signatures using Hex crate.

  • Migration Status
  • Crypto Box
  • Crypto Secret Box
  • Crypto Hash
  • Crypto Sign
  • Documentation
  • Tests
  • Build
$ cargo build --release
  • Test
$ cargo test
  • Hashing
    let message = "The quick brown fox jumps over the lazy dog";
    let hash_512 = crypto_hash_sha512(message.as_bytes().to_vec()).unwrap();
    assert_eq!(CRYPTO_HASH_SHA512_BYTES, hash_512.len());
  • Secret Key Encryption

  • Public Key Encryption

    // Alice and Bob exchanges their public keys
    let (alice_pk, alice_sk) = crypto_box_keypair().unwrap();
    let (bob_pk, bob_sk) = crypto_box_keypair().unwrap();

    let message = "The quick brown fox jumps over the lazy dog";
    let nonce = vec![0u8; CRYPTO_BOX_CURVE_25519XSALSA20POLY1305_NONCEBYTES];
    let nonce_to_open = nonce.clone();
    // Alice encrypts and authenticates a message with her secret key and Bobs public key
    let crypto_text = crypto_box(message.as_bytes().to_vec(), nonce, bob_pk, alice_sk).unwrap();

    // Bob decrypts and validates Alices message with his secret key and Alices public key
    let decrypted_message =
        crypto_box_open(crypto_text, nonce_to_open, alice_pk, bob_sk).unwrap();
    assert_eq!(
        message,
        std::str::from_utf8(
            &decrypted_message[CRYPTO_BOX_CURVE_25519XSALSA20POLY1305_ZEROBYTES..]
        )
        .unwrap()
    );
  • Digital Signatures
    let (pk, sk) = crypto_sign_keypair().unwrap();
    let message = "The quick brownfox jumps over the lazy dog";
    let signed_message = crypto_sign(message.as_bytes().to_vec(), sk).unwrap();
    let validated_message = crypto_sign_open(signed_message, pk).unwrap();
    let validated_message = std::str::from_utf8(&validated_message)
        .unwrap()
        .trim_matches(char::from(0));
    assert_eq!(message, validated_message);

References

https://nacl.cr.yp.to/

PDF - Daniel J. Bernstein, Tanja Lange, Peter Schwabe, "The security impact of a new cryptographic library"

PyNacl

You might also like...
A node API for the dprint TypeScript and JavaScript code formatter

dprint-node A node API for the dprint TypeScript and JavaScript code formatter. It's written in Rust for blazing fast speed. Usage Pass a file path an

binance API client

bian-rs 币安API Rust async SDK 完成情况 接口 现货 U本位合约 币本位合约 欧式期权 http 🚧 开发中 🆗 🚧 开发中 未开始 websocket 🚧 开发中 🆗 🚧 开发中 未开始 使用 在 Cargo.toml 中添加依赖 [dependencies]

Rest API to check if a password is in a data breach

easypwned (haveibeenpwned / HIBP) Rest API to check if a password is in a data breach. Works offline - everything stays on your machine! Database is i

OGC API & STAC - Proof of Concept

OAPI - POC Proof of concept (POC) to ingest geospatial datasets from MeteoSuisse into a SpatioTemporal Asset Catalog (STAC), expose as OGC API Feature

A demo of the Internet Computer's Bitcoin API

Bitcoin Integration Demo A demo of the bitcoin endpoints on the Internet Computer. This demo is already deployed to the IC, so you can already try it

An API and test-app that exposes zcash functionality for app consumption

Zingolib This repo provides both a library for zingoproxyclient and zingo-mobile, as well as an included cli application to interact with zcashd via l

API Utility for Hive Blockchain

Apiary - Hive API Utility WIP Todo Full API Coverage Follow Rust API Guidelines: https://rust-lang.github.io/api-guidelines/about.html Implement Displ

Gnosis Safe Tx Service API client & associated tooling

Safe Transaction Service API Client Using the SDK Instantiate an API client use safe_sdk::SafeClient; /// From a chain id, by looking up hardcoded en

Bindings to MLIR using the full C++ API

Mithril Oxide Mithril MLIR is hard to rust but we did it anyway. Rust bindings to MLIR via the C++ API. Project structure mithril-oxide: Our Rusty bin

Owner
Júlio César de Brito Gardona
Father, gopher, rustacean, open sourcerer and digital artist from Brazil.
Júlio César de Brito Gardona
WASM wrapper of mozjpeg, ready for the browser

mozjpeg-wasm This library wraps mozjpeg-sys and exposes a few functions to perform decoding, encoding and simple transformation on JPEG images using m

Tommaso 25 Nov 17, 2022
WebAssembly wrapper of the rage encryption library

rage-wasm: WebAssembly wrapper of rage rage is a simple, modern, and secure file encryption tool, using the age format. It features small explicit key

Kan-Ru Chen 35 Dec 16, 2022
An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and language wrappers. written in rust(🦀) with ❤️

Les.rs - Rust Cryptocurrency Exchange Library An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and

Crabby AI 4 Jan 9, 2023
Rust API guidelines

Rust API guidelines This is a set of recommendations on how to design and present APIs for the Rust programming language. They are authored largely by

The Rust Programming Language 1.1k Jan 3, 2023
Rust API Client for ImageKit.io a file storage and image processing service

Rust API Client for ImageKit.io a file storage and image processing service Usage You must retrieve your Public and Private Keys from the ImageKit Dev

Esteban Borai 4 Jul 31, 2022
A Rust library to interact with the MPesa API, simplifying B2C payment integrations and more.

MPesa SDK (Rust Library) A Rust library to interact with the MPesa API, simplifying B2C payment integrations and more. Features Configuration manageme

Ismael GraHms 8 Aug 23, 2023
A diffusers API in Burn (Rust)

diffusers-burn: A diffusers API in Rust/Burn ⚠️ This is still in development - contributors welcome! The diffusers-burn crate is a conversion of diffu

OxideAI 6 Nov 29, 2023
A Boring(SSL)-compatible API abstraction for Rust cryptographic implementations.

A Boring(SSL)-compatible API abstraction for Rust cryptographic implementations. What is Superboring? Superboring hides the complexity, diversity and

Frank Denis 7 Dec 29, 2023
A Simple Rust NFT API + Smart Contract

Rust NFT API Purpose Rust NFT API is a simple RESTful API developed in Rust that offers functionalities for creating, retrieving, and listing Non-Fung

Luis Soares 5 Feb 25, 2024
A Rust implementation of ECMAScript's Temporal API

Temporal in Rust ⚠️ This crate is highly experimental and NOT stable. We cannot make any guarantee that the API will be stable until 0.1.0. Do not use

Boa 8 Feb 29, 2024