FIP: Application Identifiers #107
Replies: 5 comments 7 replies
-
One concern I have of this FIP is how it might impact anonymity when using apps for direct casts. (e2ee private messaging) If direct casts could be tracked to the the app, there would be hesitancy for users to try it because the anonymity would set would shrink to that app's users. |
Beta Was this translation helpful? Give feedback.
-
Given we are going to migrate to L2 soon, perhaps we should make the metadata field required and define its own protobuf to store this information? This way we can more gracefully evolve its use over time, and encourage its use. Can always have the default create a "plaintext" metadata field which is just raw text, defaulting to empty. This way apps can still "opt-in" to the stronger verification. Do we currently have a limit on how long the metadata can be for an on-chain signer? |
Beta Was this translation helpful? Give feedback.
-
After discussion with @varunsrin, @sds, @sanjayprabhu, and @deodad, I think validating metadata signatures onchain in
We can preserve flexibility to introduce future metadata types with different fields or validation schemes by delegating validation to a contract with a defined interface. Here's a draft Solidity spec for onchain metadata validation: // Interface for all metadata validators
interface IMetadataValidator {
function validate(
uint256 userFid,
bytes memory signerKey,
bytes memory metadata
) external returns (bool);
}
// Concrete contract for Type 1, App ID specific metadata
contract AppIdMetadataValidator is Signatures, EIP712 {
// Custom struct for this metadata type.
struct AppId {
uint256 appFid;
address appSigner;
bytes signature;
}
constructor() EIP712("Farcaster MetadataValidator", "1") {}
// EIP-712 typehash for this metadata type
bytes32 constant _SIGNER_METADATA_TYPEHASH =
keccak256("AppId(uint256 userFid,uint256 appFid,bytes signerPubKey)");
function validate(
uint256 userFid,
bytes memory signerKey,
bytes memory metadataBytes
) external returns (bool) {
// Decode context specific metadata for this metadata type
AppId memory appId = abi.decode(metadataBytes, (AppId));
// Verify that the signer owns the appFid
if (IdRegistry.idOf(appId.appSigner) != appId.appFid)
revert("Signer must own app FID");
// Verify signature over userFid, appFid, signerKey
return
IdRegistry.verifyFidSignature(
appId.appSigner,
appId.appFid,
_hashTypedDataV4(
keccak256(
abi.encode(
_SIGNER_METADATA_TYPEHASH,
userFid,
metadata.appFid,
signerKey
)
)
),
sig
);
}
}
// Update KeyRegistry to 1) register validators and 2) call the registered
// validator when metadata is present.
contract KeyRegistry {
struct Metadata {
uint8 typeId;
bytes metadata;
}
mapping(uint8 typeId => IMetadataValidator) public validators;
function _add(
uint256 fid,
uint32 scheme,
bytes calldata key,
Metadata calldata metadata
) internal {
KeyData storage keyData = keys[fid][key];
if (keyData.state != KeyState.NULL) revert InvalidState();
IMetadataValidator validator = validators[metadata.typeId];
if (validator == IMetadataValidator(0)) revert("Invalid typeId");
bool isValid = validator.validate(fid, key, metadata.metadata);
if (!isValid) revert("Invalid metadata");
keyData.state = KeyState.ADDED;
keyData.scheme = scheme;
emit Add(fid, scheme, key, key, metadata);
}
function setValidator(
uint8 _type,
IMetadataValidator _validator
) external onlyOwner {
type[type] = _validator;
}
} |
Beta Was this translation helpful? Give feedback.
-
I've identified a few key considerations: Lack of Differentiation in Association TypesThere exists a challenge in distinguishing between these two distinct scenarios:
The importance of scenario 2 becomes evident in building confidence for an app that provides a non-custodial client. To illustrate, if a vulnerability arises in the direct cast mechanism of a specific client, it remains valuable to associate the app's reputation with its non-custodial mode. This way, other casters can readily identify and avoid signers connected to the client. Irrevocability of Associations for AppsA significant constraint emerges regarding an app's ability to retract such associations autonomously. Specifically, an app lacks the means to dissolve this association without obtaining userFid's consent. Consequently, the app is unable to rotate the signers employed for its users' FIDs. Consider a scenario analogous to popular communication platforms like Telegram or Discord. Imagine a userFid reported by moderators for engaging in spam or scams. While the app may desire to ban that userFid, this objective becomes unattainable if the userFid's participation is necessary to disband the association. App shared storageOne potentially intriguing application for this app-associated signer is found within the concept of a shared storage umbrella. Under this model, the app procures a substantial amount of storage, which is then shared among its users as a communal resource. However, this setup introduces a dimension to the app's authority in relation to association revocation, particularly if this feature carries significance. A practical instance could be if a userFid decides to terminate their subscription. These considerations underscore the intricate nature of association dynamics within the described framework. Potential Implementation through ERC1155:Just throwing it out there A plausible approach for implementing the delegated signer functionality, assuming the FID is treated as an NFT, is to consider the use of ERC1155. In essence, ERC1155 builds upon ERC721 but introduces the concept of sub-NFTs under each NFT (an item owned by a character in a game). These sub-NFTs could effectively symbolize the KeyRegistry entities. Ownership of a sub-NFT would translate to control over a corresponding signer. Such an arrangement would facilitate a clear distinction between the various forms of delegate signer associations mentioned earlier. To establish a sub-NFT's ID, the formula keccak256("appFid.userFid") could be employed. This method would offer a straightforward means of authorizing the opposite party to undertake association revocation. By incorporating their FID in the ID construction, they would be granted specific rights to execute designated actions. |
Beta Was this translation helpful? Give feedback.
-
Closing this discussion. App identifiers were added to FIP-7 and finalized. |
Beta Was this translation helpful? Give feedback.
-
Problem
Apps can publish messages on behalf of users by asking them to approve a Signer, which is a public key that they control. The current process has a few limitations:
If it were possible to know the identify of the application that a signer was assigned to, we can now create reputation systems for applications. This helps users and other apps on the network easily identify and avoid malicious applications.
Proposal
userFid
,appFid
andsignerPubKey
and sends it to the user's wallet applicationMetadata
The metadata field must have the following information:
Additional Notes
Beta Was this translation helpful? Give feedback.
All reactions