--unlock flag is generally a highly dangerous thing to do because it is indiscriminate, i.e. if an account is unlocked and an attacker obtains access to the RPC api, the attacker can sign anything without supplying a password.
Clef provides a way to safely circumvent --unlock while maintaining a enough automation for the network to be useable.
Prerequisites
It is useful to have basic knowledge of private networks and Clef. These topics are covered on our private networks and Introduction to Clef pages.Prepping a Clique network
First of all, set up a rudimentary testnet to have something to sign. Create a new keystore (passwordtesttesttest)
Prepping Clef
In order to make use ofclef for signing:
- Ensure
clefknows the password for the keystore. - Ensure
clefauto-approves clique signing requests.
clef must be initiated (for this example the password is clefclefclef)
clef has it’s own vault where it can store secrets and attestations.
Storing passwords in clef
With that done,clef can be made aware of the password. To do this setpw <address> is invoked to store a password for a given address. clef asks for the password, and it also asks for the master-password, in order to update and store the new secrets inside the vault.
Testing stored password
To test that the stored password is correct and being properly handled by Clef, first start clef:y to approve:
y, the password is not required - the signed block is returned to the Parallax client:
Using rules to approve blocks
Clef rules allow a piece of Javascript take over the Approve/Deny decision. The Javascript snippet has access to the same information as the manual operator. The first approach, which approves listing, and returns the request data for ApproveListing, is demonstrated below:clef can be started, pointing out the rules.js file.
raw_data could be verified to ensure it has the right rlp structure for a Clique header:
messages could also be used. They do not come from the external caller, but are generated inernally: clef parsed the incoming request and verified the Clique wellformedness of the content. The following simply checks for such a message:
clef:
clef should now happily sign blocks:
Refinements
If an attacker find the Clef “external” interface (which would only happen if you start it with http enabled), they- cannot make it sign arbitrary transactions,
- cannot sign arbitrary data message,
clique header 2 [0xae525b65bc7f711bc136f502650039cd6959c3abc28fdf0ebfe2a5f85c92f3b6] line is split, and the number stored using storage.get and storage.put:
TLDR quick-version
Creation and attestation is a one-off event:--signer <path to clef ipc>.
Summary
Clef can be used as a signer that automatically seals Clique blocks. This is a much more secure option than unlocking accounts using the Parallax client’s built-in account manager.Adapted from Clique signing in the go-ethereum documentation, © The go-ethereum Authors. See the third-party notices.

