From 577a396bafa310dd2e46607fee9d659d2dddb44f Mon Sep 17 00:00:00 2001 From: David Stainton <dstainton@elixxir.io> Date: Thu, 18 Aug 2022 16:11:46 -0400 Subject: [PATCH] Fixup requestChannelLease --- go.mod | 2 +- ud/channelLease.go | 24 ++++++++++++++++-------- ud/comms.go | 4 ++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 64b09fb6e..c4bb9a399 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module gitlab.com/elixxir/client go 1.17 replace gitlab.com/elixxir/crypto => /home/human/code/crypto - +replace gitlab.com/elixxir/comms => /home/human/code/comms require ( github.com/cloudflare/circl v1.2.0 github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 diff --git a/ud/channelLease.go b/ud/channelLease.go index d3608f939..a278eec89 100644 --- a/ud/channelLease.go +++ b/ud/channelLease.go @@ -11,7 +11,14 @@ import ( "gitlab.com/elixxir/crypto/fastRNG" ) -func requestChannelLease(userPubKey ed25519.PublicKey, username string, comms channelLeaseComms, ud *userDiscovery, receptionIdentity xxdk.ReceptionIdentity, rngGenerator *fastRNG.StreamGenerator) (int64, []byte, error) { +func requestChannelLease(userPubKey ed25519.PublicKey, + username string, + comms channelLeaseComms, + ud *userDiscovery, + receptionIdentity xxdk.ReceptionIdentity, + rngGenerator *fastRNG.StreamGenerator, + signerPubKey ed25519.PublicKey) (int64, []byte, error) { + ts := time.Now().UnixNano() privKey, err := receptionIdentity.GetRSAPrivatePem() if err != nil { @@ -24,11 +31,11 @@ func requestChannelLease(userPubKey ed25519.PublicKey, username string, comms ch } rng.Close() - msg := &mixmessages.ChannelAuthenticationRequest{ - UserID: receptionIdentity.ID.Marshal(), - UserEd25519PubKey: userPubKey, - Timestamp: ts, - UserSignedEdPubKey: fSig, + msg := &mixmessages.ChannelLeaseRequest{ + UserID: receptionIdentity.ID.Marshal(), + UserEd25519PubKey: userPubKey, + Timestamp: ts, + UserPubKeyRSASignature: fSig, } resp, err := comms.SendChannelAuthRequest(ud.host, msg) @@ -36,10 +43,11 @@ func requestChannelLease(userPubKey ed25519.PublicKey, username string, comms ch return 0, nil, err } - ok := channel.VerifyChannelLease(resp.UDLeaseEd25519Signature, resp.UDSignedEdPubKey, userPubKey, uint64(resp.Lease), nil) + ok := channel.VerifyChannelLease(resp.UDLeaseEd25519Signature, + userPubKey, username, time.Unix(0, resp.Lease), signerPubKey) if !ok { return 0, nil, errors.New("error could not verify signature returned with channel lease") } - return resp.Lease, resp.UDSignedEdPubKey, err + return resp.Lease, resp.UDLeaseEd25519Signature, err } diff --git a/ud/comms.go b/ud/comms.go index a7f25b1bb..ef517df61 100644 --- a/ud/comms.go +++ b/ud/comms.go @@ -38,7 +38,7 @@ type Comms interface { // gRPC send functions. GetHost(hostId *id.ID) (*connect.Host, bool) - SendChannelAuthRequest(host *connect.Host, message *pb.ChannelAuthenticationRequest) (*pb.ChannelAuthenticationResponse, error) + SendChannelAuthRequest(host *connect.Host, message *pb.ChannelLeaseRequest) (*pb.ChannelLeaseResponse, error) } // removeFactComms is a sub-interface of the Comms interface for the @@ -72,5 +72,5 @@ type addFactComms interface { } type channelLeaseComms interface { - SendChannelAuthRequest(host *connect.Host, message *pb.ChannelAuthenticationRequest) (*pb.ChannelAuthenticationResponse, error) + SendChannelAuthRequest(host *connect.Host, message *pb.ChannelLeaseRequest) (*pb.ChannelLeaseResponse, error) } -- GitLab