Skip to main content

Python bindings for Lylacore (soul-crypto + coach-engine)

Project description

Lylacore Python Bindings

Authors: Joysusy & Violet Klaudia 💖

Python bindings for Lylacore - cryptographic primitives and communication style coaching for AI agent identity systems.

Features

  • soul-crypto: AES-256-GCM encryption with Argon2id/PBKDF2/Scrypt key derivation
  • coach-engine: Communication style analysis and adaptation (coming soon)

Installation

pip install lylacore

Quick Start

import asyncio
import lylacore

async def main():
    # Generate a salt for key derivation
    salt = lylacore.Salt.generate()

    # Derive an encryption key from a passphrase
    key = await lylacore.derive_key("my-secure-passphrase", salt)

    # Encrypt some data
    plaintext = b"Secret message"
    nonce, ciphertext, auth_tag = lylacore.encrypt(plaintext, key)

    # Decrypt the data
    decrypted = lylacore.decrypt(ciphertext, key, nonce, auth_tag)
    assert decrypted == plaintext

    print("Encryption/decryption successful!")

asyncio.run(main())

API Reference

Classes

Salt

A 32-byte cryptographic salt for key derivation.

  • Salt.generate() - Generate a new random salt
  • Salt(data: bytes) - Create from existing bytes
  • salt.as_bytes() - Get raw bytes

Nonce

A 12-byte nonce for AES-GCM encryption.

  • Nonce.generate() - Generate a new random nonce
  • Nonce(data: bytes) - Create from existing bytes
  • nonce.as_bytes() - Get raw bytes

Key

A 32-byte encryption key.

  • key.as_bytes() - Get raw bytes (handle with care!)

AuthTag

A 16-byte authentication tag for AES-GCM.

  • AuthTag(data: bytes) - Create from existing bytes
  • auth_tag.as_bytes() - Get raw bytes

DeriveKeyOptions

Configuration for key derivation.

  • DeriveKeyOptions(algorithm="argon2id") - Options: "argon2id", "pbkdf2", "scrypt"

Functions

async derive_key(passphrase: str, salt: Salt, options: DeriveKeyOptions = None) -> Key

Derive an encryption key from a passphrase using a memory-hard KDF.

Parameters:

  • passphrase - User's passphrase (UTF-8 string)
  • salt - 32-byte salt (use Salt.generate() for new keys)
  • options - Optional KDF configuration (defaults to argon2id)

Returns: A 32-byte encryption key

encrypt(plaintext: bytes, key: Key) -> tuple[Nonce, bytes, AuthTag]

Encrypt data using AES-256-GCM.

Parameters:

  • plaintext - Data to encrypt
  • key - Encryption key from derive_key()

Returns: Tuple of (nonce, ciphertext, auth_tag)

decrypt(ciphertext: bytes, key: Key, nonce: Nonce, auth_tag: AuthTag) -> bytes

Decrypt data using AES-256-GCM.

Parameters:

  • ciphertext - Encrypted data
  • key - Same key used for encryption
  • nonce - Nonce from encrypt()
  • auth_tag - Authentication tag from encrypt()

Returns: Original plaintext

Security Notes

  • Never reuse a nonce with the same key
  • Store salt, nonce, and auth_tag alongside ciphertext (they're safe to store publicly)
  • Never log or display keys - use key.as_bytes() only when necessary
  • Argon2id is recommended for new applications (best resistance against attacks)

Requirements

  • Python 3.9+
  • Works on Windows, macOS, and Linux

License

MIT License - see LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lylacore-0.1.6.tar.gz (58.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lylacore-0.1.6-cp39-abi3-win_amd64.whl (308.2 kB view details)

Uploaded CPython 3.9+Windows x86-64

lylacore-0.1.6-cp39-abi3-macosx_11_0_arm64.whl (334.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

lylacore-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (385.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file lylacore-0.1.6.tar.gz.

File metadata

  • Download URL: lylacore-0.1.6.tar.gz
  • Upload date:
  • Size: 58.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lylacore-0.1.6.tar.gz
Algorithm Hash digest
SHA256 72cb7829a9ec231a2758755cbf138c1fa8656ca74c31a3ed7674334d9bf36e4e
MD5 4d9342ea7ec4e66942433531f00d8d92
BLAKE2b-256 de969dd62963d809fa90952c3ca1b2c26580b241c2829d9ba0adb815ca0ac68e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.6.tar.gz:

Publisher: release-python.yml on joySUSY/lylacore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lylacore-0.1.6-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: lylacore-0.1.6-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 308.2 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lylacore-0.1.6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 15fad02dc98e7de5f860a8ec608ec7f969368fa17c1a73a79ae800ca39d1dc02
MD5 19cd29eb877c4bf8f504a682f5c5a09d
BLAKE2b-256 fe6164c0b05f1ad2e57677c786813d2e2c7801aa5781c33a76806e25dafbbb77

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.6-cp39-abi3-win_amd64.whl:

Publisher: release-python.yml on joySUSY/lylacore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lylacore-0.1.6-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lylacore-0.1.6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 333b069f46837e3753498445a4bd03e303883350f903b381a7e0ba3dc5086e04
MD5 84f14746c4df01dc523c2ef28da8c3f3
BLAKE2b-256 01c72048b01caa970357db9f58a84fa6f3fd7f8880857adc7ef4d31a6a5f458f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.6-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on joySUSY/lylacore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lylacore-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lylacore-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16e979885dbb79190d74d3b181661eaef78419c81c76a3b6570f7bbfd3f804ec
MD5 bbdd9b7eb64690987a3f5c39c2a9f60c
BLAKE2b-256 d3f2be1af6c2e183813104a00224ac07c2b808d6186277beb5b4e79a1da12014

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python.yml on joySUSY/lylacore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page