Giter VIP home page Giter VIP logo

Comments (4)

Huelse avatar Huelse commented on September 24, 2024

Hello, I have tried some tests with v3.4.5, and it's just working fine. I guess there are some mistakes in your evaluator
Here is my code

from seal import *
from seal_helper import *

print_example_banner("Example: BFV Basics")

parms = EncryptionParameters(scheme_type.BFV)
poly_modulus_degree = 4096  # you can use yours, it just fast
parms.set_poly_modulus_degree(poly_modulus_degree)
parms.set_coeff_modulus(CoeffModulus.BFVDefault(poly_modulus_degree))
parms.set_plain_modulus(1024)  #  any positive integer, maybe a prime number and keep it small will be better in theory

context = SEALContext.Create(parms)
print_parameters(context)
evaluator = Evaluator(context)
encoder = IntegerEncoder(context)
keygen = KeyGenerator(context)
public_key = keygen.public_key()
secret_key = keygen.secret_key()
encryptor = Encryptor(context, public_key)
decryptor = Decryptor(context, secret_key)

value1 = -7
plain1 = Plaintext(encoder.encode(value1))
value2 = 25
plain2 = Plaintext(encoder.encode(value2))


x1 = Ciphertext()
encryptor.encrypt(plain1, x1)
evaluator.add_plain_inplace(x1, plain2)
evaluator.multiply_plain_inplace(x1, plain2)

p1 = decryptor.decrypt(x1)
v1 = encoder.decode_int64(p1)
print(v1)  # 450

from seal-python.

tedw-tech avatar tedw-tech commented on September 24, 2024

Hey,
thanks for the quick reply!

I just ran that code and it does work, however, when I add another multiplication (after the already existing one), the output is 11250, shouldn't it be 1010? Or am I confusing the plaintext modulus here with what would happen if I used batching?

from seal-python.

Huelse avatar Huelse commented on September 24, 2024

(25-7)x25x25=11250, I think it's right.
For the detail, you can refer to the notes from the example.
or the paper, which implements the BFV scheme.

from seal-python.

tedw-tech avatar tedw-tech commented on September 24, 2024

Ah, sorry, I got something mixed up with the parameters! Never mind, so no problem after all.

from seal-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.