Skip to content

BGV/BFV inverse of p mod Q #733

Open

Description

Hi,

I have a (perhaps dumb) question. In BGV or BFV, the plaintext modulus is p or p^r and Q represents the ciphertext modulus. Is there any function to compute p^{-1} mod Q? I was looking at try_invert_uint_mod (https://github.com/microsoft/SEAL/blob/main/native/src/seal/util/uintarithmod.cpp#L15) but it only supports uint64 values, while Q can go more than 64-bit.

Thanks!

Activity

  1. kimlaine commented on Nov 17, 2025

    @kimlaine
    Contributor

    The function in uintarithmod.cpp supports integers modulo a multi-word modulus. There are some overloads that are for single-word moduli, and in fact they are used (almost) always. Actually, I'm not sure if the multi-word function you mentioned is used at all, because everything is done in CRT representation.

    So, I'm not really sure what your question is. The function you pointed out takes uint64_count (the word count) as a parameter.

  2. wahyudierwin commented on Nov 17, 2025

    @wahyudierwin
    Author

    Thanks for your response, Kim Laine (@kimlaine) . I just realized my question is ambiguous and confusing, my bad.

    What I'm looking for is the ctxt.divideByP() function similar to HElib (https://github.com/homenc/HElib/blob/master/src/Ctxt.cpp#L2415). Is there any such function in SEAL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions