Skip to content
Snippets Groups Projects
Select Git revision
  • e3cf8ac9d02a5d0f26d6e9371a9e9f79c3c324cf
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

request.go

Blame
  • request.go 12.38 KiB
    package single
    
    import (
    	"bytes"
    	"github.com/pkg/errors"
    	jww "github.com/spf13/jwalterweatherman"
    	"gitlab.com/elixxir/client/cmix"
    	"gitlab.com/elixxir/client/cmix/identity/receptionID"
    	cmixMsg "gitlab.com/elixxir/client/cmix/message"
    	"gitlab.com/elixxir/client/cmix/rounds"
    	"gitlab.com/elixxir/client/single/message"
    	"gitlab.com/elixxir/crypto/contact"
    	"gitlab.com/elixxir/crypto/cyclic"
    	"gitlab.com/elixxir/crypto/e2e/auth"
    	"gitlab.com/elixxir/crypto/e2e/singleUse"
    	"gitlab.com/xx_network/crypto/csprng"
    	"gitlab.com/xx_network/primitives/id"
    	"gitlab.com/xx_network/primitives/id/ephemeral"
    	"gitlab.com/xx_network/primitives/netTime"
    	"io"
    	"sync"
    	"sync/atomic"
    	"time"
    )
    
    // Error messages.
    const (
    	// TransmitRequest
    	errPayloadSize     = "size of payload %d exceeds the maximum size of %d (%s for %s)"
    	errNetworkHealth   = "cannot send singe-use request when the network is not healthy"
    	errMakeDhKeys      = "failed to generate DH keys (%s for %s): %+v"
    	errMakeIDs         = "failed to generate IDs (%s for %s): %+v"
    	errAddFingerprint  = "failed to add fingerprint %d of %d: %+v (%s for %s)"
    	errSendRequest     = "failed to send %s request to %s: %+v"
    	errSendRequestPart = "%d requests failed to send, the request will be handleable and will time out"
    
    	// generateDhKeys
    	errGenerateInGroup = "failed to generate private key in group: %+v"
    
    	// makeIDs
    	errMakeNonce      = "failed to generate nonce: %+v"
    	errNewEphemeralID = "failed to generate address ID from newly generated ID: %+v"
    
    	// waitForTimeout
    	errResponseTimeout = "waiting for response to single-use request timed out after %s"
    )
    
    // Maximum number of request part cMix messages.
    const maxNumRequestParts = 255
    
    // GetMaxRequestSize returns the maximum size of a request payload.
    func GetMaxRequestSize(net Cmix, e2eGrp *cyclic.Group) int {
    	payloadSize := message.GetRequestPayloadSize(
    		net.GetMaxMessageLength(), e2eGrp.GetP().ByteLen())
    	requestSize := message.GetRequestContentsSize(payloadSize)
    	requestPartSize := message.GetRequestPartContentsSize(
    		net.GetMaxMessageLength())
    	return requestSize + (maxNumRequestParts * requestPartSize)
    }
    
    /* Single is a system which allows for an end-to-end encrypted anonymous request
       to be sent to another cMix client, and for them to respond. The system allows
       for communication over the mixnet without an interactive key negotiation
       because the payload inherently carries the negotiation with it. When sending
       a new request, a client create a new discreet log DH keypair as well as a new
       ID. As a result of the fact that the client never identifies itself, the
       system allows the client to stay anonymous while contacting the remote.
    */
    
    // TransmitRequest sends a request to the recipient with the given tag