security: Avoid unnecessarily public key marshaling/unmarshaling.

Most places where "recognition" of a root public key is to be tested
(via BlessingRoots.Recognized), the marshaled form of the key is
available. However, given the BlessingRoots API prior to this commit,
the code ended up unmarshaling the bytes into an object and then the
BlessingRoots implementation would marshal it back into a string
in order to lookup a cache key. This was simply a waste of time.

The BlessingRoots API (in particular the Add and Recognized methods) are
likely to not be directly used outside the Vanadium runtime
implementation. By changing their signature to take serialized keys
instead of objects, we see a significant speedup (3-9x) in
RemoteBlessingNames, which will be used by developers more frequently.

go test v.io/v23/security -bench RemoteBlessingNames
(values are in ns/op):
                              BEFORE AFTER SPEEDUP
BenchmarkRemoteBlessingNames  75746   8451 9x
BenchmarkRemoteBlessingNames  24741   8081 3x [-tags noopenssl]

It is curious that the OpenSSL implementation is still a bit slower
than a pure Go implementation in this benchmark. I'm looking into that
(and currently creation of an OpenSSL-based public key does involved an
extra Marshaling/Unmarshaling).

MultiPart: 2/3
Change-Id: I2c9776175c51b9fc56d093567d71a8341125f358
12 files changed
tree: 6c2ba5b4e08fa324cfe23ba11121b6bc0393929c
  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.