diff --git a/encoding.go b/encoding.go index 11920fb..261b769 100644 --- a/encoding.go +++ b/encoding.go @@ -57,7 +57,6 @@ type dbThresholdKey struct { V string Vi []string N string - G string } func (this *dbThresholdKey) FromThresholdKey(key *ThresholdKey) { @@ -65,7 +64,6 @@ func (this *dbThresholdKey) FromThresholdKey(key *ThresholdKey) { this.Threshold = key.Threshold this.V = fmt.Sprintf("%x", key.V) this.N = fmt.Sprintf("%x", key.N) - this.G = fmt.Sprintf("%x", key.G) this.Vi = make([]string, len(key.Vi)) for i, vi := range key.Vi { this.Vi[i] = fmt.Sprintf("%x", vi) @@ -75,10 +73,9 @@ func (this *dbThresholdKey) FromThresholdKey(key *ThresholdKey) { func (this *dbThresholdKey) ToThresholdKey(key *ThresholdKey) error { key.TotalNumberOfDecryptionServers = this.TotalNumberOfDecryptionServers key.Threshold = this.Threshold - oks := make([]bool, 3) + oks := make([]bool, 2) key.V, oks[0] = new(big.Int).SetString(this.V, 16) key.N, oks[1] = new(big.Int).SetString(this.N, 16) - key.G, oks[2] = new(big.Int).SetString(this.G, 16) if !all(oks) { return errors.New("not hexadecimal") } @@ -110,7 +107,6 @@ func (this *ThresholdKey) SetBSON(raw bson.Raw) error { type dbPrivateKey struct { N string `bson:",omitempty"` - G string `bson:",omitempty"` Lambda string `bson:",omitempty"` Mu string `bson:",omitempty"` } @@ -154,7 +150,6 @@ type dbPartialDecryptionZKP struct { E string `json:"e"` C string `json:"c"` V string `json:"v"` - G string `json:"g"` N string `json:"n"` Vi []string `json:"vi"` Decryption string `json:"decryption"` @@ -169,7 +164,6 @@ func (this *dbPartialDecryptionZKP) FromPartialDecryptionZKP(pd *PartialDecrypti this.Threshold = pd.Key.Threshold this.Z = fmt.Sprintf("%x", pd.Z) this.E = fmt.Sprintf("%x", pd.E) - this.G = fmt.Sprintf("%x", pd.Key.G) this.N = fmt.Sprintf("%x", pd.Key.N) this.C = fmt.Sprintf("%x", pd.C) this.V = fmt.Sprintf("%x", pd.Key.V) @@ -183,7 +177,7 @@ func (this *dbPartialDecryptionZKP) FromPartialDecryptionZKP(pd *PartialDecrypti func (this *dbPartialDecryptionZKP) ToPartialDecryptionZKP(pd *PartialDecryptionZKP) error { pd.Key = new(ThresholdKey) - var oks = make([]bool, 7) + var oks = make([]bool, 6) pd.Id = this.Id pd.Key.TotalNumberOfDecryptionServers = this.TotalNumberOfDecryptionServers @@ -192,9 +186,8 @@ func (this *dbPartialDecryptionZKP) ToPartialDecryptionZKP(pd *PartialDecryption pd.E, oks[1] = new(big.Int).SetString(this.E, 16) pd.C, oks[2] = new(big.Int).SetString(this.C, 16) pd.Key.V, oks[3] = new(big.Int).SetString(this.V, 16) - pd.Key.G, oks[4] = new(big.Int).SetString(this.G, 16) - pd.Key.N, oks[5] = new(big.Int).SetString(this.N, 16) - pd.Decryption, oks[6] = new(big.Int).SetString(this.Decryption, 16) + pd.Key.N, oks[4] = new(big.Int).SetString(this.N, 16) + pd.Decryption, oks[5] = new(big.Int).SetString(this.Decryption, 16) if !all(oks) { fmt.Println(oks) diff --git a/encoding_test.go b/encoding_test.go index 9e0e945..0579c35 100644 --- a/encoding_test.go +++ b/encoding_test.go @@ -85,14 +85,13 @@ func TestPartialDecryptionZKPJsonification(t *testing.T) { pd.Key.Threshold = 98 pd.Key.TotalNumberOfDecryptionServers = 230 pd.Id = 1 - pd.Key.Vi = []*big.Int{b(77), b(67)} // vi is 67 + pd.Key.Vi = []*big.Int{b(77), b(67)} pd.Key.N = b(131) pd.Key.V = b(101) pd.Decryption = b(171) pd.E = b(112) pd.C = b(99) pd.Key.N = b(345) - pd.Key.G = b(99) pd.Z = b(88) AssertJSONIsGood(pd, new(PartialDecryptionZKP), t) @@ -111,13 +110,18 @@ func TestPartialDecryptionZKPBSONification(t *testing.T) { pd.E = b(112) pd.C = b(99) pd.Key.N = b(345) - pd.Key.G = b(99) pd.Z = b(88) AssertBSONIsGood(pd, new(PartialDecryptionZKP), t) } func TestThresholdKeyBSON(t *testing.T) { - key := &ThresholdKey{PublicKey{b(9)}, 7, 6, b(3), []*big.Int{b(2), b(34)}, b(8)} + key := &ThresholdKey{ + PublicKey: PublicKey{b(9)}, + TotalNumberOfDecryptionServers: 7, + Threshold: 6, + V: b(3), + Vi: []*big.Int{b(2), b(34)}, + } AssertBSONIsGood(key, new(ThresholdKey), t) }