input-output-hk / voting-tools

Apache License 2.0
17 stars 10 forks source link

cardano-signer 1.5.0+ now supports catalyst cip-0036 metadata generation #51

Open gitmachtl opened 2 years ago

gitmachtl commented 2 years ago

Just as an info, the new version of cardano-signer 1.5.0 has implemented the upcoming CIP-0036 standard for governance/catalyst multi-delegation of voting-power. It generates the registration cbor hex string or directly the binary cbor file to submit it on chain.

Signing (CIP-36 mode) - Catalyst Voting Registration / VotingPower Delegation

### REGISTER/DELEGATE TO A SINGLE VOTING-KEY

$ cardano-signer sign --cip36 \
      --rewards-address "stake_test1urqntq4wexjylnrdnp97qq79qkxxvrsa9lcnwr7ckjd6w0cr04y4p" \
      --secret-key ../owner.staking.skey \
      --vote-public-key somevote.vkey \
      --nonce 71948552 \
      --out-file catalyst-delegation.cbor

a219ef64a5018182582057758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0010258209be513df12b3fabe7c1b8c3f9fab0968eb2168d5689bf981c2f7c35b11718b2703581de0c13582aec9a44fcc6d984be003c5058c660e1d2ff1370fd8b49ba73f041a0449d908050019ef65a1015840c839244556db17a2df914c7291c891e5abd1bd580de7786d640da9e27983efe86495cbee900eb685c08e367e778bb0860c6e366b9ec715d8fba824ef55c8aa0f

### REGISTER/DELEGATE TO MULTIPLE VOTING-KEYS WITH VOTINGPOWER 10%,20%,70%

$ cardano-signer sign --cip36 \
      --rewards-address "stake_test1urqntq4wexjylnrdnp97qq79qkxxvrsa9lcnwr7ckjd6w0cr04y4p" \
      --secret-key ../owner.staking.skey \
      --vote-public-key ../somevote.vkey \
      --vote-weight 10 \
      --vote-public-key "C2CD50D8A231FBC1444D65ABAB4F6BF74178E6DE64722558EEEF0B73DE293A8A" \
      --vote-weight 20 \
      --vote-public-key "ed25519_pk128c305nw9xh20kearuhcwj447kzlvxdfttkk6uwnrf6qfjm9276svd678w" \
      --vote-weight 70 \
      --nonce 71948552 \
      --out-file catalyst-multidelegation.cbor

a219ef64a5018382582099d1d0c4cdc8a4b206066e9606c6c3729678bd7338a8eab9bffdffa39d3df9580a825820c2cd50d8a231fbc1444d65abab4f6bf74178e6de64722558eeef0b73de293a8a1482582051f117d26e29aea7db3d1f2f874ab5f585f619a95aed6d71d31a7404cb6557b518460258209be513df12b3fabe7c1b8c3f9fab0968eb2168d5689bf981c2f7c35b11718b2703581de0c13582aec9a44fcc6d984be003c5058c660e1d2ff1370fd8b49ba73f041a0449d908050019ef65a1015840ecce4b2e10146857b9f583ce01b10a26726022963d47fd61d0fbb67b543428fa46315d4e35b2ab73e7e15f620883176422a19e780a751d71ac488053365e6402
gitmachtl commented 2 years ago

cardano-signer 1.7.0 now also supports more output options including JSON format, which will generate a user-readable registration.json (with 0x prefix for hexbytearrays cardano-style) which can also be directly used in a transactions:

Example:

$ cardano-signer sign --cip36 \
    --rewards-address "stake_test1urqntq4wexjylnrdnp97qq79qkxxvrsa9lcnwr7ckjd6w0cr04y4p" \
    --secret-key "f5beaeff7932a4164d270afde7716067582412e8977e67986cd9b456fc082e3a" \
    --vote-public-key ../myvote.voting.pkey --vote-weight 1 \
    --vote-public-key "57758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0" --vote-weight 5 \
    --nonce 123456789 \
    --json | --json-extended

JSON-Output:

{
    "61284": {
      "1": [
        [
          "0x51f117d26e29aea7db3d1f2f874ab5f585f619a95aed6d71d31a7404cb6557b5",
          1
        ],
        [
          "0x57758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0",
          5
        ]
      ],
      "2": "0x86870efc99c453a873a16492ce87738ec79a0ebd064379a62e2c9cf4e119219e",
      "3": "0xe0c13582aec9a44fcc6d984be003c5058c660e1d2ff1370fd8b49ba73f",
      "4": 123456789,
      "5": 0
    },
    "61285": {
      "1": "0xa97affe866b515f3dadb3038b4ccc58bf689005d417300fbf57d3f17eceb553d7354d919adb59a8b6dc30afb6cdda414812c3ffd4dfceebb15e391a7415bde0d"
    }
 }

JSON-Extended-Output:

{
  "workMode": "sign-cip36",
  "registrationCBOR": "a219ef64a5018282582051f117d26e29aea7db3d1f2f874ab5f585f619a95aed6d71d31a7404cb6557b50182582057758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f00502582086870efc99c453a873a16492ce87738ec79a0ebd064379a62e2c9cf4e119219e03581de0c13582aec9a44fcc6d984be003c5058c660e1d2ff1370fd8b49ba73f041a075bcd15050019ef65a1015840a97affe866b515f3dadb3038b4ccc58bf689005d417300fbf57d3f17eceb553d7354d919adb59a8b6dc30afb6cdda414812c3ffd4dfceebb15e391a7415bde0d",
  "registrationJSON": {
    "61284": {
      "1": [
        [
          "0x51f117d26e29aea7db3d1f2f874ab5f585f619a95aed6d71d31a7404cb6557b5",
          1
        ],
        [
          "0x57758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0",
          5
        ]
      ],
      "2": "0x86870efc99c453a873a16492ce87738ec79a0ebd064379a62e2c9cf4e119219e",
      "3": "0xe0c13582aec9a44fcc6d984be003c5058c660e1d2ff1370fd8b49ba73f",
      "4": 123456789,
      "5": 0
    },
    "61285": {
      "1": "0xa97affe866b515f3dadb3038b4ccc58bf689005d417300fbf57d3f17eceb553d7354d919adb59a8b6dc30afb6cdda414812c3ffd4dfceebb15e391a7415bde0d"
    }
  },
  "signDataHex": "45d05fca1f25e1a01c375dc2c8896e1fe61619852bbef2b26b4ece433c5bdeb7",
  "signature": "a97affe866b515f3dadb3038b4ccc58bf689005d417300fbf57d3f17eceb553d7354d919adb59a8b6dc30afb6cdda414812c3ffd4dfceebb15e391a7415bde0d",
  "secretKey": "f5beaeff7932a4164d270afde7716067582412e8977e67986cd9b456fc082e3a",
  "publicKey": "86870efc99c453a873a16492ce87738ec79a0ebd064379a62e2c9cf4e119219e"
}

So using cardano-signer to produce CIP-0036 conform metadata for the CardanoMainnet and Catalyst for a single 100% voting-power delegation would be as simple as runnning:

nonce=$(curl -s -X GET "https://api.koios.rest/api/v0/tip" -H "Accept: application/json" | jq -r ".[0].abs_slot") #getting slotHeight for Mainnet via koios

cardano-signer sign --cip36 \
          --rewards-address "<stakeaddress_to_receive_rewards>" \
          --secret-key stake.skey \
          --vote-public-key myvote.voting.vkey \
          --nonce ${nonce} \
          --json \
          --out-file catalyst-registration-metadata.json
gitmachtl commented 2 years ago

Signing (CIP-36 mode) - Catalyst Voting-Chain Registration/Delegation

cardano signer 1.8.0 can now calculate the nonce (if not provided) from the current machine time on its own (mainnet-slotHeight).

So a minimal registration could look like:

$ cardano-signer sign --cip36 \
    --rewards-address "stake1u55c9gha99xz3dnxxeczsr3f4kj23zs4mtpst3szlztengsv62rry" \
    --vote-public-key test.voting.vkey \
    --secret-key myStakeKey.skey \
    --json \
        --out-file catalyst-registration-metadata.json

Output: (Nonce automatically calculated from current machine time)

{
  "61284": {
    "1": [
      [ "0xc2cd50d8a231fbc1488d65abab4f6bf74178e6de64722558eeef0b73de293a8a", 1 ]
    ],
    "2": "0x57758911253aa6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0",
    "3": "0xe1e382a2fd294c28b7763670280e29ada4a88a15dac305c602f89799a2",
    "4": 73146002,
    "5": 0
  },
  "61285": {
    "1": "0x4a96002...3278ea09"
  }
}
gitmachtl commented 1 year ago

Signing (CIP-36 mode) - Catalyst Voting-Chain De-Registration

cardano-signer 1.9.0 can now also generate the newly added catalyst deregistration metadata format via the flag --deregister. Also it can calculate the nonce (if not provided) from the current machine time on its own (mainnet-slotHeight). If not provided, the --vote-purpose defaults to 0 (catalyst).

So a minimal call would look like:

$ cardano-signer sign --cip36 \
    --deregister \
    --secret-key myStakeKey.skey \
    --json

Output: (Nonce automatically calculated from current machine time)

{
  "61286": {
    "1": "0x57758911253f6b31df2a87c10eb08a2c9b8450768cb8dd0d378d93f7c2e220f0",
    "2": 74858300,
    "3": 0
  },
  "61285": {
    "1": "0xc7bec561f2b80766f78c169ccb231865048e0ed7e9fb4f98f263d00e3e4a2e6126a18f70b303be63f8e01f46dd116be5c387495a7cec707d3ebc3e6be4d87008"
  }
}
gitmachtl commented 1 year ago

Signing (CIP-36 mode) - Catalyst new rewards address (payment)

cardano-signer 1.10.1 is now supporting the changed reward payout address. It is no longer a stakeaddress, its a payment address (enterprise or base) now.

So a minimal registration could look like:

$ cardano-signer sign --cip36 \
    --rewards-address "addr1v9ux8dwy800s5pnq327g9uzh8f2fw98ldytxqaxumh3e8kqumfr6d" \
    --vote-public-key test.voting.vkey \
    --secret-key myStakeKey.skey \
    --json \
        --out-file catalyst-registration-metadata.json

Output: (Nonce automatically calculated from current machine time)

{
  "61284": {
    "1": [
      [
        "0xcd6d71f11cbd2f63326e5a50d7141a9443bd0f16f4b02f3f2f4d40acc5f83294",
        1
      ]
    ],
    "2": "0x9be513df12b3fabe7c1b8c3f9fab0968eb2168d5689bf981c2f7c35b11718b27",
    "3": "0x617863b5c43bdf0a06608abc82f0573a549714ff69166074dcdde393d8",
    "4": 78696706,
    "5": 0
  },
  "61285": {
    "1": "0x535d1ee26b844a71005043d4f151c18c8ef073d32bfb097284dd16f40e78f8bae877dccc268ab2762e96312910c95dc4685a025b474fe93c69aafa59fdf14c0b"
  }
}