Skip to content

feat(transciphering): add OPRF generation - #3835

Merged
nsarlin-zama merged 1 commit into
mainfrom
ns/chore/transciphering_fixes
Aug 21, 2026
Merged

feat(transciphering): add OPRF generation#3835
nsarlin-zama merged 1 commit into
mainfrom
ns/chore/transciphering_fixes

Conversation

@nsarlin-zama

@nsarlin-zama nsarlin-zama commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

closes: please link all relevant issues

PR content/description

small fixes made to the transciphering layer needed for the integer and hl api:

  • orpf generation with dedicated/newtype keys
  • serialization
  • decrypt method on the fhe encrypted key

I created a dedicated TranscipheringParameters enum. For the moment there is only one variant: SameAsCompute. This means that the transciphering key will be created using the compute parameters. This prepares the APIs to future optimizations where we might have dedicated parameters for the transciphering.


This change is Reviewable

@cla-bot cla-bot Bot added the cla-signed label Aug 18, 2026
@nsarlin-zama
nsarlin-zama force-pushed the ns/chore/transciphering_fixes branch from 9d0ec03 to 1d97f98 Compare August 18, 2026 10:22
@github-actions

Copy link
Copy Markdown

ℹ️ Backward-compat snapshot: neutral changes

Only neutral changes were detected. This is expected when introducing new versioned types.


➕ Neutral
  • New enum shortint::backward_compatibility::parameters::transciphering::TranscipheringParametersVersions (1 variants)
  • New enum transciphering::backward_compatibility::AesIvVersions (1 variants)
  • New enum transciphering::backward_compatibility::CompressedTranscipheringServerKeyVersions (1 variants)
  • New enum transciphering::backward_compatibility::KreyviumIVVersions (1 variants)
  • New enum transciphering::backward_compatibility::OneTimePadFheSecretMaskVersions (1 variants)
  • New enum transciphering::backward_compatibility::OneTimePadPlainSecretMaskVersions (1 variants)
  • New enum transciphering::backward_compatibility::SerializableAesFheKeyVersions (1 variants)
  • New enum transciphering::backward_compatibility::SerializableKreyviumFheKeyVersions (1 variants)
  • New enum transciphering::backward_compatibility::TranscipheringPrivateKeyVersions (1 variants)
  • New enum transciphering::backward_compatibility::TranscipheringServerKeyVersions (1 variants)

If you encounter any errors or have doubts, you can verify locally by running:

make backward_correctness BASE_REF=<base_branch_or_commit>

Where BASE_REF is the reference branch or commit to check against.

@github-actions

Copy link
Copy Markdown

Forward compatibility matrix unchanged: it still matches the committed baseline.

Matrix

Which released versions can load data produced by this branch. A ❌ is not a failure by itself: it only means forward compatibility is not (or no longer) provided for that type. What matters is whether it was reviewed.

TYPE 1.5.5 1.6.3 1.7.0
CompactPublicKey
CompactPkeCrs
ProvenCompactCiphertextList

@nsarlin-zama nsarlin-zama changed the title feat(transciphering): add key accessors, OPRF generation and compression feat(transciphering): add OPRF generation Aug 18, 2026
@nsarlin-zama
nsarlin-zama force-pushed the ns/chore/transciphering_fixes branch 2 times, most recently from d33d72b to ad08d5c Compare August 18, 2026 15:35

@mayeul-zama mayeul-zama left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mayeul-zama reviewed 15 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on nsarlin-zama and SouchonTheo).


tfhe/src/shortint/oprf.rs line 700 at r1 (raw file):

                seed,
                &[num_blocks],
                1, // Each ciphertext is a boolean

Could be stored as let max_random_bits_per_block = 1;
Would make easier to understand what this 1 means here without having to look at function definition


tfhe/src/transciphering/ciphers/aes/mod.rs line 102 at r1 (raw file):

            .oprf_key()
            .generate_random_boolean_sequence(seed, 128, sks);
        // Unwrap should not happen because the vec has 128 elements

should not panic
Applies to other places


tfhe/src/transciphering/ciphers/aes/mod.rs line 124 at r1 (raw file):

#[versionize(SerializableAesFheKeyVersions)]
pub struct SerializableAesFheKey {
    key: Vec<Ciphertext>,

I guess a [[Ciphertext; 32]; 4] would work here and simplify length management
Applies to other places


tfhe/src/transciphering/ciphers/aes/mod.rs line 94 at r1 (raw file):

    }

    pub fn random(

Could be called new_random
Applies to other places

@tmontaigu
tmontaigu self-requested a review August 19, 2026 13:57
Co-authored-by: Thomas Montaigu <thomas.montaigu@zama.ai>
Co-authored-by: Arthur Meyre <arthur.meyre@zama.ai>
@nsarlin-zama
nsarlin-zama force-pushed the ns/chore/transciphering_fixes branch from ad08d5c to b210c8a Compare August 20, 2026 16:10

@nsarlin-zama nsarlin-zama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nsarlin-zama made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on mayeul-zama, SouchonTheo, and tmontaigu).


tfhe/src/shortint/oprf.rs line 700 at r1 (raw file):

Previously, mayeul-zama wrote…

Could be stored as let max_random_bits_per_block = 1;
Would make easier to understand what this 1 means here without having to look at function definition

done


tfhe/src/transciphering/ciphers/aes/mod.rs line 94 at r1 (raw file):

Previously, mayeul-zama wrote…

Could be called new_random
Applies to other places

done


tfhe/src/transciphering/ciphers/aes/mod.rs line 102 at r1 (raw file):

Previously, mayeul-zama wrote…

should not panic
Applies to other places

done


tfhe/src/transciphering/ciphers/aes/mod.rs line 124 at r1 (raw file):

Previously, mayeul-zama wrote…

I guess a [[Ciphertext; 32]; 4] would work here and simplify length management
Applies to other places

I tried but I'm not sure it simplifies a lot, converting from [T; 128] to [[T; 32]; 4] is more clunky than it should be (unless you have a recipe I'm missing).

And since it's a serialized object anyway, length will always be runtime checked one way or another

@mayeul-zama mayeul-zama left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

:lgtm:

@mayeul-zama reviewed 4 files and all commit messages, made 2 comments, and resolved 3 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on mayeul-zama, nsarlin-zama, SouchonTheo, and tmontaigu).


tfhe/src/transciphering/ciphers/aes/mod.rs line 124 at r1 (raw file):

Previously, nsarlin-zama (Nicolas Sarlin) wrote…

I tried but I'm not sure it simplifies a lot, converting from [T; 128] to [[T; 32]; 4] is more clunky than it should be (unless you have a recipe I'm missing).

And since it's a serialized object anyway, length will always be runtime checked one way or another

Ok

@nsarlin-zama
nsarlin-zama merged commit f977daa into main Aug 21, 2026
189 of 196 checks passed
@nsarlin-zama
nsarlin-zama deleted the ns/chore/transciphering_fixes branch August 21, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants