Do not export internal threshold generator functions
This commit is contained in:
2 files changed
+55
-55
No files matched your search
@@ -15,7 +15,7 @@ func TestGenerateSafePrimesOfThresholdKeyGenerator(t *testing.T) {
|
||||
tkh := new(ThresholdKeyGenerator)
|
||||
tkh.nbits = 10
|
||||
tkh.Random = rand.Reader
|
||||
p, q, err := tkh.GenerateSafePrimes()
|
||||
p, q, err := tkh.generateSafePrimes()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
@@ -29,7 +29,7 @@ func TestInitPandP1(t *testing.T) {
|
||||
tkh.nbits = 10
|
||||
tkh.Random = rand.Reader
|
||||
|
||||
tkh.InitPandP1()
|
||||
tkh.initPandP1()
|
||||
AreSafePrimes(tkh.p, tkh.p1, 10, t)
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ func TestInitQandQ1(t *testing.T) {
|
||||
tkh.nbits = 10
|
||||
tkh.Random = rand.Reader
|
||||
|
||||
tkh.InitQandQ1()
|
||||
tkh.initQandQ1()
|
||||
AreSafePrimes(tkh.q, tkh.q1, 10, t)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestInitPsAndQs(t *testing.T) {
|
||||
tkh.nbits = 10
|
||||
tkh.Random = rand.Reader
|
||||
|
||||
tkh.InitPsAndQs()
|
||||
tkh.initPsAndQs()
|
||||
AreSafePrimes(tkh.q, tkh.q1, 10, t)
|
||||
AreSafePrimes(tkh.q, tkh.q1, 10, t)
|
||||
}
|
||||
@@ -56,17 +56,17 @@ func TestInitPsAndQs(t *testing.T) {
|
||||
func TestArePsAndQsGood(t *testing.T) {
|
||||
tkh := new(ThresholdKeyGenerator)
|
||||
tkh.p, tkh.p1, tkh.q, tkh.q1 = b(6), b(5), b(4), b(3)
|
||||
if !tkh.ArePsAndQsGood() {
|
||||
if !tkh.arePsAndQsGood() {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
tkh.p, tkh.p1, tkh.q, tkh.q1 = b(6), b(5), b(6), b(3)
|
||||
if tkh.ArePsAndQsGood() {
|
||||
if tkh.arePsAndQsGood() {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
tkh.p, tkh.p1, tkh.q, tkh.q1 = b(6), b(5), b(5), b(3)
|
||||
if tkh.ArePsAndQsGood() {
|
||||
if tkh.arePsAndQsGood() {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func TestArePsAndQsGood(t *testing.T) {
|
||||
func TestInitShortcuts(t *testing.T) {
|
||||
tkh := new(ThresholdKeyGenerator)
|
||||
tkh.p, tkh.p1, tkh.q, tkh.q1 = b(11), b(7), b(5), b(3)
|
||||
tkh.InitShortcuts()
|
||||
tkh.initShortcuts()
|
||||
|
||||
if n(tkh.n) != 11*5 {
|
||||
t.Error("wrong n", tkh.n)
|
||||
@@ -93,8 +93,8 @@ func TestInitShortcuts(t *testing.T) {
|
||||
func TestInitD(t *testing.T) {
|
||||
tkh := new(ThresholdKeyGenerator)
|
||||
tkh.p, tkh.p1, tkh.q, tkh.q1 = b(863), b(431), b(839), b(419)
|
||||
tkh.InitShortcuts()
|
||||
tkh.InitD()
|
||||
tkh.initShortcuts()
|
||||
tkh.initD()
|
||||
if n(tkh.d)%n(tkh.m) != 0 {
|
||||
t.Fail()
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func TestInitNumerialValues(t *testing.T) {
|
||||
tkh.nbits = 10
|
||||
tkh.Random = rand.Reader
|
||||
|
||||
if err := tkh.InitNumerialValues(); err != nil {
|
||||
if err := tkh.initNumerialValues(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
@@ -118,11 +118,11 @@ func TestGenerateHidingPolynomial(t *testing.T) {
|
||||
tkh.nbits = 10
|
||||
tkh.Threshold = 10
|
||||
tkh.Random = rand.Reader
|
||||
if err := tkh.InitNumerialValues(); err != nil {
|
||||
if err := tkh.initNumerialValues(); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if err := tkh.GenerateHidingPolynomial(); err != nil {
|
||||
if err := tkh.generateHidingPolynomial(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
p := tkh.polynomialCoefficients
|
||||
@@ -147,7 +147,7 @@ func TestComputeShare(t *testing.T) {
|
||||
tkh.TotalNumberOfDecryptionServers = 5
|
||||
tkh.nm = b(103)
|
||||
tkh.polynomialCoefficients = []*big.Int{b(29), b(88), b(51)}
|
||||
share := tkh.ComputeShare(2)
|
||||
share := tkh.computeShare(2)
|
||||
if n(share) != 31 {
|
||||
t.Error("error computing a share. ", share)
|
||||
}
|
||||
@@ -159,16 +159,16 @@ func TestCreateShares(t *testing.T) {
|
||||
tkh.Threshold = 10
|
||||
tkh.TotalNumberOfDecryptionServers = 100
|
||||
tkh.Random = rand.Reader
|
||||
if err := tkh.InitNumerialValues(); err != nil {
|
||||
if err := tkh.initNumerialValues(); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if err := tkh.GenerateHidingPolynomial(); err != nil {
|
||||
if err := tkh.generateHidingPolynomial(); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if shares := tkh.CreateShares(); len(shares) != 100 {
|
||||
if shares := tkh.createShares(); len(shares) != 100 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func TestCreateViArray(t *testing.T) {
|
||||
tkh.TotalNumberOfDecryptionServers = 10
|
||||
tkh.v = b(54)
|
||||
tkh.nSquare = b(101 * 101)
|
||||
vArr := tkh.CreateViArray([]*big.Int{b(12), b(90), b(103)})
|
||||
vArr := tkh.createViArray([]*big.Int{b(12), b(90), b(103)})
|
||||
exp := []*big.Int{b(6162), b(304), b(2728)}
|
||||
if !reflect.DeepEqual(vArr, exp) {
|
||||
t.Fail()
|
||||
@@ -187,7 +187,7 @@ func TestCreateViArray(t *testing.T) {
|
||||
|
||||
func TestGetThresholdKeyGenerator(t *testing.T) {
|
||||
tkh := GetThresholdKeyGenerator(50, 10, 6, rand.Reader)
|
||||
if err := tkh.InitNumerialValues(); err != nil {
|
||||
if err := tkh.initNumerialValues(); err != nil {
|
||||
t.Error(nil)
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func TestComputeV(t *testing.T) {
|
||||
tkh.n = b(1907 * 1823)
|
||||
tkh.nSquare = new(big.Int).Mul(tkh.n, tkh.n)
|
||||
for i := 0; i < 100; i++ {
|
||||
if err := tkh.ComputeV(); err != nil {
|
||||
if err := tkh.computeV(); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user