-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: secure p2p #354
feat: secure p2p #354
Conversation
Terraform Feature Environment (dev-354)Terraform Initialization ⚙️
|
0f6bbbc
to
4ca4fe6
Compare
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.
Haven't finished reviewing yet, but this is my thoughts so far
keys/src/hpke.rs
Outdated
|
||
/// This can be used to customize the generated key. This will be used as a sort of | ||
/// versioning mechanism for the key. | ||
const INFO_ENTROPY: &[u8] = b"session-key-v1"; |
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.
Hmm, can you give an example of a situation when we would want "bump" this version?
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 is just extra info for generating the derived key fro encryption. So it's more for contextual info. It's useful when we end up using the same key as encryption and signing, but we don't se it can just empty or static like this. I just arbitrarily made it into a versioning scheme
@@ -34,6 +42,7 @@ pub struct InitializingContractState { | |||
#[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug)] | |||
pub struct RunningContractState { | |||
pub epoch: u64, | |||
// TODO: why is this account id for participants instead of participant id? |
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 is kind of like a preparation for #330
Ideally nodes should be identified by the account id they use for interacting with the contract and the participant id should be given to them at runtime by the contract
@@ -0,0 +1,156 @@ | |||
use borsh::{self, BorshDeserialize, BorshSerialize}; |
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.
FYI I want Michel to take a look at this to make sure we are not misusing anything here, will let you know how it goes
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.
sounds good
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.
@itegulov Are we good to go?
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.
Great work. Let's merge this one and #380, merge conflicts, etc. It's hard to proceed with two big PRs not being merged.
@@ -22,6 +26,10 @@ pub struct ParticipantInfo { | |||
pub id: ParticipantId, | |||
pub account_id: AccountId, | |||
pub url: String, | |||
/// The public key used for encrypting messages. | |||
pub cipher_pk: hpke::PublicKey, | |||
/// The public key used for verifying messages. |
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.
I would rather have longer names here and in other places, like msg_encryption_pk
, msg_signature_pk
. People and other developers can confuse these with key shares.
@@ -0,0 +1,156 @@ | |||
use borsh::{self, BorshDeserialize, BorshSerialize}; |
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.
@itegulov Are we good to go?
client: &Client, | ||
url: U, | ||
message: MpcMessage, | ||
) -> Result<(), SendError> { | ||
let encrypted = SignedMessage::encrypt(message, participant, sign_sk, cipher_pk) |
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 is encryption and signing in one function, right?
#[error("sync failed: {0}")] | ||
SyncError(String), | ||
#[error(transparent)] | ||
DataConversion(#[from] serde_json::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.
nit: <name>Error(
Ok, I am merging this to avoid conflicts and we can address comments in a follow up PR |
Terraform Feature Environment Destroy (dev-354)Terraform Initialization ⚙️
|
This implements secure p2p communication between two nodes.
Adds/msg-private
endpoint for secure messaging on protocolSendPrivate
actions.msg
endpoint is now encrypted when sending messages