FIP: JSON Farcaster Signatures #208
Replies: 7 comments 5 replies
-
|
Is there something we should take care of to make this interoperable between languages? (I have the protobuf serialization issue in mind, is there a danger we will have a similar issue?) |
Beta Was this translation helpful? Give feedback.
-
|
So glad we're standardizing this |
Beta Was this translation helpful? Give feedback.
-
|
Do addresses need to be checksummed or is all lower case fine? |
Beta Was this translation helpful? Give feedback.
-
|
Note that JFS are not JWS. There are two main differences:
See JFS implementation below that documents in-depth signature validation for both app and custody keys: https://github.com/nounder/json-farcaster-signature/blob/master/jfs.ts |
Beta Was this translation helpful? Give feedback.
-
Where is the |
Beta Was this translation helpful? Give feedback.
-
|
Is this something that could be done in Warpcast, or would we be expected to create a new Farcaster account using a terminal to host frames? |
Beta Was this translation helpful? Give feedback.
-
|
Is there a reference on "Compute the signature using the algorithm corresponding to the key" ? I have a custody address, but unclear what signing algorithm applies. Perhaps missing a link? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
FIP: Farcaster JSON Signatures
FIP: Farcaster JSON Signatures
Title: Farcaster JSON Signatures
Authors: @deodad
Problem
Farcaster identities don't have a standardized way to sign arbitrary payloads.
Specification
JSON Farcaster Signatures (JFS) provides a simple standard to compactly and efficiently sign JSON data. This specification is inspired by JWS but it is not a strict implementation of it.
A JFS is made up of three components:
To create a JFS:
For step 3, the signing input is as follows:
ASCII(BASE64URL(UTF8(Header)) || '.' || BASE64URL(Payload))The entire JFS can then be compactly serialized as follows:
BASE64URL(header) + "." + BASE64URL(payload) + "." + BASE64URL(signature)Alternatively the JFS can be serialized into a JSON format as follows:
To validate a JFS:
headerfrom the serialized representation and validate the following:signaturefrom the serialized representation and validate the following:Signing methods:
Custody Example
Signing
Validating
Note on legacy custody signatures
For a long time this specification incorrectly had the following example for encoding ECDSA signatures:
The problem here is
signaturereturned is a hex string but the Buffer interprets it asutf-8. The result is that rather than the raw bytes getting encoded, the bytes of theutf-8bytes of that string get encoded. To accept one of these misencoded signatures you can try falling back like so:keyvalue specified in the header.See the @farcaster/jfs package for a NodeJS implementation.
FAQ
Is there an official library for generating and verifying JFS signatures?
Yes. Use the @farcaster/jfs package.
Can a smart contract wallet generate a JFS signature?
Yes. Custody and auth address signatures may be signed by smart contract accounts. The @farcaster/jfs package verifies smart contract signatures using a Viem public client for OP mainnet, which verifies EOA, ERC-1271, ERC-6492, and ERC-8010 signatures. Note that you may need to generate a different signature type depending on whether the signing account is deployed to OP mainnet.
Why are some signatures longer than others?
The base64 encoded JFS "signature" field is either 176 characters or 88 characters. Signatures in the 176-character format are legacy custody signatures, which encode the signature bytes as a hex string. (See "note on legacy custody signatures" above). Signatures in the shorter 88-character format encode the signature bytes directly to base64. New tooling should use the shorter 88-character format, but accept legacy signatures for backwards compatibility.
Beta Was this translation helpful? Give feedback.
All reactions