@agenticprimitives/contracts 1.0.0-alpha.5 → 1.0.0-alpha.50
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 +119 -27
- package/README.md +47 -12
- package/deployments-base-sepolia.json +52 -1
- package/deployments-faithchain.json +103 -0
- package/deployments-hopechain.json +78 -0
- package/deployments-paymaster-anvil.json +1 -0
- package/deployments-registries-base-sepolia.json +1 -0
- package/deployments-registries-hopechain.json +1 -0
- package/dist/abi/AccountBootstrap.json +99 -0
- package/dist/abi/AgentAccount.json +461 -67
- package/dist/abi/AgentAccountFactory.json +309 -0
- package/dist/abi/AgentNameAttributeResolver.json +212 -0
- package/dist/abi/AgentNameRegistry.json +544 -0
- package/dist/abi/AgentNameUniversalResolver.json +222 -0
- package/dist/abi/AgentProfileResolver.json +236 -0
- package/dist/abi/AgentRegistryBase.json +1003 -0
- package/dist/abi/AgentRelationship.json +405 -0
- package/dist/abi/AgenticGovernance.json +155 -0
- package/dist/abi/AgreementRegistry.json +203 -5
- package/dist/abi/AllowedMethodsEnforcer.json +193 -0
- package/dist/abi/AllowedTargetsEnforcer.json +193 -0
- package/dist/abi/ApprovedHashRegistry.json +267 -2
- package/dist/abi/AttestationRegistry.json +242 -0
- package/dist/abi/AttributeStorage.json +24 -0
- package/dist/abi/CallDataHashEnforcer.json +193 -0
- package/dist/abi/CustodyPolicy.json +422 -55
- package/dist/abi/DelegationManager.json +292 -0
- package/dist/abi/DigestBindingEnforcer.json +541 -0
- package/dist/abi/Eip7702.json +13 -0
- package/dist/abi/EstateProjectionRegistry.json +599 -0
- package/dist/abi/Generation5Bridge.json +355 -0
- package/dist/abi/GeoFeatureRegistry.json +235 -0
- package/dist/abi/IAgentAccountFactoryView.json +26 -0
- package/dist/abi/IAgentAccountGovernanceTimelockView.json +15 -0
- package/dist/abi/IApprovedHashRegistryWrite.json +35 -0
- package/dist/abi/ICustodyEpochView.json +28 -0
- package/dist/abi/ICustodyPolicyAccountModuleView.json +31 -0
- package/dist/abi/ICustodyPolicyFactoryView.json +13 -0
- package/dist/abi/ICustodyPolicyPasskeyView.json +50 -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/IPaymentReceiptRegistry.json +50 -0
- package/dist/abi/IRedemptionContext.json +15 -0
- package/dist/abi/IRegistryMembershipPolicy.json +70 -0
- package/dist/abi/ITimelockVeto.json +93 -0
- package/dist/abi/ITreasurySpendPolicyAccountView.json +44 -0
- package/dist/abi/IUpgradeVoucherView.json +26 -0
- package/dist/abi/MockUSDC.json +621 -0
- package/dist/abi/OntologyTermRegistry.json +268 -0
- package/dist/abi/PayloadClassesEnforcer.json +310 -0
- package/dist/abi/PaymentEnforcer.json +639 -0
- package/dist/abi/PaymentEscrow.json +501 -0
- package/dist/abi/PaymentReceiptRegistry.json +388 -0
- package/dist/abi/PermissionlessSubregistry.json +353 -0
- package/dist/abi/PricedSubregistry.json +1141 -0
- package/dist/abi/QuorumEnforcer.json +209 -0
- package/dist/abi/ReceiptAnchorRegistry.json +346 -0
- package/dist/abi/RelationshipTypeRegistry.json +268 -0
- package/dist/abi/ShapeRegistry.json +268 -0
- package/dist/abi/SignatureVerifier.json +196 -0
- package/dist/abi/SkillDefinitionRegistry.json +235 -0
- package/dist/abi/SmartAgentPaymaster.json +445 -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 +667 -0
- package/dist/abi/UpgradeVoucher.json +328 -0
- package/dist/abi/ValueEnforcer.json +193 -0
- package/dist/abi/index.d.ts +35 -0
- package/dist/abi/index.js +35 -0
- package/dist/deployments/base-sepolia.d.ts +11 -0
- package/dist/deployments/base-sepolia.js +51 -28
- package/dist/deployments/faithchain.d.ts +77 -0
- package/dist/deployments/faithchain.js +107 -0
- package/dist/deployments/hopechain.d.ts +68 -0
- package/dist/deployments/hopechain.js +82 -0
- package/dist/deployments/index.d.ts +7 -2
- package/dist/deployments/index.js +15 -0
- package/dist/deployments/paymaster-anvil.d.ts +11 -0
- package/dist/deployments/paymaster-anvil.js +9 -0
- package/dist/deployments/registries-base-sepolia.d.ts +10 -0
- package/dist/deployments/registries-base-sepolia.js +8 -0
- package/dist/deployments/registries-hopechain.d.ts +10 -0
- package/dist/deployments/registries-hopechain.js +8 -0
- package/package.json +37 -7
- package/src/AccountBootstrap.sol +38 -0
- package/src/AgentAccount.sol +1091 -134
- package/src/AgentAccountFactory.sol +198 -21
- package/src/ApprovedHashRegistry.sol +134 -10
- package/src/IAgentAccount.sol +37 -0
- package/src/SmartAgentPaymaster.sol +275 -22
- package/src/UniversalSignatureValidator.sol +7 -0
- package/src/UpgradeVoucher.sol +87 -0
- package/src/agency/DelegationManager.sol +299 -76
- package/src/agency/ICaveatEnforcer.sol +10 -0
- package/src/agency/IDelegationManager.sol +37 -5
- package/src/agreement/AgreementRegistry.sol +105 -35
- package/src/attestation/AttestationRegistry.sol +220 -40
- package/src/custody/CustodyPolicy.sol +588 -70
- package/src/custody/TreasurySpendPolicy.sol +338 -0
- package/src/enforcers/AllowedMethodsEnforcer.sol +13 -2
- package/src/enforcers/AllowedTargetsEnforcer.sol +13 -2
- package/src/enforcers/CallDataHashEnforcer.sol +7 -1
- package/src/enforcers/DigestBindingEnforcer.sol +182 -0
- package/src/enforcers/PayloadClassesEnforcer.sol +36 -0
- package/src/enforcers/PaymentEnforcer.sol +291 -0
- package/src/enforcers/QuorumEnforcer.sol +24 -3
- package/src/enforcers/TimestampEnforcer.sol +7 -1
- package/src/enforcers/ValueEnforcer.sol +13 -2
- package/src/geo/GeoFeatureRegistry.sol +67 -22
- package/src/governance/AgenticGovernance.sol +187 -4
- package/src/governance/GovernanceManaged.sol +2 -0
- package/src/governance/StableProxyGoverned.sol +79 -0
- package/src/governance/StableProxyGovernedOneShot.sol +93 -0
- package/src/identity/AgentProfilePredicates.sol +23 -0
- package/src/identity/AgentProfileResolver.sol +22 -2
- package/src/libraries/Eip7702.sol +36 -0
- package/src/libraries/SignatureSlotRecovery.sol +28 -7
- package/src/libraries/SignatureVerifier.sol +52 -0
- package/src/libraries/WebAuthnLib.sol +16 -0
- package/src/migration/Generation5Bridge.sol +364 -0
- package/src/mocks/MockUSDC.sol +152 -0
- package/src/naming/AgentNameAttributeResolver.sol +29 -4
- package/src/naming/AgentNamePredicates.sol +89 -0
- package/src/naming/AgentNameRegistry.sol +324 -20
- package/src/naming/AgentNameUniversalResolver.sol +35 -2
- package/src/naming/PermissionlessSubregistry.sol +82 -25
- package/src/naming/PricedSubregistry.sol +293 -0
- package/src/ontology/AttributeStorage.sol +93 -80
- package/src/ontology/OntologyTermRegistry.sol +58 -2
- package/src/ontology/ShapeRegistry.sol +58 -2
- package/src/payments/PaymentEscrow.sol +187 -0
- package/src/payments/PaymentReceiptRegistry.sol +100 -0
- package/src/provenance/ReceiptAnchorRegistry.sol +67 -0
- package/src/registry/AgentRegistryBase.sol +372 -0
- package/src/registry/EstateProjectionRegistry.sol +177 -0
- package/src/registry/IRegistryMembershipPolicy.sol +30 -0
- package/src/relationships/AgentRelationship.sol +129 -8
- package/src/relationships/RelationshipTypeRegistry.sol +58 -2
- package/src/skills/SkillDefinitionRegistry.sol +61 -17
|
@@ -43,7 +43,8 @@ interface IDelegationManager {
|
|
|
43
43
|
event DelegationRevoked(bytes32 indexed delegationHash);
|
|
44
44
|
|
|
45
45
|
/// @notice Redeem a delegation chain to execute an action on behalf of the delegator.
|
|
46
|
-
/// The delegator's smart account executes the call via
|
|
46
|
+
/// The ROOT delegator's smart account executes the call via `execute`.
|
|
47
|
+
/// `target` may not be that account itself (spec 445 / audit DLG-2).
|
|
47
48
|
function redeemDelegation(
|
|
48
49
|
Delegation[] calldata delegations,
|
|
49
50
|
address target,
|
|
@@ -58,12 +59,37 @@ interface IDelegationManager {
|
|
|
58
59
|
/// works for Variant A delegations.
|
|
59
60
|
function revokeDelegation(bytes32 delegationHash) external;
|
|
60
61
|
|
|
61
|
-
/// @notice
|
|
62
|
-
///
|
|
63
|
-
///
|
|
64
|
-
///
|
|
62
|
+
/// @notice Authenticated revocation. Caller must be either `delegation.delegator` or
|
|
63
|
+
/// `delegation.delegate`. The DELEGATOR revokes its own struct with no signature check
|
|
64
|
+
/// (spec 445 / audit DLG-9: a dormant delegation must be revocable); the DELEGATE must
|
|
65
|
+
/// present a struct whose signature verifies, so it cannot revoke a forged hash.
|
|
65
66
|
function revokeDelegationByOwner(Delegation calldata delegation) external;
|
|
66
67
|
|
|
68
|
+
/// @notice The chain context of the caveat hook now running (spec 450 §6): `links` is the number of
|
|
69
|
+
/// delegations in the chain being redeemed, `position` the root-first index of the delegation whose
|
|
70
|
+
/// caveat is being checked (0 = the root grant, `links - 1` = the leaf the redeemer holds). With both,
|
|
71
|
+
/// an enforcer can bound a chain's length (`links`) or the re-delegations made below its own link
|
|
72
|
+
/// (`links - 1 - position`).
|
|
73
|
+
/// @dev An OBSERVATION for caveat enforcers, valid only while one of THIS manager's `beforeHook` /
|
|
74
|
+
/// `afterHook` calls is running inside {redeemDelegation}. It is not an authority and grants nothing,
|
|
75
|
+
/// and it is not a count of redemptions. Outside a hook — no redemption in flight, during chain
|
|
76
|
+
/// validation or the executed call — it REVERTS `NotInCaveatHook()`; there is no sentinel that could
|
|
77
|
+
/// be mistaken for "depth 0". The view verifiers hold no context of their own: called outside a hook,
|
|
78
|
+
/// a caveat that reads this reverts and {verifyAuthorizationForCall} returns `(false,
|
|
79
|
+
/// "caveat-failed")`; called while a hook is running, both verifiers return `(false,
|
|
80
|
+
/// "in-redemption")` without evaluating anything, so they never judge a chain by another chain's
|
|
81
|
+
/// numbers. An enforcer must let the revert propagate (fail closed) and read this only from
|
|
82
|
+
/// `msg.sender`, the manager that called its hook; a manager without this function reverts too.
|
|
83
|
+
///
|
|
84
|
+
/// The rule for a depth enforcer (`links` alone is NOT it — it counts ancestors the link does not
|
|
85
|
+
/// control): in `beforeHook`, take `maxBelow` from the signed `terms`, never from the
|
|
86
|
+
/// redeemer-supplied `args`; read `(links, position)` from `msg.sender` and let a revert propagate;
|
|
87
|
+
/// revert unless `links - 1 - position <= maxBelow` (the re-delegations made below this link — the
|
|
88
|
+
/// chain is hash-linked, so an intermediary can neither change that count nor drop the caveat). Every
|
|
89
|
+
/// link carrying the caveat is checked, so the strictest ancestor wins; `maxBelow = 0` forbids any
|
|
90
|
+
/// re-delegation.
|
|
91
|
+
function redemptionDepth() external view returns (uint256 links, uint256 position);
|
|
92
|
+
|
|
67
93
|
/// @notice Check if a delegation has been revoked.
|
|
68
94
|
function isRevoked(bytes32 delegationHash) external view returns (bool);
|
|
69
95
|
|
|
@@ -72,6 +98,10 @@ interface IDelegationManager {
|
|
|
72
98
|
/// Used by trust-substrate contracts (e.g. AttestationRegistry's
|
|
73
99
|
/// bilateral-consent path per spec 242 PD-9) to validate a packed
|
|
74
100
|
/// delegation as a signed authorization predicate.
|
|
101
|
+
/// @dev ⚠️ DANGER — chain-only; does NOT evaluate caveats. `true` is NOT permission for any
|
|
102
|
+
/// specific call. Use {verifyAuthorizationForCall} (fail-closed, evaluates caveats) or live
|
|
103
|
+
/// redemption to authorize a concrete (target, value, calldata).
|
|
104
|
+
/// Returns `(false, "in-redemption")` while a caveat hook of a redemption on this manager is running.
|
|
75
105
|
/// @param delegations Delegation chain, leaf first
|
|
76
106
|
/// @param sender The address that would be the redeemer
|
|
77
107
|
/// @return ok True if the chain verifies
|
|
@@ -87,6 +117,8 @@ interface IDelegationManager {
|
|
|
87
117
|
/// and every caveat passes under `staticcall`; a denied OR non-view-evaluable caveat
|
|
88
118
|
/// yields `false` ("use live redemption"). Lets a registry bind consent to the exact
|
|
89
119
|
/// call inside its own transaction. Caveat evaluation mirrors `redeemDelegation`.
|
|
120
|
+
/// Returns `(false, "in-redemption")` while a caveat hook of a redemption on this manager is
|
|
121
|
+
/// running (spec 450 §6, see {redemptionDepth}); callable from the executed call.
|
|
90
122
|
/// @param delegations Delegation chain, leaf first
|
|
91
123
|
/// @param sender The address that would be the redeemer
|
|
92
124
|
/// @param target The exact target of the delegated call
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.28;
|
|
3
3
|
|
|
4
4
|
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
5
|
+
import {Eip7702} from "../libraries/Eip7702.sol";
|
|
6
|
+
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
7
|
+
import "../governance/StableProxyGoverned.sol";
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* @title AgreementRegistry
|
|
@@ -28,8 +31,19 @@ import "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
|
28
31
|
* AR-10 isAssertableCommitment view gateway for AttestationRegistry
|
|
29
32
|
* AR-11 party SA addresses NEVER appear in register() calldata
|
|
30
33
|
* AR-12 single on-chain row per agreement (D-37)
|
|
34
|
+
* AR-13 (spec 445 / REG-1) the commitment COMMITS TO ITS ISSUER: `issuerCommitment` must equal
|
|
35
|
+
* keccak256(abi.encodePacked(issuer)), so nobody can register a commitment they merely saw under
|
|
36
|
+
* an issuer (or, through the issuer signature, a schema) of their own. The row key stays the
|
|
37
|
+
* commitment — one row per agreement, read API unchanged.
|
|
38
|
+
* AR-14 (REG-7) nullifiers are scoped to the agreement: an unrelated agreement cannot burn one.
|
|
31
39
|
*/
|
|
32
|
-
contract AgreementRegistry {
|
|
40
|
+
contract AgreementRegistry is StableProxyGoverned {
|
|
41
|
+
/// @notice Spec 447 — a DIRECT deployment, initialized here with no governance (its code is frozen, as
|
|
42
|
+
/// before). Behind a stable proxy, `initialize(governance_)` instead; the governance is then the only
|
|
43
|
+
/// upgrade authority. This contract has no admin of its own: governance can replace the code behind
|
|
44
|
+
/// the proxy and nothing else.
|
|
45
|
+
constructor() initializer {}
|
|
46
|
+
|
|
33
47
|
// ─── Constants ──────────────────────────────────────────────────────
|
|
34
48
|
|
|
35
49
|
uint64 public constant EPOCH_SECONDS = 3600;
|
|
@@ -46,8 +60,20 @@ contract AgreementRegistry {
|
|
|
46
60
|
/// digest model; the TS side derives the same constant (cross-stack
|
|
47
61
|
/// typehash-equality gate). Plain struct hash (no domain separator),
|
|
48
62
|
/// matching the attestation registry's JOINT_CONSENT_TYPEHASH.
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
/// AGR-1 (audit 2026-06-10): also bind chainId + this contract so a transition signature
|
|
64
|
+
/// cannot be replayed on another chain or a redeployed registry.
|
|
65
|
+
bytes32 internal constant TRANSITION_TYPEHASH = keccak256(
|
|
66
|
+
"AgreementTransition(bytes32 agreementCommitment,uint8 toStatus,bytes32 nullifier,uint256 chainId,address verifyingContract)"
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/// @dev SC-1 (audit 2026-06-09): the issuer attestation digest is RECOMPUTED on-chain from the
|
|
70
|
+
/// agreement's contents + chain + this contract — it is NOT a caller-supplied free-form hash.
|
|
71
|
+
/// Binds (agreementCommitment, schemaHash, issuer, chainId, verifyingContract) so a signature
|
|
72
|
+
/// lifted from any other context cannot back an attacker-chosen commitment. The TS side derives
|
|
73
|
+
/// the same constant (cross-stack typehash-equality gate).
|
|
74
|
+
bytes32 internal constant AGREEMENT_ISSUER_TYPEHASH = keccak256(
|
|
75
|
+
"AgreementIssuerAttestation(bytes32 agreementCommitment,bytes32 schemaHash,address issuer,uint256 chainId,address verifyingContract)"
|
|
76
|
+
);
|
|
51
77
|
|
|
52
78
|
// ─── Errors ─────────────────────────────────────────────────────────
|
|
53
79
|
|
|
@@ -59,6 +85,9 @@ contract AgreementRegistry {
|
|
|
59
85
|
error NullifierUsed();
|
|
60
86
|
error CommitmentMismatch();
|
|
61
87
|
error SignerNotParty();
|
|
88
|
+
/// @notice REG-1 — `issuerCommitment` is not the commitment of `issuer`: the caller is trying to
|
|
89
|
+
/// register an agreement under an issuer the agreement does not name.
|
|
90
|
+
error IssuerNotBound();
|
|
62
91
|
|
|
63
92
|
// ─── Storage ────────────────────────────────────────────────────────
|
|
64
93
|
|
|
@@ -74,8 +103,10 @@ contract AgreementRegistry {
|
|
|
74
103
|
/// @dev key = agreementCommitment hash
|
|
75
104
|
mapping(bytes32 => AgreementRow) private _rows;
|
|
76
105
|
|
|
77
|
-
/// @dev AR-08: nullifier set for replay protection on status transitions
|
|
78
|
-
|
|
106
|
+
/// @dev AR-08 / AR-14 (REG-7): nullifier set for replay protection on status transitions, PER
|
|
107
|
+
/// AGREEMENT — agreementCommitment => nullifier => used. A global set let anyone with an
|
|
108
|
+
/// agreement of their own burn the nullifier of a pending transition they saw.
|
|
109
|
+
mapping(bytes32 => mapping(bytes32 => bool)) private _nullifiers;
|
|
79
110
|
|
|
80
111
|
// ─── Requests ───────────────────────────────────────────────────────
|
|
81
112
|
|
|
@@ -85,9 +116,8 @@ contract AgreementRegistry {
|
|
|
85
116
|
struct AgreementIssuancePayload {
|
|
86
117
|
bytes32 schemaHash;
|
|
87
118
|
address issuer;
|
|
88
|
-
/// @dev
|
|
89
|
-
|
|
90
|
-
/// @dev issuer's signature over `attestationStructHash`.
|
|
119
|
+
/// @dev issuer's signature over the RECOMPUTED issuer-attestation digest (SC-1). The contract
|
|
120
|
+
/// derives the digest from the payload contents — no caller-supplied attestation hash.
|
|
91
121
|
bytes issuerSignature;
|
|
92
122
|
/// @dev The asserted canonical commitment hash; we verify recomputation.
|
|
93
123
|
bytes32 agreementCommitment;
|
|
@@ -149,12 +179,32 @@ contract AgreementRegistry {
|
|
|
149
179
|
);
|
|
150
180
|
if (recomputed != p.agreementCommitment) revert CommitmentMismatch();
|
|
151
181
|
|
|
182
|
+
// AR-13 / REG-1 — the commitment names its issuer. `issuerCommitment` is one of the hashed
|
|
183
|
+
// components above, so requiring it to be the commitment of `p.issuer` makes the row's issuer a
|
|
184
|
+
// function of the commitment itself: a party who only SAW the commitment (mempool, an insider)
|
|
185
|
+
// cannot register it under its own issuer — and the issuer signature below binds the schema, so
|
|
186
|
+
// not under its own schema either. `issuer` is already public in this calldata, so nothing new
|
|
187
|
+
// is revealed (the SDK has always derived issuerCommitment this way).
|
|
188
|
+
if (p.issuerCommitment != keccak256(abi.encodePacked(p.issuer))) revert IssuerNotBound();
|
|
189
|
+
|
|
152
190
|
if (_rows[p.agreementCommitment].agreementCommitment != bytes32(0)) {
|
|
153
191
|
revert AlreadyRegistered();
|
|
154
192
|
}
|
|
155
193
|
|
|
156
|
-
// AR-02 —
|
|
157
|
-
|
|
194
|
+
// AR-02 / SC-1 — RECOMPUTE the issuer-attestation digest from the agreement contents (+ chain +
|
|
195
|
+
// this contract) and verify the issuer signed THAT. A signature over an arbitrary digest from
|
|
196
|
+
// any other context can no longer back an attacker-chosen commitment.
|
|
197
|
+
bytes32 issuerDigest = keccak256(
|
|
198
|
+
abi.encode(
|
|
199
|
+
AGREEMENT_ISSUER_TYPEHASH,
|
|
200
|
+
p.agreementCommitment,
|
|
201
|
+
p.schemaHash,
|
|
202
|
+
p.issuer,
|
|
203
|
+
block.chainid,
|
|
204
|
+
address(this)
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
if (!_isValidSignatureBool(p.issuer, issuerDigest, p.issuerSignature)) {
|
|
158
208
|
revert InvalidIssuerSignature();
|
|
159
209
|
}
|
|
160
210
|
|
|
@@ -198,13 +248,15 @@ contract AgreementRegistry {
|
|
|
198
248
|
) {
|
|
199
249
|
revert InvalidStatus();
|
|
200
250
|
}
|
|
251
|
+
// REG-7: DISPUTED → DISPUTED is not a transition (it only emitted an event and spent a nullifier).
|
|
252
|
+
if (p.toStatus == row.status) revert InvalidStatus();
|
|
201
253
|
// DISPUTED → COMPLETED / REVOKED needs bilateral.
|
|
202
254
|
// ACTIVE → DISPUTED: either-party allowed.
|
|
203
255
|
// ACTIVE → COMPLETED / REVOKED: bilateral.
|
|
204
256
|
|
|
205
257
|
// AR-08 — replay protection
|
|
206
|
-
if (_nullifiers[p.nullifier]) revert NullifierUsed();
|
|
207
|
-
_nullifiers[p.nullifier] = true;
|
|
258
|
+
if (_nullifiers[p.agreementCommitment][p.nullifier]) revert NullifierUsed();
|
|
259
|
+
_nullifiers[p.agreementCommitment][p.nullifier] = true;
|
|
208
260
|
|
|
209
261
|
// RW1-2 (ADR-0027): PROVE the signers are the agreement's parties. Recompute the agreement
|
|
210
262
|
// commitment from the REVEALED parties + components (register's exact formula) and require it
|
|
@@ -222,7 +274,7 @@ contract AgreementRegistry {
|
|
|
222
274
|
// caller-supplied hash. The signed payload is canonically bound to (commitment, toStatus,
|
|
223
275
|
// nullifier) here, on chain.
|
|
224
276
|
bytes32 transitionDigest = keccak256(
|
|
225
|
-
abi.encode(TRANSITION_TYPEHASH, p.agreementCommitment, p.toStatus, p.nullifier)
|
|
277
|
+
abi.encode(TRANSITION_TYPEHASH, p.agreementCommitment, p.toStatus, p.nullifier, block.chainid, address(this))
|
|
226
278
|
);
|
|
227
279
|
|
|
228
280
|
bool bilateralRequired = (p.toStatus != STATUS_DISPUTED);
|
|
@@ -253,11 +305,22 @@ contract AgreementRegistry {
|
|
|
253
305
|
/// that permits public joint assertion (currently any non-NONE
|
|
254
306
|
/// status; revoked agreements can still be jointly disclosed as
|
|
255
307
|
/// historical record).
|
|
308
|
+
///
|
|
309
|
+
/// @dev NOT a consent or validity oracle (audit 2026-06-10). A `true`
|
|
310
|
+
/// result means only that `agreementCommitment` is REGISTERED — it is
|
|
311
|
+
/// an opaque back-reference, NOT proof that any particular party
|
|
312
|
+
/// consented, that the agreement is currently valid, or that a given
|
|
313
|
+
/// credential is bound to it. Bilateral consent for a joint assertion
|
|
314
|
+
/// is established separately by `AttestationRegistry.assertJointAgreement`,
|
|
315
|
+
/// which recomputes both parties' consent signatures. Consumers MUST
|
|
316
|
+
/// NOT treat the boolean here as authorization.
|
|
256
317
|
function isAssertableCommitment(
|
|
257
318
|
bytes32 agreementCommitment,
|
|
258
319
|
address /* actor */
|
|
259
320
|
) external view returns (bool ok, string memory reason) {
|
|
260
321
|
AgreementRow memory row = _rows[agreementCommitment];
|
|
322
|
+
// Zero-default existence check (a registered row always stores its non-zero commitment) — benign.
|
|
323
|
+
// slither-disable-next-line incorrect-equality
|
|
261
324
|
if (row.agreementCommitment == bytes32(0)) return (false, "not-registered");
|
|
262
325
|
return (true, "");
|
|
263
326
|
}
|
|
@@ -265,42 +328,49 @@ contract AgreementRegistry {
|
|
|
265
328
|
/// @notice Get the on-chain row.
|
|
266
329
|
function getRecord(bytes32 agreementCommitment) external view returns (AgreementRow memory) {
|
|
267
330
|
AgreementRow memory row = _rows[agreementCommitment];
|
|
331
|
+
// Zero-default existence check — benign.
|
|
332
|
+
// slither-disable-next-line incorrect-equality
|
|
268
333
|
if (row.agreementCommitment == bytes32(0)) revert NotRegistered();
|
|
269
334
|
return row;
|
|
270
335
|
}
|
|
271
336
|
|
|
272
|
-
/// @notice Has a nullifier been consumed?
|
|
273
|
-
function isNullifierUsed(bytes32 n) external view returns (bool) {
|
|
274
|
-
return _nullifiers[n];
|
|
337
|
+
/// @notice Has a nullifier been consumed for this agreement? (REG-7: nullifiers are per agreement.)
|
|
338
|
+
function isNullifierUsed(bytes32 agreementCommitment, bytes32 n) external view returns (bool) {
|
|
339
|
+
return _nullifiers[agreementCommitment][n];
|
|
275
340
|
}
|
|
276
341
|
|
|
277
342
|
// ─── Internal ───────────────────────────────────────────────────────
|
|
278
343
|
|
|
344
|
+
/// @dev ERC-1271 for contract signers, low-s ECDSA for EOAs. REG-16 / spec 448 §0 (EIP-7702): a delegated
|
|
345
|
+
/// EOA (`0xef0100 ‖ delegate`) is an EOA here — ECDSA only. Its attached code is never asked, because
|
|
346
|
+
/// whoever obtained one authorization signature from the key chose that code. One mechanism per kind
|
|
347
|
+
/// of signer (ADR-0013).
|
|
279
348
|
function _isValidSignatureBool(
|
|
280
349
|
address signer,
|
|
281
350
|
bytes32 digest,
|
|
282
351
|
bytes memory signature
|
|
283
352
|
) internal view returns (bool) {
|
|
284
|
-
if (signer.code.length > 0)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
353
|
+
if (signer.code.length > 0 && !Eip7702.isDelegatedEOA(signer)) return _erc1271Ok(signer, digest, signature);
|
|
354
|
+
// P2-2 (audit 2026-06-10): OpenZeppelin ECDSA.tryRecover rejects high-s (malleable) signatures and
|
|
355
|
+
// malformed lengths. The error value is checked explicitly: on any error `recovered` is zero and
|
|
356
|
+
// is NOT compared (a zero `signer` can therefore never match).
|
|
291
357
|
bytes32 ethHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", digest));
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
// solhint-disable-next-line no-inline-assembly
|
|
297
|
-
assembly {
|
|
298
|
-
r := mload(add(signature, 0x20))
|
|
299
|
-
s := mload(add(signature, 0x40))
|
|
300
|
-
v := byte(0, mload(add(signature, 0x60)))
|
|
301
|
-
}
|
|
302
|
-
if (v < 27) v += 27;
|
|
303
|
-
address recovered = ecrecover(ethHash, v, r, s);
|
|
358
|
+
// The third return value is the error ARGUMENT (the offending length / s); the error KIND is checked.
|
|
359
|
+
// slither-disable-next-line unused-return
|
|
360
|
+
(address recovered, ECDSA.RecoverError err, ) = ECDSA.tryRecover(ethHash, signature);
|
|
361
|
+
if (err != ECDSA.RecoverError.NoError) return false;
|
|
304
362
|
return recovered != address(0) && recovered == signer;
|
|
305
363
|
}
|
|
364
|
+
|
|
365
|
+
/// @dev ERC-1271 by raw staticcall: a signer that reverts, returns nothing, or returns fewer than 32
|
|
366
|
+
/// bytes is "not valid" — it cannot make this registry's call revert while decoding its answer.
|
|
367
|
+
function _erc1271Ok(address signer, bytes32 digest, bytes memory signature) private view returns (bool) {
|
|
368
|
+
(bool ok, bytes memory ret) =
|
|
369
|
+
signer.staticcall(abi.encodeWithSelector(IERC1271.isValidSignature.selector, digest, signature));
|
|
370
|
+
if (!ok || ret.length < 32) return false;
|
|
371
|
+
return bytes32(ret) == bytes32(IERC1271.isValidSignature.selector);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
|
|
375
|
+
uint256[48] private __gap;
|
|
306
376
|
}
|