Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

216 build keychainprogram #217

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Conversation

benjaminpreiss
Copy link
Collaborator

@benjaminpreiss benjaminpreiss commented Oct 9, 2023

@benjaminpreiss benjaminpreiss linked an issue Oct 9, 2023 that may be closed by this pull request

// TODO: Unsure about encryptProvider here honestly - should this be layer 1 keychain?
async open(parameters: {
identity: Identity;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identity already exist if you do

this.identity inside open (it is a global thing on 'this')

}
}

export class KeychainProgram extends Program {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implements Keychain maybe? from '@peerbit/keychain'


export class KeychainProgram extends Program {
@field({ type: Documents<EncryptedExtendedKey> })
keys: Documents<EncryptedExtendedKey>;
Copy link
Member

@marcus-pousette marcus-pousette Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When PR #215 is merged it should in practice just be possible to just do

@field({ type: Documents<Ed25519Keypair> })
keys: Documents<Ed25519Keypair>; // or something else secret

and later just do

sharedKeychain.keys.put(keypair, { encryption : { hash: ` the hash of the secret key you want to use` } })

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, well it depends if you want to have a a public and private part of the document of course. Then you need the EncryptedExtendedKey type

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, but isn't the problem that the encryption property on the put method encrypts the whole key? How would I then find the public key of someone else that I want to encrypt something for, if the public key is encrypted as well?

Copy link
Collaborator Author

@benjaminpreiss benjaminpreiss Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

___ I edited this message by mistake ___ // marcus

Copy link
Collaborator Author

@benjaminpreiss benjaminpreiss Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I have also been thinking - sometimes, a user I want to encrypt something for has not generated a keypair yet. So at that time of speaking, I want to generate a keypair for him that is only single use. And that might have to be marked as such?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property on the put method encrypts the whole key? How would I then find the public key of someone else that I want to encrypt something for, if the public key is encrypted as well?

Ah yee for this to work the decryption has to be performed by keys that exist in a lower level keychain. When you use the put method there PublicKeyEnvelope (in the crypto lib) will leak the publickeys of the parties that can decrypt the message, which allows you to figure out if you can decrypt a message.

I think it might be easier to reason about stuff if you would separate "encryption" utilties from this shared-keychain. So this keychain stores keys that are encrypted, but the keys for providing the encryption for storing these keys for this keychain perhaps needs to originate from a lower level keychain.

It could in practice also be possible that keys in this keychain are allso encrypted by keys that also exist in this keychain, but then you need to make sure you are loading the database in the right order kind of (which is possible in practice there is a oplog behind the scenes that allows you to link commits)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to revoke keys I think you need a revoked flag on the keypair object, or something like that. Else you could in theory also just use the delete function of the document store and assumes keys are only valid if they exist in the keychain

@marcus-pousette marcus-pousette force-pushed the master branch 4 times, most recently from f692297 to 015dae4 Compare January 30, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build KeychainProgram
2 participants