rpc/stream/vif: reuse vif auth in vc

This change allows to reuse VIF authentication in VCs when the peer
is the same as VIF - i.e., non-through-proxy connection.

Details:
  o During a VIF setup, peers exchange their endpoint and save VIF
    authentication, which can be used in the following VCs.
  o During vif.Dial(), re-use the VIF authentication when
     - a principal given to vif.InternalNewDialedVIF() and one given to
       vif.Dial() are same, and
     - two remote endpoints are same or the given endpoint is null
       which means a direct connection with hostname and port
     - a server verifies a signature for reusing the VIF authentication
       that are sent from a client.
  o When reusing VIF auth
    - a dialed VC creates a new public and private key, but uses
      a server's public key which were exchanged during VIF setup.
      The VC sends the new public key to the server, but skips
      all authentication except running server authorizer.
    - a accepted VC creates a new crypter using the VIF's public and
      private key pair with a new public key from the client.
      The server doesn't send a SetupVC response and skips the
      authentication.

RPC Setup Benchmark: (in GCE)
  o OLD: RPC Connection  30.27 ms/rpc
  o NEW: RPC Connection  14.02 ms/rpc

Agent Benchmark: (in GCE)
benchmark                                      old ns/op     new ns/op     delta
BenchmarkSignNoAgent-4                         936403        932508        -0.42%
BenchmarkSignCachedAgent-4                     5309176       1764895       -66.76%
BenchmarkSignUncachedAgent-4                   5381638       1758834       -67.32%
BenchmarkDefaultNoAgent-4                      137           140           +2.19%
BenchmarkDefaultCachedAgent-4                  44.7          45.2          +1.12%
BenchmarkDefaultUncachedAgent-4                7828080       3846960       -50.86%
BenchmarkRecognizedNegativeNoAgent-4           34227         36651         +7.08%
BenchmarkRecognizedNegativeCachedAgent-4       33353         35574         +6.66%
BenchmarkRecognizedNegativeUncachedAgent-4     4291997       944295        -78.00%
BenchmarkRecognizedNoAgent-4                   13485         14271         +5.83%
BenchmarkRecognizedCachedAgent-4               13031         13456         +3.26%
BenchmarkRecognizedUncachedAgent-4             4016690       785538        -80.44%

MultiPart: 2/2
Change-Id: Ida0c8f65a7b0083d8b75e59af45202c6276964d6
23 files changed
tree: 1eb05d01a5ec9678fe5d15490437eb6fbd6b58e2
  1. cmd/
  2. examples/
  3. internal/
  4. lib/
  5. runtime/
  6. services/
  7. test/
  8. .gitignore
  9. AUTHORS
  10. CONTRIBUTORS
  11. envvar.go
  12. envvar_test.go
  13. LICENSE
  14. PATENTS
  15. README.md
  16. VERSION
README.md

Vanadium

This repository contains a reference implementation of the Vanadium APIs.

Unlike the APIs in https://github.com/vanadium/go.v23, which promises to provide backward compatibility this repository makes no such promises.