Skip to main content

Calibur Key Management

These Calibur7702Account methods add, inspect and revoke keys on a delegated Calibur account, and sign UserOperations with a registered passkey. To create the account from an existing EOA, delegate it and send UserOperations, start with Calibur Account.

Root key

The EOA's own key (the root key, keyHash = bytes32(0)) is always admin and cannot be revoked. Keys registered with createRegisterKeyMetaTransactions are always non-admin.

Methods at a Glance​

MethodSignatureReturns
createSecp256k1Key (static)Calibur7702Account.createSecp256k1Key(address)CaliburKey
createWebAuthnP256Key (static)Calibur7702Account.createWebAuthnP256Key(x, y)CaliburKey
createP256Key (static)Calibur7702Account.createP256Key(x, y)CaliburKey
getKeyHash (static)Calibur7702Account.getKeyHash(key)string
createRegisterKeyMetaTransactions (static)Calibur7702Account.createRegisterKeyMetaTransactions(key, settings?)[SimpleMetaTransaction, SimpleMetaTransaction]
createRevokeKeyMetaTransaction (static)Calibur7702Account.createRevokeKeyMetaTransaction(keyHash)SimpleMetaTransaction
createRevokeAllKeysMetaTransactionscreateRevokeAllKeysMetaTransactions(providerRpc)Promise<SimpleMetaTransaction[]>
createUpdateKeySettingsMetaTransaction (static)Calibur7702Account.createUpdateKeySettingsMetaTransaction(keyHash, settings)SimpleMetaTransaction
packKeySettings (static)Calibur7702Account.packKeySettings(settings)bigint
unpackKeySettings (static)Calibur7702Account.unpackKeySettings(packed)CaliburKeySettingsResult
isKeyRegisteredisKeyRegistered(providerRpc, keyHash)Promise<boolean>
getKeySettingsgetKeySettings(providerRpc, keyHash)Promise<CaliburKeySettingsResult>
getKeygetKey(providerRpc, keyHash)Promise<CaliburKey>
getKeysgetKeys(providerRpc, overrides?)Promise<CaliburKey[]>
formatWebAuthnSignatureformatWebAuthnSignature(keyHash, webAuthnAuth, overrides?)string
createDummyWebAuthnSignature (static)Calibur7702Account.createDummyWebAuthnSignature(keyHash)string

For step-by-step flows, see the Passkey Authentication and Key Management guides.

Key Management Methods​

createSecp256k1Key​

Static method. Creates a secp256k1 key descriptor from an Ethereum address.

example.ts
import { Calibur7702Account } from "abstractionkit";

const secondaryAddress = "0x742D35CC6634C0532925a3B844Bc9E7595F2bD18";
const key = Calibur7702Account.createSecp256k1Key(secondaryAddress);

console.log(key);
// { keyType: 2, publicKey: "0x000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f2bd18" }

Source code​

createSecp256k1Key

createWebAuthnP256Key​

Static method. Creates a WebAuthn P-256 key descriptor from public key coordinates. Use this when registering a passkey on the account.

example.ts
import { Calibur7702Account } from "abstractionkit";

// Extract x, y coordinates from a WebAuthn credential
const x = 0x1234...n; // P-256 public key x coordinate
const y = 0x5678...n; // P-256 public key y coordinate

const webAuthnKey = Calibur7702Account.createWebAuthnP256Key(x, y);
const keyHash = Calibur7702Account.getKeyHash(webAuthnKey);
console.log("Key hash:", keyHash);

Source code​

createWebAuthnP256Key

createP256Key​

Static method. Creates a raw P-256 (secp256r1) key descriptor from public key coordinates. Use this for non-WebAuthn P-256 keys.

example.ts
import { Calibur7702Account } from "abstractionkit";

const x = 0x1234...n; // P-256 public key x coordinate
const y = 0x5678...n; // P-256 public key y coordinate

const p256Key = Calibur7702Account.createP256Key(x, y);
const keyHash = Calibur7702Account.getKeyHash(p256Key);
console.log("Key hash:", keyHash);

Source code​

createP256Key

getKeyHash​

Static method. Computes the key hash for a Calibur key. Uses double hashing: keccak256(abi.encode(uint8 keyType, bytes32 keccak256(publicKey))).

example.ts
import { Calibur7702Account } from "abstractionkit";

const key = Calibur7702Account.createSecp256k1Key("0x742D35CC6634C0532925a3B844Bc9E7595F2bD18");
const keyHash = Calibur7702Account.getKeyHash(key);

console.log("Key hash:", keyHash);
// bytes32 hex string, e.g. "0xabc123..."

Source code​

getKeyHash

createRegisterKeyMetaTransactions​

Static method. Creates meta-transactions to register a new key on the Calibur account. Returns two transactions ([register, update]) that must both be included in the same UserOperation. For safety, the key is always registered as non-admin, and the method throws if settings.isAdmin is true.

example.ts
import { Calibur7702Account } from "abstractionkit";

// Create the key to register
const newKey = Calibur7702Account.createSecp256k1Key("0x742D35CC6634C0532925a3B844Bc9E7595F2bD18");

// Build register + update transactions (both required in the same UserOp)
const registerTxs = Calibur7702Account.createRegisterKeyMetaTransactions(
newKey,
{
expiration: Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60, // 30 days
}
);

// Include both transactions in the UserOperation
const userOperation = await smartAccount.createUserOperation(
registerTxs, // array of two SimpleMetaTransactions
nodeRpc,
bundlerRpc,
);

Source code​

createRegisterKeyMetaTransactions

createRevokeKeyMetaTransaction​

Static method. Creates a meta-transaction to revoke a key from the Calibur account. Only admin keys can execute revoke operations.

example.ts
import { Calibur7702Account } from "abstractionkit";

const keyHash = "0x...key-hash-to-revoke";
const revokeTx = Calibur7702Account.createRevokeKeyMetaTransaction(keyHash);

// Include in a UserOperation signed by an admin key
const userOperation = await smartAccount.createUserOperation(
[revokeTx],
nodeRpc,
bundlerRpc,
);

Source code​

createRevokeKeyMetaTransaction

createUpdateKeySettingsMetaTransaction​

Static method. Creates a meta-transaction to update settings for a registered key. Only admin keys can execute update operations. Throws if isAdmin is set to true in the settings.

example.ts
import { Calibur7702Account } from "abstractionkit";

const keyHash = "0x...registered-key-hash";

// Extend key expiration to 1 year from now
const updateTx = Calibur7702Account.createUpdateKeySettingsMetaTransaction(
keyHash,
{
expiration: Math.floor(Date.now() / 1000) + 365 * 24 * 60 * 60,
}
);

const userOperation = await smartAccount.createUserOperation(
[updateTx],
nodeRpc,
bundlerRpc,
);

Source code​

createUpdateKeySettingsMetaTransaction

packKeySettings​

Static method. Packs key settings into a single uint256 value. Layout: (isAdmin << 200) | (expiration << 160) | hook.

expiration is a unix timestamp in seconds. Since v0.4.1, packKeySettings throws a RangeError if expiration does not fit the contract's uint40 field (for example, a millisecond timestamp from Date.now()) or if hook is outside the 160-bit address range. hook is parsed with BigInt, so a non-numeric string throws a SyntaxError instead.

example.ts
import { Calibur7702Account } from "abstractionkit";

const packed = Calibur7702Account.packKeySettings({
hook: "0x0000000000000000000000000000000000000000",
expiration: Math.floor(Date.now() / 1000) + 86400, // 1 day
isAdmin: false,
});

console.log("Packed settings:", packed);

Source code​

packKeySettings

unpackKeySettings​

Static method. Unpacks a uint256 settings value into a CaliburKeySettingsResult object with all fields populated.

example.ts
import { Calibur7702Account } from "abstractionkit";

const packed = 0x...n; // packed settings from the contract

const settings = Calibur7702Account.unpackKeySettings(packed);
console.log("Admin:", settings.isAdmin);
console.log("Expiration:", settings.expiration);
console.log("Hook:", settings.hook);

Source code​

unpackKeySettings

Key Read Methods​

isKeyRegistered​

Checks if a key is registered on this account by querying the on-chain isRegistered(bytes32) function.

example.ts
const keyHash = Calibur7702Account.getKeyHash(key);
const isRegistered = await smartAccount.isKeyRegistered(
"https://ethereum-sepolia-rpc.publicnode.com",
keyHash,
);

console.log("Key registered:", isRegistered);

Source code​

isKeyRegistered

getKeySettings​

Gets the settings for a registered key. Returns a CaliburKeySettingsResult with hook address, expiration timestamp, and admin flag.

example.ts
const keyHash = Calibur7702Account.getKeyHash(key);
const settings = await smartAccount.getKeySettings(
"https://ethereum-sepolia-rpc.publicnode.com",
keyHash,
);

console.log("Admin:", settings.isAdmin);
console.log("Expiration:", settings.expiration === 0 ? "never" : new Date(settings.expiration * 1000).toISOString());
console.log("Hook:", settings.hook);

Source code​

getKeySettings

getKey​

Gets the full key data for a registered key, including the key type and ABI-encoded public key bytes.

example.ts
const keyHash = "0x...registered-key-hash";
const key = await smartAccount.getKey(
"https://ethereum-sepolia-rpc.publicnode.com",
keyHash,
);

console.log("Key type:", key.keyType); // 0 = P256, 1 = WebAuthnP256, 2 = Secp256k1
console.log("Public key:", key.publicKey);

Source code​

getKey

getKeys​

Returns all keys registered on this account. Iterates keyCount() and keyAt(i) to enumerate all keys.

example.ts
const keys = await smartAccount.getKeys(
"https://ethereum-sepolia-rpc.publicnode.com",
);

for (const key of keys) {
const keyHash = Calibur7702Account.getKeyHash(key);
const settings = await smartAccount.getKeySettings(nodeRpc, keyHash);
console.log("Key:", keyHash.slice(0, 18) + "...");
console.log(" Type:", key.keyType);
console.log(" Admin:", settings.isAdmin);
}

Source code​

getKeys

Passkey Signing Methods​

formatWebAuthnSignature​

Formats a WebAuthn (passkey) assertion into Calibur's signature format. Use this after getting an assertion from the browser's navigator.credentials.get() API. The challenge for the assertion should be the UserOperation hash.

example.ts
import { Calibur7702Account, WebAuthnSignatureData } from "abstractionkit";

// After getting a WebAuthn assertion from the browser
const webAuthnSignatureData: WebAuthnSignatureData = {
authenticatorData: "0x...",
clientDataJSON: '{"type":"webauthn.get","challenge":"...","origin":"https://example.com"}',
challengeIndex: 23n, // index of '"challenge"' in clientDataJSON
typeIndex: 1n, // index of '"type"' in clientDataJSON
r: 0x...n,
s: 0x...n,
};

const keyHash = Calibur7702Account.getKeyHash(webAuthnKey);

// Format the WebAuthn signature for the UserOperation
userOperation.signature = smartAccount.formatWebAuthnSignature(
keyHash,
webAuthnSignatureData,
);

Source code​

formatWebAuthnSignature

createDummyWebAuthnSignature​

Static method. Creates a dummy WebAuthn signature for gas estimation when signing with a passkey. The key hash must correspond to an actually registered key on the account, otherwise the contract's validateUserOp will revert.

example.ts
import { Calibur7702Account } from "abstractionkit";

const keyHash = Calibur7702Account.getKeyHash(webAuthnKey);

const dummySignature = Calibur7702Account.createDummyWebAuthnSignature(keyHash);

// Pass as override during UserOperation creation for accurate gas estimation
const userOperation = await smartAccount.createUserOperation(
transactions,
nodeRpc,
bundlerRpc,
{ dummySignature },
);

Source code​

createDummyWebAuthnSignature