Skip to content
Snippets Groups Projects
Commit f4e22b7d authored by Josh Brooks's avatar Josh Brooks
Browse files

Remove roundErrors from digest in round info

parent 166bc974
No related branches found
No related tags found
2 merge requests!58Revert "Modify waiting lock",!9Release
...@@ -45,7 +45,7 @@ func checkdigest(t *testing.T, gs signature.GenericRsaSignable) { ...@@ -45,7 +45,7 @@ func checkdigest(t *testing.T, gs signature.GenericRsaSignable) {
valField := r.Field(i) valField := r.Field(i)
typeField := r.Type().Field(i) typeField := r.Type().Field(i)
if typeField.Name == "EccSignature" || typeField.Name == "Signature" || typeField.Name == "state" || typeField.Name == "sizeCache" || typeField.Name == "unknownFields" || strings.Contains(typeField.Name, "XXX") { if typeField.Name == "EccSignature" || typeField.Name == "Signature" || typeField.Name == "Errors" || typeField.Name == "state" || typeField.Name == "sizeCache" || typeField.Name == "unknownFields" || strings.Contains(typeField.Name, "XXX") {
fmt.Printf("Skipping field.\n") fmt.Printf("Skipping field.\n")
continue continue
} }
...@@ -79,24 +79,6 @@ func checkdigest(t *testing.T, gs signature.GenericRsaSignable) { ...@@ -79,24 +79,6 @@ func checkdigest(t *testing.T, gs signature.GenericRsaSignable) {
v := reflect.ValueOf(arr) v := reflect.ValueOf(arr)
valField.Set(v) valField.Set(v)
case []*RoundError:
randNodeId := make([]byte, 33)
rand.Read(randNodeId)
rea := []*RoundError{
{
Id: rand.Uint64(),
NodeId: randNodeId,
Error: RandStringRunes(4),
},
{
Id: rand.Uint64(),
NodeId: randNodeId,
Error: RandStringRunes(4),
},
}
v := reflect.ValueOf(rea)
valField.Set(v)
case []*ClientError: case []*ClientError:
randClientId := make([]byte, 33) randClientId := make([]byte, 33)
rand.Read(randClientId) rand.Read(randClientId)
......
...@@ -81,13 +81,6 @@ func (m *RoundInfo) Digest(nonce []byte, h hash.Hash) []byte { ...@@ -81,13 +81,6 @@ func (m *RoundInfo) Digest(nonce []byte, h hash.Hash) []byte {
h.Write(data) h.Write(data)
} }
// Hash the
for _, roundErr := range m.Errors {
sha := crypto.SHA256.New()
data := roundErr.Digest(nonce, sha)
h.Write(data)
}
// Hash nonce // Hash nonce
h.Write(nonce) h.Write(nonce)
......
...@@ -68,7 +68,8 @@ func (r *Round) Get() *pb.RoundInfo { ...@@ -68,7 +68,8 @@ func (r *Round) Get() *pb.RoundInfo {
if err != nil { if err != nil {
jww.FATAL.Panicf("Could not validate "+ jww.FATAL.Panicf("Could not validate "+
"the roundInfo signature: %+v: %v", r.info, err) "the roundInfo signature: %+v: %v", r.info, err)
} } }
}
atomic.StoreUint32(r.needsValidation, 1) atomic.StoreUint32(r.needsValidation, 1)
} }
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"testing" "testing"
) )
// Unit test
func TestUpdates_AddRound(t *testing.T) { func TestUpdates_AddRound(t *testing.T) {
u := NewUpdates() u := NewUpdates()
// Construct a mock round object // Construct a mock round object
...@@ -34,6 +35,7 @@ func TestUpdates_AddRound(t *testing.T) { ...@@ -34,6 +35,7 @@ func TestUpdates_AddRound(t *testing.T) {
} }
} }
// Unit test
func TestUpdates_GetUpdate(t *testing.T) { func TestUpdates_GetUpdate(t *testing.T) {
u := NewUpdates() u := NewUpdates()
updateID := 3 updateID := 3
...@@ -64,23 +66,31 @@ func TestUpdates_GetUpdate(t *testing.T) { ...@@ -64,23 +66,31 @@ func TestUpdates_GetUpdate(t *testing.T) {
} }
} }
// Unit test
func TestUpdates_GetUpdates(t *testing.T) { func TestUpdates_GetUpdates(t *testing.T) {
u := NewUpdates() u := NewUpdates()
pubKey, err := testutils.LoadPublicKeyTesting(t)
if err != nil {
t.Errorf("Failed to load public key: %v", err)
t.FailNow()
}
ecKey, _ := testutils.LoadEllipticPublicKey()
updateID := 3 updateID := 3
// Construct a mock round object // Construct a mock round object
roundInfoOne := &mixmessages.RoundInfo{ roundInfoOne := &mixmessages.RoundInfo{
ID: 0, ID: 0,
UpdateID: uint64(updateID), UpdateID: uint64(updateID),
} }
// Sign the round on the keys
if err := testutils.SignRoundInfoRsa(roundInfoOne, t); err != nil { if err := testutils.SignRoundInfoRsa(roundInfoOne, t); err != nil {
t.Errorf("Failed to sign mock round info: %v", err) t.Errorf("Failed to sign mock round info: %v", err)
} }
pubKey, err := testutils.LoadPublicKeyTesting(t) if err := testutils.SignRoundInfoEddsa(roundInfoOne, ecKey, t); err != nil {
if err != nil { t.Errorf("Failed to sign mock round info: %v", err)
t.Errorf("Failed to load public key: %v", err)
t.FailNow()
} }
ecKey, _ := testutils.LoadEllipticPublicKey()
roundOne := NewRound(roundInfoOne, pubKey, ecKey.PublicKey()) roundOne := NewRound(roundInfoOne, pubKey, ecKey.PublicKey())
...@@ -92,6 +102,9 @@ func TestUpdates_GetUpdates(t *testing.T) { ...@@ -92,6 +102,9 @@ func TestUpdates_GetUpdates(t *testing.T) {
if err := testutils.SignRoundInfoRsa(roundInfoTwo, t); err != nil { if err := testutils.SignRoundInfoRsa(roundInfoTwo, t); err != nil {
t.Errorf("Failed to sign mock round info: %v", err) t.Errorf("Failed to sign mock round info: %v", err)
} }
if err := testutils.SignRoundInfoEddsa(roundInfoTwo, ecKey, t); err != nil {
t.Errorf("Failed to sign mock round info: %v", err)
}
roundTwo := NewRound(roundInfoTwo, pubKey, ecKey.PublicKey()) roundTwo := NewRound(roundInfoTwo, pubKey, ecKey.PublicKey())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment