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

Propagate refactor of signature.ec in xxCrypto

parent fb1a8a82
Branches
Tags
2 merge requests!58Revert "Modify waiting lock",!9Release
...@@ -6,14 +6,13 @@ require ( ...@@ -6,14 +6,13 @@ require (
github.com/aws/aws-lambda-go v1.8.1 // indirect github.com/aws/aws-lambda-go v1.8.1 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.4.2 github.com/golang/protobuf v1.4.2
github.com/katzenpost/core v0.0.14
github.com/nyaruka/phonenumbers v1.0.60 // indirect github.com/nyaruka/phonenumbers v1.0.60 // indirect
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
gitlab.com/elixxir/crypto v0.0.6 gitlab.com/elixxir/crypto v0.0.6
gitlab.com/elixxir/primitives v0.0.3-0.20210409190923-7bf3cd8d97e7 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/comms v0.0.4-0.20210430033032-d30d75c1530f
gitlab.com/xx_network/crypto v0.0.5-0.20210413200952-56bd15ec9d99 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/primitives v0.0.4-0.20210412170941-7ef69bce5a5c
gitlab.com/xx_network/ring v0.0.2 gitlab.com/xx_network/ring v0.0.2
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
......
...@@ -217,6 +217,10 @@ gitlab.com/xx_network/comms v0.0.4-0.20210414191603-0904bc6eeda2 h1:4Xhw5zO9ggeD ...@@ -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.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 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.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 h1:oMihOD4FQUgjMk6bGFgx/opQviYP89YLnRRRLjtEEOw=
gitlab.com/xx_network/crypto v0.0.0/go.mod h1:6SXiU/WM2h7h/WhZW8NCEx7AAb7ZO2B2dnJOeAdeOGk= 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= 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 ...@@ -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.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 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.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-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.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug=
gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc= gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc=
......
...@@ -12,10 +12,10 @@ import ( ...@@ -12,10 +12,10 @@ import (
"crypto" "crypto"
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"github.com/katzenpost/core/crypto/eddsa"
"gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/primitives/states"
"gitlab.com/xx_network/comms/messages" "gitlab.com/xx_network/comms/messages"
"gitlab.com/xx_network/comms/signature" "gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"reflect" "reflect"
"testing" "testing"
...@@ -226,11 +226,11 @@ func TestNDF_SignVerifyEddsa(t *testing.T) { ...@@ -226,11 +226,11 @@ func TestNDF_SignVerifyEddsa(t *testing.T) {
BatchSize: testBatch, BatchSize: testBatch,
} }
// Generate keys // Generate keys
privateKey, err := eddsa.NewKeypair(rand.Reader) privateKey, err := ec.NewKeyPair(rand.Reader)
if err != nil { if err != nil {
t.Fatalf("Failed to generate key: %+v", err) t.Fatalf("Failed to generate key: %+v", err)
} }
pubKey := privateKey.PublicKey() pubKey := privateKey.GetPublic()
// Sign message // Sign message
err = signature.SignEddsa(testRoundInfo, privateKey) err = signature.SignEddsa(testRoundInfo, privateKey)
...@@ -258,11 +258,11 @@ func TestNdf_SignVerifyEddsa_Error(t *testing.T) { ...@@ -258,11 +258,11 @@ func TestNdf_SignVerifyEddsa_Error(t *testing.T) {
BatchSize: testBatch, BatchSize: testBatch,
} }
// Generate keys // Generate keys
privateKey, err := eddsa.NewKeypair(rand.Reader) privateKey, err := ec.NewKeyPair(rand.Reader)
if err != nil { if err != nil {
t.Errorf("Failed to generate key: %+v", err) t.Errorf("Failed to generate key: %+v", err)
} }
pubKey := privateKey.PublicKey() pubKey := privateKey.GetPublic()
// Sign message // Sign message
err = signature.SignEddsa(testRoundInfo, privateKey) err = signature.SignEddsa(testRoundInfo, privateKey)
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
package dataStructures package dataStructures
import ( import (
"github.com/katzenpost/core/crypto/eddsa"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
pb "gitlab.com/elixxir/comms/mixmessages" pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/comms/signature" "gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"sync/atomic" "sync/atomic"
) )
...@@ -22,11 +22,11 @@ type Round struct { ...@@ -22,11 +22,11 @@ type Round struct {
info *pb.RoundInfo info *pb.RoundInfo
needsValidation *uint32 needsValidation *uint32
rsaPubKey *rsa.PublicKey rsaPubKey *rsa.PublicKey
ecPubKey *eddsa.PublicKey ecPubKey *ec.PublicKey
} }
// Constructor of a Round object. // 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) validationDefault := uint32(0)
return &Round{ return &Round{
info: ri, info: ri,
......
...@@ -28,7 +28,7 @@ func TestUpdates_AddRound(t *testing.T) { ...@@ -28,7 +28,7 @@ func TestUpdates_AddRound(t *testing.T) {
} }
ecKey, _ := testutils.LoadEllipticPublicKey(t) ecKey, _ := testutils.LoadEllipticPublicKey(t)
rnd := NewRound(ri, pubKey, ecKey.PublicKey()) rnd := NewRound(ri, pubKey, ecKey.GetPublic())
err = u.AddRound(rnd) err = u.AddRound(rnd)
if err != nil { if err != nil {
t.Errorf("Failed to add round: %+v", err) t.Errorf("Failed to add round: %+v", err)
...@@ -58,7 +58,7 @@ func TestUpdates_GetUpdate(t *testing.T) { ...@@ -58,7 +58,7 @@ func TestUpdates_GetUpdate(t *testing.T) {
t.Errorf("Failed to sign mock round info: %v", err) 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) _ = u.AddRound(rnd)
_, err = u.GetUpdate(updateID) _, err = u.GetUpdate(updateID)
if err != nil { if err != nil {
...@@ -92,7 +92,7 @@ func TestUpdates_GetUpdates(t *testing.T) { ...@@ -92,7 +92,7 @@ func TestUpdates_GetUpdates(t *testing.T) {
t.Errorf("Failed to sign mock round info: %v", err) 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 // Construct a second eound
roundInfoTwo := &mixmessages.RoundInfo{ roundInfoTwo := &mixmessages.RoundInfo{
...@@ -106,7 +106,7 @@ func TestUpdates_GetUpdates(t *testing.T) { ...@@ -106,7 +106,7 @@ func TestUpdates_GetUpdates(t *testing.T) {
t.Errorf("Failed to sign mock round info: %v", err) 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) _ = u.AddRound(roundOne)
// Add second round twice (shouldn't duplicate) // Add second round twice (shouldn't duplicate)
......
...@@ -20,10 +20,10 @@ func TestNewRound(t *testing.T) { ...@@ -20,10 +20,10 @@ func TestNewRound(t *testing.T) {
ri := &mixmessages.RoundInfo{ID: uint64(1), UpdateID: uint64(1)} 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 // 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."+ t.Errorf("Initial round values from constructor are not expected."+
"\n\tExpected round info: %v"+ "\n\tExpected round info: %v"+
"\n\tReceived round info: %v"+ "\n\tReceived round info: %v"+
...@@ -66,7 +66,7 @@ func TestNewRound_Get(t *testing.T) { ...@@ -66,7 +66,7 @@ func TestNewRound_Get(t *testing.T) {
ecPubKey, _ := testutils.LoadEllipticPublicKey(t) ecPubKey, _ := testutils.LoadEllipticPublicKey(t)
testutils.SignRoundInfoEddsa(ri, ecPubKey, 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) // Check the initial value of the atomic value (lazily)
if *rnd.needsValidation != 0 { if *rnd.needsValidation != 0 {
......
...@@ -12,7 +12,6 @@ package network ...@@ -12,7 +12,6 @@ package network
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/katzenpost/core/crypto/eddsa"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
pb "gitlab.com/elixxir/comms/mixmessages" pb "gitlab.com/elixxir/comms/mixmessages"
...@@ -52,7 +51,7 @@ type Instance struct { ...@@ -52,7 +51,7 @@ type Instance struct {
// using the RSA key or the EC key. // using the RSA key or the EC key.
// Set to true, they shall use elliptic, set to false they shall use RSA // Set to true, they shall use elliptic, set to false they shall use RSA
useElliptic bool useElliptic bool
ecPublicKey *eddsa.PublicKey ecPublicKey *ec.PublicKey
// Waiting Rounds // Waiting Rounds
waitingRounds *ds.WaitingRounds waitingRounds *ds.WaitingRounds
...@@ -169,14 +168,14 @@ func NewInstance(c *connect.ProtoComms, partial, full *ndf.NetworkDefinition, er ...@@ -169,14 +168,14 @@ func NewInstance(c *connect.ProtoComms, partial, full *ndf.NetworkDefinition, er
useElliptic: useElliptic, useElliptic: useElliptic,
} }
var ecPublicKey *eddsa.PublicKey var ecPublicKey *ec.PublicKey
if full != nil && full.Registration.EllipticPubKey != "" { if full != nil && full.Registration.EllipticPubKey != "" {
ecPublicKey, err = ec.LoadPublicKeyFromString(i.GetEllipticPublicKey()) ecPublicKey, err = ec.LoadPublicKey(i.GetEllipticPublicKey())
if err != nil { if err != nil {
return nil, errors.WithMessage(err, fmt.Sprintf("Could not load elliptic key from ndf")) return nil, errors.WithMessage(err, fmt.Sprintf("Could not load elliptic key from ndf"))
} }
} else if partial.Registration.EllipticPubKey != "" { } else if partial.Registration.EllipticPubKey != "" {
ecPublicKey, err = ec.LoadPublicKeyFromString(i.GetEllipticPublicKey()) ecPublicKey, err = ec.LoadPublicKey(i.GetEllipticPublicKey())
if err != nil { if err != nil {
return nil, errors.WithMessage(err, fmt.Sprintf("Could not load elliptic key from ndf")) return nil, errors.WithMessage(err, fmt.Sprintf("Could not load elliptic key from ndf"))
} }
......
...@@ -9,16 +9,19 @@ package testutils ...@@ -9,16 +9,19 @@ package testutils
import ( import (
"crypto/rand" "crypto/rand"
"github.com/katzenpost/core/crypto/eddsa"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
pb "gitlab.com/elixxir/comms/mixmessages" pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/comms/testkeys" "gitlab.com/elixxir/comms/testkeys"
"gitlab.com/xx_network/comms/signature" "gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"testing" "testing"
) )
const privKeyEncoded = `uVAt6d+y3XW699L3THlcoTA2utw2dhoqnX6821x6OcnOliwX84eajmp45IZ+STw0dUl8uJtZwDKDuHVX6ZpGzg==`
func LoadPublicKeyTesting(i interface{}) (*rsa.PublicKey, error) { func LoadPublicKeyTesting(i interface{}) (*rsa.PublicKey, error) {
switch i.(type) { switch i.(type) {
case *testing.T: case *testing.T:
...@@ -63,7 +66,7 @@ func LoadPrivateKeyTesting(i interface{}) (*rsa.PrivateKey, error) { ...@@ -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) { switch i.(type) {
case *testing.T: case *testing.T:
break break
...@@ -75,11 +78,14 @@ func LoadEllipticPublicKey(i interface{}) (*eddsa.PrivateKey, error) { ...@@ -75,11 +78,14 @@ func LoadEllipticPublicKey(i interface{}) (*eddsa.PrivateKey, error) {
jww.FATAL.Panicf("SignRoundInfoRsa is restricted to testing only. Got %T", i) 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 { if err != nil {
return nil, errors.Errorf("Failed to generate new keypair: %v", err) 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 return ecKey, nil
} }
...@@ -112,7 +118,7 @@ func SignRoundInfoRsa(ri *pb.RoundInfo, i interface{}) error { ...@@ -112,7 +118,7 @@ func SignRoundInfoRsa(ri *pb.RoundInfo, i interface{}) error {
return nil 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) { switch i.(type) {
case *testing.T: case *testing.T:
break break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment