Skip to content

Commit

Permalink
feat: add passkey authenticator to sui
Browse files Browse the repository at this point in the history
  • Loading branch information
joyqvq committed Jun 7, 2024
1 parent ed69a2f commit 89ebdda
Show file tree
Hide file tree
Showing 11 changed files with 562 additions and 6 deletions.
143 changes: 140 additions & 3 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c101a517
fastcrypto-tbls = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c101a5176799db3eb9c801b844e7add92153d291" }
fastcrypto-zkp = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c101a5176799db3eb9c801b844e7add92153d291", package = "fastcrypto-zkp" }
fastcrypto-vdf = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c101a5176799db3eb9c801b844e7add92153d291", features = ["experimental"] }
passkey = "0.2.0"
coset = "0.3"
p256 = { version = "0.13.2", features = ["ecdsa"] }

# anemo dependencies
anemo = { git = "https://github.com/mystenlabs/anemo.git", rev = "26d415eb9aa6a2417be3c03c57d6e93c30bd1ad7" }
Expand Down
6 changes: 4 additions & 2 deletions crates/sui-keys/src/key_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ pub fn derive_key_pair_from_path(
}
SignatureScheme::BLS12381
| SignatureScheme::MultiSig
| SignatureScheme::ZkLoginAuthenticator => Err(SuiError::UnsupportedFeatureError {
| SignatureScheme::ZkLoginAuthenticator
| SignatureScheme::PasskeyAuthenticator => Err(SuiError::UnsupportedFeatureError {
error: format!("key derivation not supported {:?}", key_scheme),
}),
}
Expand Down Expand Up @@ -160,7 +161,8 @@ pub fn validate_path(
}
SignatureScheme::BLS12381
| SignatureScheme::MultiSig
| SignatureScheme::ZkLoginAuthenticator => Err(SuiError::UnsupportedFeatureError {
| SignatureScheme::ZkLoginAuthenticator
| SignatureScheme::PasskeyAuthenticator => Err(SuiError::UnsupportedFeatureError {
error: format!("key derivation not supported {:?}", key_scheme),
}),
}
Expand Down
6 changes: 6 additions & 0 deletions crates/sui-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ sui-enum-compat-util.workspace = true
fastcrypto = { workspace = true, features = ["copy_key"] }
fastcrypto-tbls.workspace = true
fastcrypto-zkp.workspace = true
passkey.workspace = true

typed-store-error.workspace = true
derive_more.workspace = true
Expand All @@ -82,6 +83,11 @@ proptest.workspace = true
proptest-derive.workspace = true
serde_yaml.workspace = true
expect-test.workspace = true
coset.workspace = true
url.workspace = true
tokio.workspace = true
async-trait.workspace = true
p256.workspace = true

[[bench]]
name = "accumulator_bench"
Expand Down
1 change: 1 addition & 0 deletions crates/sui-types/src/base_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ impl TryFrom<&GenericSignature> for SuiAddress {
GenericSignature::ZkLoginAuthenticator(zklogin) => {
SuiAddress::try_from_unpadded(&zklogin.inputs)
}
GenericSignature::PasskeyAuthenticator(s) => Ok(SuiAddress::from(&s.get_pk()?)),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/sui-types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,7 @@ pub enum SignatureScheme {
BLS12381, // This is currently not supported for user Sui Address.
MultiSig,
ZkLoginAuthenticator,
PasskeyAuthenticator,
}

impl SignatureScheme {
Expand All @@ -1650,6 +1651,7 @@ impl SignatureScheme {
SignatureScheme::MultiSig => 0x03,
SignatureScheme::BLS12381 => 0x04, // This is currently not supported for user Sui Address.
SignatureScheme::ZkLoginAuthenticator => 0x05,
SignatureScheme::PasskeyAuthenticator => 0x06,
}
}

Expand All @@ -1668,6 +1670,7 @@ impl SignatureScheme {
0x03 => Ok(SignatureScheme::MultiSig),
0x04 => Ok(SignatureScheme::BLS12381),
0x05 => Ok(SignatureScheme::ZkLoginAuthenticator),
0x06 => Ok(SignatureScheme::PasskeyAuthenticator),
_ => Err(SuiError::KeyConversionError(
"Invalid key scheme".to_string(),
)),
Expand Down
1 change: 1 addition & 0 deletions crates/sui-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub mod move_package;
pub mod multisig;
pub mod multisig_legacy;
pub mod object;
pub mod passkey_authenticator;
pub mod programmable_transaction_builder;
pub mod quorum_driver_types;
pub mod randomness_state;
Expand Down
Loading

0 comments on commit 89ebdda

Please sign in to comment.