-
Notifications
You must be signed in to change notification settings - Fork 0
Add functions to encrypt and decrypt messages without signing or verifying them #14
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I think in this case looking at core if in this scenerio we keep the Signed message type but for the Signature we put in a null signature or junk data this will be fine as core will still have all the necessary fields but on public it will ignore the sig field all together |
|
||
#[wasm_bindgen(js_name = encryptOnly)] | ||
/// Encrypts, signs, and serializes a SignedMessage to JSON. | ||
pub fn encrypt_only(sk: Vec<u8>, msg: Vec<u8>, pk: Vec<u8>) -> Result<String, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't have a sk though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The secret key is used to derive an encryption keypair. We could omit this argument and generate an ephemeral one internally.
But i think if doing that, we may as well also sign the message with it and not have to have an EncryptedMessage type.
Personally i think the best solution is to close this PR, and create an ephemeral signing keypair on entropy-js
when making a request, so that the signature request each node receives can be checked they come from the same source, even if the keypair is only used for that particular message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya we can do that, should be simple enough and we can use that account ID in the session ID all solutions handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we would need to make a function that allows for the account to be passed in rather then derived from the sk
|
just checked with session ID that is already the case https://github.com/entropyxyz/entropy-core/blob/master/crates/threshold-signature-server/src/user/api.rs#L198 so we just need one function that allows a client to set the account different from the sk (as new does not do that) and then use it when we have public accounts on the client side (sdk) |
I'm not budging on this one - i think we should generate an ephemeral secret key from within the SDK and leave things here as they are. In my understanding - the signature request account is whatever account is requesting a signature, which in the public case can be anyone, including a short lived keypair generated just for a single set of signature requests. If we want to be able to indicate which entropy account should be associated with the signature request, i think that should be done with a field on This relates to entropyxyz/entropy-core#484 - i think keyshares should not be stored under the signature request account, but either the program modification account, or the public verification key. If we let people set an arbitrary account ID here to cater for public programs, well run into problems when we try to implement permissioned programs - as for permissioned we need to know both the author of the request and what entropy account they are requesting to sign with. |
This addresses: #13
This adds a struct
EncryptedMessage
, which is identical toSignedMessage
except for that it does not include a signature or the author's public signing key.Wasm bindings
encryptOnly
anddecryptOnly
are also provided.The idea is to use this in Entropy for public key visibility where we do not want to restrict which messages are signed by the network based on the identity of the requester.
However i think there are reasons why we might anyway want to sign these requests, even if it is only with an ephemeral keypair:
SignedMessage
or anEncryptedMessage
until we know what the key visibility is. So we will have to attempt to parse JSON as aSignedMessage
and if that fails attempt to parse as anEncryptedMessage
. I think this complicates things a bit.So i am not sure this PR is a good idea.