- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
          feat(Biz): Add helper functions to support BizPasskeySessionAccount
          #4516
        
          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
Conversation
| /// \return The signed authorization. | ||
| #[tw_ffi(ty = static_function, class = TWEip7702, name = SignAuthorization)] | ||
| #[no_mangle] | ||
| pub unsafe extern "C" fn tw_eip7702_sign_authorization( | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Ethereum message signature functionality meet your needs?
Refers:
wallet-core/src/proto/Ethereum.proto
Line 318 in 6d1a0ed
| MessageType_eip7702_authorization = 5; | 
| fn test_message_signer_sign_eip7702_authorization() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @10gic, I think it does, but our client app depends on the function already, I want to leave it as is for now. But let me mark as deprecated
* Rename `TWWebAuthn` module to `TWWebAuthnSolidity`
| Binary size comparison➡️ aarch64-apple-ios: - 14.11 MB
+ 14.15 MB 	 +50 KB➡️ aarch64-apple-ios-sim: - 14.11 MB
+ 14.16 MB 	 +50 KB➡️ aarch64-linux-android: - 18.57 MB
+ 18.64 MB 	 +72 KB➡️ armv7-linux-androideabi: - 15.53 MB
+ 15.59 MB 	 +60 KB➡️ wasm32-unknown-emscripten: - 13.23 MB
+ 13.29 MB 	 +54 KB | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @satoshiotomakan! Just asked for one minor clarification.
|  | ||
| /// Encodes `Biz.removeSession` function call to deregister a session passkey public key. | ||
| /// | ||
| /// \param session_passkey_public_key The nist256p1 (aka secp256p1) public key of the session passkey. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we support both nist and secp here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nist256p1 and secp256p1 are names of the same elliptic curve, however "official" and more recognized name is secp256p1. In WalletCore, we inherited this name from C++ TWCurve enum and TrezorCrypto, and we continue naming it like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I thought both are ECDSA but have different params, which made us have two separate implementations.
https://github.com/trustwallet/wallet-core/blob/master/rust/tw_keypair/src/ecdsa/secp256k1/keypair.rs
https://github.com/trustwallet/wallet-core/blob/master/rust/tw_keypair/src/ecdsa/nist256p1/keypair.rs
| "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000"; | ||
| let client_data_json = r#"{"type":"webauthn.get","challenge":"fRMDMfFrs9K8PXLbAoedB0XURSWS5Wcj3osnzx7gBsc","origin":"https://sign.coinbase.com","crossOrigin":false}"#; | ||
|  | ||
| // secp256p1 (nist256p1) private key. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
| use tw_memory::ffi::{Nonnull, NullableMut, RawPtrTrait}; | ||
| use tw_misc::try_or_else; | ||
|  | ||
| /// Computes WebAuthn message hash to be signed with secp256p1 private key. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says secp here though.
This pull request adds support for Passkey Session operations in the Barz module, enabling registration, removal, nonce encoding, and batch execution of transactions using passkey sessions. It introduces new ABI encoding functions, FFI bindings, and comprehensive tests to ensure correct behavior.
Passkey Session ABI and Encoding Support
BizPasskeySessionAccountstruct inbiz_passkey_session.rswith methods for registering, removing, and executing with passkey sessions, including ABI encoding logic for these operations.barz/core.rsfor encoding register, remove, nonce, and batch execution calls for passkey sessions, with error handling for invalid public keys and nonce values. [1] [2]FFI Bindings
BizmoduleBarz.getEncodedHashtoBiz.getEncodedHashBarz.getSignedHashtoBiz.getSignedHashBiz.encodeRegisterSessionCallBiz.encodeRemoveSessionCallBiz.encodePasskeySessionNonceBiz.encodeExecuteWithPasskeySessionCallEip7702moduleBarz.getAuthorizationHashtoEip7702.getAuthorizationHashBarz.signAuthorizationtoEip7702.signAuthorizationWebAuthnSoliditymodule with the following methods:WebAuthnSolidity.getMessageHashWebAuthnSolidity.GetFormattedSignatureTesting and Validation
barz_ffi.rsto validate passkey session registration, removal, nonce encoding, and batch execution, ensuring ABI outputs match expected values.Refactoring and Internal Improvements
biz.rsto use a dedicated function for array token conversion, improving code clarity and reuse. [1] [2] [3] [4]