Authorization
RISExAuthorization contract interface for managing session keys, permissions, and signer registration
Overview
The RISExAuthorization contract manages session key lifecycle (register, revoke, permissions) and provides
EIP-712 typed data signature verification. It combines three sub-interfaces:
- ISignerManager — Session key registration, revocation, and permission management
- IPermitWitness — Witness permits with deadline validation
- IPermitSingle — ERC-2612 style single-token permits
Nonce System
RISExAuthorization uses a bitmap-based nonce system for replay protection:
nonceAnchor(uint48): The epoch anchor for the nonce windownonceBitmap(uint8): The bit index within the 256-bit bitmap for this epoch
This allows up to 256 concurrent valid nonces per epoch, rather than requiring sequential nonce usage.
Permission System
Session keys can have granular permissions:
enum Permission {
None, // No permissions
All, // Full access
Perps, // Perpetual trading only
Spot, // Spot trading only
MoveFund // Fund movement (deposit/withdraw) only
}Contract Functions
Register Signer
Description
Registers a signer (session key) to sign on behalf of an account. The account must provide an EIP-712 typed data
signature authorizing the signer. The signer is granted Permission.All by default.
function registerSigner(
address account,
address signer,
string memory message,
uint48 nonceAnchor,
uint8 nonceBitmap,
uint32 expiration,
bytes memory accountSignature
) external;Parameters
account: The account address that will authorize the signersigner: The signer address that will sign on behalf of the accountmessage: A human-readable message string included in the account's signaturenonceAnchor: The epoch anchor for replay protectionnonceBitmap: The bit index within the nonce bitmapexpiration: The expiration timestamp (uint32) when the session key expiresaccountSignature: EIP-712 signature from the account authorizing the signer
Example
address account = 0x...;
address signer = 0x...;
string memory message = "Authorize signer";
uint48 nonceAnchor = ...; // Current nonce anchor
uint8 nonceBitmap = 0; // First available bit
uint32 expiration = uint32(block.timestamp + 30 days);
bytes32 registerHash = _hashTypedDataV4(
keccak256(
abi.encode(
REGISTER_SIGNER_TYPEHASH,
// "RegisterSigner(address signer,string message,uint32 expiration,uint48 nonceAnchor,uint8 nonceBitmap)"
signer,
keccak256(abi.encodePacked(message)),
expiration,
nonceAnchor,
nonceBitmap
)
)
);
bytes memory accountSignature = _signTypedDataHash(accountPrivateKey, registerHash);
risExAuthorization.registerSigner(
account,
signer,
message,
nonceAnchor,
nonceBitmap,
expiration,
accountSignature
);Register Sender Signer
Description
Registers a signer to sign on behalf of msg.sender directly, without requiring a separate account signature.
This is a convenience function when the account owner is the transaction sender. The signer is granted
Permission.All by default.
function registerSenderSigner(
address signer,
uint48 nonceAnchor,
uint8 nonceBitmap,
uint32 expiration
) external;Parameters
signer: The signer address to authorizenonceAnchor: The epoch anchor for replay protectionnonceBitmap: The bit index within the nonce bitmapexpiration: The expiration timestamp when the session key expires
Example
// Register a signer for the calling account (no separate signature needed)
uint48 nonceAnchor = ...; // Current nonce anchor from getNonceState()
risExAuthorization.registerSenderSigner(
signerAddress,
nonceAnchor,
0, // nonceBitmap
uint32(block.timestamp + 30 days)
);Revoke Signer
Description
Revokes a signer's authorization to sign on behalf of an account. The signer must currently be authorized. The account must provide an EIP-712 typed data signature.
function revokeSigner(
address account,
address signer,
uint48 nonceAnchor,
uint8 nonceBitmap,
bytes memory accountSignature
) external;Parameters
account: The account address that authorized the signersigner: The signer address to revokenonceAnchor: The epoch anchor for replay protectionnonceBitmap: The bit index within the nonce bitmapaccountSignature: EIP-712 signature from the account authorizing the revocation
Example
address account = 0x...;
address signer = 0x...;
uint48 nonceAnchor = ...;
uint8 nonceBitmap = 1;
bytes32 revokeHash = _hashTypedDataV4(
keccak256(
abi.encode(
REVOKE_SIGNER_TYPEHASH,
// "RevokeSigner(address signer,uint48 nonceAnchor,uint8 nonceBitmap)"
signer,
nonceAnchor,
nonceBitmap
)
)
);
bytes memory accountSignature = _signTypedDataHash(accountPrivateKey, revokeHash);
risExAuthorization.revokeSigner(account, signer, nonceAnchor, nonceBitmap, accountSignature);Enable Permission
Description
Enables a specific permission for a signer. Requires an EIP-712 signature from the account.
function enablePermission(
address account,
address signer,
uint48 nonceAnchor,
uint8 nonceBitmap,
Permission permission,
bytes memory accountSignature
) external;Parameters
account: The account addresssigner: The signer address to grant the permission tononceAnchor: The epoch anchor for replay protectionnonceBitmap: The bit index within the nonce bitmappermission: The permission to enable (Perps, Spot, MoveFund, or All)accountSignature: EIP-712 signature from the account
Disable Permission
Description
Disables a specific permission for a signer. Requires an EIP-712 signature from the signer.
function disablePermission(
address account,
address signer,
uint48 nonceAnchor,
uint8 nonceBitmap,
Permission permission,
bytes memory signerSignature
) external;Parameters
account: The account addresssigner: The signer address to revoke the permission fromnonceAnchor: The epoch anchor for replay protectionnonceBitmap: The bit index within the nonce bitmappermission: The permission to disablesignerSignature: EIP-712 signature from the signer
View Functions
Get Session Key Status
Description
Returns the current status of a session key.
function getSessionKeyStatus(
address account,
address signer
) external view returns (SessionKeyStatus);Returns
SessionKeyStatus: One ofNone,Authorized,Expired, orRevoked
Has Permission
Description
Checks whether a signer has a specific permission for an account.
function hasPermission(
address account,
address signer,
Permission permission
) external view returns (bool);Session Keys
Description
Returns the session key details for an account and signer pair.
function sessionKeys(
address account,
address signer
) external view returns (uint32 expiration, uint32 permissionBitmap, SessionKeyStatus status);Returns
expiration: The expiration timestamppermissionBitmap: Bitmap of enabled permissionsstatus: Current session key status
Is Nonce Used
Description
Returns whether a specific nonce has been used for an account.
function isNonceUsed(
address account,
uint48 nonceAnchor,
uint8 nonceBitmap
) external view returns (bool);Get Nonce State
Description
Returns the current nonce anchor and full bitmap for an account.
function getNonceState(
address account
) external view returns (uint48 nonceAnchor, uint256 bitmap);EIP-712 Typehashes
The following typehash accessors are available for constructing EIP-712 signatures:
function REGISTER_SIGNER_TYPEHASH() external pure returns (bytes32);
function VERIFY_SIGNER_TYPEHASH() external pure returns (bytes32);
function REVOKE_SIGNER_TYPEHASH() external pure returns (bytes32);
function ENABLE_PERMISSION_TYPEHASH() external pure returns (bytes32);
function DISABLE_PERMISSION_TYPEHASH() external pure returns (bytes32);
function VERIFY_WITNESS_TYPEHASH() external pure returns (bytes32);
function PERMIT_SINGLE_TYPEHASH() external pure returns (bytes32);