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

refactor: #1819 signature and secret renamings #4179

Conversation

etorreborre
Copy link
Member

The purpose of this PR is to get a more consistent terminology:

  • A Signature is a just a list of bytes transferred over the wire

  • An IdentityChangeSignature is a signature authenticating an IdentityChange. This gives it more context and avoid the naming clashes identified in Module structure of the Rust libraries needs cleaning up #1819

  • the SecretVault interface has been renamed to KeyVault since it is dealing with keys and returning KeyIds. So instead of "generating a secret and getting back a key id" we "generate a key and get back a key id"

  • this change has been extended to KeyAttributes (instead of SecretAttributes for the attributes of a key)

  • the above renaming clashed with the existing KeyAttribute struct (containing both a key label and some key attributes). That structure is actually not very useful since a key label is used independently from the key attributes:

    • the key label is used in conjunction with identity changes
    • while the key attributes are used with the Vault API which doesn't know about key labels

@etorreborre etorreborre self-assigned this Feb 1, 2023
@etorreborre etorreborre force-pushed the etorreborre/refactor/#1819-signature-secret-renamings branch from b00b098 to ab72cf7 Compare February 1, 2023 13:25
this is shows that this is a more specific kind of signature than the Signature type in types.rs
in order to avoid clashes I had to temporarily have a PrivateKeyAttributes to support a key label
a further commit will separate the label out
@etorreborre etorreborre force-pushed the etorreborre/refactor/#1819-signature-secret-renamings branch from ab72cf7 to 5c399b8 Compare February 1, 2023 13:29
@etorreborre etorreborre force-pushed the etorreborre/refactor/#1819-signature-secret-renamings branch from 5c399b8 to 6812066 Compare February 1, 2023 13:54
@etorreborre etorreborre marked this pull request as ready for review February 1, 2023 14:10
@etorreborre etorreborre requested a review from a team as a code owner February 1, 2023 14:10
#[derive(Serialize, Deserialize, Clone, Zeroize, Encode, Decode)]
#[zeroize(drop)]
#[cbor(transparent)]
pub struct SecretKey(#[n(0)] SecretKeyVec);
pub struct PrivateKey(#[n(0)] PrivateKeyVec);
Copy link
Member

Choose a reason for hiding this comment

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

Could you please elaborate what is the reasoning on that renaming?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's the one presented in the description, the fact that the SecretVault API talks about secrets but return key ids. It would be better to make the naming consistent. What would you propose to solve this discrepancy?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I thought renaming SecretVault -> KeyVault and SecretKey -> PrivateKey are two separate things, are they related?

#[derive(Serialize, Deserialize, Copy, Clone, Debug, Encode, Decode, Eq, PartialEq, Zeroize)]
#[rustfmt::skip]
#[cbor(index_only)]
pub enum SecretType {
pub enum KeyType {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure renaming Secret -> Key is technically correct. Key is more narrow term, for example I don't think a Buffer with sensitive data can be called a Key

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes and that might be a hint that we should separate this data from the rest. For example in hasher_impl.rs we try to retrieve the salt and fail at runtime if it doesn't have the right type. Maybe this is an indication that this kind of data (that is always Ephemeral as far as I understand) should be stored separately inside a Vault.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, having different types for these things may be a great idea, but before we have that I'm not sure this renaming makes sense to me

use ockam_core::{Encodable, Result};
use serde::{Deserialize, Serialize};

/// Key change data creation
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CreateKeyChangeData {
prev_change_id: ChangeIdentifier,
key_attributes: PrivateKeyAttributes,
key_label: String,
Copy link
Member

Choose a reason for hiding this comment

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

That would probably break backwards compatibility and therefore break Ockam Orchestrator

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting, that raises 2 questions in my mind:

  1. do we have tests to check the compatibility with Orchestrator? Because they should have been broken with that change
  2. we should probably have a data structure that is purely used to communicate with the Orchestrator. Are we sending the full structure of changes as-is to the Orchestrator? Where is that done?

Copy link
Member

Choose a reason for hiding this comment

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

Change history is overly complex, we can break backward compatibility here once but let's do it soon and in one sweep.

Copy link
Member

Choose a reason for hiding this comment

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

We use rust sidecar for Identity implementation, so there are no second implementation and no second structure for Identity. The problem is that we have existing persistent identities in our system (e.g. Orchestrator has its Identity stored somewhere in its db), which probably won't deserialize because of the changed structure. Unfortunately, there is no backwards compatibility test

Copy link
Member

Choose a reason for hiding this comment

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

Can't we create one right now by hardcoding a fully populated encoded Identity in the test?

@@ -244,6 +244,15 @@ impl KeyAttributes {
length,
}
}

/// Create default key attributes
pub fn default_attributes() -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

I think being explicit when you generate a secret could be very useful

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean that we should actually not have such a function?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

@etorreborre
Copy link
Member Author

I'm closing this PR for now. In particular since it highlighted the need to do some preparation work on:

  • the serialization of identity data with other nodes in a versioned way
  • possibly the management of non-key, ephemeral, data outside of the vault

@etorreborre etorreborre closed this Feb 2, 2023
@mrinalwadhwa mrinalwadhwa deleted the etorreborre/refactor/#1819-signature-secret-renamings branch March 9, 2023 07:22
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.

4 participants