JuliaCrypto / SEAL.jl

SEAL.jl is an easy-to-use wrapper for the original SEAL library and supports homomorphic encryption with the BFV and CKKS schemes.

Home Page:https://juliacrypto.github.io/SEAL.jl/stable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negative numbers in plaintext raises error

narger-ef opened this issue · comments

Hello there, it's always me :D

I was wondering if I'm doing something wrong or it's just a casting problem with the "-" symbol.

In practical, the code

Plaintext("-1")
or
Plaintext(string(-1))

raises an Invalid argument error

Am I doing something wrong?
Unfortunately I can't use C++ version therefore I can't tell if this doesn't even work on C++

Thank you!

Here are the formatting rules from the SEAL source code:

        The string description of the polynomial must adhere to the format returned
        by to_string(),
        which is of the form "7FFx^3 + 1x^1 + 3" and summarized by the following
        rules:
        1. Terms are listed in order of strictly decreasing exponent
        2. Coefficient values are non-negative and in hexadecimal format (upper
        and lower case letters are both supported)
        3. Exponents are positive and in decimal format
        4. Zero coefficient terms (including the constant term) may be (but do
        not have to be) omitted
        5. Term with the exponent value of one must be exactly written as x^1
        6. Term with the exponent value of zero (the constant term) must be written
        as just a hexadecimal number without exponent
        7. Terms must be separated by exactly <space>+<space> and minus is not
        allowed
        8. Other than the +, no other terms should have whitespace

In 2. it says "coefficient values are non-negative". Thus, I hope this answers your question.

Ok thanks, sorry for the trivial question.

I guess, in general, there is always need to:

negate!(c, c, evaluator)

Feel free to close this issue if it has been resolved.

Thank you again !