Skip to content

Migrating from OPPRL v2 to v3

OPPRL v3 is the post-quantum version of the protocol. It replaces the RSA key pair used by v1 and v2 with an ML-KEM-1024 key pair (FIPS 203). When you share data, ephemeral tokens are protected with ML-KEM key encapsulation plus AES-256-GCM instead of RSA-OAEP. Someone who records your data in transit today cannot decrypt it later with a quantum computer.

New integrations should use OpprlV3. Upgrading spindle-token to 3.0 does not force a migration: OpprlV0, OpprlV1 and OpprlV2 are unchanged, and existing code keeps producing the same tokens.

Are v3 tokens compatible with v2 tokens?

No. Plan the migration around these rules:

  • v3 tokens never match v2 tokens, even for identical PII. v3 derives its tokenization key from the ML-KEM private key, not the RSA key, so a v2 token and a v3 token for the same person are different strings.
  • Keys are not interchangeable. v3 needs an ML-KEM private key (a 64-byte seed) and the recipient's ML-KEM public key (1,568 bytes). RSA PEM keys are rejected for v3, and ML-KEM keys are rejected for v1/v2.
  • Ephemeral tokens are version-specific. A v2 ephemeral token can only be restored with OpprlV2, and a v3 one only with OpprlV3. Agree on the version with your data partner before you send data. It cannot be detected from the tokens.
  • One version per operation. A single tokenize, transcrypt_out or transcrypt_in call (or CLI command) cannot mix v3 tokens with tokens from another version. It raises a ValueError if you try. Process each version in a separate call.

The token structure is the same in both versions: the same 13 tokens, built from the same attributes with the same normalization rules. Only the cryptography and the token names differ (opprl_token_1v3 instead of opprl_token_1v2).

Migration steps

  1. Upgrade to spindle-token>=3.0.0.

  2. Generate an ML-KEM key pair and store the private key in your secrets manager.

    from spindle_token import generate_keys
    
    private_seed, public_key = generate_keys()  # ML-KEM by default
    

    Or from the command line: spindle-token keygen private.key public.key. To use environment variables, set SPINDLE_TOKEN_PRIVATE_KEY to the base64 of the private seed.

  3. Exchange ML-KEM public keys with your data partners, and authenticate them the same way you authenticate RSA public keys today.

  4. Re-tokenize your datasets from the source PII with OpprlV3. Replace OpprlV2 with OpprlV3 in your attribute mapping and token list; nothing else changes.

    from spindle_token import tokenize
    from spindle_token.opprl import OpprlV3
    
    tokens = tokenize(
        pii,
        col_mapping={
            OpprlV3.first_name: "first_name",
            OpprlV3.last_name: "last_name",
            OpprlV3.gender: "gender",
            OpprlV3.birth_date: "birth_date",
        },
        tokens=[OpprlV3.token1, OpprlV3.token2, OpprlV3.token3],
        private_key=private_seed,
    )
    

    Because v2 and v3 tokens never match, link a v2 dataset only to other v2 datasets, and a v3 dataset only to other v3 datasets. Keep your v2 RSA key until no dataset you still link against uses v2 tokens.

  5. Switch data sharing to v3 with each partner once both sides have v3 keys and v3 datasets. Until then, keep exchanging v2 ephemeral tokens with partners who have not migrated.

Choosing when to migrate

On Dec 2, 2026 the NSA advised an immediate transition to post-quantum cryptography, because adversaries are already collecting encrypted data to decrypt once quantum computers can. The RSA transcryption in v1/v2 is exposed to that kind of attack. Datasets that never leave your organization are not transcrypted, so their exposure is lower. Migrate the data you share first.