[Feature] Add KeyStore interface for persistent Proving and Verifying Key storage
Motivation
Aleo functions require a proving key and verifying key per function. On execution, if the keys do not currently exist, they are synthesized and stored in the local Process object. However This synthesis process takes a long time and execution time can be cut down drastically by inserting pre-synthesized keys. Normally on executors with filesystems, these keys are stored locally on disk automatically by SnarkVM. However wasm has no direct access to a filesystem, thus proving and verifying keys must be passed into wasm externally by JS.
Because JS can operate in multiple contexts (such as the browser, node.js on a machine with a filesystem, or perhaps an enclave environment) key storage will necessarily need to be different depending on the operational context.
Currently there no convenient abstractions in the SDK for managing proving and verifying keys and it is not clear to many users how to do proper proving and verifying key management. This PR adds a KeyStore abstraction that provides methods for storing and retrieving proving and verifying keys and provides a default implementation called the FileSystemKeyProvider for NodeJS sdk users that have access to filesystems.
This PR also adds the KeyStore object to the FunctionKeyProvider interface for convenient access.
Test Plan
- Several unit tests should be written against the
FileSystemKeyProviderto ensure theKeyStoreinterface operates as desired. - Unit tests should test the new keyStore() method against the
OfflineKeyProviderandAleoKeyProviderto ensure these interfaces work as desired.
@copilot please add the desired unit tests specified in this PR in a file in a ./sdk/tests/keystore.test.ts file.
@iamalwaysuncomfortable I've opened a new pull request, #1139, to work on those changes. Once the pull request is ready, I'll request review from you.