Skip to content

Commit

Permalink
fixup! homomorphic: big refactor, renamed homomorphic -> elgamal
Browse files Browse the repository at this point in the history
add method Ciphertext.Select
  • Loading branch information
altergui committed Dec 6, 2024
1 parent da1f17a commit cd5b6db
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions elgamal/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ func (z *Ciphertext) AssertIsEqual(api frontend.API, x *Ciphertext) {
api.AssertIsEqual(z.C2.X, x.C2.X)
api.AssertIsEqual(z.C2.Y, x.C2.Y)
}

// Select if b is true, sets z = i1, else z = i2, and returns z
func (z *Ciphertext) Select(api frontend.API, b frontend.Variable, i1 *Ciphertext, i2 *Ciphertext) *Ciphertext {
z.C1.X = api.Select(b, i1.C1.X, i2.C1.X)
z.C1.Y = api.Select(b, i1.C1.Y, i2.C1.Y)
z.C2.X = api.Select(b, i1.C2.X, i2.C2.X)
z.C2.Y = api.Select(b, i1.C2.Y, i2.C2.Y)
return z
}

0 comments on commit cd5b6db

Please sign in to comment.