FIP-7: Onchain Signers #103
Replies: 6 comments 14 replies
-
Still processing this. Anyways, I had independently worked on something like this which is probably more gas efficient considering storage writes. But dunno what constraints you‘re optimizing for so your‘s probably fits FC architecture a bit better. Anyways, here‘s what I‘m looking to implement with Kiwi https://github.com/attestate/delegator2#readme Biggest drawback I see with mine: A relayer cannot easily send the TX for a user |
Beta Was this translation helpful? Give feedback.
-
Are you preventing bots from front running and hence DoS‘ing or stealing signers? |
Beta Was this translation helpful? Give feedback.
-
Can you elaborate what you mean by a compaction strategy and cost/complexity? Is the complexity that bad? A LIFO-like rule and reliable ordering could possibly be created as follows, similar to how it's done in Secure Scuttlebutt:
With regards to UX, I think it comes down to building for what is likely to happen most often, ie, will new signers need to be created more often, or will forks and errors occur more often? Especially if this is all happening just from a Custody Wallet app, most likely for 95% of users a high quality, trusted wallet app, imo it's the former. Use the blockchain to protect in times of chaos & war without it constraining in times of co-ordination & peace 😝? |
Beta Was this translation helpful? Give feedback.
-
They’re both valid , but only one of them has the private key and can
produce signed messages with it
…On Sun, Jul 9, 2023 at 11:59 AM Tim Daubenschütz ***@***.***> wrote:
that‘s fine if the tx goes through (same as in the attestate/delegator v1
design), but as FC hubble node, which transaction sender do you now
consider the real originator of the signer add request? Hence in delegator2
we generate the signer add key through ecrecover
—
Reply to this email directly, view it on GitHub
<#103 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEBD4XGSOAG3XQ4XQFBNGDXPL5Q5ANCNFSM6AAAAAA2DIU4SQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
This is a great example of where BLS keys/signatures can be useful. With pairing based curves, you can do delegated/signatures. So one BLS keys authorizes another BLS key to sign messages on it's behalf. Using proxy signatures, you don't have to add a signer if a fid wants to let an application sign on it's behalf. An article that mentions proxy signatures: https://medium.com/harmony-one/exploring-bls-keys-on-the-harmony-protocol-understanding-generation-management-and-use-cases-b8722f7219fc Here is an interesting article on Forward secure signatures using pairing based crypto: https://www.sciencedirect.com/science/article/abs/pii/S0020025517300403 Forward secure signatures address the issue of backdating a signature before a key was revoked. https://medium.com/cryptoadvance/bls-signatures-better-than-schnorr-5a7fe30ea716 Adding/Revoking a key through a smart contract call that costs a fee will pose problems in gaining adoption. A cryptographic accumulator can be used to reduce the amount of on-chain calls: https://github.com/Hmac512/accumulator/blob/main/test/accumulator/ecc/main.go It will require some system design changes to support. Cryptographic accumulators are the basis of Verkle trees. |
Beta Was this translation helpful? Give feedback.
-
Given the spec handles different key types, it is quite extensible. I am curious how you expect the standardization process for adding new key will work, because:
A new key type can't be added unless the hubs agree to support verifying the sigs. What if a separate So the hub-monorepo would just have to regularly update that dependency. For each key type a |
Beta Was this translation helpful? Give feedback.
-
Onchain Signers
Title: Onchain Signers
Type: Implementation FIP
Authors: horsefacts, sanjay, v
Abstract
Signers should be set onchain on an L2 contract to avoid usability problems with CRDT consensus.
Problem
Signers are used to delegate permissions to post on a user's behalf without giving up control over the Farcaster identity. The Signer is a key pair whose public key is signed by the fid's custody address and stored on a hub. Signers are tracked using a CRDT which allows keys to be added and removed. There are a few usability problems in the current implementation:
The CRDT must have a limit on how many signers can be added. Crossing the limit causes the earliest signer to be removed (FIFO). A user adding a signer may accidentally erase data created by their first signer. LIFO rules would be ideal, but this isn't possible without reliable timestamps.
When an fid transfers custody addresses, the signature chain from address to fid to signer is broken. Hubs will discard unsigned messages after a short delay, unless the new address submits a signature, which could cause unintentional data loss.
There are mitigations to these problems — a compaction can solve (1) and an approach like multi-signatures can make (2) bearable. But these solutions come at the cost of storage and additional complexity, and do not solve the problem entirely.
Specification
We propose tracking signers onchain with a Key Registry which maps fids to signers. The registry is extensible so that we can change the kinds of keys we use for signers or add keys for other purposes like encryption.
When a key is added, the KeyRegistry checks the IdRegistry and assigns the keys to the caller's fid. Mapping keys to the fid instead of the custody address solves (2) by maintaining the relationship when the fid is transferred. Storing keys onchain lets hubs avoid limits since the blockchain implements its own fee system, avoiding (1).
Four inputs are needed to register a new key pair to a caller:
key
- the public key materialkeyType
- the type of key material providedmetadata
- additional information about the key requestmetadataType
- the type of metadata being providedKeys are stateful and exist in the states
null
,added
orremoved
. The owner may add and remove keys at any time, but removed keys can never be re-added. The same key can be added by other fids and may exist in different states across fids. A sample implementation of the Key Registry can be seen in Appendix A.Validation
The Key Registry must validate the key and metadata by calling a validation contract which returns a boolean. Each tuple of (keyType, metadataType) encodes validation rules in a contract registered with the Key Registry. Each validation contract must have a
validate
method that requires:fid
- the fid of the user registering the keykey
- the public key materialmetadata
- information about the requestThe owner can add and update the validation contracts at any time. A sample interface for the validator can be seen in Appendix B.
Key Types
1. Ed25519
A valid public key on Curve25519 used to sign Farcaster messages on behalf of an fid. The key is not validated onchain but is validated by Farcaster Hubs.
Metadata Types
1. Signed Key Request
A signature that proves that an fid (requesting fid) asked another fid (primary fid) to authorize a key pair. For example, if an app asks a user for a key it would sign a message proving that it made the ask. This lets us attribute signers to specific entities which is useful for a wide range of things from knowing which apps are being used to filtering content based on the applications that generated them. This type-specific metadata must be an ABI-encoded struct with the following format:
Where
requestingFid
is the fid requesting the key,requestSigner
is the owner ofrequestingFid
, andsignature
is an EIP-712 signature with the following format:Hub Changes
Hubs must implement KeyRegistrySignerStore which tracks currently active keys for each fid. When the KeyRegistry emits an event for a key where
keyType ==1
andmetadataType == 1
, it is added or removed from the store. The existing SignerStore CRDT to track SignerAdd/SignerRemove messages is deprecated. The Hubs also expose APIs for this new functionality and deprecate unused APIs which are described in Appendix C. The exact process for transitioning from SignerStore to KeyRegistrySignerStore is described in Release.The General Rules for CRDTs are simplified to:
Changes in the KeyRegistry may cause a Signer to be removed for an fid, which should revoke all messages created by that signer for that fid.
Rationale
Will the additional cost deter users from adding applications?
It will likely cost between $.1 and $1 to add a signer at today’s L2 gas prices, though we expect that to reduce over time. Wallet clients like Warpcast can simplify the user experience by allowing payments to be made via fiat methods or L1. They can reduce the friction to add signers by charging a flat “signup fee” which covers the cost of signers being added later.
Why can’t users re-add the same signer?
The only use case for this is re-adding an accidentally deleted signer. In such cases, its more secure to issue a new signer and re-sign the messages. Disallowing signer reuse also simplifies sync logic for Hubs.
Why is the smart contract not upgradeable?
An upgradeable contract would allow changing logic without having to re-initialize the contract. However, it reduces trust since an administrator can upgrade the contract, change the logic, add keys to a user and forge messages under their identity.
Why can’t a signer be revoked without deleting the messages created by it?
A user revoking a signer typically expects that the owner of the signer can no longer create messages. However, this won’t be true since new messages created with an incorrect, older timestamp before the revocation will be accepted. Allowing this will lead to confusion, and its preferable to create a new signer and resign messages if they need to be preserved.
Why not have counterfactual signers that exist off-chain and on-chain?
A counterfactual system is possible but at the cost of significant complexity. The likely outcome in such a case is that wallets and apps will design their experiences around the off-chain signers, resulting in all the same problems that we face today.
Release
SmartContractSignerStore
Appendix A: Key Registry
Appendix B: Validator
Appendix C: Hub API Changes
The following APIs calls will be added:
The following API calls will be deprecated:
rpc GetSigner(SignerRequest) returns (Message); rpc GetSignersByFid(FidRequest) returns (MessagesResponse); rpc GetAllSignerMessagesByFid(FidRequest) returns (MessagesResponse); // submitMessage will no longer accept SignerAdd or SignerRemove, which will be deprecated
Beta Was this translation helpful? Give feedback.
All reactions