Comments (4)
Here's the poly.add lowering. For x, y
inputs to the addition, with coefficient modulus mod
and bit width B =2^N
in the case that mod
does not divide B
.
c1, n1 = addui_extended(x, y)
c0 = [c1 % mod] + [n1 * (B % mod)] % mod
Is it possible that the following sum overflows mod 2^N
?
[c1 % mod] + [n1 * (B % mod)]
The answer is no. If that were to happen, then
[[(x + y) % B] % mod] + [B % mod] > B
Note both left operands are less than mod
. So if this were true, then
mod > B/2
(strictly greater because it does not divide it).
If so, then
[B % mod] < B/2
Which would imply that
[[(x + y) % B] % mod] > B/2
But this is impossible because mod < B/2
cc @j2kun
from heir.
Why is mod < B/2
? I can imagine a (maybe bizarre) case in which the ring is Z/pZ
, where p
is a prime of the form 2^N - 1
, and N
is the bit width of the container.
I don't think any of the Mersenne primes align with powers of two, so that's why this case is kind of bizarre. But 2^32 - 5 is prime, as is 2^32 - 17 (see https://t5k.org/lists/2small/0bit.html)
from heir.
It's derived from the assumption that the sum overflows (which reaches a contradiction)
[B % mod] < B/2
from heir.
@j2kun 's correction
Following mod > B/2
, B % mod = B - mod
[[(x + y) % B] % mod] + [B % mod] > B
[[(x + y) % B] % mod] > mod
from heir.
Related Issues (20)
- Add `secret.generic` canonicalization pattern removing an unused yielded value
- Integrate Lattigo as a library implementation to target at various levels HOT 2
- [comb to cggi] secret type conversion does not support tensors or memrefs HOT 1
- Add an OpenFHE exit dialect for arithmetic schemes HOT 5
- cggi-to-tfhe-rust: Support conversion of LWE ciphertext tensors
- Migrate to bazel 7
- Not all passes are shown on the website
- Add use-def independence analysis to StraightLineVectorizer HOT 1
- Add a configuration flag that allows `StraightLineVectorizer` to create vectorized ops of a specific width
- tf2fhe: Figure out the correct support for `memref` globals in the pipeline HOT 1
- Improve the toposort algorithm so that it is aware of op compatibility
- [secret]: Invalid parsing of a secret.generic HOT 1
- Weird bug in ListOption? [secret-distribute-generic] HOT 2
- secret canonicalization bug: segfault on eraseOp uses when removing unused yielded values
- secret-capture-generic-ambient-scope hangs on input HOT 1
- secret-capture-generic-ambient-scope: error in replacing the captured variables. HOT 2
- feature: capture ambient scope for generics should copy constants into their bodies instead of add a block arg
- yosys-optimizer: yosys re-orders some inputs, and the code relies on input ordering HOT 1
- cggi-to-comb: does not handle multi-dimensional memrefs properly HOT 4
- comb-to-cggi error when lowering plaintext-only truth table ops
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heir.