Wishlist
Signature login
A wallet signs a login message with a shielded key. The app examines the signature. The login is off the chain: it has zero transactions and zero fees.
Wallets do not have this function today. This page has two designs. The viewing key signature is from Julian (craftsoldier). The app key signature is from c-node.
Necessary changes
- Improves
- Log in with Zcash
- Wallets
- A new function: sign a login message with a shielded key.
- ZIP
- A new ZIP for the login message and the keys. See Parts of a spec.
- Consensus
- No change.
- Status
- Proposal. A spec is not written yet.
Problem
An app uses Log in with Zcash with the wallets of today. Each login is two payments. Thus, each login has two transactions, two fees and a delay. The service also needs a worker with a code key.
With a signature, these costs are zero. On Ethereum, apps use ERC-4361 for this function. On Zcash, wallets sign messages with transparent keys at most. ZIP 304 is for Sapling keys only.
Mechanism
Viewing key signature
Each shielded receiver of an address is already a public key. Its secret key is the incoming viewing key
ivk.
pk_d = [ivk]g_d
g_d the base point of the receiver, from its diversifier
pk_d the public key in the receiver
The wallet makes a Schnorr signature with ivk as the secret key and g_d as the base
point. The app has g_d and pk_d from the address, and it examines the signature
with them. Thus, the address is the account of the user, as in Log in with Zcash.
The wallet calculates g_d from its own diversifier only. An app that chooses the base point
B can find [ivk]B from the signature. If B is the epk of an Orchard note to the user, [ivk]B is its shared secret.
For a Sapling note, the shared secret is [8ivk]B.
Thus, the app can read that note if the wallet uses its epk as the base point.
The signature contains a point R and a number. The challenge is a hash of a domain tag, the
diversifier d, pk_d, R and the login message. Thus, the signature is
valid for one receiver and one login message only.
App key signature
A shielded wallet has a spend authorizing key ask and its public key ak. In RedDSA,
a wallet can randomize this key pair with a secret number α. Each shielded spend already has a signature from
a randomized key.
α = PRF(wallet secret, domain)
rk = ak + [α]G
rsk = ask + α
domain the domain of the app, for example app.example
G the base point of the spend signatures
rk the public key of the user at this app
rsk the secret key of the user at this app
The wallet calculates α with a keyed hash, from a secret of the wallet and the domain of the app. Thus, the wallet has a different key pair for each app. The wallet calculates the secret from the seed, with ZIP 32 registered key derivation. If the secret is from the full viewing key, each holder of that key can calculate α. Thus, each holder of the full viewing key can link the app keys of the user.
A wallet that the user restores from the seed calculates the same keys again. An account that participants make with a FROST distributed key generation has no seed. For that account, developers must give the source of the secret in the spec.
Sequence
- The app makes a login message, as in ERC-4361. The message has the domain of the app, a nonce and an expiry time. The app makes a new nonce for each login.
- The wallet shows the domain to the user. A wallet in the browser also compares the domain with the host of the page.
- The wallet signs the message. The secret key is
ivk, or the keyrskfor the domain. - The wallet sends the signature to the app. It also sends the address, or the key
rk. - The app examines the signature. It also examines the domain, the nonce and the expiry time. The app accepts each nonce one time only.
- If all of them are correct, the user is logged in. The account of the user is the address, or the key
rk.
A wallet on a different device cannot see the page. There, the user must compare the domain in the wallet with the host of the page.
Comparison
| Design | Transactions | Account | Necessary key | Wallet support |
|---|---|---|---|---|
| Code in a memo | 2 | The address | Incoming viewing key | Wallets with ZIP 321 and memos |
| Viewing key signature | 0 | The address | Incoming viewing key | A new wallet function |
| App key signature | 0 | One key for each app | Spend authorizing key | A new wallet function |
What apps can find from each signature
The app uses a correct viewing key signature as proof that the wallet has the address's ivk.
With the memo code, the app checks that the user knows the code only.
Each holder of the incoming viewing key can log in as the address.
A user who gives the viewing key to a different person also gives the login.
The app uses a correct app key signature as proof that the user has the secret key rsk. Only a holder of
ask can calculate rsk. Thus, a viewing key is insufficient for a login.
A FROST group can hold an account, with a threshold of t participants. For that account,
t participants make each app key signature together, in a rerandomized FROST round with α.
Each participant who has the incoming viewing key can make a viewing key signature alone. Thus, for that
account, the threshold is in effect for the app key signature only.
With the app key signature, the app gets rk only. Because α is secret, two apps cannot calculate
that their keys are from the same ak. Thus, apps cannot link the app keys of one user.
There, the address of the user stays secret. To show that rk and an address are from the same
key, the wallet must also make a zero-knowledge proof. ZIP 304 has
this proof for Sapling keys only.
Parts of a spec
- Message format. The fields of the login message and their sequence, as in ERC-4361.
-
Receiver. For the viewing key signature. A unified address can have more than one shielded receiver.
A Sapling receiver and an Orchard receiver have different
ivkvalues. For each receiver type, all receivers that the wallet gives to senders for one account have oneivk. The change receivers of the account have a differentivk. Developers must give the receiver type in the spec. - Calculation of α. For the app key signature. One calculation for all wallets. Thus, a user who moves to a different wallet keeps the same accounts.
- Hash personalization. For the app key signature. Wallets already use these keys in transactions. RedPallas has one fixed hash personalization for all signatures. Thus, the wallet signs a hash of the login message, as in ZIP 304. This hash has a personalization for logins only. The wallet calculates this hash itself. The wallet never signs 32 bytes from the app. Thus, a login signature is invalid for a transaction.
- Transport. A path from the app to the wallet and back. For example, a QR code for the message and an HTTPS request for the signature.