Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

libsodium

БесплатноБез исполняемых скриптовНе проверен

libsodium — modern, easy-to-use, audited crypto library. Provides authenticated encryption (XSalsa20-Poly1305, XChaCha20-Poly1305, AES-GCM), public-key…

claude-dev-suiteот claude-dev-suite★ 51 звезда на GitHub

Об этом скилле

libsodium

Deep Knowledge: Use mcp__documentation__fetch_docs with technology: libsodium.

Why libsodium

libsodium is the safest general-purpose crypto library for application-level use:

  • Modern primitives with sensible defaults (XChaCha20-Poly1305, X25519, Ed25519, Argon2id)
  • Misuse-resistant API — no nonce reuse traps, no IV management mistakes
  • Audited by multiple third parties
  • Bindings everywhere — C, Rust, Python, JS, Java/Kotlin, Swift, Go
  • Permissive license (ISC)
  • Constant-time implementations

For wallet apps, libsodium covers everything except secp256k1 (Bitcoin). Pair with secp256k1 for full coverage.

Primitives Cheat Sheet

Need Use Function family
Symmetric authenticated encryption XChaCha20-Poly1305 crypto_secretbox
Streaming symmetric encryption XChaCha20-Poly1305 + chunks crypto_secretstream
Public-key encryption X25519 + XSalsa20-Poly1305 crypto_box
Hybrid (sealed) public-key encryption X25519 anonymous crypto_box_seal
Digital signatures Ed25519 crypto_sign
Key exchange X25519 crypto_kx
Password hashing Argon2id crypto_pwhash
Generic hashing BLAKE2b crypto_generichash
MAC HMAC-SHA256/512 crypto_auth
Key derivation from key HKDF / BLAKE2b crypto_kdf
Random bytes ChaCha20 (CSPRNG) randombytes_buf
Constant-time compare — sodium_memcmp
Memory wipe — sodium_memzero

Rust — sodiumoxide or dryoc

For new Rust code, prefer dryoc (pure Rust, no system deps):

[dependencies]
dryoc = "0.7"
use dryoc::dryocsecretbox::DryocSecretBox;
use dryoc::types::*;

fn encrypt_seed(seed: &[u8], key: &[u8; 32]) -> (Vec<u8>, Vec<u8>) {
    let nonce = dryoc::dryocsecretbox::Nonce::gen();
    let key_array: dryoc::dryocsecretbox::Key = dryoc::dryocsecretbox::Key::try_from(key).unwrap();
    let ciphertext = DryocSecretBox::encrypt_to_vecbox(seed, &nonce, &key_array);
    (nonce.to_vec(), ciphertext.to_vec())
}

fn decrypt_seed(ciphertext: &[u8], nonce: &[u8], key: &[u8; 32]) -> Result<Vec<u8>, dryoc::Error> {
    let key_array: dryoc::dryocsecretbox::Key = dryoc::dryocsecretbox::Key::try_from(key).unwrap();
    let nonce_array: dryoc::dryocsecretbox::Nonce = dryoc::dryocsecretbox::Nonce::try_from(nonce).unwrap();
    let secret_box = DryocSecretBox::from_bytes(ciphertext)?;
    secret_box.decrypt_to_vec(&nonce_array, &key_array)
}

Or use sodiumoxide (binds the C lib):

[dependencies]
sodiumoxide = "0.2"
use sodiumoxide::crypto::secretbox;

sodiumoxide::init().unwrap();

let key = secretbox::gen_key();
let nonce = secretbox::gen_nonce();
let ciphertext = secretbox::seal(b"plaintext", &nonce, &key);
let plaintext = secretbox::open(&ciphertext, &nonce, &key).unwrap();

SecretBox (Symmetric Authenticated Encryption)

use dryoc::dryocsecretbox::DryocSecretBox;

let key = dryoc::dryocsecretbox::Key::gen();      // 32 bytes
let nonce = dryoc::dryocsecretbox::Nonce::gen();  // 24 bytes (XSalsa20)

let ciphertext = DryocSecretBox::encrypt_to_vecbox(b"plaintext", &nonce, &key);
let plaintext = ciphertext.decrypt_to_vec(&nonce, &key).unwrap();

Critical: never reuse the same (key, nonce) pair. With XSalsa20's 24-byte nonce, random nonces are safe (~2^96 messages).

SecretStream (Authenticated Streaming)

For encrypting files in chunks (constant memory, can stream from network):

use dryoc::dryocstream::*;

// Encrypt
let key = Key::gen();
let mut push_stream = DryocStream::init_push(&key);
let header = push_stream.header().clone();

let mut output = Vec::new();
output.extend_from_slice(header.as_array());

for chunk in chunks(input, 64 * 1024) {
    let tag = if chunk.is_last { Tag::FINAL } else { Tag::MESSAGE };
    let encrypted = push_stream.push_to_vec(chunk.data, None, tag).unwrap();
    output.extend_from_slice(&encrypted);
}

// Decrypt
let header_bytes = &input[0..Header::LEN];
let mut pull_stream = DryocStream::init_pull(&key, header_bytes.try_into().unwrap()).unwrap();

let mut decrypted = Vec::new();
let mut offset = Header::LEN;
while offset < input.len() {
    let chunk_end = (offset + chunk_size).min(input.len());
    let (data, tag) = pull_stream.pull_to_vec(&input[offset..chunk_end], None).unwrap();
    decrypted.extend_from_slice(&data);
    offset = chunk_end;
    if tag == Tag::FINAL { break; }
}

Use case: encrypted backups, log files, large blobs — anything you don't want to load entirely into memory.

Password Hashing — Argon2id

For deriving keys from user passwords (or wrapping wallet seed encryption keys with a password).

use dryoc::pwhash::*;

let password = b"correct horse battery staple";
let salt = Salt::gen();

// Hash for storage (stretched with Argon2id)
let hash = VecPwHash::hash_with_salt(
    password,
    salt.clone(),
    Config::sensitive(),
Полный SKILL.md на GitHub

Установить libsodium в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob
Write
Edit

FAQ

Что делает скилл libsodium?

libsodium — modern, easy-to-use, audited crypto library. Provides authenticated encryption (XSalsa20-Poly1305, XChaCha20-Poly1305, AES-GCM), public-key cryptography (X25519, Ed25519), key derivation (Argon2id, HKDF, BLAKE2b), password hashing, and authenticated streams (secretstream). Wraps NaCl with better defaults. Bindings for Rust (sodiumoxide, libsodium-sys-stable, dryoc), Python (PyNaCl), JS (libsodium-wrappers), Java/Android (lazysodium-android), Swift (Sodium / Clibsodium). USE WHEN: user mentions "libsodium", "NaCl", "Sodium", "secretbox", "crypto_secretstream", "Argon2", "Argon2id", "X25519", "Ed25519", "PyNaCl", "lazysodium", "ChaCha20-Poly1305", "XSalsa20" DO NOT USE FOR: SQLite encryption - use `databases/sqlcipher` DO NOT USE FOR: File encryption format - use `security/age-encryption` DO NOT USE FOR: Bitcoin/secp256k1 crypto - use `bitcoin/cryptography/*` DO NOT USE FOR: TLS - use `security/rustls` or platform TLS stack

Как установить скилл libsodium?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл libsodium запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить libsodium с