skills/computer-science/cs-crypto/SKILL.md
Cryptography: AES, RSA/ECC, SHA-256/Blake3, PKI/X.509, TLS, digital signatures, ZKP, quantum resistance
npx skillsauth add alphaonedev/openclaw-graph cs-cryptoInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill equips the AI to implement and utilize cryptographic techniques for data security, including encryption, hashing, key management, and protocols like TLS, ensuring secure operations in code or CLI environments.
Always initialize cryptographic operations with secure random keys and handle exceptions for invalid inputs. For AES encryption, generate a key first, then encrypt/decrypt in a single function call. Use hardware security modules (HSMs) for key storage if available. Pattern for hashing: input data -> hash object -> update and finalize. For TLS, wrap sockets with SSL contexts. Example pattern in Python:
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
key = b'32-byte-key-for-aes-256' # Use secure key generation
iv = os.urandom(16)
cipher = Cipher(algorithms.AES(key), modes.CBC(iv))
encryptor = cipher.encryptor()
encrypted = encryptor.update(b"plaintext") + encryptor.finalize()
For CLI, pipe inputs to OpenSSL commands with specific flags.
openssl enc -aes-256-cbc -pbkdf2 -iter 10000 -in input.file -out output.enc -k $ENCRYPT_KEY (use -salt for added security).openssl genpkey -algorithm RSA -out private.pem -pkeyopt rsa_keygen_bits:2048 then export public key with openssl rsa -in private.pem -pubout -out public.pem.echo -n "data_to_hash" | openssl dgst -sha256 -binary | base64 or in Python: import hashlib; hash_obj = hashlib.sha256(b"data").digest().openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -subj "/CN=example.com".import ssl; context = ssl.create_default_context(); context.load_cert_chain(certfile="cert.pem", keyfile="key.pem").openssl dgst -sha256 -sign private.pem -out signature.bin input.file, verify with openssl dgst -sha256 -verify public.pem -signature signature.bin input.file.from libzkp import prove; proof = prove(statement, witness).oqsprov genpkey -algorithm Kyber512 -out key.pem.Install required libraries first, e.g., pip install cryptography openssl or use system OpenSSL. For authenticated services like cloud KMS, set environment variables: export AWS_KMS_KEY=$SERVICE_API_KEY and reference in code, e.g., os.environ.get('AWS_KMS_KEY'). Handle keys via secure vaults; never log them. For multi-tool integration, wrap OpenSSL in scripts: import subprocess and run subprocess.run(['openssl', 'enc', ...]). Ensure compatibility with languages like Python or Go; for Go, use crypto/aes package.
Always wrap cryptographic calls in try-except blocks to catch specific exceptions, e.g., in Python: from cryptography.exceptions import InvalidSignature; try: verifier.verify(signature, data) except InvalidSignature: raise ValueError("Signature invalid"). For CLI, check exit codes: if openssl command fails, parse stderr for errors like "bad decrypt" and retry with correct key. Common issues: invalid keys (use openssl errstr for codes), hash mismatches (recompute and compare), or TLS handshake failures (debug with -debug flag). Log errors with context, e.g., key length or mode errors, and fallback to alternative algorithms if needed.
Encrypt a sensitive string with AES-256-GCM and decrypt it: In Python:
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
key = b'32-byte-long-secret-key-here'
aesgcm = AESGCM(key)
nonce = os.urandom(12)
encrypted = aesgcm.encrypt(nonce, b"confidential data", None)
decrypted = aesgcm.decrypt(nonce, encrypted, None) # Output: b"confidential data"
Use this for securing API payloads; store nonce with encrypted data.
Generate an RSA key pair, sign a message, and verify the signature:
Via CLI: First, generate keys: openssl genrsa -out private.pem 2048. Sign: openssl dgst -sha256 -sign private.pem -out sig.bin message.txt. Verify: openssl dgst -sha256 -verify public.pem -signature sig.bin message.txt (outputs "Verified OK" if successful).
In code (Python):
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
signature = private_key.sign(b"message", padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.MAX_LENGTH), hashes.SHA256())
public_key = private_key.public_key()
public_key.verify(signature, b"message", padding.PSS(...), hashes.SHA256()) # No error if valid
Apply this for authenticating transactions or documents.
tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui