CryptoContext->Eval... Tracing Framework #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a tracing framework that is essentially zero-cost when disabled at compile time (
-DENABLE_TRACER=OFF) and extremely low-cost when enabled (-DENABLE_TRACER=ON) but not being used (seeNullTracerandNullFunctionTracer).The framework is extremely flexible in terms of what kind of tracing it allows.
A basic example is provided in the form of
example-tracer.h(run exampleexample-tracingwith tracing enabled to see an example trace or see this gist).However, the real power of the system is probably more apparent by looking at the HeraclesTracer from IntelLabs/encrypted-computing-sdk.
The framework consists of three components:
CryptoContext::EvalAdd,LeveledSHE::EvalAdd,RNSCKKS::EvalAdd, etc) register what function is being called, along with its inputs and outputs.Tracerclass (or, rather, a non-abstract derived class) is designed to keep track of global (where "global" here means "relative to a specificCryptoContext") state and is in charge of startingFunctionTracerinstances when requested by the tracing callbacks.FunctionTraceris responsible for collecting information about the specific function it was created for. In order to facilitate this, it has (read) access (by reference/shared_ptr) to the actual inputs provided to the traced function. This means that each tracing implementation is entirely free in how (or even if) it chooses to track data flows.While the old tracing system tried to use raw memory addresses as identifiers, and an early iteration of this new system tried to keep track of object constructors/assignments, the current version of the framework does not actually prescribe any specific approach. However, it is strongly suggested to use the approach used by
SimpleTracer, which hashes the serialization of an object to arrive at a unique id. In order to improve human readability, instead of using the raw hashes as identifiers, there is a little abstraction layer that assigns human-readable unique ids of the formciphertext_1,ciphertext_2,plaintext_1, etc.