Skip to content

Commit

Permalink
Migrate to new OpenMLS storage API (#692)
Browse files Browse the repository at this point in the history
* bump openMLS to get errors for updating

* small tweaks

* attempt at overriding this

* format it

* remove crypto config

* get through all the initial errors

* fix up the sql keystore to actually read and write correctly

* getting the impl closer to compiling

* error for methods we wont use

* get everything compiling

* more mls tweaks

* fix up the basic credential issues

* remove save functions

* fix up the errirs

* update the table name

* fix up some of the mut stuff

* cargo build works

* bring back key value signature

* change version to integer

* use correct sqlite

* update the migration and database name

* fix up merge

* update the schema

* fix up some testings

* get the test compiling

* write some tests for it

* keep it dry

* fix up the test

* make sure all the keys align

* small tweaks to naming

* update to latest mls with fixes

* modify the tests a bit

* comment out failing tests for now

* fix up merge errors

* fix up the concurrency of the db

* format it

* fix up a bunch of lint issues

* fix up all the lint issues

* fixup append and read_list

* fix remove_item

* fixup clear proposals

* fix up the lint

* serialize aad before writing

* fixup psk sotrage and some debug info

* store resumption psks

* fix welcome decryption

* fix encryption epoch key pairs

* fix lock on the db

* reformat

* point at new openmls version

* fix up a small lint issue

* fix diesel deprecation warnings (#743)

* point to the merge commit

* remove some unwraps

* remove another unwrap

* pull out queries into constants

* remove the final unwraps

* dry up the query code

* code clean up 1

* final pass on cleaning up code

* fix up the linter

* undo the changes that may have broken it

* small tweak to linter

* remove two unwraps

* remove the unwrap from hpke

* remove the last unwrap

* surface pending commit error

---------

Co-authored-by: Franziskus Kiefer <[email protected]>
Co-authored-by: Andrew Plaza <[email protected]>
Co-authored-by: Andrew Plaza <[email protected]>
  • Loading branch information
4 people authored May 17, 2024
1 parent bba18be commit 7075f3f
Show file tree
Hide file tree
Showing 22 changed files with 1,514 additions and 208 deletions.
61 changes: 46 additions & 15 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ futures-core = "0.3.30"
hex = "0.4.3"
jsonrpsee = { version = "0.22", features = ["macros", "server", "client-core"] }
log = "0.4"
openmls = { git = "https://github.com/xmtp/openmls", rev = "52cad0e" }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "52cad0e" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "52cad0e" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "52cad0e" }
openmls = { git = "https://github.com/xmtp/openmls", rev = "0239b96" }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "0239b96" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "0239b96" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "0239b96" }
prost = "^0.12"
prost-types = "^0.12"
rand = "0.8.5"
Expand Down
61 changes: 46 additions & 15 deletions bindings_ffi/Cargo.lock

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

17 changes: 6 additions & 11 deletions mls_validation_service/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ fn validate_key_package(key_package_bytes: Vec<u8>) -> Result<ValidateKeyPackage

let credential = verified_key_package.inner.leaf_node().credential();

let basic_credential = BasicCredential::try_from(credential).map_err(|e| e.to_string())?;
let basic_credential =
BasicCredential::try_from(credential.clone()).map_err(|e| e.to_string())?;

Ok(ValidateKeyPackageResult {
installation_id: verified_key_package.installation_id(),
Expand All @@ -386,10 +387,8 @@ mod tests {
extensions::{ApplicationIdExtension, Extension, Extensions},
prelude::{
tls_codec::Serialize, Ciphersuite, Credential as OpenMlsCredential, CredentialWithKey,
CryptoConfig,
},
prelude_test::KeyPackage,
versions::ProtocolVersion,
};
use openmls_basic_credential::SignatureKeyPair;
use openmls_rust_crypto::OpenMlsRustCrypto;
Expand Down Expand Up @@ -541,17 +540,13 @@ mod tests {

let kp = kp
.build(
CryptoConfig {
ciphersuite: CIPHERSUITE,
version: ProtocolVersion::default(),
},
CIPHERSUITE,
&rust_crypto,
keypair,
credential_with_key.clone(),
)
.unwrap();

kp.tls_serialize_detached().unwrap()
kp.key_package().tls_serialize_detached().unwrap()
}

fn to_signature_keypair(key: SigningKey) -> SignatureKeyPair {
Expand All @@ -569,7 +564,7 @@ mod tests {
async fn test_validate_key_packages_happy_path() {
let (identity, keypair, account_address) = generate_identity();

let credential: OpenMlsCredential = BasicCredential::new(identity).unwrap().into();
let credential: OpenMlsCredential = BasicCredential::new(identity).into();
let credential_with_key = CredentialWithKey {
credential,
signature_key: keypair.to_public_vec().into(),
Expand Down Expand Up @@ -602,7 +597,7 @@ mod tests {
let (identity, keypair, account_address) = generate_identity();
let (_, other_keypair, _) = generate_identity();

let credential: OpenMlsCredential = BasicCredential::new(identity).unwrap().into();
let credential: OpenMlsCredential = BasicCredential::new(identity).into();
let credential_with_key = CredentialWithKey {
credential,
// Use the wrong signature key to make the validation fail
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE openmls_key_value;
Loading

0 comments on commit 7075f3f

Please sign in to comment.