Passport Integration Guide
Passport is an MPC-based programmable, distributed, and non-custodial key management system, that allows users to generate wallets, scoped to their application, either via user Passkeys or any developer defined authentication method. Passport also allows users to sign messages, transactions, encrypt data, and more. Using secure multi-party computation (MPC) algorithms Passport splits private keys into shares that are solely distributed among nodes in the network. It also leverages secure enclaves and developer-defined policies, to ensure that the decryption of keys is confined to an enclave and that the signing process adheres to the policy framework established by your application.
Combining Passport with Account Kit allows you to create a seamless user experience for your users, with the security of Passport's MPC-based key management system and the flexibility of Account Abstraction. You can use Passport through the aa-signers
package to generate integrated wallets at scale, and then leverage aa-alchemy
to create smart accounts for your users.
Integration
Getting Started
You can get started on Passport by configuring your scope and authentication rules, you can find detailed instructions on this, by following the Passport Documentation.
Install the SDK
Using PassportSigner
in the aa-signers
package requires installation of the @0xpass/passport
and @0xpass/webauthn-signer
.
npm i @0xpass/passport
npm i @0xpass/webauthn-signer
yarn add @0xpass/passport
yarn add @0xpass/webauthn-signer
Create a PassportSigner
Next, setup the Passport SDK and create an authenticated PassportSigner
using the aa-signers
package to use an authenticated Passport Signer, you need to register a user account, which is attached to your application scope, following that you can authenticate the user, and and begin combining with Alchemy's Account Kit.
import { PassportSigner } from "@alchemy/aa-signers/passport";
import { Passport } from "@0xpass/passport";
import { WebauthnSigner } from "@0xpass/webauthn-signer";
import { http } from "viem";
import { sepolia } from "@alchemy/aa-core";
export const passport = new Passport({
scope_id: "scope_id",
signer: new WebauthnSigner({
rpId: "rpId",
rpName: "rpName",
}),
});
export const createPassportSigner = async () => {
const passportSigner = new PassportSigner({ inner: passport });
await passportSigner.authenticate({
username: "test",
userDisplayName: "test",
chain: sepolia,
fallbackProvider: http(
"https://eth-sepolia.g.alchemy.com/v2/ALCHEMY_API_KEY"
),
});
return passportSigner;
};
Use it with Light Account
Let's see it in action with aa-alchemy
and ModularAccount
from aa-accounts
:
import { createModularAccountAlchemyClient } from "@alchemy/aa-alchemy";
import { sepolia } from "@alchemy/aa-core";
import { createPassportSigner } from "./passport";
const chain = sepolia;
await passport.register({ username: "test", userDisplayName: "test" });
const provider = await createModularAccountAlchemyClient({
apiKey: "ALCHEMY_API_KEY",
chain,
signer: await createPassportSigner(),
});
import { PassportSigner } from "@alchemy/aa-signers/passport";
import { Passport } from "@0xpass/passport";
import { WebauthnSigner } from "@0xpass/webauthn-signer";
import { http } from "viem";
import { sepolia } from "@alchemy/aa-core";
export const passport = new Passport({
scope_id: "scope_id",
signer: new WebauthnSigner({
rpId: "rpId",
rpName: "rpName",
}),
});
export const createPassportSigner = async () => {
const passportSigner = new PassportSigner({ inner: passport });
await passportSigner.authenticate({
username: "test",
userDisplayName: "test",
chain: sepolia,
fallbackProvider: http(
"https://eth-sepolia.g.alchemy.com/v2/ALCHEMY_API_KEY"
),
});
return passportSigner;
};