đ¨âđģSDK core
To install the Banana SDK Pass (Passkey Manager Module), use either of the following commands:
Or
Instance Creation and Imports
Developers can access the PasskeyEoaSigner module by importing it from the '@rize-labs/paas' SDK:
Once the PasskeyEoaSigner module is successfully imported, you can create an instance by passing a JSON-RPC provider. After creating the instance, you can start using it by initializing it with a unique username using the init
method. This mapping between the signer and passkeys is facilitated by the 'paas' package for signing messages and transactions.
Create a PasskeySignerEoa instance as follows:
Note: If the provided username is already in use, the corresponding public key will be fetched. An authentication request will be sent to sign a random message to check if a private key exists in the device's secure enclave environment. If successful, the signer will be initialized. Otherwise, an error will be thrown "You are not authorized to use this wallet",
indicating that you are not authorized to use this wallet.
Methods by passkeySigner
PasskeyEoaSigner class overrides the existing Signer class methods, adds a few more methods for passkey management, and implements the TypedDataSigner class provided by ethers library. It inherits and overrides all the necessary methods required by an abstract signer class which are
getChainId
getAddress
signTransaction
signMessage
_signTypedData
static getPasskey
connect
Below are the details and usage of each of the methods.
getChainId
getChainId
: Retrieves the chainId of the current network corresponding to the JSON-RPC provider passed during the initialization of the PasskeyEoaSigner instance.
Usage
getAddress
getAddress
: Retrieves the Ethereum-compatible address (H160 formatted) corresponding to the EOA of the signer instance. PasskeyEoaSigner overrides this method and calculates the address from the fetched public values of the passkeys.
Usage
signTransaction
signTransaction
: Currently not supported by PasskeyEoaSigner, as it is not required for 4337 smart contract wallets. In 4337 compatible smart contract wallets, userOpHash is signed using the signMessage
method.
signMessage
signMessage
: Signs a provided message (bytes or string) using the passkeys initialized/fetched by the signer. The method returns the signature appended with the signed message. The first 32 bytes of the signature represent the signature itself, while the remaining 32 bytes contain the signed message.
Usage
_signTypedData
_signTypedData
: Signs a hash of a typed message by providing the domain, types, and value as arguments. The method returns the signature appended with the signed message hash. The first 32 bytes of the signature represent the signature, while the remaining 32 bytes contain the signed message.
Usage
getPasskey
getPasskey
: A static method implemented in PasskeyEoaSigner to retrieve the passkey's public values corresponding to a given username. The passkey's X and Y public values are used to set the owner of the smart contract wallet during initialization. Additionally, theinitialize
method is also used to generate an init code which would help in contract deployment via userOp and also to fetch the counterfactual address of where the smart contract wallet would going to be deployed.
Usage
The getPasskey
method is commonly used for operations such as setting the owner of a smart contract wallet, generating initialization code for contract deployment via userOp, and obtaining the counterfactual address where the smart contract wallet will be deployed.
Please note that the returned Passkey
object contains the public values of the passkey, not the private key itself.
connect
connect
Not implemented because not required.
If you have any questions, please feel free to ask on the Banana SDK Discord forum.
Last updated