diff --git a/paillier.go b/paillier.go index 9a2ab6c..6012e09 100644 --- a/paillier.go +++ b/paillier.go @@ -37,6 +37,9 @@ func (pub *PublicKey) Encrypt(m *big.Int, random io.Reader) (*Cypher, error) { } nSquare := pub.GetNSquare() + // g is _always_ equal n+1 + // Threshold encryption is safe only for g=n+1 choice. + // See [DJN 10], section 5.1 g := new(big.Int).Add(pub.N, big.NewInt(1)) gm := new(big.Int).Exp(g, m, nSquare) rn := new(big.Int).Exp(r, pub.N, nSquare) diff --git a/thresholdkey.go b/thresholdkey.go index 3ade718..95a6371 100644 --- a/thresholdkey.go +++ b/thresholdkey.go @@ -14,7 +14,6 @@ type ThresholdKey struct { Threshold int V *big.Int Vi []*big.Int - G *big.Int // usually G is set to N+1 } // returns the value of (4*delta**2)** -1 mod n @@ -165,7 +164,6 @@ func (this *ThresholdPrivateKey) GetThresholdKey() *ThresholdKey { ret.V = new(big.Int).Add(this.V, big.NewInt(0)) ret.Vi = this.copyVi() ret.N = new(big.Int).Add(this.N, big.NewInt(0)) - ret.G = new(big.Int).Add(this.N, big.NewInt(1)) return ret } diff --git a/thresholdkey_generator.go b/thresholdkey_generator.go index 3260277..5e6e1c3 100644 --- a/thresholdkey_generator.go +++ b/thresholdkey_generator.go @@ -219,7 +219,6 @@ func (this *ThresholdKeyGenerator) createViArray(shares []*big.Int) (viArray []* func (this *ThresholdKeyGenerator) createPrivateKey(i int, share *big.Int, viArray []*big.Int) *ThresholdPrivateKey { ret := new(ThresholdPrivateKey) ret.N = this.n - ret.G = new(big.Int).Add(ret.N, ONE) ret.V = this.v ret.TotalNumberOfDecryptionServers = this.TotalNumberOfDecryptionServers diff --git a/thresholdkey_generator_test.go b/thresholdkey_generator_test.go index 78359cb..e03262e 100644 --- a/thresholdkey_generator_test.go +++ b/thresholdkey_generator_test.go @@ -207,7 +207,7 @@ func TestGenerate(t *testing.T) { if len(tpk.Vi) != 10 { t.Fail() } - if tpk.G == nil || tpk.N == nil { + if tpk.N == nil { t.Fail() } if tpk.Threshold != 6 || tpk.TotalNumberOfDecryptionServers != 10 { diff --git a/thresholdkey_test.go b/thresholdkey_test.go index 23578e2..99ef1c5 100644 --- a/thresholdkey_test.go +++ b/thresholdkey_test.go @@ -224,7 +224,6 @@ func TestDecryption(t *testing.T) { tk.Threshold = 2 tk.TotalNumberOfDecryptionServers = 2 tk.N = b(637753) - tk.G = b(637754) tk.V = b(70661107826) if msg, err := tk.CombinePartialDecryptions([]*PartialDecryption{share1, share2}); err != nil { t.Error(err)