Code Monkey home page Code Monkey logo

Comments (3)

FlorentCLMichel avatar FlorentCLMichel commented on August 15, 2024

Hi,

(Disclaimer : I'm not affiliated with Zama, and just happened to have had similar issues before. Obviously, if there is any contradiction, an answer given by a member of the Zama team should be seen as more trustworthy than mine.)

I think the issue here is that Rust does not automatically convert between integer types (like 2) and floating-point types (like 2.). Your code may work if you add a dot after the 2, e.g, replace 2*x*x by 2.*x*x. For instance, to compute 2x^2, replacing the line

    let encoder_output = Encoder::new(0., 100., 6, 0)?;

by

    let encoder_output = Encoder::new(0., 200., 6, 0)?;

and

    let c2 = c1.bootstrap_with_function(&bsk, |x| x * x, &encoder_output)?;

by

    let c2 = c1.bootstrap_with_function(&bsk, |x| 2. * x * x, &encoder_output)?;

in the example should work.

As far as I am aware, programmable bootstrapping only allows to evaluate univariate functions, and so can not be used to compute (x+y)/2 if x and y are different messages. However, since this particular function is linear, it can be reconstructed using ciphertext addition (see https://docs.zama.ai/concrete/lib/simple-operations/adding-two-ciphertexts.html) and multiplication by a constant (https://docs.zama.ai/concrete/lib/simple-operations/multiplying-a-ciphertext-by-a-constant.html#multiplying-an-lwe-by-a-real-constant), e.g.

x.add_with_padding_inplace(&y)?;
x.mul_constant_with_padding_inplace(0.5, 0.5, 4)?;

(The second and third parameters may not be optimal for your use case.)

from concrete.

aPere3 avatar aPere3 commented on August 15, 2024

Hello @dimk1 👋 ,

Thanks @FlorentCLMichel for answering on this one 🙂 .

Indeed, your problem is just that the 2 literal is expected to be coerced to an integer type by the compiler, whereas 2. is coerced to a floating point number type. Usually if you see {integer} or {float} in an error message, it means that the compiler is not able to coerce a numeric literal to a raw type.

Also, note that in Rust, the ^ operator is not used for exponentiation, but for bitwise xoring.

For multivariate bootstrap, there is, to the best of our knowledge, no solution to support it in a general way unfortunately.

I close the issue since there is nothing actionable on our side, but feel free to add more comments or open a new one if necessary 🙂

from concrete.

dimk1 avatar dimk1 commented on August 15, 2024

Excellent support, thank you very much.

from concrete.

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.