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.7.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.7-cp39-abi3-win_amd64.whl (308.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

lylacore-0.1.7-cp39-abi3-macosx_11_0_arm64.whl (334.6 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

lylacore-0.1.7-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.7.tar.gz.

File metadata

  • Download URL: lylacore-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 874f77bb173a101ec4830e37bb86370c6c1b28775c0cbd9c0de9aac5c2ea2c5b
MD5 9568dd6ceac4ef962b23b69e2fa8c25b
BLAKE2b-256 80314c4862d7c64c3f5987994c8c411119df357f5978bbbe7ec82b89fc709609

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.7.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.7-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: lylacore-0.1.7-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 308.3 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.7-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0b0bc915fed3b577d68536c2d3a05aea3482eeb9da40646007c146ea1c1b9da2
MD5 c99acee4d19f510fb6ad4bc47184b103
BLAKE2b-256 5d3b8bcba6c8a3ca076e20e5290b7ec80700bd71497491cbdd63be326375303a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.7-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.7-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lylacore-0.1.7-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eae85e4b8cb96f9fcd5b6d777a45ba1d1da48c714d29e504266bf06851a45cd6
MD5 cfe4545ae99b91efe3b349b82e680131
BLAKE2b-256 65270b8480c144207cc9c61625dedbbdf0f9a66b50f5bb0ade8b460b1b2aa9d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.7-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.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lylacore-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3b06c9f579f1fa26f14fc3b95fff26daec8a82aa79afa893afc3bdcbe15e66a
MD5 4cd8f8f21953fcfc387d5a736a96693f
BLAKE2b-256 41621a4378eda18c90f4a5af9b5b7808bb9299d3813d5e4a8c0b1679d27108a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lylacore-0.1.7-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