Skip to content

Commit

Permalink
fix: backward incompatible database schemas. It only preserves Proteu…
Browse files Browse the repository at this point in the history
…s compatibility when migrating from CC 0.11.0 -> 1.0.0. For anything MLS-related it is recommended to wipe all the groups
  • Loading branch information
beltram committed Sep 29, 2023
1 parent 93db655 commit dc46478
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 58 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ branch = "2.x"
[patch.crates-io.openmls]
package = "openmls"
git = "https://github.com/wireapp/openmls"
#tag = "v1.0.0-pre.core-crypto-1.0.0"
branch = "feat/rfc9420"
tag = "v0.20.3-pre.core-crypto-1.0.0"
# branch = "feat/rfc9420"

[patch.crates-io.openmls_traits]
package = "openmls_traits"
git = "https://github.com/wireapp/openmls"
#tag = "v1.0.0-pre.core-crypto-1.0.0"
branch = "feat/rfc9420"
tag = "v0.20.3-pre.core-crypto-1.0.0"
# branch = "feat/rfc9420"

[patch.crates-io.openmls_basic_credential]
package = "openmls_basic_credential"
git = "https://github.com/wireapp/openmls"
#tag = "v1.0.0-pre.core-crypto-1.0.0"
branch = "feat/rfc9420"
tag = "v0.20.3-pre.core-crypto-1.0.0"
# branch = "feat/rfc9420"

[patch.crates-io.openmls_x509_credential]
package = "openmls_x509_credential"
git = "https://github.com/wireapp/openmls"
#tag = "v1.0.0-pre.core-crypto-1.0.0"
branch = "feat/rfc9420"
tag = "v0.20.3-pre.core-crypto-1.0.0"
# branch = "feat/rfc9420"

[patch.crates-io.hpke]
git = "https://github.com/wireapp/rust-hpke.git"
Expand Down
3 changes: 3 additions & 0 deletions crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ oid-registry = "0.6"
async-recursion = "1"
uniffi = { workspace = true, optional = true }

# TODO: remove when coarsetime > 0.1.28 released
coarsetime = "=0.1.23"

[dependencies.proteus-wasm]
version = "2.1"
features = ["hazmat"]
Expand Down
62 changes: 12 additions & 50 deletions keystore/src/connection/platform/generic/migrations/V1__schema.sql
Original file line number Diff line number Diff line change
@@ -1,64 +1,26 @@
CREATE TABLE mls_credentials (
id BLOB,
credential BLOB
);

CREATE TABLE mls_signature_keypairs (
signature_scheme INT,
keypair BLOB,
pk BLOB,
credential_id BLOB
);

CREATE TABLE mls_hpke_private_keys (
pk BLOB,
sk BLOB
);

CREATE TABLE mls_encryption_keypairs (
pk BLOB,
sk BLOB
);

CREATE TABLE mls_psk_bundles (
psk_id BLOB,
psk BLOB
CREATE TABLE mls_keys (
id VARCHAR(255) UNIQUE,
key BLOB
);

CREATE TABLE mls_keypackages (
keypackage_ref BLOB,
keypackage BLOB
CREATE TABLE mls_identities (
id VARCHAR(255) UNIQUE,
signature BLOB,
credential BLOB
);

CREATE TABLE mls_groups (
id BLOB,
state BLOB,
parent_id BLOB
);

CREATE TABLE mls_pending_groups (
id BLOB,
state BLOB,
cfg BLOB,
parent_id BLOB
state BLOB
);

CREATE TABLE proteus_prekeys (
id INT UNIQUE,
key BLOB
);

CREATE TABLE proteus_identities (
pk BLOB,
sk BLOB
);

CREATE TABLE proteus_sessions (
id VARCHAR(255) UNIQUE,
session BLOB
);

CREATE TABLE e2ei_enrollment (
id VARCHAR(255) UNIQUE,
content BLOB
CREATE TABLE mls_pending_groups (
id BLOB,
state BLOB,
cfg BLOB
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE proteus_identities (
sk BLOB,
pk BLOB
);

CREATE TABLE proteus_sessions (
id VARCHAR(255) UNIQUE,
session BLOB
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE mls_groups ADD COLUMN parent_id BLOB;
ALTER TABLE mls_pending_groups ADD COLUMN parent_id BLOB;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE e2ei_enrollment (
id VARCHAR(255) UNIQUE,
content BLOB
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- Both those table are used only in MLS and we do not need to maintain backward compatibility there
DROP TABLE mls_keys;
DROP TABLE mls_identities;

CREATE TABLE mls_signature_keypairs (
signature_scheme INT,
keypair BLOB,
pk BLOB,
credential_id BLOB
);

CREATE TABLE mls_credentials (
id BLOB,
credential BLOB
);

CREATE TABLE mls_hpke_private_keys (
pk BLOB,
sk BLOB
);

CREATE TABLE mls_encryption_keypairs (
pk BLOB,
sk BLOB
);

CREATE TABLE mls_psk_bundles (
psk_id BLOB,
psk BLOB
);

CREATE TABLE mls_keypackages (
keypackage_ref BLOB,
keypackage BLOB
);

0 comments on commit dc46478

Please sign in to comment.