Skip to content

Commit

Permalink
feat: Use -dalek fast proteus version
Browse files Browse the repository at this point in the history
  • Loading branch information
OtaK authored and beltram committed Jul 20, 2023
1 parent 53610c5 commit 5f56013
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ branch = "otak/fix-1.0.3"
[patch.crates-io.proteus-traits]
package = "proteus-traits"
git = "https://github.com/wireapp/proteus"
branch = "otak/2.0-ec-send-sync"
branch = "2.x"

[patch.crates-io.openmls]
package = "openmls"
Expand Down
4 changes: 2 additions & 2 deletions crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ wire-e2e-identity = { version = "0.4", default-features = false }
indexmap = "2"

[dependencies.proteus-wasm]
version = "2.0"
version = "2.1"
features = ["hazmat"]
optional = true
git = "https://github.com/wireapp/proteus"
branch = "otak/2.0-ec-send-sync"
branch = "2.x"

[dependencies.proteus-traits]
optional = true
Expand Down
5 changes: 5 additions & 0 deletions crypto/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ pub enum ProteusError {
ProteusEncodeError(#[from] proteus_wasm::EncodeError),
#[cfg(feature = "proteus")]
#[error(transparent)]
/// Various internal Proteus errors
ProteusInternalError(#[from] proteus_wasm::error::ProteusError),
#[cfg(feature = "proteus")]
#[error(transparent)]
/// Error when there's a critical error within a proteus Session
ProteusSessionError(#[from] proteus_wasm::session::Error<core_crypto_keystore::CryptoKeystoreError>),
}
Expand All @@ -321,6 +325,7 @@ impl ProteusError {
ProteusError::ProteusDecodeError(e) => e.code() as u32,
ProteusError::ProteusEncodeError(e) => e.code() as u32,
ProteusError::ProteusSessionError(e) => e.code() as u32,
ProteusError::ProteusInternalError(e) => e.code() as u32,
}
} else {
0
Expand Down
14 changes: 9 additions & 5 deletions crypto/src/proteus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl ProteusCentral {
let pk = identity.pk_raw();
// SAFETY: Byte lengths are ensured at the keystore level so this function is safe to call, despite being cursed

unsafe { IdentityKeyPair::from_raw_key_pair(*sk, *pk) }
unsafe { IdentityKeyPair::from_raw_key_pair(*sk, *pk).map_err(ProteusError::from)? }
} else {
Self::create_identity(keystore).await?
};
Expand All @@ -339,7 +339,7 @@ impl ProteusCentral {
let pk = hex::decode(pk_fingerprint)?;

let ks_identity = ProteusIdentity {
sk: kp.secret_key.as_slice().into(),
sk: kp.secret_key.to_keypair_bytes().into(),
pk,
};
keystore.save(ks_identity).await?;
Expand Down Expand Up @@ -669,7 +669,10 @@ impl ProteusCentral {
let prekey_dir = root_dir.join("prekeys");

let mut identity = if let Some(store_kp) = keystore.find::<ProteusIdentity>(&[]).await? {
Some(unsafe { IdentityKeyPair::from_raw_key_pair(*store_kp.sk_raw(), *store_kp.pk_raw()) })
Some(unsafe {
IdentityKeyPair::from_raw_key_pair(*store_kp.sk_raw(), *store_kp.pk_raw())
.map_err(ProteusError::from)?
})
} else {
let identity_dir = root_dir.join("identities");

Expand All @@ -696,7 +699,7 @@ impl ProteusCentral {
let pk = kp.public_key.public_key.as_slice().into();

let ks_identity = ProteusIdentity {
sk: kp.secret_key.as_slice().into(),
sk: kp.secret_key.to_keypair_bytes().into(),
pk,
};

Expand Down Expand Up @@ -824,6 +827,7 @@ impl ProteusCentral {
let mut proteus_identity = if let Some(store_kp) = keystore.find::<ProteusIdentity>(&[]).await? {
Some(unsafe {
proteus_wasm::keys::IdentityKeyPair::from_raw_key_pair(*store_kp.sk_raw(), *store_kp.pk_raw())
.map_err(ProteusError::from)?
})
} else {
let transaction = db
Expand All @@ -850,7 +854,7 @@ impl ProteusCentral {
let pk = hex::decode(pk_fingerprint)?;

let ks_identity = ProteusIdentity {
sk: kp.secret_key.as_slice().into(),
sk: kp.secret_key.to_keypair_bytes().into(),
pk,
};
keystore.save(ks_identity).await?;
Expand Down
4 changes: 2 additions & 2 deletions interop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ webdriver-install = "0.3"
fantoccini = "0.19"

[dependencies.proteus-wasm]
version = "2.0"
version = "2.1"
features = ["hazmat"]
optional = true
git = "https://github.com/wireapp/proteus"
branch = "otak/2.0-ec-send-sync"
branch = "2.x"



6 changes: 3 additions & 3 deletions keystore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ log = { version = "0.4", optional = true }
optional = true
package = "proteus-traits"
git = "https://github.com/wireapp/proteus"
branch = "otak/2.0-ec-send-sync"
branch = "2.x"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
async-fs = "1.5"
Expand Down Expand Up @@ -107,9 +107,9 @@ core-crypto-keystore = { path = ".", features = ["idb-regression-test", "log-que
pretty_env_logger = "0.5"

[dev-dependencies.proteus-wasm]
version = "2.0"
version = "2.1"
git = "https://github.com/wireapp/proteus"
branch = "otak/2.0-ec-send-sync"
branch = "2.x"

[target.'cfg(not(target_family = "wasm"))'.dev-dependencies.criterion]
version = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
"ts-loader": "^9.4.2",
"typescript": "^4.9.5"
}
}
}

0 comments on commit 5f56013

Please sign in to comment.