Check threshold public key bit length

This commit is contained in:
Piotr Dyraga committed 2018-08-08 10:44:28 +02:00
1 parent 408bafa61a
commit 3394a6136a
3 files changed
+136 -26

No files matched your search

+35 -7
View File
@@ -8,7 +8,11 @@ import (
)
func getThresholdPrivateKey() *ThresholdPrivateKey {
tkh := GetThresholdKeyGenerator(32, 10, 6, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 10, 6, rand.Reader)
if err != nil {
panic(err)
}
tpks, err := tkh.Generate()
if err != nil {
panic(err)
@@ -184,7 +188,11 @@ func TestupdateCprime(t *testing.T) {
}
func TestEncryptingDecryptingSimple(t *testing.T) {
tkh := GetThresholdKeyGenerator(32, 2, 1, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 2, 1, rand.Reader)
if err != nil {
t.Fatal(err)
}
tpks, err := tkh.Generate()
if err != nil {
t.Error(err)
@@ -205,7 +213,11 @@ func TestEncryptingDecryptingSimple(t *testing.T) {
}
func TestEncryptingDecrypting(t *testing.T) {
tkh := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
if err != nil {
t.Fatal(err)
}
tpks, err := tkh.Generate()
if err != nil {
t.Error(err)
@@ -227,7 +239,11 @@ func TestEncryptingDecrypting(t *testing.T) {
}
func TestHomomorphicThresholdEncryption(t *testing.T) {
tkh := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
if err != nil {
t.Fatal(err)
}
tpks, _ := tkh.Generate()
plainText1 := b(13)
@@ -278,7 +294,11 @@ func TestValidate(t *testing.T) {
}
func TestCombinePartialDecryptionsZKP(t *testing.T) {
tkh := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
if err != nil {
t.Fatal(err)
}
tpks, err := tkh.Generate()
if err != nil {
t.Error(err)
@@ -311,7 +331,11 @@ func TestCombinePartialDecryptionsZKP(t *testing.T) {
}
func TestCombinePartialDecryptionsWith100Shares(t *testing.T) {
tkh := GetThresholdKeyGenerator(32, 100, 50, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 100, 50, rand.Reader)
if err != nil {
t.Fatal(err)
}
tpks, err := tkh.Generate()
if err != nil {
t.Error(err)
@@ -338,7 +362,11 @@ func TestCombinePartialDecryptionsWith100Shares(t *testing.T) {
}
func TestVerifyDecryption(t *testing.T) {
tkh := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
tkh, err := GetThresholdKeyGenerator(32, 2, 2, rand.Reader)
if err != nil {
t.Fatal(err)
}
tpks, err := tkh.Generate()
pk := &tpks[0].ThresholdPublicKey