Cover photo

All about Farcaster Signers

Approving, revoking, and using them to re-sign messages.

vrypan.eth

vrypan.eth

Most users know "Signers" as "this thing you have to pay for when you connect a new app". One of the first articles in Purple Sumbarine, was about Farcaster Signers, but my understanding has evolved since then, and we also have new tools and advances since then.

In order to understand signers, you have to keep in mind that all interactions with hubs take place by sending hubs a "message" that has a specific structure. So, when you cast, like, or recast, the app you are using sends a message to a hub saying "@vrypan.eth casted Hello World", or "@vrypan.eth liked this cast".

Messages look something like this under the hood:

post image

As you can see such messages have two parts.

  • The data part: this is more or less what we usually consider the content, like the text of the cast, the date it was casted, the user who casted.

  • The metadata part which has a hash of the data, a digital signature of the hash, and the key that produced the signature: the signer.

What you see in the signer filed is not the actual signer, but the public key of the signer.

Why we need signers

In a centralized network such as twitter or facebook, you usually have a username and a password. You use your credentials to connect to a server, and then the server knows that you are who your credentials say you are. There is no other way to post something to the service, and the centralized server is the absolute authority of what was posted by whom.

Farcaster is an open, p2p network. Anyone with some technical knowledge can create a program that sends messages to the Farcaster network. The only way to verify the authenticity of these messages, is by their digital signature.

Each Farcaster user has their own keypair, a private and a public key. If you signed up using Warpcast, your recovery phrase can be used to generate this pair. This keypair also corresponds to an ethereum address, what is often called in Farcaster the custody wallet.

So, you could actually sign your messages using your private key. But users rarely create these messages on their computer using a program they wrote. They connect to a service or app, like buidler and after authenticating with it, it posts on their behalf. The problem is you don't want to give them your private key. This would be the equivalent of giving a gmail integration your username and password (and to some extent, not even being able to change the password).

Here is where Farcaster Signers come to play: Instead of giving an app your private key, the app creates a new random key, and asks you to approve it. You approve it using your private key and you register your approval onchain (gas cost!). From this point on, any hub that receives a message signed by this Signer, can check the blockchain to verify that you have approved the signer and accept it as authentic.

Warpcast and meta-transactions

When you make a call to a smart contract, the caller has to pay the gas for its execution. This is why adding or revoking a signer (onchain transactions) have a cost.

Normally, your Farcaster custody wallet would need to have some OP ETH to perform these transactions.

But wait. There's a workaround: KeyGateway, the smart contract used to approve Signers, allows meta-transactions. You can think of meta-transactions like this:

  • The user who wants to perform a transaction signs the transaction or an authorization to perform the transaction using his wallet. This is an offline action.

  • The signed transaction is not sent to the smart contract, but it is shared offchain with a third party, usually called the "relayer".

  • The relayer performs the transaction and pays the required gas.

Warpcast takes advantage of this feature to hide the added complexity of using a blockchain: It will ask the user to pay them $1, and then they use a meta-transaction and they pay for the gas.

This is roughly the equivalent of them saying "Just sign this paper, give me $1, and I'll take care of the rest."

The actual gas cost for adding and removing signers is usually well bellow $1. Warpcast now allows users to also pay using Warps, an in-app credit system: You can buy 500 Wraps for $5, and approving a signer will usually cost around 40-50 Warps (depending on gas cost at the time of the transaction).

(Warps are an interesting experiment that deserve a separate article.)

Revoking a signer

Obviously, a user must be able to revoke a signer, and they can do so using their private key and posting the revokation onchain to let everyone know that the signer is no longer authorized to act on their behalf. This was the whole point of not giving away our private key in the first place.

But, when a signer is revoked, hubs see messages that are no longer signed by a valid signer. Most people's first thought is OK, but these are old messages signed when the signer was valid. But you have to keep in mind that Farcaster is an open, p2p network. Hubs are added and removed all the time. You could spin up your hub right now (it's actually quite easy) and your hub would receive messages from other hubs it discovers in order to get its history (aka state) up to date. How can your newly created hub know when a message was signed?

This is why hubs have a simple way of "thinking": not a valid signer, not a valid message. And, as a result, when you revoke a Signer, all messages signed using it, are pruned by hubs!

This looks bad. The truth is there is a simple solution that no app (to my knowledge) has implemented (yet). Remember the message example we used earlier? What if you signed the same message with a different signer?

post image
A new signer will create a new signature

Signing the message with new signer will create a new signature, but the message data and the message hash will stay the same: Same user (fid), same content, same timestamp.

  • To any client, this new, re-signed message is the same as the original one.

  • To any hub, this is a valid message, provided that the original (same hash) is not in the hub's database.

So, an app could:

  1. Download all your messages (your Farcaster history)

  2. When you remove a signer, and some messages are pruned, re-sign these messages (from your download) with a new signer.

  3. Post the re-signed messages to a hub.

You can perform the above steps using https://github.com/vrypan/fario if you are comfortable working in the command line. You will have to:

  • Backup your data using fario-out --all.

  • Use fario-grep to select the records signed by the signer you want to remove.

  • Remove the signer using fario-signers remove and create a new signer using fario-signers add

  • Re-sign the messages using fario-signers sign

  • Upload the re-signed messages using fario-in

Final thoughts

Signers are an elegant approach to delegating permissions. It allows users to easily let an app act on their behalf, but at any point in time, they can revoke this permission.

The lack of a simple, user-friendly app that allows users to revoke a signer without deleting all activity performed using it, is definitely a pain-point looking for solutions: Right now, using a signer means that you are stuck with it, since revoking access will delete any casts, likes, recasts and follows you have performed using it. (Unless you are one of the few users who understand the technical details of Signers, and have the skills to use something like fario or put together a script by yourself.)

Looking forward to try the first apps that will give a user-friendly solution to this!

0xbac5...5fF9
Commented 1 year ago

My commment

nuconomy.⌐◨-◨Farcaster
nuconomy.⌐◨-◨
Commented 11 months ago

Useful post by @purplesubmarine for understanding what is happening behind the scenes with sighners.

nuconomy.⌐◨-◨Farcaster
nuconomy.⌐◨-◨
Commented 11 months ago

Is there any way to audit where you signers came from if you've forgotten which apps were authorised?

nuconomy.⌐◨-◨Farcaster
nuconomy.⌐◨-◨
Commented 11 months ago

Answering my own question 😅 This Dune dashboard shows you which apps your signers map to: https://dune.com/jkavithamahesh/farcasterprofile

vrypan |--o--|Farcaster
vrypan |--o--|
Commented 1 year ago

@v in retrospect, do you think that, overall, the decision to go with EdDSA signers was a good one? I get the performance gains argument, but limits how these signatures can be used by smart contracts. Should we move to ECDSA or maybe add support for ECDSA signers?

Dan RomeroFarcaster
Dan Romero
Commented 1 year ago

You can't legally store ECDSA keys in the cloud without a license in the US.

vrypan |--o--|Farcaster
vrypan |--o--|
Commented 1 year ago

Ouch! I didn't know this!

:grin:Farcaster
:grin:
Commented 1 year ago

wow wtf I didn’t know this

EladFarcaster
Elad
Commented 1 year ago

Bonkers

Sheldon TrotmanFarcaster
Sheldon Trotman
Commented 1 year ago

This is NUTS!

Sheldon TrotmanFarcaster
Sheldon Trotman
Commented 1 year ago

Doesn’t this mean all the WaaS (email/phone to EOA) platforms are DOA?

timbeiko.ethFarcaster
timbeiko.eth
Commented 1 year ago

What?

Dan RomeroFarcaster
Dan Romero
Commented 1 year ago
Darryl Yeo 🛠️Farcaster
Darryl Yeo 🛠️
Commented 1 year ago

WHAT

✳️ nibnalin on daimoFarcaster
✳️ nibnalin on daimo
Commented 1 year ago

do you store eddsa keys in the cloud right now? I thought I signed up with my own private key and passkeys for recovery aren't stored by you?

vrypan |--o--|Farcaster
vrypan |--o--|
Commented 1 year ago

These are the signer keys, not your wallet key.

Dan RomeroFarcaster
Dan Romero
Commented 1 year ago

eddsa aka signers are in warpcast cloud ecdsa is on your mobile device in a passkey

JoshuaFarcaster
Joshua
Commented 1 year ago

On the other hand, it is great for Substrate based chains. Substrate based chains support ed25519 as the default type along with sr25519 & ecdsa. This is what made everything *click* for me over the weekend & and there are some unique ideas that will come out of this

vrypan |--o--|Farcaster
vrypan |--o--|
Commented 2 years ago

I tried to put technical info about Signers in an easy to read format. I hope both technical and non-technical users will find it useful. https://paragraph.xyz/@purplesubmarine/all-about-signers

ChrisCoCreatedFarcaster
ChrisCoCreated
Commented 2 years ago

Very useful! I’m using signers in my app and didn’t know all this. Wonder if @neynar implementation of shared signers will solve for some of this. 🤔

Phil CockfieldFarcaster
Phil Cockfield
Commented 2 years ago

Super helpful distillation…thanks so much @vrypan.eth

dylanFarcaster
dylan
Commented 2 years ago

This is a great read — thank you for sharing this!

Edric 🎩Farcaster
Edric 🎩
Commented 2 years ago

Super clear. I just wish each section had some visuals – that would be awesome.

fommes🎩 🐲 👁️🚪Farcaster
fommes🎩 🐲 👁️🚪
Commented 2 years ago

just testing... if I comment here, is it shown below the original paragraph article? ...

ChrisCoCreatedFarcaster
ChrisCoCreated
Commented 2 years ago

yup!

All about Farcaster Signers