You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Switch from using the global agent to using global keypairs for tests #404
#264 introduced our global agent which is used in our tests as a way to reduce setup time (since we no longer need to create an agent for every test). However, this solution complicates our tests by requiring all side effects to be reversed (some side effects cannot be undone, e.g. sigchain changes and some identities changes) and preventing tests that use the global agent from running in parallel.
An alternative solution is to have a pre-generated root private key that we can pass into the PolykeyAgent creation. This should sidestep the key generation process and speed up agent creation significantly.
I'm going to change this up slightly and include it in MatrixAI/Polykey-CLI#10, #391. Instead of using mocking for this I'll add a parameter/ENV for setting the root private key to skip the generation step. We can extend this change to key mocking across all tests. That should be a separate issue however.
The changes here should be
Allow override to KeyManager generation to provide a root private key to skip keypair generation.
Propigate this override up to the PolykeyAgent parameters
create tests confirming this behaviour.
Propagate this change up to pk agent start and pk bootstrap. Including new parameter + env variable.
Replace all usages of global agent with root key override.
I also need to create a new issue to replace key mocking for all tests.
The neat thing is, with the new private-Key override we gain the feature of having a node signed by another node. This can be done by generating the node with a private key of another node and then renewing the keys to generate a new root key-pair signed by the previous one. The affect of which is having the node essentially signed by the other node.
pk agent start and pk bootstrap take the --private-key-file parameter now. This will be a path to a file containing the private key in Pem format. SInce the Pem format includes newlines, we can't pass it directly as an ENV or parameter.
The Pem is passed through createPolykeyAgent to createKeyManager. It is converted to a keyPair inside the key manager during the key generation step. I originally tried using the PrivateKey format but that contained functions inside it that were lost at certain stages of passing the key around.
I'm starting on removing the global agent in the tests now.
Activity
tegefaulkes commentedon Jul 15, 2022
I'm going to change this up slightly and include it in MatrixAI/Polykey-CLI#10, #391. Instead of using mocking for this I'll add a parameter/ENV for setting the root private key to skip the generation step. We can extend this change to key mocking across all tests. That should be a separate issue however.
The changes here should be
KeyManagergeneration to provide a root private key to skip keypair generation.PolykeyAgentparameterspk agent startandpk bootstrap. Including new parameter + env variable.I also need to create a new issue to replace key mocking for all tests.
feat: added ability to override keypair generation with `privateKeyOv…
tegefaulkes commentedon Jul 15, 2022
The neat thing is, with the new private-Key override we gain the feature of having a node signed by another node. This can be done by generating the node with a private key of another node and then renewing the keys to generate a new root key-pair signed by the previous one. The affect of which is having the node essentially signed by the other node.
CMCDragonkai commentedon Jul 15, 2022
Loading a key that is created by another node is not exactly the same as cross-signing (PKI). See #154 for what I mean.
feat: added `--private-key` option to `CommandStart.ts` and `CommandB…
feat: added `--private-key-file` option to `CommandStart.ts` and `Com…
tegefaulkes commentedon Jul 18, 2022
pk agent startandpk bootstraptake the--private-key-fileparameter now. This will be a path to a file containing the private key in Pem format. SInce the Pem format includes newlines, we can't pass it directly as an ENV or parameter.The Pem is passed through
createPolykeyAgenttocreateKeyManager. It is converted to a keyPair inside the key manager during the key generation step. I originally tried using thePrivateKeyformat but that contained functions inside it that were lost at certain stages of passing the key around.I'm starting on removing the global agent in the tests now.
CMCDragonkai commentedon Jul 18, 2022
I'm thinking you should call this parameter
--root-key. Do we use-filesuffix in other parameters?CMCDragonkai commentedon Jul 18, 2022
And yes you can pass newlines as environment variable. It's not a problem. Variables in shell Env can have newlines.
CMCDragonkai commentedon Jul 18, 2022
Also if this parameter is specified, you have to ignore any usage of recovery code. It needs to be ignored.
If the file is password protected you'll need both a password to decrypt it, and a password to encrypt it.
So
--passwordwould decrypt it if necessary and be the same password to encrypt.tegefaulkes commentedon Jul 18, 2022
I'll double check the Env.
As for the
-filesuffix. we have--recovery-code-file,--password-new-file,--password-fileet al. I can change it to--root-key-file.fixin: added `PK_ROOT_KEY` ENV and changed `--private-key-file` to `-…
test: added `setupTestAgent` for creating test agents
9 remaining items
feat: added `--private-key-file` option to `CommandStart.ts` and `Com…
fixin: added `PK_ROOT_KEY` ENV and changed `--private-key-file` to `-…
test: added `setupTestAgent` for creating test agents
wip: removing global agent usuage
test: removing global agent usage
fix: moved `globalRootKeyPems.ts` to fixtures
feat: added ability to override keypair generation with `privateKeyOv…
feat: added `--private-key-file` option to `CommandStart.ts` and `Com…
test: added `setupTestAgent` for creating test agents
test: removing global agent usage
fix: moved `globalRootKeyPems.ts` to fixtures
fix: moved `globalRootKeyPems.ts` to fixtures