Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIP-0036 | Adding the deregistration metadata format #349

Merged
merged 6 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CIP-0010/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
},
{
"transaction_metadatum_label": 61285,
"description": "CIP-0015 - Catalyst registration"
"description": "CIP-0015 - Catalyst witness"
},
{
"transaction_metadatum_label": 61286,
"description": "CIP-0015 - Catalyst registration"
"description": "CIP-0015 - Catalyst deregistration"
}
]
63 changes: 62 additions & 1 deletion CIP-0036/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ as follows.
This ensures that the voter's total voting power is never accidentally reduced through poor choices of weights,
and that all voting powers are exact ADA.

### Example
### Example - Registration

Voting registration example:
```
Expand Down Expand Up @@ -137,6 +137,64 @@ Witness example:
}
```

### Deregistration metadata format (Catalyst)

This deregistration format is currently only specified for Catalyst (vote_purpose=0), other voting chain purposes may handle a deregistration in a different way.

Definition:
- A deregistration removes all the voting power (associated stake amount) for the provided stake credential from the delegated vote-public-keys.
- A deregistration resets the state of the stake credential on the voting chain like they were never registered before.
- A deregistration transaction is a regular Cardano transaction with a specific transaction metadata associated with it.

Notably, there should be three entries inside the metadata map (key 61286):
- The public key of the stake signing key
- A nonce that identifies that most recent deregistration.
- A non-negative integer that indicates the purpose of the vote. For now, we define 0 as the value to use for Catalyst, and leave others for future use.

Be aware, the deregistration metadata key is 61286, and not 61284 like it is used for a registration! The registraton metadata format and specification is independent from the deregistration one, and may not be supported by all wallets/tools.

### Example - Deregistration (Catalyst)

```
{
61286: {
// stake_pub - CBOR byte array
1: "0x57758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0",
// nonce
2: 74412400,
// voting_purpose: 0 = Catalyst
3: 0
},
61285: {
// witness - ED25119 signature CBOR byte array
1: "0xadb7c90955c348e432545276798478f02ee7c2be61fd44d22f9de22131d9bcf0b23eb413766b74b9e7ba740e71266467a5d35363411346972db9e7b710b00603"
}
}
```
CBOR-Hex:
`A219EF66A301582057758911253F6B31DF2A87C10EB08A2C9B8450768CB8DD0D378D93F7C2E220F0021A046F7170030019EF65A1015840ADB7C90955C348E432545276798478F02EE7C2BE61FD44D22F9DE22131D9BCF0B23EB413766B74B9E7BA740E71266467A5D35363411346972DB9E7B710B00603`

The entries under keys 1, 2 and 3 represent the staking credential on the Cardano network, a nonce, and a voting purpose, respectively.
A deregistration with these metadata will be considered valid if the following conditions hold:

- The stake credentials is a stake public-key byte array (of CBOR major type 2)
- The nonce is an unsigned integer (of CBOR major type 0) that should be
monotonically rising across all transactions with the same staking key.
The advised way to construct a nonce is to use the current slot number.
This is a simple way to keep the nonce increasing without having to access
the previous transaction data.
- The voting_purpose is an unsigned integer (of CBOR major type 0)

To produce the witness field in case of a staking public key, the CBOR representation of a map containing
a single entry with key 61286 and the deregistration metadata map in the
format above is formed, designated here as `sign_data`.
This data is signed with the staking key as follows: first, the
blake2b-256 hash of `sign_data` is obtained. This hash is then signed
using the Ed25519 signature algorithm. The witness metadata entry is
added to the transaction under key 61285 as a CBOR map with a single entry
that consists of the integer key 1 and signature as obtained above as the byte array value.


### Metadata schema

See the [schema file](./schema.cddl)
Expand Down Expand Up @@ -171,6 +229,9 @@ Fund 8:
- added the `voting_purpose` field to limit the scope of the delegations.
- rename the `staking_pub_key` field to `stake_credential` and `registration_signature` to `registration_witness` to allow for future credentials additions.

Fund 10:
- added the `deregistration` metadata format.

## Copyright

This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode)
Expand Down
16 changes: 16 additions & 0 deletions CIP-0036/schema.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ key_registration = {
registration_witness = {
1 : $stake_witness
}


deregistration_cbor = {
61286: key_deregistration,
61285: deregistration_witness
}

key_deregistration = {
1 : $stake_credential,
2 : $nonce,
? 3 : $voting_purpose .default 0
}

deregistration_witness = {
1 : $stake_witness
}