# pyqrllib

> [!NOTE]
> This code relates to version 1.x of QRL, the world's first open-source PQ
> blockchain, which has been securing digital assets since December 2016.
> The next generation of QRL, version 2.0, is in development and has its own
> repositories. See [this discussion page](https://github.com/orgs/theQRL/discussions/2).

`pyqrllib` is the Python binding for the QRL core cryptographic library. It
exposes the QRL XMSS implementation, SHA2-256 and SHAKE hashing, address and
mnemonic helpers, and the repository's historical Dilithium and Kyber APIs.

This project is under active development. Interfaces and serialized formats
may change without backward compatibility.

## Install

```bash
python3 -m pip install pyqrllib
```

The Python package is tested on Linux x64.

## Cryptographic standards status

The XMSS parameters selected for QRL predate NIST's standardization in
[SP 800-208](https://csrc.nist.gov/pubs/sp/800/208/final). The formats and
parameter choices implemented here are QRL-specific.

The Kyber and Dilithium APIs use pre-standard candidate-era implementations
retained for QRL v1 compatibility. They do not implement ML-KEM (FIPS 203) or
ML-DSA (FIPS 204).

## XMSS state belongs to the caller

Never reuse an XMSS OTS index with the same private key. Reuse can make
forgery possible. See
[RFC 8391 section 1.1](https://www.rfc-editor.org/rfc/rfc8391.html#section-1.1).

Best practice is to keep signing under application and user control. Maintain
an independent, durable ledger of every OTS index reserved or consumed by a
signing attempt. When a signature is returned, associate the signature or its
stable identifier with that index in the ledger. Coordinate the ledger across
all processes, objects, backups, and restored seeds, enforcing the requirement
for copied or partitioned keys in
[RFC 8391 section 4.1.12](https://www.rfc-editor.org/rfc/rfc8391.html#section-4.1.12).
Reserve and persist an index before signing, and burn it even if signing fails.
This ordering follows
[RFC 8391 section 4.1.9](https://www.rfc-editor.org/rfc/rfc8391.html#section-4.1.9).
Do not use the signer's in-memory index as the only record.

Copying a signer or reconstructing it from the same seed does not create a new
key or an independent index space.

`getSK`, `getSeed`, `getHexSeed`, and `getMnemonic` export private key
material. Returned Python objects are controlled by the caller and may have
runtime copies that qrllib cannot erase. Internal erasure is defense in depth,
not a guarantee that no compiler, runtime, allocator, operating system, or
third-party copy remains. Export secrets only when needed, keep them out of
logs, and overwrite mutable caller-owned buffers before release.

Project source, platform coverage, and development commands are in the
[repository README](https://github.com/theQRL/qrllib#readme).
