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

Add legacy credential type #425

Merged
merged 28 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3912b99
Gen protos
richardhuaaa Jan 16, 2024
ea1b276
Validate v2 signature
richardhuaaa Jan 16, 2024
e4f3efb
Generate latest proto changes
richardhuaaa Jan 17, 2024
320636b
Restructure Eip191 association for consistency
richardhuaaa Jan 17, 2024
206008e
Finished validation
richardhuaaa Jan 18, 2024
858097a
Tidy
richardhuaaa Jan 18, 2024
81e903d
Split into separate files
richardhuaaa Jan 18, 2024
cfd8afe
Fix tests
richardhuaaa Jan 18, 2024
91999c6
Split out LegacySignedPublicKey and add method for generating LegacyC…
richardhuaaa Jan 18, 2024
1570e82
Add sign_sha256 to k256helper
richardhuaaa Jan 19, 2024
f7078e1
iso8601_time -> created_ns
richardhuaaa Jan 19, 2024
2502d1d
Split validated_legacy_signed_public_key
richardhuaaa Jan 19, 2024
fc5181d
Add tests for legacy_create_identity_association
richardhuaaa Jan 19, 2024
45f1db1
tidy
richardhuaaa Jan 19, 2024
0aad765
Merge remote-tracking branch 'origin/main' into rich/legacy-association
richardhuaaa Jan 19, 2024
acde6b5
Fix test
richardhuaaa Jan 19, 2024
fb2928f
Merge remote-tracking branch 'origin/main' into rich/legacy-association
richardhuaaa Jan 24, 2024
8d6d072
Regen protos
richardhuaaa Jan 24, 2024
2e4276a
Remove unwrap()
richardhuaaa Jan 24, 2024
afc910a
Merge remote-tracking branch 'origin/main' into rich/legacy-association
richardhuaaa Jan 27, 2024
46a6389
Fix conflicting refactors
richardhuaaa Feb 1, 2024
38745a7
Update openMLS dep
richardhuaaa Feb 2, 2024
1a5c045
Merge/reimplement changes from main
richardhuaaa Feb 2, 2024
b0aa32c
Fix lint
richardhuaaa Feb 2, 2024
999013a
Merge remote-tracking branch 'origin/main' into rich/legacy-association
richardhuaaa Feb 2, 2024
9021ae1
Format
richardhuaaa Feb 2, 2024
892c8f4
Merge remote-tracking branch 'origin/main' into rich/legacy-association
richardhuaaa Feb 2, 2024
78f31a2
Gen protos from main
richardhuaaa Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bindings_ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev/gen_protos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if ! cargo install --list | grep "protoc-gen-prost-crate" > /dev/null; then
fi
fi

if ! buf generate https://github.com/xmtp/proto.git#branch=main,subdir=proto; then
if ! buf generate https://github.com/xmtp/proto.git#branch=rich/legacy-keys-2,subdir=proto; then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will switch back to main before merging

echo "Failed to generate protobuf definitions"
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions mls_validation_service/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod tests {
use openmls_basic_credential::SignatureKeyPair;
use openmls_rust_crypto::OpenMlsRustCrypto;
use prost::Message;
use xmtp_mls::{association::Credential, InboxOwner};
use xmtp_mls::{credential::Credential, InboxOwner};
use xmtp_proto::xmtp::{
mls::message_contents::MlsCredential as CredentialProto,
mls_validation::v1::validate_key_packages_request::KeyPackage as KeyPackageProtoWrapper,
Expand All @@ -152,8 +152,8 @@ mod tests {
let _pub_key = signature_key_pair.public();
let account_address = wallet.get_address();

let credential = Credential::create_eip191(&signature_key_pair, &wallet)
.expect("failed to create credential");
let credential =
Credential::create(&signature_key_pair, &wallet).expect("failed to create credential");
let credential_proto: CredentialProto = credential.into();

(
Expand Down
1 change: 1 addition & 0 deletions xmtp_mls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ toml = "0.7.4"
tracing = "0.1.37"
xmtp_cryptography = { path = "../xmtp_cryptography" }
xmtp_proto = { path = "../xmtp_proto", features = ["proto_full"] }
xmtp_v2 = { path = "../xmtp_v2" }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think once we get to shaving fat off the WASM build we're going to want to extract the functions we need from this crate to avoid bloat. Or get really aggressive with features.

Problem for another day


[dev-dependencies]
ctor = "0.2"
Expand Down
23 changes: 17 additions & 6 deletions xmtp_mls/IDENTITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ XMTP installations consist of a long-lived Ed25519 key-pair (the 'installation k
2. The app prompts the user to sign the public key with their Ethereum wallet. The user is expected to inspect the text and reject the signing request if the data is invalid, for example if the account address is not the one they intended. The format for version 1 of the association text is as follows:

```
XMTP: Grant Messaging Access
XMTP : Grant Messaging Access

Current Time: <ISO 8601 date and time in UTC>
Account Address: <ethereum address>
Installation ID: <hex(last_20_bytes(keccak256(Ed25519PublicKey)))>

For more info: https://xmtp.org/signatures/
```

3. The signature and related data is then protobuf-serialized to form the MLS Credential:
Expand All @@ -64,14 +66,14 @@ XMTP installations consist of a long-lived Ed25519 key-pair (the 'installation k
struct {
association_text_version: i32,
signature: bytes,
iso8601_time: string,
created_ns: u64,
account_address: string,
} Eip191Association;
} GrantMessagingAccessAssociation;


struct {
installation_public_key: bytes,
eip191_association: Eip191Association
association: GrantMessagingAccessAssociation
} MlsCredential;
```

Expand Down Expand Up @@ -100,19 +102,28 @@ Users may revoke an installation as follows:
1. The app prompts the user to sign the revocation with their Ethereum wallet. The user is expected to inspect the text and reject the signing request if the data is invalid, for example if the account address is not the one they intended. The format for version 1 of the association text is as follows:

```
XMTP: Revoke Messaging Access
XMTP : Revoke Messaging Access

Current Time: <ISO 8601 date and time in UTC>
Account Address: <ethereum address>
Installation ID: <hex(last_20_bytes(keccak256(Ed25519PublicKey)))>

For more info: https://xmtp.org/signatures/
```

1. The signature and related data is then protobuf-serialized to form the revocation:

```
struct {
association_text_version: i32,
signature: bytes,
created_ns: u64,
account_address: string,
} RevokeMessagingAccessAssociation;

struct {
installation_public_key: bytes,
eip191_association: Eip191Association
association: RevokeMessagingAccessAssociation
} InstallationRevocation;
```

Expand Down
Loading
Loading