Pass a public key bit length when creating a threshold key generator #11

Merged
pdyraga merged 16 commits from master into master 2018-08-10 06:50:47 -04:00
Showing only changes of commit 5332558625 - Show all commits
+5 -5
View File
@@ -23,7 +23,7 @@ type ThresholdKeyGenerator struct {
PublicKeyBitLength int PublicKeyBitLength int
TotalNumberOfDecryptionServers int TotalNumberOfDecryptionServers int
Threshold int Threshold int
Random io.Reader random io.Reader
// Both p1 and q1 are primes of length nbits - 1 // Both p1 and q1 are primes of length nbits - 1
p1 *big.Int p1 *big.Int
@@ -73,7 +73,7 @@ func GetThresholdKeyGenerator(
PublicKeyBitLength: publicKeyBitLength, PublicKeyBitLength: publicKeyBitLength,
TotalNumberOfDecryptionServers: totalNumberOfDecryptionServers, TotalNumberOfDecryptionServers: totalNumberOfDecryptionServers,
Threshold: threshold, Threshold: threshold,
Random: random, random: random,
}, nil }, nil
} }
@@ -82,7 +82,7 @@ func (tkg *ThresholdKeyGenerator) generateSafePrimes() (*big.Int, *big.Int, erro
timeout := 120 * time.Second timeout := 120 * time.Second
safePrimeBitLength := tkg.PublicKeyBitLength / 2 safePrimeBitLength := tkg.PublicKeyBitLength / 2
return GenerateSafePrime(safePrimeBitLength, concurrencyLevel, timeout, tkg.Random) return GenerateSafePrime(safePrimeBitLength, concurrencyLevel, timeout, tkg.random)
} }
func (tkg *ThresholdKeyGenerator) initPandP1() error { func (tkg *ThresholdKeyGenerator) initPandP1() error {
@@ -133,7 +133,7 @@ func (tkg *ThresholdKeyGenerator) initPsAndQs() error {
// v generates a cyclic group of squares in Zn^2. // v generates a cyclic group of squares in Zn^2.
func (tkg *ThresholdKeyGenerator) computeV() error { func (tkg *ThresholdKeyGenerator) computeV() error {
var err error var err error
tkg.v, err = GetRandomGeneratorOfTheQuadraticResidue(tkg.nSquare, tkg.Random) tkg.v, err = GetRandomGeneratorOfTheQuadraticResidue(tkg.nSquare, tkg.random)
return err return err
} }
@@ -186,7 +186,7 @@ func (tkg *ThresholdKeyGenerator) generateHidingPolynomial() error {
tkg.polynomialCoefficients[0] = tkg.d tkg.polynomialCoefficients[0] = tkg.d
var err error var err error
for i := 1; i < tkg.Threshold; i++ { for i := 1; i < tkg.Threshold; i++ {
tkg.polynomialCoefficients[i], err = rand.Int(tkg.Random, tkg.nm) tkg.polynomialCoefficients[i], err = rand.Int(tkg.random, tkg.nm)
if err != nil { if err != nil {
return err return err
} }