Skip to content

Commit

Permalink
rename ./mhe to ./multi_party
Browse files Browse the repository at this point in the history
  • Loading branch information
qantik committed Jul 24, 2024
1 parent c35663d commit ea81515
Show file tree
Hide file tree
Showing 63 changed files with 163 additions and 9,302 deletions.
20 changes: 10 additions & 10 deletions examples/multi_party/int_pir/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/tuneinsight/lattigo/v5/core/rlwe"
"github.com/tuneinsight/lattigo/v5/mhe"
"github.com/tuneinsight/lattigo/v5/multi_party"
"github.com/tuneinsight/lattigo/v5/ring"
"github.com/tuneinsight/lattigo/v5/schemes/bgv"
"github.com/tuneinsight/lattigo/v5/utils/sampling"
Expand Down Expand Up @@ -36,11 +36,11 @@ type party struct {
sk *rlwe.SecretKey
rlkEphemSk *rlwe.SecretKey

ckgShare mhe.PublicKeyGenShare
rkgShareOne mhe.RelinearizationKeyGenShare
rkgShareTwo mhe.RelinearizationKeyGenShare
gkgShare mhe.GaloisKeyGenShare
cksShare mhe.KeySwitchShare
ckgShare multi_party.PublicKeyGenShare
rkgShareOne multi_party.RelinearizationKeyGenShare
rkgShareTwo multi_party.RelinearizationKeyGenShare
gkgShare multi_party.GaloisKeyGenShare
cksShare multi_party.KeySwitchShare

input []uint64
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func cksphase(params bgv.Parameters, P []*party, result *rlwe.Ciphertext) *rlwe.

l.Println("> KeySwitch Phase")

cks, err := mhe.NewKeySwitchProtocol(params, ring.DiscreteGaussian{Sigma: 1 << 30, Bound: 6 * (1 << 30)}) // Collective public-key re-encryption
cks, err := multi_party.NewKeySwitchProtocol(params, ring.DiscreteGaussian{Sigma: 1 << 30, Bound: 6 * (1 << 30)}) // Collective public-key re-encryption
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func ckgphase(params bgv.Parameters, crs sampling.PRNG, P []*party) *rlwe.Public

l.Println("> PublicKeyGen Phase")

ckg := mhe.NewPublicKeyGenProtocol(params) // Public key generation
ckg := multi_party.NewPublicKeyGenProtocol(params) // Public key generation

ckgCombined := ckg.AllocateShare()
for _, pi := range P {
Expand Down Expand Up @@ -306,7 +306,7 @@ func rkgphase(params bgv.Parameters, crs sampling.PRNG, P []*party) *rlwe.Reline

l.Println("> RelinearizationKeyGen Phase")

rkg := mhe.NewRelinearizationKeyGenProtocol(params) // Relineariation key generation
rkg := multi_party.NewRelinearizationKeyGenProtocol(params) // Relineariation key generation

_, rkgCombined1, rkgCombined2 := rkg.AllocateShare()

Expand Down Expand Up @@ -357,7 +357,7 @@ func gkgphase(params bgv.Parameters, crs sampling.PRNG, P []*party) (galKeys []*

l.Println("> RTG Phase")

gkg := mhe.NewGaloisKeyGenProtocol(params) // Rotation keys generation
gkg := multi_party.NewGaloisKeyGenProtocol(params) // Rotation keys generation

for _, pi := range P {
pi.gkgShare = gkg.AllocateShare()
Expand Down
16 changes: 8 additions & 8 deletions examples/multi_party/int_psi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/tuneinsight/lattigo/v5/core/rlwe"
"github.com/tuneinsight/lattigo/v5/mhe"
"github.com/tuneinsight/lattigo/v5/multi_party"
"github.com/tuneinsight/lattigo/v5/ring"
"github.com/tuneinsight/lattigo/v5/schemes/bgv"
"github.com/tuneinsight/lattigo/v5/utils/sampling"
Expand Down Expand Up @@ -36,10 +36,10 @@ type party struct {
sk *rlwe.SecretKey
rlkEphemSk *rlwe.SecretKey

ckgShare mhe.PublicKeyGenShare
rkgShareOne mhe.RelinearizationKeyGenShare
rkgShareTwo mhe.RelinearizationKeyGenShare
pcksShare mhe.PublicKeySwitchShare
ckgShare multi_party.PublicKeyGenShare
rkgShareOne multi_party.RelinearizationKeyGenShare
rkgShareTwo multi_party.RelinearizationKeyGenShare
pcksShare multi_party.PublicKeySwitchShare

input []uint64
}
Expand Down Expand Up @@ -310,7 +310,7 @@ func pcksPhase(params bgv.Parameters, tpk *rlwe.PublicKey, encRes *rlwe.Cipherte
// Collective key switching from the collective secret key to
// the target public key

pcks, err := mhe.NewPublicKeySwitchProtocol(params, ring.DiscreteGaussian{Sigma: 1 << 30, Bound: 6 * (1 << 30)})
pcks, err := multi_party.NewPublicKeySwitchProtocol(params, ring.DiscreteGaussian{Sigma: 1 << 30, Bound: 6 * (1 << 30)})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -348,7 +348,7 @@ func rkgphase(params bgv.Parameters, crs sampling.PRNG, P []*party) *rlwe.Reline

l.Println("> RelinearizationKeyGen Phase")

rkg := mhe.NewRelinearizationKeyGenProtocol(params) // Relineariation key generation
rkg := multi_party.NewRelinearizationKeyGenProtocol(params) // Relineariation key generation
_, rkgCombined1, rkgCombined2 := rkg.AllocateShare()

for _, pi := range P {
Expand Down Expand Up @@ -398,7 +398,7 @@ func ckgphase(params bgv.Parameters, crs sampling.PRNG, P []*party) *rlwe.Public

l.Println("> PublicKeyGen Phase")

ckg := mhe.NewPublicKeyGenProtocol(params) // Public key generation
ckg := multi_party.NewPublicKeyGenProtocol(params) // Public key generation
ckgCombined := ckg.AllocateShare()
for _, pi := range P {
pi.ckgShare = ckg.AllocateShare()
Expand Down
48 changes: 24 additions & 24 deletions examples/multi_party/thresh_eval_key_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"time"

"github.com/tuneinsight/lattigo/v5/core/rlwe"
"github.com/tuneinsight/lattigo/v5/mhe"
"github.com/tuneinsight/lattigo/v5/multi_party"
"github.com/tuneinsight/lattigo/v5/utils/sampling"
)

// This example showcases the use of the mhe package to generate an evaluation key in a multiparty setting.
// This example showcases the use of the multi_party package to generate an evaluation key in a multiparty setting.
// It simulate multiple parties and their interactions within a single Go program using multiple goroutines.
// The parties use the t-out-of-N-threshold RLWE encryption scheme as described in "An Efficient Threshold
// Access-Structure for RLWE-Based Multiparty Homomorphic Encryption" (2022) by Mouchet, C., Bertrand, E. and
Expand All @@ -33,28 +33,28 @@ import (

// party represents a party in the scenario.
type party struct {
mhe.GaloisKeyGenProtocol
mhe.Thresholdizer
mhe.Combiner
multi_party.GaloisKeyGenProtocol
multi_party.Thresholdizer
multi_party.Combiner

i int
sk *rlwe.SecretKey
tsk mhe.ShamirSecretShare
ssp mhe.ShamirPolynomial
shamirPk mhe.ShamirPublicPoint
tsk multi_party.ShamirSecretShare
ssp multi_party.ShamirPolynomial
shamirPk multi_party.ShamirPublicPoint

genTaskQueue chan genTask
}

// cloud represents the cloud server assisting the parties.
type cloud struct {
mhe.GaloisKeyGenProtocol
multi_party.GaloisKeyGenProtocol

aggTaskQueue chan genTaskResult
finDone chan rlwe.GaloisKey
}

var crp map[uint64]mhe.GaloisKeyGenCRP
var crp map[uint64]multi_party.GaloisKeyGenCRP

// Run simulate the behavior of a party during the key generation protocol. The parties process
// a queue of share-generation tasks which is attributed to them by a protocol orchestrator
Expand All @@ -73,7 +73,7 @@ func (p *party) Run(wg *sync.WaitGroup, params rlwe.Parameters, N int, P []*part
if t == N {
sk = p.sk
} else {
activePk := make([]mhe.ShamirPublicPoint, 0)
activePk := make([]multi_party.ShamirPublicPoint, 0)
for _, pi := range task.group {
activePk = append(activePk, pi.shamirPk)
}
Expand Down Expand Up @@ -111,12 +111,12 @@ func (p *party) String() string {
func (c *cloud) Run(galEls []uint64, params rlwe.Parameters, t int) {

shares := make(map[uint64]*struct {
share mhe.GaloisKeyGenShare
share multi_party.GaloisKeyGenShare
needed int
}, len(galEls))
for _, galEl := range galEls {
shares[galEl] = &struct {
share mhe.GaloisKeyGenShare
share multi_party.GaloisKeyGenShare
needed int
}{c.AllocateShare(), t}
shares[galEl].share.GaloisElement = galEl
Expand Down Expand Up @@ -210,32 +210,32 @@ func main() {

wg := new(sync.WaitGroup)
C := &cloud{
GaloisKeyGenProtocol: mhe.NewGaloisKeyGenProtocol(params),
GaloisKeyGenProtocol: multi_party.NewGaloisKeyGenProtocol(params),
aggTaskQueue: make(chan genTaskResult, len(galEls)*N),
finDone: make(chan rlwe.GaloisKey, len(galEls)),
}

// Initialize the parties' state
P := make([]*party, N)
skIdeal := rlwe.NewSecretKey(params)
shamirPks := make([]mhe.ShamirPublicPoint, 0)
shamirPks := make([]multi_party.ShamirPublicPoint, 0)

for i := range P {
pi := new(party)
pi.GaloisKeyGenProtocol = mhe.NewGaloisKeyGenProtocol(params)
pi.GaloisKeyGenProtocol = multi_party.NewGaloisKeyGenProtocol(params)
pi.i = i
pi.sk = kg.GenSecretKeyNew()
pi.genTaskQueue = make(chan genTask, k)

if t != N {
pi.Thresholdizer = mhe.NewThresholdizer(params)
pi.Thresholdizer = multi_party.NewThresholdizer(params)
pi.tsk = pi.AllocateThresholdSecretShare()
var err error
pi.ssp, err = pi.GenShamirPolynomial(t, pi.sk)
if err != nil {
panic(err)
}
pi.shamirPk = mhe.ShamirPublicPoint(i + 1)
pi.shamirPk = multi_party.ShamirPublicPoint(i + 1)
}

P[i] = pi
Expand All @@ -249,14 +249,14 @@ func main() {
// if t < N, use the t-out-of-N scheme and performs the share-resharing procedure.
if t != N {
for _, pi := range P {
pi.Combiner = mhe.NewCombiner(params, pi.shamirPk, shamirPks, t)
pi.Combiner = multi_party.NewCombiner(params, pi.shamirPk, shamirPks, t)
}

fmt.Println("Performing threshold setup")
shares := make(map[*party]map[*party]mhe.ShamirSecretShare, len(P))
shares := make(map[*party]map[*party]multi_party.ShamirSecretShare, len(P))
for _, pi := range P {

shares[pi] = make(map[*party]mhe.ShamirSecretShare)
shares[pi] = make(map[*party]multi_party.ShamirSecretShare)

for _, pj := range P {
share := pi.AllocateThresholdSecretShare()
Expand All @@ -283,7 +283,7 @@ func main() {

// Sample the common random polynomials from the CRS.
// For the scenario, we consider it is provided as-is to the parties.
crp = make(map[uint64]mhe.GaloisKeyGenCRP)
crp = make(map[uint64]multi_party.GaloisKeyGenCRP)
for _, galEl := range galEls {
crp[galEl] = P[0].SampleCRP(crs)
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func main() {

fmt.Printf("Checking the keys... ")

noise := mhe.NoiseGaloisKey(params, t)
noise := multi_party.NoiseGaloisKey(params, t)

for _, galEl := range galEls {

Expand All @@ -347,7 +347,7 @@ type genTask struct {

type genTaskResult struct {
galEl uint64
rtgShare mhe.GaloisKeyGenShare
rtgShare multi_party.GaloisKeyGenShare
}

func getTasks(galEls []uint64, groups [][]*party) []genTask {
Expand Down
Loading

0 comments on commit ea81515

Please sign in to comment.