Skip to content

Commit

Permalink
docs: Fix ModSwitch, Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sp301415 committed Jun 7, 2024
1 parent ecf6c08 commit a08aaa7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ fmt.Println(dec.DecryptLWEBool(ctOut)) // false

## Benchmarks
All results were measured from Intel i5-13400F, with roughly equivalent parameters.
|Operation|TFHE-go|TFHE-rs (v0.6.0)|
|Operation|TFHE-go|TFHE-rs (v0.6.1)|
|---------|-------|-------|
|Gate Bootstrapping|8.22ms|8.82ms|
|Programmable Bootstrapping (6 bits)|26.78ms|72.93ms|
|Gate Bootstrapping|8.13ms|8.45ms|
|Programmable Bootstrapping (6 bits)|26.30ms|69.22ms|

## Security
TFHE-go has not been audited or reviewed by security experts, and may contain critical vulnerabilities. Use at your own risk. See [SECURITY](https://github.com/sp301415/tfhe-go/blob/master/SECURITY.md) for more details.
Expand Down
4 changes: 2 additions & 2 deletions mktfhe/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (e *Evaluator[T]) BlindRotate(ct LWECiphertext[T], lut tfhe.LookUpTable[T])
return ctOut
}

// BlindRotateAssign assigns the blind rotation of LWE ciphertext with respect to LUT to ctOut.
// BlindRotateAssign computes the blind rotation of LWE ciphertext with respect to LUT and writes it to ctOut.
func (e *Evaluator[T]) BlindRotateAssign(ct LWECiphertext[T], lut tfhe.LookUpTable[T], ctOut GLWECiphertext[T]) {
ctOut.Clear()

Expand All @@ -106,7 +106,7 @@ func (e *Evaluator[T]) BlindRotateParallel(ct LWECiphertext[T], lut tfhe.LookUpT
return ctOut
}

// BlindRotateParallelAssign assigns the blind rotation of LWE ciphertext with respect to LUT to ctOut in parallel.
// BlindRotateParallelAssign computes the blind rotation of LWE ciphertext with respect to LUT and writes it to ctOut in parallel.
func (e *Evaluator[T]) BlindRotateParallelAssign(ct LWECiphertext[T], lut tfhe.LookUpTable[T], ctOut GLWECiphertext[T]) {
ctOut.Clear()

Expand Down
7 changes: 3 additions & 4 deletions tfhe/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@ func (e *Evaluator[T]) BootstrapLUTAssign(ct LWECiphertext[T], lut LookUpTable[T
}
}

// ModSwitch computes x2N = round(2N * x / Q)
// and returns x2N as an unsigned representation.
// ModSwitch switches the modulus of x from Q to 2 * LookUpTableSize.
func (e *Evaluator[T]) ModSwitch(x T) int {
return int(math.Round(e.modSwitchConstant * float64(x)))
return int(math.Round(e.modSwitchConstant*float64(x))) % (2 * e.Parameters.lookUpTableSize)
}

// BlindRotate returns the blind rotation of LWE ciphertext with respect to LUT.
Expand All @@ -133,7 +132,7 @@ func (e *Evaluator[T]) BlindRotate(ct LWECiphertext[T], lut LookUpTable[T]) GLWE
return ctOut
}

// BlindRotateAssign computes the blind rotation of LWE ciphertext with respect to LUT.
// BlindRotateAssign computes the blind rotation of LWE ciphertext with respect to LUT, and writes it to ctOut.
func (e *Evaluator[T]) BlindRotateAssign(ct LWECiphertext[T], lut LookUpTable[T], ctOut GLWECiphertext[T]) {
switch {
case e.Parameters.lookUpTableSize > e.Parameters.polyDegree:
Expand Down

0 comments on commit a08aaa7

Please sign in to comment.