diff --git a/mixmessages/ndf.go b/mixmessages/ndf.go index 319e47018caf5dae0c270cd8669f076f3715c14a..90241b385a11e512578aa770f30f6301d5c8045c 100644 --- a/mixmessages/ndf.go +++ b/mixmessages/ndf.go @@ -31,7 +31,9 @@ func (m *NDF) SetSig(newSig []byte) error { // ClearSignature clears out NDF's signature func (m *NDF) ClearSig() { - m.Signature = &RSASignature{} + if m.Signature!=nil{ + m.Signature.Signature = nil + } } // GetNonce gets the value of the nonce diff --git a/mixmessages/roundError.go b/mixmessages/roundError.go index 5c9f38712facb0431b9270c6f11f5d0a36e795f8..b5adc455d7f6aa9f97f2e192faf0ac2df1e1f53b 100644 --- a/mixmessages/roundError.go +++ b/mixmessages/roundError.go @@ -31,7 +31,9 @@ func (m *RoundError) SetSig(newSig []byte) error { // ClearSignature clears out RoundError's signature func (m *RoundError) ClearSig() { - m.Signature = &RSASignature{} + if m.Signature!=nil{ + m.Signature.Signature=nil + } } // GetNonce gets the value of the nonce diff --git a/mixmessages/roundInfo.go b/mixmessages/roundInfo.go index dfa0489689f92aac4bf841d58947f44f81520ae2..930c8582b74973fc1e7c43e7bc9264ce9cb070fc 100644 --- a/mixmessages/roundInfo.go +++ b/mixmessages/roundInfo.go @@ -31,7 +31,9 @@ func (m *RoundInfo) SetSig(newSig []byte) error { // ClearSignature clears out roundInfo's signature func (m *RoundInfo) ClearSig() { - m.Signature = &RSASignature{} + if m.Signature!=nil{ + m.Signature.Signature=nil + } } // GetNonce gets the value of the nonce diff --git a/network/securedNdf_test.go b/network/securedNdf_test.go index 89c3d20a27f5a1fc59d5efda51fd5d31c6cec418..4ab84182ed467e015b4d556693e307ed0221a533 100644 --- a/network/securedNdf_test.go +++ b/network/securedNdf_test.go @@ -1,6 +1,13 @@ package network -import "testing" +import ( + pb "gitlab.com/elixxir/comms/mixmessages" + "gitlab.com/elixxir/crypto/signature" + "gitlab.com/elixxir/crypto/signature/rsa" + "gitlab.com/elixxir/primitives/ndf" + "math/rand" + "testing" +) func TestNewSecuredNdf(t *testing.T) { sndf := NewSecuredNdf() @@ -9,3 +16,34 @@ func TestNewSecuredNdf(t *testing.T) { } } +func TestSecuredNdf_update(t *testing.T) { + src:=rand.New(rand.NewSource(42)) + privKey, err := rsa.GenerateKey(src, 768) + + if err!=nil{ + t.Errorf("Could not generate rsa key: %s", err) + } + + f := pb.NDF{} + + baseNDF := ndf.NetworkDefinition{} + f.Ndf, err = baseNDF.Marshal() + + if err!=nil{ + t.Errorf("Could not generate serialized ndf: %s", err) + } + + err = signature.Sign(&f, privKey) + + if err!=nil{ + t.Errorf("Could not sign serialized ndf: %s", err) + } + + sndf := NewSecuredNdf() + err = sndf.update(&f,privKey.GetPublic()) + + if err!=nil{ + t.Errorf("Could not update ndf: %s", err) + } + +} \ No newline at end of file