Activation transactions
To build an activation transaction, you must have the following:
- A (possibly random) Cardano signing key;
- A Wallet token name -- it is the above signing key's corresponding public key hash;
- A JSON Web Token (JWT) for the specific user obtained from Google;
- A ZK proof for the JWT and Wallet token;
- Beacon token UTxO.
For more details about the ZK Proof, see the Smart wallet Prover API reference for details. In a nutshell, it produces Proof bytes given public exponent and public modulus for RSA, JWT signature and token name.
Upon activation, a token will be minted. Its Minting policy is the web2Auth script applied to the Wallet config and user ID (email). Token name is the public key hash. The redeemer for the minting script can be viewed here. Below is an overview of its fields:
data JWTParts = JWTParts
{ jwtHeader :: BuiltinByteString
, jwtPrefix :: BuiltinByteString
, jwtSuffix :: BuiltinByteString
}
newtype KeyId = KeyId
{ keyId :: BuiltinByteString
}
data Web2Auth = Web2Auth JWTParts ProofBytes TokenName KeyId
JWTParts describes parts of the JSON Web Token received from Google. jwtHeader is the unmodified token header; jwtPrefix is the part of the payload immediately before the user ID (or email) field; jwtSuffix is the part of the payload immediately after the user ID vield value. For instance, if the JWT is
{
"alg": "HS256",
"typ": "JWT",
"kid": "130fdcefcc8ed7be6bedfa6fc879722040c92b38"
}
{
"sub": "1234567890",
"name": "John Doe",
"admin": true,
"email": "jdoe@zkfold.io",
"iat": 1516239022
}
then, JWT header is
{
"alg": "HS256",
"typ": "JWT",
"kid": "130fdcefcc8ed7be6bedfa6fc879722040c92b38"
}
JWT prefix is
{
"sub": "1234567890",
"name": "John Doe",
"admin": true,
and JWT duffix is (notice the comma)
,
"iat": 1516239022
}
ProofBytes represent a serialised PlonK proof. The serialisation function is described here.
TokenName is minted token name without policy id;
KeyID is the ID (kid) of the Google key used to sign the JWT.
Wallet's address is determined by its email. It is a script address, and the script is the wallet script applied to the currency symbol of the minting script and stake validator script hash.
An activation transaction must:
- Mint exactly one token with Minting policy, Token name and redeemer described above;
- Have the newly-minted token in the outputs at the wallet address;
- Have Beacon token UTxO Transaction ID as a reference input;
- Be signed with the previously generated Cardano signing key;
- Register a stake certificate with the checkSig script as validator and Signature i j as redeemer, where i is the number of output with the wallet token and j is the index of the signatory corresponding to that token;
- Have any funds being sent to the recipient listed in the outputs.
Transaction must have inputs with sufficient funds to pay for the transaction (about 1.67 ADA network fees + 2 ADA stake certificate registration) and be balanced as well -- any change should return to the sender.