@agenticprimitives/contracts 1.0.0-alpha.48 → 1.0.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUDIT.md +36 -4
- package/dist/abi/AccountBootstrap.json +99 -0
- package/dist/abi/AgentAccount.json +95 -56
- package/dist/abi/AgentAccountFactory.json +189 -0
- package/dist/abi/AgentNameAttributeResolver.json +188 -0
- package/dist/abi/AgentNameRegistry.json +170 -0
- package/dist/abi/AgentNameUniversalResolver.json +188 -0
- package/dist/abi/AgentProfileResolver.json +188 -0
- package/dist/abi/AgentRegistryBase.json +193 -0
- package/dist/abi/AgentRelationship.json +193 -0
- package/dist/abi/AgenticGovernance.json +123 -0
- package/dist/abi/AgreementRegistry.json +193 -0
- package/dist/abi/AllowedMethodsEnforcer.json +193 -0
- package/dist/abi/AllowedTargetsEnforcer.json +193 -0
- package/dist/abi/ApprovedHashRegistry.json +220 -0
- package/dist/abi/AttestationRegistry.json +193 -0
- package/dist/abi/CallDataHashEnforcer.json +193 -0
- package/dist/abi/CustodyPolicy.json +195 -80
- package/dist/abi/DelegationManager.json +185 -0
- package/dist/abi/DigestBindingEnforcer.json +188 -0
- package/dist/abi/Eip7702.json +13 -0
- package/dist/abi/EstateProjectionRegistry.json +193 -0
- package/dist/abi/Generation5Bridge.json +355 -0
- package/dist/abi/GeoFeatureRegistry.json +193 -0
- package/dist/abi/ICustodyEpochView.json +28 -0
- package/dist/abi/IDelegationManager.json +18 -0
- package/dist/abi/IGeneration4Reads.json +143 -0
- package/dist/abi/IGeneration5Account.json +33 -0
- package/dist/abi/IGeneration5Voucher.json +26 -0
- package/dist/abi/IMoveAccountView.json +57 -0
- package/dist/abi/IMoveCustodyView.json +169 -0
- package/dist/abi/IMoveFactoryView.json +41 -0
- package/dist/abi/ITimelockVeto.json +93 -0
- package/dist/abi/OntologyTermRegistry.json +211 -0
- package/dist/abi/PayloadClassesEnforcer.json +193 -0
- package/dist/abi/PaymentEnforcer.json +188 -0
- package/dist/abi/PaymentEscrow.json +177 -0
- package/dist/abi/PaymentReceiptRegistry.json +206 -0
- package/dist/abi/PermissionlessSubregistry.json +188 -0
- package/dist/abi/PricedSubregistry.json +215 -0
- package/dist/abi/QuorumEnforcer.json +193 -0
- package/dist/abi/ReceiptAnchorRegistry.json +193 -0
- package/dist/abi/RelationshipTypeRegistry.json +211 -0
- package/dist/abi/ShapeRegistry.json +211 -0
- package/dist/abi/SignatureVerifier.json +196 -0
- package/dist/abi/SkillDefinitionRegistry.json +193 -0
- package/dist/abi/SmartAgentPaymaster.json +236 -1
- package/dist/abi/StableProxyGoverned.json +190 -0
- package/dist/abi/StableProxyGovernedOneShot.json +172 -0
- package/dist/abi/TimestampEnforcer.json +193 -0
- package/dist/abi/TreasurySpendPolicy.json +193 -0
- package/dist/abi/UpgradeVoucher.json +156 -4
- package/dist/abi/ValueEnforcer.json +193 -0
- package/dist/abi/index.d.ts +14 -0
- package/dist/abi/index.js +14 -0
- package/package.json +1 -1
- package/src/AccountBootstrap.sol +38 -0
- package/src/AgentAccount.sol +149 -41
- package/src/AgentAccountFactory.sol +52 -13
- package/src/ApprovedHashRegistry.sol +98 -9
- package/src/SmartAgentPaymaster.sol +96 -12
- package/src/UniversalSignatureValidator.sol +7 -0
- package/src/UpgradeVoucher.sol +16 -3
- package/src/agency/DelegationManager.sol +106 -32
- package/src/agency/IDelegationManager.sol +28 -0
- package/src/agreement/AgreementRegistry.sol +16 -15
- package/src/attestation/AttestationRegistry.sol +39 -16
- package/src/custody/CustodyPolicy.sol +36 -35
- package/src/custody/TreasurySpendPolicy.sol +10 -1
- package/src/enforcers/AllowedMethodsEnforcer.sol +7 -1
- package/src/enforcers/AllowedTargetsEnforcer.sol +7 -1
- package/src/enforcers/CallDataHashEnforcer.sol +7 -1
- package/src/enforcers/DigestBindingEnforcer.sol +5 -2
- package/src/enforcers/PayloadClassesEnforcer.sol +7 -1
- package/src/enforcers/PaymentEnforcer.sol +5 -2
- package/src/enforcers/QuorumEnforcer.sol +7 -1
- package/src/enforcers/TimestampEnforcer.sol +7 -1
- package/src/enforcers/ValueEnforcer.sol +7 -1
- package/src/geo/GeoFeatureRegistry.sol +15 -1
- package/src/governance/AgenticGovernance.sol +145 -0
- package/src/governance/GovernanceManaged.sol +2 -0
- package/src/governance/StableProxyGoverned.sol +79 -0
- package/src/governance/StableProxyGovernedOneShot.sol +93 -0
- package/src/identity/AgentProfileResolver.sol +11 -2
- package/src/libraries/Eip7702.sol +36 -0
- package/src/libraries/SignatureSlotRecovery.sol +4 -0
- package/src/libraries/SignatureVerifier.sol +52 -0
- package/src/libraries/WebAuthnLib.sol +3 -0
- package/src/migration/Generation5Bridge.sol +364 -0
- package/src/naming/AgentNameAttributeResolver.sol +12 -2
- package/src/naming/AgentNameRegistry.sol +84 -10
- package/src/naming/AgentNameUniversalResolver.sol +9 -2
- package/src/naming/PermissionlessSubregistry.sol +13 -2
- package/src/naming/PricedSubregistry.sol +59 -3
- package/src/ontology/OntologyTermRegistry.sol +30 -2
- package/src/ontology/ShapeRegistry.sol +30 -2
- package/src/payments/PaymentEscrow.sol +16 -1
- package/src/payments/PaymentReceiptRegistry.sol +28 -3
- package/src/provenance/ReceiptAnchorRegistry.sol +13 -1
- package/src/registry/AgentRegistryBase.sol +21 -1
- package/src/registry/EstateProjectionRegistry.sol +15 -1
- package/src/relationships/AgentRelationship.sol +17 -1
- package/src/relationships/RelationshipTypeRegistry.sol +30 -2
- package/src/skills/SkillDefinitionRegistry.sol +15 -1
package/src/AgentAccount.sol
CHANGED
|
@@ -14,6 +14,7 @@ import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
|
14
14
|
import "./IAgentAccount.sol";
|
|
15
15
|
import "./libraries/SignatureSlotRecovery.sol";
|
|
16
16
|
import "./libraries/WebAuthnLib.sol";
|
|
17
|
+
import {SignatureVerifier} from "./libraries/SignatureVerifier.sol";
|
|
17
18
|
|
|
18
19
|
/// @dev Minimal subset of AgentAccountFactory's surface used by the
|
|
19
20
|
/// account to look up factory-scoped capability roles. We avoid a
|
|
@@ -133,6 +134,11 @@ contract AgentAccount is
|
|
|
133
134
|
/// it is running NOW. Zero / no code ⇒ every upgrade is refused (fail closed) — see
|
|
134
135
|
/// `upgradeToAndCall` for the migration statement.
|
|
135
136
|
address private immutable _upgradeVoucher;
|
|
137
|
+
/// @notice Spec 449: the stateless verifier that runs this implementation's WebAuthn assertion check (decode,
|
|
138
|
+
/// authenticator data, client data, low-s, P-256) — moved out of this bytecode for EIP-170 room. Created
|
|
139
|
+
/// by this implementation's constructor, so it is part of what the upgrade voucher vouched; reached by
|
|
140
|
+
/// STATICCALL from `_verifyWebAuthn` only, and it holds no state and no authority.
|
|
141
|
+
address public immutable signatureVerifier;
|
|
136
142
|
|
|
137
143
|
/// @dev Authorized DelegationManager (ERC-7710 executor)
|
|
138
144
|
address private _delegationManager;
|
|
@@ -220,6 +226,31 @@ contract AgentAccount is
|
|
|
220
226
|
/// CustodyPolicy's job), regardless of custody mode.
|
|
221
227
|
bool private transient _delegationExecCtx;
|
|
222
228
|
|
|
229
|
+
/// @dev Spec 447 — transient "a vouched upgrade's migration call is running" flag. Set only inside
|
|
230
|
+
/// {upgradeToAndCall}, after the voucher accepted `(newImplementation, keccak256(data))`, around the
|
|
231
|
+
/// delegatecall of `data`. {migrateFactory} runs only while it is set, so the factory an account reads its
|
|
232
|
+
/// canonical custody policy, delegation manager, governance and roles from is moved only by migration data
|
|
233
|
+
/// governance vouched for — never by a standalone call a custodian could make later with any factory
|
|
234
|
+
/// (GC's upgrade rehearsal hazard: a migration also vouched with empty data).
|
|
235
|
+
///
|
|
236
|
+
/// LAYOUT. Transient variables are APPENDED, never inserted: an upgrade runs old and new code in one
|
|
237
|
+
/// transaction, so the three flags above keep the positions generation 4 gave them and this one takes the
|
|
238
|
+
/// next (slot 0, offset 3). `Generation5Bridge` writes this position by name; `check:storage-layouts` gates
|
|
239
|
+
/// the transient layout.
|
|
240
|
+
bool private transient _upgradeMigrationCtx;
|
|
241
|
+
|
|
242
|
+
/// @dev Audit 2026-12-02 C1-4 — transient "this account was initialized in this transaction". The factory's
|
|
243
|
+
/// one-time module-install exception (`onlySelfOrFactoryInit`) exists only while it is set: the factory
|
|
244
|
+
/// installs a governed account's policy in the transaction that creates it, and a self-governed account —
|
|
245
|
+
/// which the factory never installs anything on — leaves that transaction with the exception gone, as does
|
|
246
|
+
/// an account that moved to a new factory. Appended after `_upgradeMigrationCtx` (slot 0, offset 4).
|
|
247
|
+
bool private transient _initializedThisTx;
|
|
248
|
+
|
|
249
|
+
/// @dev Transient "the custody epoch was bumped in this transaction" (set in `_bumpCustodyEpoch`). On a
|
|
250
|
+
/// custody-governed account `approveDigest` refuses while it is set, outside the custody policy's own
|
|
251
|
+
/// context — see `approveDigest`. Appended after `_initializedThisTx` (slot 0, offset 5).
|
|
252
|
+
bool private transient _epochBumpedThisTx;
|
|
253
|
+
|
|
223
254
|
/// @dev Spec 007 Phase A.5 — maximum permitted upgrade timelock to
|
|
224
255
|
/// protect against an owner accidentally setting an absurdly
|
|
225
256
|
/// large delay that bricks future migrations.
|
|
@@ -325,6 +356,13 @@ contract AgentAccount is
|
|
|
325
356
|
/// @dev Spec 410 §1 (THESIS-1a): the approved-hash registry is reachable only through
|
|
326
357
|
/// `approveDigest` / `revokeDigest` / `revokeAllApprovedDigests`, never as an execute target.
|
|
327
358
|
error ApprovedHashRegistryOnlyViaAccount();
|
|
359
|
+
/// @dev Spec 447: {migrateFactory} outside a vouched upgrade's migration call.
|
|
360
|
+
error MigrationOnly();
|
|
361
|
+
error ApprovalAfterCustodyChange();
|
|
362
|
+
/// @dev Spec 447: the migration target is not a factory (no code, or no custody policy / delegation manager).
|
|
363
|
+
error NotAFactory(address target);
|
|
364
|
+
/// @dev Spec 447: `custodyInit` must be given exactly when the account is custody-governed.
|
|
365
|
+
error CustodyInitMismatch(bool governed);
|
|
328
366
|
|
|
329
367
|
// Spec 445 — generation 4.
|
|
330
368
|
/// @notice §1.3 (i): the implementation's `UpgradeVoucher` does not vouch for this
|
|
@@ -512,6 +550,7 @@ contract AgentAccount is
|
|
|
512
550
|
// ─── Constructor / Initializer ──────────────────────────────────
|
|
513
551
|
|
|
514
552
|
constructor(IEntryPoint entryPoint_, address approvedHashRegistry_, address upgradeVoucher_) {
|
|
553
|
+
signatureVerifier = address(new SignatureVerifier());
|
|
515
554
|
_entryPoint = entryPoint_;
|
|
516
555
|
_approvedHashRegistry = approvedHashRegistry_;
|
|
517
556
|
_upgradeVoucher = upgradeVoucher_;
|
|
@@ -589,6 +628,7 @@ contract AgentAccount is
|
|
|
589
628
|
|
|
590
629
|
_delegationManager = dm;
|
|
591
630
|
_factory = factory_;
|
|
631
|
+
_initializedThisTx = true; // audit C1-4: the factory's install exception lives in this transaction only
|
|
592
632
|
// Spec 445 §1.3 (ii): a factory-less (legacy / direct-deploy) account has no canonical delegation
|
|
593
633
|
// manager to compare against, so its initial one is stamped under epoch 0 — and lapses, like any
|
|
594
634
|
// other non-canonical manager, at the first retirement unless re-affirmed. A factory-born account
|
|
@@ -717,10 +757,72 @@ contract AgentAccount is
|
|
|
717
757
|
* a generation-4 DelegationManager is a `setDelegationManager` — non-canonical for that account, so
|
|
718
758
|
* it must be re-affirmed at every rotation; its custody policy keeps the old action set.
|
|
719
759
|
*/
|
|
760
|
+
/// @notice ERC-1822, asked of THIS implementation by an account about to upgrade to it. Answered only for an
|
|
761
|
+
/// account whose running implementation carries this implementation's voucher (spec 448 §0, audit
|
|
762
|
+
/// 2026-12-02 H-2): an account still running code with another voucher — every generation-4 account —
|
|
763
|
+
/// cannot upgrade to this implementation directly, whatever pair its own voucher vouches. Its one way in
|
|
764
|
+
/// is `Generation5Bridge`, whose completion runs `migrateFactory`.
|
|
765
|
+
function proxiableUUID() external view override notDelegated returns (bytes32) {
|
|
766
|
+
if (AgentAccount(payable(msg.sender)).upgradeVoucher() != _upgradeVoucher) revert UpgradeNotVouched(address(this), 0);
|
|
767
|
+
return ERC1967Utils.IMPLEMENTATION_SLOT;
|
|
768
|
+
}
|
|
769
|
+
|
|
720
770
|
function upgradeToAndCall(address newImplementation, bytes memory data) public payable override onlyProxy {
|
|
721
771
|
_authorizeUpgrade(newImplementation);
|
|
722
772
|
_requireVouchedUpgrade(newImplementation, keccak256(data));
|
|
773
|
+
_upgradeMigrationCtx = true;
|
|
723
774
|
super.upgradeToAndCall(newImplementation, data);
|
|
775
|
+
_upgradeMigrationCtx = false;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/// @notice Spec 447 §3.3 — move this account to a new factory, IN PLACE (same address, same custodians,
|
|
779
|
+
/// same storage). Callable only as a vouched upgrade's migration call: the generation-5 move is
|
|
780
|
+
/// `upgradeToAndCall(gen5Implementation, abi.encodeCall(this.migrateFactory, (stableFactory, custodyInit)))`
|
|
781
|
+
/// with that exact pair vouched by governance (and, on a custody-governed account, applied by its own
|
|
782
|
+
/// quorum through `ApplySystemUpdate`). From then on the account reads its canonical custody policy,
|
|
783
|
+
/// delegation manager, governance, bundler and session issuer from the new (stable) factory.
|
|
784
|
+
///
|
|
785
|
+
/// A CUSTODY-GOVERNED account keeps its custody: when the new factory's canonical policy differs from
|
|
786
|
+
/// the installed one, the new policy is installed with `custodyInit` (the account's own configuration,
|
|
787
|
+
/// the `onInstall` encoding) and the old one is unlisted — it can no longer act on this account; its
|
|
788
|
+
/// stale state stays in the old contract. Without this the account would silently stop being
|
|
789
|
+
/// custody-governed (the old policy is no longer canonical). A self-governed account passes empty
|
|
790
|
+
/// `custodyInit`.
|
|
791
|
+
/// @dev Refused outside a migration (`MigrationOnly`), for a factory with no code or one that names no custody
|
|
792
|
+
/// policy or delegation manager (PR #751: a non-factory `_factory` bricks the account), for a governed
|
|
793
|
+
/// account with no `custodyInit`, and for `custodyInit` on an account that is not governed.
|
|
794
|
+
function migrateFactory(address newFactory, bytes calldata custodyInit) external {
|
|
795
|
+
if (!_upgradeMigrationCtx) revert MigrationOnly();
|
|
796
|
+
if (newFactory.code.length == 0) revert NotAFactory(newFactory);
|
|
797
|
+
address newPolicy = IAgentAccountFactoryView(newFactory).custodyPolicy();
|
|
798
|
+
if (newPolicy == address(0) || IAgentAccountFactoryView(newFactory).delegationManager() == address(0)) {
|
|
799
|
+
revert NotAFactory(newFactory);
|
|
800
|
+
}
|
|
801
|
+
address oldFactory = _factory;
|
|
802
|
+
address oldPolicy = oldFactory == address(0) ? address(0) : IAgentAccountFactoryView(oldFactory).custodyPolicy();
|
|
803
|
+
ModulesStorage storage $ = _modulesStorage();
|
|
804
|
+
bool governed = oldPolicy != address(0) && $.installed[MODULE_TYPE_EXECUTOR][oldPolicy];
|
|
805
|
+
if (governed != (custodyInit.length != 0)) revert CustodyInitMismatch(governed);
|
|
806
|
+
|
|
807
|
+
// Audit H-2 (C1-2 / C3-1): the registry this implementation reads was an ordinary call target for the
|
|
808
|
+
// code the account ran before, so anything approved there (for this or any later custody epoch) was
|
|
809
|
+
// approved outside `approveDigest`. The move voids all of it HERE, in every custody mode — not in a step
|
|
810
|
+
// of the mover's batch.
|
|
811
|
+
_revokeAllApproved();
|
|
812
|
+
emit FactoryMigrated(oldFactory, newFactory);
|
|
813
|
+
_factory = newFactory;
|
|
814
|
+
if (!governed || newPolicy == oldPolicy) return;
|
|
815
|
+
|
|
816
|
+
$.installed[MODULE_TYPE_EXECUTOR][oldPolicy] = false;
|
|
817
|
+
_removeFromList($.installedList[MODULE_TYPE_EXECUTOR], oldPolicy);
|
|
818
|
+
delete _moduleEpochStamp[oldPolicy];
|
|
819
|
+
emit ModuleUninstalled(MODULE_TYPE_EXECUTOR, oldPolicy);
|
|
820
|
+
|
|
821
|
+
$.installed[MODULE_TYPE_EXECUTOR][newPolicy] = true;
|
|
822
|
+
$.installedList[MODULE_TYPE_EXECUTOR].push(newPolicy);
|
|
823
|
+
_moduleEpochStamp[newPolicy] = _custodyEpoch + 1;
|
|
824
|
+
IERC7579ModuleLike(newPolicy).onInstall(custodyInit); // a refusal reverts the whole upgrade
|
|
825
|
+
emit ModuleInstalled(MODULE_TYPE_EXECUTOR, newPolicy);
|
|
724
826
|
}
|
|
725
827
|
|
|
726
828
|
/// @dev Spec 445 §1.3 (i). See `upgradeToAndCall`. Low-level staticcall so a voucher that reverts or
|
|
@@ -1165,7 +1267,7 @@ contract AgentAccount is
|
|
|
1165
1267
|
_;
|
|
1166
1268
|
return;
|
|
1167
1269
|
}
|
|
1168
|
-
if (msg.sender == _factory && !_factoryInitConsumed) {
|
|
1270
|
+
if (msg.sender == _factory && _initializedThisTx && !_factoryInitConsumed) {
|
|
1169
1271
|
_factoryInitConsumed = true;
|
|
1170
1272
|
_;
|
|
1171
1273
|
return;
|
|
@@ -1935,53 +2037,35 @@ contract AgentAccount is
|
|
|
1935
2037
|
* revert during validation as a banned account — much worse
|
|
1936
2038
|
* than a clean "this sig is invalid" return.
|
|
1937
2039
|
*
|
|
1938
|
-
*
|
|
1939
|
-
*
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
2040
|
+
* The decode runs in an external call (which CAN be
|
|
2041
|
+
* try/catch'd) — since spec 449 the call is to
|
|
2042
|
+
* `signatureVerifier`, which replaced the self-call
|
|
2043
|
+
* `decodeWebAuthnAssertion`.
|
|
1942
2044
|
*/
|
|
1943
2045
|
function _verifyWebAuthn(bytes32 hash, bytes memory payload) internal view returns (bool) {
|
|
1944
|
-
|
|
2046
|
+
// Spec 449: decoding and verification run in `signatureVerifier` (stateless; this implementation's own).
|
|
2047
|
+
// Any revert there — a payload that does not decode, or anything else — is "invalid", never a revert out
|
|
2048
|
+
// of validation (audit C-7; C1-8).
|
|
2049
|
+
SignatureVerifier v = SignatureVerifier(signatureVerifier);
|
|
2050
|
+
try v.credentialOf(payload) returns (bytes32 cid) {
|
|
1945
2051
|
PasskeyStorage storage $ = _passkeyStorage();
|
|
1946
|
-
PasskeyEntry storage key = $.keys[
|
|
2052
|
+
PasskeyEntry storage key = $.keys[cid];
|
|
1947
2053
|
if (key.x == 0 && key.y == 0) return false;
|
|
1948
2054
|
// H7-C.1 / CON-WEBAUTHN-001: pin per-credential rpIdHash + require UP.
|
|
1949
|
-
// R8.2 / ATL-SEC-03:
|
|
1950
|
-
//
|
|
1951
|
-
|
|
1952
|
-
// (demo-sso, demo-sso-next, demo-org, demo-web-recovery); the
|
|
1953
|
-
// third-party audit (2026-05-31) correctly observed that the
|
|
1954
|
-
// contract still passed `requireUv: false` here. That meant a
|
|
1955
|
-
// permissive authenticator could produce a UP-only assertion
|
|
1956
|
-
// and we'd accept it. R8.2 makes UV strictly required on every
|
|
1957
|
-
// ERC-1271 verify. Browser ceremonies that pass
|
|
1958
|
-
// `userVerification: 'preferred'` will be REJECTED at the
|
|
1959
|
-
// signature step — those apps (demo-web, demo-web-pro) MUST
|
|
1960
|
-
// upgrade to `'required'` for production deployments. Tests
|
|
1961
|
-
// exercising lower-assurance flows can install a separate
|
|
1962
|
-
// passkey-validator module that relaxes this check.
|
|
1963
|
-
bytes32 rpIdHash = $.rpIdHashOf[a.credentialIdDigest];
|
|
2055
|
+
// R8.2 / ATL-SEC-03: User Verification is required on every verify (`verifyWebAuthn` passes
|
|
2056
|
+
// `requireUv = true`); a lower-assurance flow installs a separate validator module.
|
|
2057
|
+
bytes32 rpIdHash = $.rpIdHashOf[cid];
|
|
1964
2058
|
if (rpIdHash == bytes32(0)) return false;
|
|
1965
|
-
|
|
2059
|
+
try v.verifyWebAuthn(payload, hash, key.x, key.y, rpIdHash) returns (bool ok) {
|
|
2060
|
+
return ok;
|
|
2061
|
+
} catch {
|
|
2062
|
+
return false;
|
|
2063
|
+
}
|
|
1966
2064
|
} catch {
|
|
1967
2065
|
return false;
|
|
1968
2066
|
}
|
|
1969
2067
|
}
|
|
1970
2068
|
|
|
1971
|
-
/**
|
|
1972
|
-
* @notice External decoder wrapper used by `_verifyWebAuthn` to
|
|
1973
|
-
* bound `abi.decode` reverts. MUST stay `external` so the
|
|
1974
|
-
* caller can wrap it in `try { … } catch { … }`. Marked
|
|
1975
|
-
* pure — no state access, just decode.
|
|
1976
|
-
*/
|
|
1977
|
-
function decodeWebAuthnAssertion(bytes calldata payload)
|
|
1978
|
-
external
|
|
1979
|
-
pure
|
|
1980
|
-
returns (WebAuthnLib.Assertion memory)
|
|
1981
|
-
{
|
|
1982
|
-
return abi.decode(payload, (WebAuthnLib.Assertion));
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
2069
|
// ─── Owner Management ───────────────────────────────────────────
|
|
1986
2070
|
|
|
1987
2071
|
/// @inheritdoc IAgentAccount
|
|
@@ -2159,6 +2243,8 @@ contract AgentAccount is
|
|
|
2159
2243
|
event DigestRevoked(bytes32 indexed digest, uint64 epoch);
|
|
2160
2244
|
/// @dev Spec 410 §1 — every approval this account ever made is void (registry-side epoch bump).
|
|
2161
2245
|
event AllDigestsRevoked();
|
|
2246
|
+
/// @notice Spec 447 — the account now reads its system addresses from `newFactory`.
|
|
2247
|
+
event FactoryMigrated(address indexed oldFactory, address indexed newFactory);
|
|
2162
2248
|
|
|
2163
2249
|
/// @notice Register a new WebAuthn credential bound to a specific RP.
|
|
2164
2250
|
/// `onlySelf` — callable via a UserOp signed by any existing signer
|
|
@@ -2267,6 +2353,7 @@ contract AgentAccount is
|
|
|
2267
2353
|
function _bumpCustodyEpoch() internal {
|
|
2268
2354
|
uint64 next = _custodyEpoch + 1;
|
|
2269
2355
|
_custodyEpoch = next;
|
|
2356
|
+
_epochBumpedThisTx = true;
|
|
2270
2357
|
emit CustodyEpochBumped(next);
|
|
2271
2358
|
address pending = _pendingUpgrade.newImplementation;
|
|
2272
2359
|
if (_pendingUpgrade.readyAt != 0) {
|
|
@@ -2284,16 +2371,33 @@ contract AgentAccount is
|
|
|
2284
2371
|
/// creating custodian, and the epoch (R917-C-2) plus `revokeAllApprovedDigests` on every
|
|
2285
2372
|
/// recovery path (spec 410 §1.2) close the persistence risk instead. A delegation stack cannot
|
|
2286
2373
|
/// reach it (`_isGovernanceSelector`).
|
|
2374
|
+
/// On a custody-governed account no approval is made after a custody-epoch bump in the same
|
|
2375
|
+
/// transaction except by the custody policy itself (`RotateCredential`'s re-approval list): a user
|
|
2376
|
+
/// operation validates before it executes, so a custodian being retired or recovered away could
|
|
2377
|
+
/// otherwise wrap the quorum's applied change in her own batch and approve under the NEW epoch after
|
|
2378
|
+
/// she is out (audit 2026-12-02 H-2 / THESIS-1a). Transient, so it covers every later operation of
|
|
2379
|
+
/// the same bundle too. A mode-0 account rotates in its own batch and is not affected.
|
|
2287
2380
|
function approveDigest(bytes32 digest) external onlySelf {
|
|
2288
2381
|
if (_approvedHashRegistry == address(0)) revert ApprovedHashRegistryOnlyViaAccount();
|
|
2289
|
-
|
|
2382
|
+
if (approvalRefused()) revert ApprovalAfterCustodyChange();
|
|
2383
|
+
// The registry derives the key under this account's current epoch itself (audit 2026-12-02 H-2).
|
|
2384
|
+
IApprovedHashRegistryWrite(_approvedHashRegistry).approveHash(digest);
|
|
2290
2385
|
emit DigestApproved(digest, _custodyEpoch);
|
|
2291
2386
|
}
|
|
2292
2387
|
|
|
2388
|
+
/// @notice Whether an approval made by this account NOW would be refused: a custody-governed account whose
|
|
2389
|
+
/// custody epoch was bumped, or which completed its move to this generation, earlier in this
|
|
2390
|
+
/// transaction, outside the custody policy's own call. `approveDigest` refuses on it, and the
|
|
2391
|
+
/// `ApprovedHashRegistry` asks it of every account signer, so an approval sent to the registry
|
|
2392
|
+
/// directly (a still-running generation-4 call frame after the move) is refused the same way.
|
|
2393
|
+
function approvalRefused() public view returns (bool) {
|
|
2394
|
+
return _epochBumpedThisTx && !_custodyGovCtx && _hasCustodyGovernance();
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2293
2397
|
/// @notice Revoke one approval made under the current epoch.
|
|
2294
2398
|
function revokeDigest(bytes32 digest) external onlySelf {
|
|
2295
2399
|
if (_approvedHashRegistry == address(0)) revert ApprovedHashRegistryOnlyViaAccount();
|
|
2296
|
-
IApprovedHashRegistryWrite(_approvedHashRegistry).revokeHash(
|
|
2400
|
+
IApprovedHashRegistryWrite(_approvedHashRegistry).revokeHash(digest);
|
|
2297
2401
|
emit DigestRevoked(digest, _custodyEpoch);
|
|
2298
2402
|
}
|
|
2299
2403
|
|
|
@@ -2304,8 +2408,12 @@ contract AgentAccount is
|
|
|
2304
2408
|
/// Recovery re-approves nothing: the person re-issues from a reviewed list (spec 410 §1.2).
|
|
2305
2409
|
function revokeAllApprovedDigests() external onlySelf {
|
|
2306
2410
|
_requireCustodyGoverned();
|
|
2307
|
-
|
|
2308
|
-
|
|
2411
|
+
_revokeAllApproved();
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
/// @dev No registry wired: nothing was ever approvable (the sentinel fails closed), so there is nothing to
|
|
2415
|
+
/// void — a no-op, never a revert, so a recovery or a move on such an account still completes.
|
|
2416
|
+
function _revokeAllApproved() internal {
|
|
2309
2417
|
if (_approvedHashRegistry != address(0)) IApprovedHashRegistryWrite(_approvedHashRegistry).revokeAll();
|
|
2310
2418
|
emit AllDigestsRevoked();
|
|
2311
2419
|
}
|
|
@@ -6,6 +6,9 @@ import "./AgentAccount.sol";
|
|
|
6
6
|
import {AgentAccountInitParams} from "./IAgentAccount.sol";
|
|
7
7
|
import {CustodyPolicy} from "./custody/CustodyPolicy.sol";
|
|
8
8
|
import "./governance/GovernanceManaged.sol";
|
|
9
|
+
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
10
|
+
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
11
|
+
import {AccountBootstrap} from "./AccountBootstrap.sol";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* @title AgentAccountFactory
|
|
@@ -45,7 +48,7 @@ import "./governance/GovernanceManaged.sol";
|
|
|
45
48
|
* proposal + 48h timelock and propagates automatically to every
|
|
46
49
|
* existing AgentAccount.
|
|
47
50
|
*/
|
|
48
|
-
contract AgentAccountFactory is GovernanceManaged {
|
|
51
|
+
contract AgentAccountFactory is GovernanceManaged, Initializable, UUPSUpgradeable {
|
|
49
52
|
AgentAccount public immutable accountImplementation;
|
|
50
53
|
address public immutable delegationManager;
|
|
51
54
|
address public immutable custodyPolicy;
|
|
@@ -84,7 +87,14 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
84
87
|
event BundlerSignerChanged(address indexed oldVal, address indexed newVal);
|
|
85
88
|
event SessionIssuerChanged(address indexed oldVal, address indexed newVal);
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
/// @notice Spec 447 §3.2 — the placeholder every new account proxy first points at. Created once, in the
|
|
91
|
+
/// initializer (so behind a proxy its `factory` is the PROXY), and kept in storage: a factory upgrade never
|
|
92
|
+
/// changes it, so a person's counterfactual address never changes with the code.
|
|
93
|
+
AccountBootstrap public accountBootstrap;
|
|
94
|
+
/// @dev Spec 447 — accounts this factory created (`isAccountFromFactory`).
|
|
95
|
+
mapping(address => bool) private _created;
|
|
96
|
+
|
|
97
|
+
uint256[48] private __gap;
|
|
88
98
|
|
|
89
99
|
// ─── Errors ─────────────────────────────────────────────────────────
|
|
90
100
|
|
|
@@ -155,7 +165,7 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
155
165
|
address approvedHashRegistry_,
|
|
156
166
|
bool relaxedT4Floor_,
|
|
157
167
|
address upgradeVoucher_
|
|
158
|
-
) GovernanceManaged(governance_) {
|
|
168
|
+
) GovernanceManaged(governance_) initializer {
|
|
159
169
|
if (custodyPolicy_ == address(0)) revert ZeroAddress();
|
|
160
170
|
accountImplementation = new AgentAccount(entryPoint_, approvedHashRegistry_, upgradeVoucher_);
|
|
161
171
|
approvedHashRegistry = approvedHashRegistry_;
|
|
@@ -163,12 +173,32 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
163
173
|
relaxedT4Floor = relaxedT4Floor_;
|
|
164
174
|
delegationManager = delegationManager_;
|
|
165
175
|
custodyPolicy = custodyPolicy_;
|
|
176
|
+
_initializeFactory(bundlerSigner_, sessionIssuer_);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// @notice Spec 447 — the proxy's initializer: the factory's STORAGE (roles, the bootstrap placeholder). Its
|
|
180
|
+
/// immutables (implementation, manager, policy, registry, voucher, governance) are the implementation's
|
|
181
|
+
/// and name stable proxies. Runs once per proxy; never on an implementation (its constructor ran it).
|
|
182
|
+
function initializeFactory(address bundlerSigner_, address sessionIssuer_) external initializer {
|
|
183
|
+
_initializeFactory(bundlerSigner_, sessionIssuer_);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function _initializeFactory(address bundlerSigner_, address sessionIssuer_) private {
|
|
166
187
|
bundlerSigner = bundlerSigner_;
|
|
167
188
|
sessionIssuer = sessionIssuer_;
|
|
189
|
+
accountBootstrap = new AccountBootstrap(address(this));
|
|
168
190
|
emit BundlerSignerChanged(address(0), bundlerSigner_);
|
|
169
191
|
emit SessionIssuerChanged(address(0), sessionIssuer_);
|
|
170
192
|
}
|
|
171
193
|
|
|
194
|
+
/// @dev Spec 447: only governance upgrades the factory (behind a proxy; a direct deployment never upgrades).
|
|
195
|
+
function _authorizeUpgrade(address) internal view override onlyGovernance {}
|
|
196
|
+
|
|
197
|
+
/// @notice Spec 447 §3.2 — on-chain provenance: whether `account` was created by this factory.
|
|
198
|
+
function isAccountFromFactory(address account) external view returns (bool) {
|
|
199
|
+
return _created[account];
|
|
200
|
+
}
|
|
201
|
+
|
|
172
202
|
// ─── Governance-only setters ─────────────────────────────────────────
|
|
173
203
|
|
|
174
204
|
function setBundlerSigner(address newBundler) external onlyGovernance {
|
|
@@ -217,11 +247,12 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
217
247
|
address addr = _getAddressFromSalt(params, deploySalt);
|
|
218
248
|
if (addr.code.length > 0) return AgentAccount(payable(addr));
|
|
219
249
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
);
|
|
250
|
+
// Spec 447 §3.2: deployed pointing at the placeholder (so the address never depends on the code), then
|
|
251
|
+
// upgraded to the account implementation and initialized, in this same transaction.
|
|
252
|
+
ERC1967Proxy proxy = new ERC1967Proxy{salt: deploySalt}(address(accountBootstrap), "");
|
|
253
|
+
AccountBootstrap(address(proxy)).bootstrap(address(accountImplementation), _initData(params));
|
|
224
254
|
account = AgentAccount(payable(address(proxy)));
|
|
255
|
+
_created[address(account)] = true;
|
|
225
256
|
|
|
226
257
|
if (params.mode > 0) {
|
|
227
258
|
bytes memory validatorInit = _buildValidatorInitData(params, timelockOverrides, address(account));
|
|
@@ -286,21 +317,29 @@ contract AgentAccountFactory is GovernanceManaged {
|
|
|
286
317
|
uint32[7] calldata timelockOverrides,
|
|
287
318
|
uint256 salt
|
|
288
319
|
) internal pure returns (bytes32) {
|
|
289
|
-
|
|
320
|
+
// Spec 447 §3.2: the custodians and initial passkey move into the salt — before, they were committed through
|
|
321
|
+
// the init data inside the proxy's creation code, which no longer carries it. The address still commits to
|
|
322
|
+
// the complete custody configuration (CA-F1), and to nothing about code.
|
|
323
|
+
return keccak256(abi.encode(
|
|
324
|
+
salt, params.mode, params.trustees, timelockOverrides,
|
|
325
|
+
params.custodians, params.initialPasskeyCredentialIdDigest, params.initialPasskeyX, params.initialPasskeyY,
|
|
326
|
+
params.initialPasskeyRpIdHash
|
|
327
|
+
));
|
|
290
328
|
}
|
|
291
329
|
|
|
292
330
|
function _getAddressFromSalt(
|
|
293
|
-
AgentAccountInitParams calldata
|
|
331
|
+
AgentAccountInitParams calldata,
|
|
294
332
|
bytes32 deploySalt
|
|
295
333
|
) internal view returns (address) {
|
|
296
|
-
|
|
297
|
-
return _create2Address(initData, deploySalt);
|
|
334
|
+
return _create2Address(deploySalt);
|
|
298
335
|
}
|
|
299
336
|
|
|
300
|
-
|
|
337
|
+
/// @dev Spec 447 §3.2: the proxy's creation code carries only the placeholder — no implementation, no manager,
|
|
338
|
+
/// no init data — so the address is a function of (this factory, the placeholder, the salt).
|
|
339
|
+
function _create2Address(bytes32 salt) internal view returns (address) {
|
|
301
340
|
bytes memory proxyBytecode = abi.encodePacked(
|
|
302
341
|
type(ERC1967Proxy).creationCode,
|
|
303
|
-
abi.encode(address(
|
|
342
|
+
abi.encode(address(accountBootstrap), bytes(""))
|
|
304
343
|
);
|
|
305
344
|
bytes32 bytecodeHash = keccak256(proxyBytecode);
|
|
306
345
|
return address(uint160(uint256(keccak256(
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.28;
|
|
3
3
|
|
|
4
|
+
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
5
|
+
import {Eip7702} from "./libraries/Eip7702.sol";
|
|
6
|
+
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
|
7
|
+
|
|
8
|
+
/// @dev The one read the registry makes of an account signer (audit 2026-12-02 H-2).
|
|
9
|
+
interface ICustodyEpochView {
|
|
10
|
+
function custodyEpoch() external view returns (uint64);
|
|
11
|
+
function approvalRefused() external view returns (bool);
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
/**
|
|
5
15
|
* @title ApprovedHashRegistry
|
|
6
16
|
* @notice On-chain pre-approved hashes — the `v == 1` path of Safe's
|
|
@@ -27,12 +37,27 @@ pragma solidity ^0.8.28;
|
|
|
27
37
|
* smart account can `approveHash` + perform the delegated action
|
|
28
38
|
* in one userOp.
|
|
29
39
|
*
|
|
30
|
-
* R917-C-2 (spec 408 §1.2): an `AgentAccount`'s `0x03` sentinel does NOT
|
|
31
|
-
* it
|
|
40
|
+
* R917-C-2 (spec 408 §1.2): an `AgentAccount`'s `0x03` sentinel does NOT consult the raw hash —
|
|
41
|
+
* it consults `AgentAccount.approvedHashKey(hash)` = `keccak256(abi.encode(hash, custodyEpoch))`,
|
|
32
42
|
* so an approval planted by a custodian who is later removed is void once the account's custody
|
|
33
|
-
* epoch moves.
|
|
43
|
+
* epoch moves.
|
|
44
|
+
*
|
|
45
|
+
* THE KEY IS DERIVED HERE, never taken from the caller (audit 2026-12-02 H-2, THESIS-1a). A signer
|
|
46
|
+
* with code is an account: `approveHash(h)` / `revokeHash(h)` act on
|
|
47
|
+
* `keccak256(abi.encode(h, msg.sender.custodyEpoch()))` — the epoch the account is in NOW, read from
|
|
48
|
+
* it. A caller cannot name a future epoch, whatever code it runs: generation-4 code (which may call
|
|
49
|
+
* this registry directly, before or in the same call frame as its move to generation 5) and the
|
|
50
|
+
* generation-5 `approveDigest` alike. A signer with no code (an EOA, the `QuorumEnforcer` `v == 1`
|
|
51
|
+
* slot's usual signer) approves the raw hash: its approval dies with its key. A contract that does not
|
|
52
|
+
* answer `custodyEpoch()` cannot approve or revoke a single hash here (fail closed, ADR-0013).
|
|
53
|
+
*
|
|
54
|
+
* Spec 447 (generation 5): deployed behind a UUPS proxy at an address that never changes. The registry is
|
|
55
|
+
* an IMMUTABLE of every `AgentAccount` implementation, so before this, fixing it meant a new instance, every
|
|
56
|
+
* account upgrading to reach it, and every approval made again (with a window in which a hash approved in the
|
|
57
|
+
* new registry ahead of time would count — GC's upgrade rehearsal, 2026-11-30). Behind a stable proxy a fix
|
|
58
|
+
* is a new implementation: the address the accounts hold, and every approval and epoch, stay.
|
|
34
59
|
*/
|
|
35
|
-
contract ApprovedHashRegistry {
|
|
60
|
+
contract ApprovedHashRegistry is Initializable, UUPSUpgradeable {
|
|
36
61
|
/// @dev R917-C-2 (spec 408 §1.2): an approval is recorded with the signer's epoch at the time
|
|
37
62
|
/// (`epoch + 1`, so a set slot is never zero); `revokeAll()` bumps the epoch and voids every
|
|
38
63
|
/// approval the signer ever made in one call. `isApproved` is the ONE read: the `0x03` sentinel
|
|
@@ -41,26 +66,90 @@ contract ApprovedHashRegistry {
|
|
|
41
66
|
mapping(address => mapping(bytes32 => uint64)) private _approvedAt;
|
|
42
67
|
/// signer => current epoch
|
|
43
68
|
mapping(address => uint64) private _epoch;
|
|
69
|
+
/// @dev Spec 447: the only upgrade authority (the `AgenticGovernance` contract, acting through its timelock).
|
|
70
|
+
/// Zero = never upgradeable.
|
|
71
|
+
address private _governance;
|
|
72
|
+
/// @dev Storage gap; this layout is gated by `check:storage-layouts`.
|
|
73
|
+
uint256[47] private __gap;
|
|
74
|
+
|
|
75
|
+
/// @dev Spec 447: an upgrade by anything but this registry's governance.
|
|
76
|
+
error NotGovernance();
|
|
77
|
+
/// @dev Spec 447: a registry with no governance cannot be upgraded.
|
|
78
|
+
error UpgradeWithoutGovernance();
|
|
79
|
+
/// @dev Spec 447: a non-zero governance with no code (an upgrade authority that can never act).
|
|
80
|
+
error GovernanceHasNoCode(address governance);
|
|
81
|
+
/// @dev The signing account answered `approvalRefused()` true: its custody changed, or it moved, earlier in this
|
|
82
|
+
/// transaction, so an approval now could outlive the custodian who sent it.
|
|
83
|
+
error ApprovalAfterCustodyChange();
|
|
44
84
|
|
|
45
85
|
event HashApproved(address indexed signer, bytes32 indexed hash);
|
|
46
86
|
event HashRevoked(address indexed signer, bytes32 indexed hash);
|
|
47
87
|
/// @dev R917-C-2 — every approval `signer` made before this event is void.
|
|
48
88
|
event AllHashesRevoked(address indexed signer, uint64 epoch);
|
|
49
89
|
|
|
90
|
+
/// @notice A DIRECT deployment (tests, a one-off instance): initialized here with no governance, so it works on
|
|
91
|
+
/// its own, can never be upgraded, and nobody can initialize it later.
|
|
92
|
+
constructor() initializer {}
|
|
93
|
+
|
|
94
|
+
/// @notice The proxy's initializer (spec 447). `governance_` is the upgrade authority; zero freezes the code.
|
|
95
|
+
function initialize(address governance_) external initializer {
|
|
96
|
+
if (governance_ != address(0) && governance_.code.length == 0) revert GovernanceHasNoCode(governance_);
|
|
97
|
+
Eip7702.refuseDelegatedEOA(governance_); // "has code" is not "is a contract" (spec 448 §0)
|
|
98
|
+
_governance = governance_;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// @notice The upgrade authority (zero = none).
|
|
102
|
+
function governance() external view returns (address) {
|
|
103
|
+
return _governance;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// @dev Spec 447: only governance upgrades; never a registry without one. UUPS's `onlyProxy` already refuses an
|
|
107
|
+
/// upgrade of a direct deployment.
|
|
108
|
+
function _authorizeUpgrade(address) internal view override {
|
|
109
|
+
address gov = _governance;
|
|
110
|
+
if (gov == address(0)) revert UpgradeWithoutGovernance();
|
|
111
|
+
Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
|
|
112
|
+
if (msg.sender != gov) revert NotGovernance();
|
|
113
|
+
}
|
|
114
|
+
|
|
50
115
|
/**
|
|
51
116
|
* @notice Pre-approve a hash. `msg.sender` is the signer; only
|
|
52
117
|
* this address can later be counted by `QuorumEnforcer`
|
|
53
118
|
* for this hash.
|
|
54
119
|
*/
|
|
55
120
|
function approveHash(bytes32 hash) external {
|
|
56
|
-
|
|
57
|
-
|
|
121
|
+
bytes32 key = _keyOf(msg.sender, hash);
|
|
122
|
+
// An account in the same transaction as its custody change or its move approves nothing (audit 2026-12-02
|
|
123
|
+
// H-2, the move-transaction route); one that cannot answer is refused.
|
|
124
|
+
Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
|
|
125
|
+
if (msg.sender.code.length != 0 && ICustodyEpochView(msg.sender).approvalRefused()) {
|
|
126
|
+
revert ApprovalAfterCustodyChange();
|
|
127
|
+
}
|
|
128
|
+
_approvedAt[msg.sender][key] = _epoch[msg.sender] + 1;
|
|
129
|
+
emit HashApproved(msg.sender, key);
|
|
58
130
|
}
|
|
59
131
|
|
|
60
|
-
/// @notice Revoke a previously-approved hash before redemption.
|
|
132
|
+
/// @notice Revoke a previously-approved hash before redemption (keyed as `approveHash` keys it).
|
|
61
133
|
function revokeHash(bytes32 hash) external {
|
|
62
|
-
|
|
63
|
-
|
|
134
|
+
bytes32 key = _keyOf(msg.sender, hash);
|
|
135
|
+
_approvedAt[msg.sender][key] = 0;
|
|
136
|
+
emit HashRevoked(msg.sender, key);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// @notice The key `approveHash(hash)` from `signer` records NOW: the raw hash for a signer with no code;
|
|
140
|
+
/// `keccak256(abi.encode(hash, signer.custodyEpoch()))` for an account. Reverts for a contract
|
|
141
|
+
/// that does not answer `custodyEpoch()`.
|
|
142
|
+
function keyOf(address signer, bytes32 hash) external view returns (bytes32) {
|
|
143
|
+
return _keyOf(signer, hash);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/// @dev Audit 2026-12-02 H-2 / THESIS-1a: the epoch is the caller's own current one, read here — never an
|
|
147
|
+
/// argument. One mechanism per kind of signer; an account that cannot say its epoch is refused.
|
|
148
|
+
function _keyOf(address signer, bytes32 hash) private view returns (bytes32) {
|
|
149
|
+
// A delegated EOA is keyed as the EOA it is (spec 448 §0): it approves nothing (refused above) but can
|
|
150
|
+
// still revoke the raw approvals its key made before it delegated.
|
|
151
|
+
if (signer.code.length == 0 || Eip7702.isDelegatedEOA(signer)) return hash;
|
|
152
|
+
return keccak256(abi.encode(hash, ICustodyEpochView(signer).custodyEpoch()));
|
|
64
153
|
}
|
|
65
154
|
|
|
66
155
|
/// @notice R917-C-2 — revoke EVERY hash `msg.sender` ever approved, in one call. The per-hash
|