Skip to content

fix(session-keys): honor expiry == 0 as never-expires sentinel#70

Open
Ridwannurudeen wants to merge 1 commit intoSeismicSystems:mainfrom
Ridwannurudeen:fix/66-expiry-zero-never-expires
Open

fix(session-keys): honor expiry == 0 as never-expires sentinel#70
Ridwannurudeen wants to merge 1 commit intoSeismicSystems:mainfrom
Ridwannurudeen:fix/66-expiry-zero-never-expires

Conversation

@Ridwannurudeen
Copy link
Copy Markdown

Problem

Keys created with expiry = 0 are documented as "never expires" in both the Key struct NatSpec and the IShieldedDelegationAccount interface:

/// @dev Unix timestamp at which the key expires (0 = never).
uint40 expiry;

However, both execute() and verifyAndConsumeNonce() used a strict > comparison:

require(S.expiry > block.timestamp, "key expired");

Since 0 > block.timestamp is always false, any key created with expiry = 0 was permanently locked out — a documented feature that silently didn't work. Callers relying on unlimited-expiry keys get an immediate revert on every call.

Fix

Change both expiry checks to treat 0 as the unlimited sentinel:

require(S.expiry == 0 || S.expiry > block.timestamp, "key expired");

This matches the documented behavior in IShieldedDelegationAccount.sol and the Key struct NatSpec.

Files changed

  • contracts/src/seismic-std-lib/session-keys/ShieldedDelegationAccount.sol
    • execute(): session-key path expiry check
    • verifyAndConsumeNonce(): expiry check

Closes #66

…verifyAndConsumeNonce

Keys created with expiry = 0 are documented as 'never expires' in both the Key struct
NatSpec and the IShieldedDelegationAccount interface. However, the runtime checks in
execute() and verifyAndConsumeNonce() used a strict > comparison:

  require(S.expiry > block.timestamp, "key expired");

Since 0 > block.timestamp is always false, any key created with expiry = 0 was
permanently locked out — a documented feature that silently didn't work.

Fix: change both checks to allow expiry == 0 as the sentinel for unlimited keys:

  require(S.expiry == 0 || S.expiry > block.timestamp, "key expired");

Fixes SeismicSystems#66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(seismic-std-lib): keys with expiry == 0 are permanently unusable despite being documented as unlimited

1 participant