-
Notifications
You must be signed in to change notification settings - Fork 1
/
refresh.go
44 lines (36 loc) · 1.74 KB
/
refresh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package dbfv
import (
"github.com/dwkim606/test_lattigo/bfv"
"github.com/dwkim606/test_lattigo/ring"
"github.com/dwkim606/test_lattigo/rlwe"
)
// RefreshProtocol is a struct storing the relevant parameters for the Refresh protocol.
type RefreshProtocol struct {
MaskedTransformProtocol
}
// RefreshShare is a struct storing a party's share in the Refresh protocol.
type RefreshShare struct {
MaskedTransformShare
}
// NewRefreshProtocol creates a new Refresh protocol instance.
func NewRefreshProtocol(params bfv.Parameters, sigmaSmudging float64) (rfp *RefreshProtocol) {
rfp = new(RefreshProtocol)
rfp.MaskedTransformProtocol = *NewMaskedTransformProtocol(params, sigmaSmudging)
return
}
// AllocateShare allocates the shares of the PermuteProtocol
func (rfp *RefreshProtocol) AllocateShare() *RefreshShare {
return &RefreshShare{*rfp.MaskedTransformProtocol.AllocateShare()}
}
// GenShares generates a share for the Refresh protocol.
func (rfp *RefreshProtocol) GenShares(sk *rlwe.SecretKey, ciphertext *bfv.Ciphertext, crs *ring.Poly, shareOut *RefreshShare) {
rfp.MaskedTransformProtocol.GenShares(sk, ciphertext, crs, nil, &shareOut.MaskedTransformShare)
}
// Aggregate aggregates two parties' shares in the Refresh protocol.
func (rfp *RefreshProtocol) Aggregate(share1, share2, shareOut *RefreshShare) {
rfp.MaskedTransformProtocol.Aggregate(&share1.MaskedTransformShare, &share2.MaskedTransformShare, &shareOut.MaskedTransformShare)
}
// Finalize applies Decrypt, Recode and Recrypt on the input ciphertext.
func (rfp *RefreshProtocol) Finalize(ciphertext *bfv.Ciphertext, crs *ring.Poly, share *RefreshShare, ciphertextOut *bfv.Ciphertext) {
rfp.MaskedTransformProtocol.Transform(ciphertext, nil, crs, &share.MaskedTransformShare, ciphertextOut)
}