diff --git a/go.mod b/go.mod index eba9aafbf36c3ca0fe5771510d1a22203485430b..6722cf7c514fbd6207da0d177663f66db8ca67d3 100644 --- a/go.mod +++ b/go.mod @@ -6,14 +6,13 @@ require ( github.com/aws/aws-lambda-go v1.8.1 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/protobuf v1.4.2 - github.com/katzenpost/core v0.0.14 github.com/nyaruka/phonenumbers v1.0.60 // indirect github.com/pkg/errors v0.9.1 github.com/spf13/jwalterweatherman v1.1.0 gitlab.com/elixxir/crypto v0.0.6 gitlab.com/elixxir/primitives v0.0.3-0.20210409190923-7bf3cd8d97e7 - gitlab.com/xx_network/comms v0.0.4-0.20210414225551-37262e764468 - gitlab.com/xx_network/crypto v0.0.5-0.20210413200952-56bd15ec9d99 + gitlab.com/xx_network/comms v0.0.4-0.20210430033032-d30d75c1530f + gitlab.com/xx_network/crypto v0.0.5-0.20210430032852-de40a2ed3ac9 gitlab.com/xx_network/primitives v0.0.4-0.20210412170941-7ef69bce5a5c gitlab.com/xx_network/ring v0.0.2 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect diff --git a/go.sum b/go.sum index 6e962061fc201e4f11a5569d34f948a8e892097b..3d134a398a58b33608a5fed920aef091e8b114af 100644 --- a/go.sum +++ b/go.sum @@ -217,6 +217,10 @@ gitlab.com/xx_network/comms v0.0.4-0.20210414191603-0904bc6eeda2 h1:4Xhw5zO9ggeD gitlab.com/xx_network/comms v0.0.4-0.20210414191603-0904bc6eeda2/go.mod h1:PXbUpBMUcDygpEV1ptEc/pych07YkYQ/tv0AQPw+BRk= gitlab.com/xx_network/comms v0.0.4-0.20210414225551-37262e764468 h1:09cm7A2rSbNZQdYH+95zPj5vu3FyM1Vy2H1REU3YgpA= gitlab.com/xx_network/comms v0.0.4-0.20210414225551-37262e764468/go.mod h1:fUw26IhQ2MtjUnQVLO7TQ4tdr+g6qJPGrKfhXCb4R1E= +gitlab.com/xx_network/comms v0.0.4-0.20210430025258-f3181ea80694 h1:SO9r8vSKDNttbu3lVz1eZT6dExbI1pxSTOK3U47Bh/M= +gitlab.com/xx_network/comms v0.0.4-0.20210430025258-f3181ea80694/go.mod h1:Kz78eH5KgZupdwGqAbuPPma2t2rVocOyRNX4kinlNwQ= +gitlab.com/xx_network/comms v0.0.4-0.20210430033032-d30d75c1530f h1:6VShp/2fwtu7Rj2NVXj973CqVa0cwoqFuVH/OMJnljw= +gitlab.com/xx_network/comms v0.0.4-0.20210430033032-d30d75c1530f/go.mod h1:eV8FYDdFNV/tx7gHM3YpPczkSuZq+vRMEF0HyL9s6YM= gitlab.com/xx_network/crypto v0.0.0 h1:oMihOD4FQUgjMk6bGFgx/opQviYP89YLnRRRLjtEEOw= gitlab.com/xx_network/crypto v0.0.0/go.mod h1:6SXiU/WM2h7h/WhZW8NCEx7AAb7ZO2B2dnJOeAdeOGk= gitlab.com/xx_network/crypto v0.0.1/go.mod h1:NxXzXzzUYrqf37iYzjMTOWVq5wxSGePH5YrQCR8IojA= @@ -243,6 +247,12 @@ gitlab.com/xx_network/crypto v0.0.5-0.20210413184628-dbc1dd97ed5e h1:rfPQio950Ga gitlab.com/xx_network/crypto v0.0.5-0.20210413184628-dbc1dd97ed5e/go.mod h1:Rz97srKNbUOnMk+gKyRnJYIVIA6bGBj+BB5Of6Pfyng= gitlab.com/xx_network/crypto v0.0.5-0.20210413200952-56bd15ec9d99 h1:2WYJ+gkFAzlcdvmBzmNxx5ANNEf+p08EoT+Qeiptzw8= gitlab.com/xx_network/crypto v0.0.5-0.20210413200952-56bd15ec9d99/go.mod h1:Rz97srKNbUOnMk+gKyRnJYIVIA6bGBj+BB5Of6Pfyng= +gitlab.com/xx_network/crypto v0.0.5-0.20210430024055-946be28d5a0d h1:WWGL5qCSse+lrxkn6WQUVd0rfrEAusUS2a5vrDK7W10= +gitlab.com/xx_network/crypto v0.0.5-0.20210430024055-946be28d5a0d/go.mod h1:Rz97srKNbUOnMk+gKyRnJYIVIA6bGBj+BB5Of6Pfyng= +gitlab.com/xx_network/crypto v0.0.5-0.20210430031848-df1e0799a433 h1:LJQDZzGJllIwRqCAeTNpyzr1j+WsRll9MT1Zv/DIGeQ= +gitlab.com/xx_network/crypto v0.0.5-0.20210430031848-df1e0799a433/go.mod h1:Rz97srKNbUOnMk+gKyRnJYIVIA6bGBj+BB5Of6Pfyng= +gitlab.com/xx_network/crypto v0.0.5-0.20210430032852-de40a2ed3ac9 h1:bneOUsRAnHOIWTWbMxzMPq++bxNOCqr96/7+60l/rHM= +gitlab.com/xx_network/crypto v0.0.5-0.20210430032852-de40a2ed3ac9/go.mod h1:Rz97srKNbUOnMk+gKyRnJYIVIA6bGBj+BB5Of6Pfyng= gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA= gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug= gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc= diff --git a/mixmessages/roundInfo_test.go b/mixmessages/roundInfo_test.go index dcba0e8499b385b688adb86e879d3a0699eeb753..86f64ef8f1772a8b374e753abb8aa09dbff158a1 100644 --- a/mixmessages/roundInfo_test.go +++ b/mixmessages/roundInfo_test.go @@ -12,10 +12,10 @@ import ( "crypto" "crypto/rand" "encoding/base64" - "github.com/katzenpost/core/crypto/eddsa" "gitlab.com/elixxir/primitives/states" "gitlab.com/xx_network/comms/messages" "gitlab.com/xx_network/comms/signature" + "gitlab.com/xx_network/crypto/signature/ec" "gitlab.com/xx_network/crypto/signature/rsa" "reflect" "testing" @@ -226,11 +226,11 @@ func TestNDF_SignVerifyEddsa(t *testing.T) { BatchSize: testBatch, } // Generate keys - privateKey, err := eddsa.NewKeypair(rand.Reader) + privateKey, err := ec.NewKeyPair(rand.Reader) if err != nil { t.Fatalf("Failed to generate key: %+v", err) } - pubKey := privateKey.PublicKey() + pubKey := privateKey.GetPublic() // Sign message err = signature.SignEddsa(testRoundInfo, privateKey) @@ -258,11 +258,11 @@ func TestNdf_SignVerifyEddsa_Error(t *testing.T) { BatchSize: testBatch, } // Generate keys - privateKey, err := eddsa.NewKeypair(rand.Reader) + privateKey, err := ec.NewKeyPair(rand.Reader) if err != nil { t.Errorf("Failed to generate key: %+v", err) } - pubKey := privateKey.PublicKey() + pubKey := privateKey.GetPublic() // Sign message err = signature.SignEddsa(testRoundInfo, privateKey) diff --git a/network/dataStructures/round.go b/network/dataStructures/round.go index 3f0d9c50db144126af0e853dcd373762cbbf016f..fc69fa26b97522ffffaf5dda987cf2eaed4120d6 100644 --- a/network/dataStructures/round.go +++ b/network/dataStructures/round.go @@ -7,10 +7,10 @@ package dataStructures import ( - "github.com/katzenpost/core/crypto/eddsa" jww "github.com/spf13/jwalterweatherman" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/xx_network/comms/signature" + "gitlab.com/xx_network/crypto/signature/ec" "gitlab.com/xx_network/crypto/signature/rsa" "sync/atomic" ) @@ -22,11 +22,11 @@ type Round struct { info *pb.RoundInfo needsValidation *uint32 rsaPubKey *rsa.PublicKey - ecPubKey *eddsa.PublicKey + ecPubKey *ec.PublicKey } // Constructor of a Round object. -func NewRound(ri *pb.RoundInfo, rsaPubKey *rsa.PublicKey, ecPubKey *eddsa.PublicKey) *Round { +func NewRound(ri *pb.RoundInfo, rsaPubKey *rsa.PublicKey, ecPubKey *ec.PublicKey) *Round { validationDefault := uint32(0) return &Round{ info: ri, diff --git a/network/dataStructures/roundUpdates_test.go b/network/dataStructures/roundUpdates_test.go index bd13216864381dacd5c34eb8768e5794185d5bb6..60037b46db85b293a232d59cdf7e37e45502a5df 100644 --- a/network/dataStructures/roundUpdates_test.go +++ b/network/dataStructures/roundUpdates_test.go @@ -28,7 +28,7 @@ func TestUpdates_AddRound(t *testing.T) { } ecKey, _ := testutils.LoadEllipticPublicKey(t) - rnd := NewRound(ri, pubKey, ecKey.PublicKey()) + rnd := NewRound(ri, pubKey, ecKey.GetPublic()) err = u.AddRound(rnd) if err != nil { t.Errorf("Failed to add round: %+v", err) @@ -58,7 +58,7 @@ func TestUpdates_GetUpdate(t *testing.T) { t.Errorf("Failed to sign mock round info: %v", err) } - rnd := NewRound(ri, pubKey, ecKey.PublicKey()) + rnd := NewRound(ri, pubKey, ecKey.GetPublic()) _ = u.AddRound(rnd) _, err = u.GetUpdate(updateID) if err != nil { @@ -92,7 +92,7 @@ func TestUpdates_GetUpdates(t *testing.T) { t.Errorf("Failed to sign mock round info: %v", err) } - roundOne := NewRound(roundInfoOne, pubKey, ecKey.PublicKey()) + roundOne := NewRound(roundInfoOne, pubKey, ecKey.GetPublic()) // Construct a second eound roundInfoTwo := &mixmessages.RoundInfo{ @@ -106,7 +106,7 @@ func TestUpdates_GetUpdates(t *testing.T) { t.Errorf("Failed to sign mock round info: %v", err) } - roundTwo := NewRound(roundInfoTwo, pubKey, ecKey.PublicKey()) + roundTwo := NewRound(roundInfoTwo, pubKey, ecKey.GetPublic()) _ = u.AddRound(roundOne) // Add second round twice (shouldn't duplicate) diff --git a/network/dataStructures/round_test.go b/network/dataStructures/round_test.go index 7ba9ae8df566dde06182afc22e7071a071ac5751..4b9cbcbe15267c61cf5ad567e572752a4f879d71 100644 --- a/network/dataStructures/round_test.go +++ b/network/dataStructures/round_test.go @@ -20,10 +20,10 @@ func TestNewRound(t *testing.T) { ri := &mixmessages.RoundInfo{ID: uint64(1), UpdateID: uint64(1)} - rnd := NewRound(ri, pubKey, ecKey.PublicKey()) + rnd := NewRound(ri, pubKey, ecKey.GetPublic()) // Check that values in object match inputted values - if rnd.info != ri || rnd.rsaPubKey != pubKey || rnd.ecPubKey != ecKey.PublicKey() { + if rnd.info != ri || rnd.rsaPubKey != pubKey || rnd.ecPubKey != ecKey.GetPublic() { t.Errorf("Initial round values from constructor are not expected."+ "\n\tExpected round info: %v"+ "\n\tReceived round info: %v"+ @@ -66,7 +66,7 @@ func TestNewRound_Get(t *testing.T) { ecPubKey, _ := testutils.LoadEllipticPublicKey(t) testutils.SignRoundInfoEddsa(ri, ecPubKey, t) - rnd := NewRound(ri, pubKey, ecPubKey.PublicKey()) + rnd := NewRound(ri, pubKey, ecPubKey.GetPublic()) // Check the initial value of the atomic value (lazily) if *rnd.needsValidation != 0 { diff --git a/network/instance.go b/network/instance.go index 95758bfaf9451708b4f9aed536a9581cc566ba63..8079198014e7f403a1901cccd03278e2a7bb2b91 100644 --- a/network/instance.go +++ b/network/instance.go @@ -12,7 +12,6 @@ package network import ( "bytes" "fmt" - "github.com/katzenpost/core/crypto/eddsa" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" pb "gitlab.com/elixxir/comms/mixmessages" @@ -52,7 +51,7 @@ type Instance struct { // using the RSA key or the EC key. // Set to true, they shall use elliptic, set to false they shall use RSA useElliptic bool - ecPublicKey *eddsa.PublicKey + ecPublicKey *ec.PublicKey // Waiting Rounds waitingRounds *ds.WaitingRounds @@ -169,14 +168,14 @@ func NewInstance(c *connect.ProtoComms, partial, full *ndf.NetworkDefinition, er useElliptic: useElliptic, } - var ecPublicKey *eddsa.PublicKey + var ecPublicKey *ec.PublicKey if full != nil && full.Registration.EllipticPubKey != "" { - ecPublicKey, err = ec.LoadPublicKeyFromString(i.GetEllipticPublicKey()) + ecPublicKey, err = ec.LoadPublicKey(i.GetEllipticPublicKey()) if err != nil { return nil, errors.WithMessage(err, fmt.Sprintf("Could not load elliptic key from ndf")) } } else if partial.Registration.EllipticPubKey != "" { - ecPublicKey, err = ec.LoadPublicKeyFromString(i.GetEllipticPublicKey()) + ecPublicKey, err = ec.LoadPublicKey(i.GetEllipticPublicKey()) if err != nil { return nil, errors.WithMessage(err, fmt.Sprintf("Could not load elliptic key from ndf")) } diff --git a/testutils/utils.go b/testutils/utils.go index c0506bfa8b83a46bdffe21003c2ef7242d8024d9..5d060d55b00d445d9858824eca804289d3c3a84b 100644 --- a/testutils/utils.go +++ b/testutils/utils.go @@ -9,16 +9,19 @@ package testutils import ( "crypto/rand" - "github.com/katzenpost/core/crypto/eddsa" "github.com/pkg/errors" jww "github.com/spf13/jwalterweatherman" pb "gitlab.com/elixxir/comms/mixmessages" "gitlab.com/elixxir/comms/testkeys" "gitlab.com/xx_network/comms/signature" + "gitlab.com/xx_network/crypto/signature/ec" "gitlab.com/xx_network/crypto/signature/rsa" "testing" ) +const privKeyEncoded = `uVAt6d+y3XW699L3THlcoTA2utw2dhoqnX6821x6OcnOliwX84eajmp45IZ+STw0dUl8uJtZwDKDuHVX6ZpGzg==` + + func LoadPublicKeyTesting(i interface{}) (*rsa.PublicKey, error) { switch i.(type) { case *testing.T: @@ -63,7 +66,7 @@ func LoadPrivateKeyTesting(i interface{}) (*rsa.PrivateKey, error) { } -func LoadEllipticPublicKey(i interface{}) (*eddsa.PrivateKey, error) { +func LoadEllipticPublicKey(i interface{}) (*ec.PrivateKey, error) { switch i.(type) { case *testing.T: break @@ -75,11 +78,14 @@ func LoadEllipticPublicKey(i interface{}) (*eddsa.PrivateKey, error) { jww.FATAL.Panicf("SignRoundInfoRsa is restricted to testing only. Got %T", i) } - ecKey, err := eddsa.NewKeypair(rand.Reader) + ecKey, err := ec.NewKeyPair(rand.Reader) if err != nil { return nil, errors.Errorf("Failed to generate new keypair: %v", err) } - + err = ecKey.UnmarshalText(privKeyEncoded) + if err != nil { + return nil, errors.Errorf("Failed to unmarshal private key: %v", err) + } return ecKey, nil } @@ -112,7 +118,7 @@ func SignRoundInfoRsa(ri *pb.RoundInfo, i interface{}) error { return nil } -func SignRoundInfoEddsa(ri *pb.RoundInfo, key *eddsa.PrivateKey, i interface{}) error { +func SignRoundInfoEddsa(ri *pb.RoundInfo, key *ec.PrivateKey, i interface{}) error { switch i.(type) { case *testing.T: break