From 578eea3ec41deed77a81594bed3c3b2b9d581cd1 Mon Sep 17 00:00:00 2001 From: Ajinkya Rajandekar Date: Tue, 28 May 2024 21:07:34 +0100 Subject: [PATCH] Use magic byte instead of tag to differentiate between pre-attestation and attestation --- src/apdu_sign.c | 15 +++-- src/baking_auth.c | 24 ++------ src/baking_auth.h | 3 +- src/delegates.h | 142 ++++++++++++++++++++++++++++++++++++++++++++++ src/globals.h | 2 +- src/types.h | 11 ++++ 6 files changed, 168 insertions(+), 29 deletions(-) create mode 100644 src/delegates.h diff --git a/src/apdu_sign.c b/src/apdu_sign.c index 00af1963..f62720dc 100644 --- a/src/apdu_sign.c +++ b/src/apdu_sign.c @@ -186,13 +186,6 @@ static bool sign_reject(void) { return true; } -/// Magic byte values -/// See: https://tezos.gitlab.io/user/key-management.html#signer-requests -#define MAGIC_BYTE_UNSAFE_OP 0x03u /// magic byte of an operation -#define MAGIC_BYTE_BLOCK 0x11u /// magic byte of a block -#define MAGIC_BYTE_PREATTESTATION 0x12u /// magic byte of a pre-attestation -#define MAGIC_BYTE_ATTESTATION 0x13u /// magic byte of an attestation - /** * @brief Carries out final checks before signing * @@ -303,11 +296,17 @@ int handle_sign(buffer_t *cdata, const bool last, const bool with_hash) { TZ_ASSERT(G.packet_index == 1u, EXC_PARSE_ERROR); TZ_ASSERT(buffer_read_u8(cdata, &G.magic_byte), EXC_PARSE_ERROR); + bool is_attestation = false; switch (G.magic_byte) { case MAGIC_BYTE_PREATTESTATION: + is_attestation = false; + TZ_ASSERT(parse_consensus_operation(cdata, &G.parsed_baking_data, is_attestation), + EXC_PARSE_ERROR); case MAGIC_BYTE_ATTESTATION: - TZ_ASSERT(parse_consensus_operation(cdata, &G.parsed_baking_data), EXC_PARSE_ERROR); + is_attestation = true; + TZ_ASSERT(parse_consensus_operation(cdata, &G.parsed_baking_data, is_attestation), + EXC_PARSE_ERROR); break; case MAGIC_BYTE_BLOCK: TZ_ASSERT(parse_block(cdata, &G.parsed_baking_data), EXC_PARSE_ERROR); diff --git a/src/baking_auth.c b/src/baking_auth.c index a16b5964..48d95cde 100644 --- a/src/baking_auth.c +++ b/src/baking_auth.c @@ -216,10 +216,6 @@ bool parse_block(buffer_t *buf, parsed_baking_data_t *const out) { return true; } -#define TAG_PREATTESTATION 20 -#define TAG_ATTESTATION 21 -#define TAG_ATTESTATION_DAL 23 - /** * Data: * + (4 bytes) uint32: chain id of the block @@ -230,12 +226,14 @@ bool parse_block(buffer_t *buf, parsed_baking_data_t *const out) { * + (4 bytes) uint32: round of the related block * + (32 bytes) uint8 *: hash of the related block */ -bool parse_consensus_operation(buffer_t *buf, parsed_baking_data_t *const out) { +bool parse_consensus_operation(buffer_t *buf, + parsed_baking_data_t *const out, + bool is_attestation) { uint8_t tag; if (!buffer_read_u32(buf, &out->chain_id.v, BE) || // chain id !buffer_seek_cur(buf, 32u * sizeof(uint8_t)) || // ignore branch - !buffer_read_u8(buf, &tag) || // tag + !buffer_read_u8(buf, &tag) || // ignore tag !buffer_seek_cur(buf, sizeof(uint16_t)) || // ignore slot !buffer_read_u32(buf, &out->level, BE) || // level !buffer_read_u32(buf, &out->round, BE) || // round @@ -243,20 +241,8 @@ bool parse_consensus_operation(buffer_t *buf, parsed_baking_data_t *const out) { ) { return false; } - - switch (tag) { - case TAG_PREATTESTATION: - out->type = BAKING_TYPE_PREATTESTATION; - break; - case TAG_ATTESTATION: - case TAG_ATTESTATION_DAL: - out->type = BAKING_TYPE_ATTESTATION; - break; - default: - return false; - } + out->type = is_attestation ? BAKING_TYPE_ATTESTATION : BAKING_TYPE_PREATTESTATION; out->is_tenderbake = true; - return true; } diff --git a/src/baking_auth.h b/src/baking_auth.h index ab74e137..e29576d0 100644 --- a/src/baking_auth.h +++ b/src/baking_auth.h @@ -79,6 +79,7 @@ bool parse_block(buffer_t *buf, parsed_baking_data_t *const out); * * @param buf: input buffer containing the consensus operation * @param out: baking data output + * @param is_attestation: whether its an attestation or pre-attestation. * @return bool: returns false if it is invalid */ -bool parse_consensus_operation(buffer_t *buf, parsed_baking_data_t *const out); +bool parse_consensus_operation(buffer_t *buf, parsed_baking_data_t *const out, bool is_attestation); diff --git a/src/delegates.h b/src/delegates.h new file mode 100644 index 00000000..d2b55dc3 --- /dev/null +++ b/src/delegates.h @@ -0,0 +1,142 @@ +#pragma once + +#include "types.h" +#include "os.h" + +// This file is generated by the ./tools/gen-delegates.sh script. + +typedef struct { + uint8_t bakerAccount[HASH_SIZE_B58]; + char* bakerName; +} named_delegate_t; + +static const named_delegate_t named_delegates[] = { + {.bakerAccount = "tz1N4GQ8gYgMdq6gUsja783KJButHUHn5K7z", .bakerName = "Obsidian"}, + {.bakerAccount = "tz1TDSmoZXwVevLTEvKCTHWpomG76oC9S2fJ", .bakerName = "Tezos Capital Legacy"}, + {.bakerAccount = "tz1Tnjaxk6tbAeC2TmMApPh8UsrEVQvhHvx5", .bakerName = "Crypto Delegate"}, + {.bakerAccount = "tz1WCd2jm4uSt4vntk4vSuUWoZQGhLcDuR9q", .bakerName = "Happy Tezos"}, + {.bakerAccount = "tz3e75hU4EhDU3ukyJueh5v6UvEHzGwkg3yC", .bakerName = "At James"}, + {.bakerAccount = "tz1VmiY38m3y95HqQLjMwqnMS7sdMfGomzKi", .bakerName = "Lucid Mining"}, + {.bakerAccount = "tz1P2Po7YM526ughEsRbY4oR9zaUPDZjxFrb", .bakerName = "P2P Validator"}, + {.bakerAccount = "tz1NortRftucvAkD1J58L32EhSVrQEWJCEnB", .bakerName = "Bake'n'Rolls"}, + {.bakerAccount = "tz1g8vkmcde6sWKaG2NN9WKzCkDM6Rziq194", .bakerName = "StakeNow"}, + {.bakerAccount = "tz1c3Wh8gNMMsYwZd67JndQpYxdaaPUV27E7", .bakerName = "TezosBC"}, + {.bakerAccount = "tz1Xek93iSXXckyQ6aYLVS5Rr2tge2en7ZxS", .bakerName = "XTZ Delegate"}, + {.bakerAccount = "tz1Ldzz6k1BHdhuKvAtMRX7h5kJSMHESMHLC", .bakerName = "PayTezos"}, + {.bakerAccount = "tz3adcvQaKXTCg12zbninqo3q8ptKKtDFTLv", .bakerName = "Tezzigator"}, + {.bakerAccount = "tz1d6Fx42mYgVFnHUW8T8A7WBfJ6nD9pVok8", .bakerName = "My Tezos Baking"}, + {.bakerAccount = "tz1aqcYgG6NuViML5vdWhohHJBYxcDVLNUsE", .bakerName = "LetzBake!"}, + {.bakerAccount = "tz1KksC8RvjUWAbXYJuNrUbontHGor26Cztk", .bakerName = "Bakednode"}, + {.bakerAccount = "tz1W5VkdB5s7ENMESVBtwyt9kyvLqPcUczRT", .bakerName = "Tezgate"}, + {.bakerAccount = "tz1cYufsxHXJcvANhvS55h3aY32a9BAFB494", .bakerName = "BAKER-IL"}, + {.bakerAccount = "tz1MDKr36woXfVtrtXfV1ppPJERxPcm2wU6V", .bakerName = "Stack Tezos"}, + {.bakerAccount = "tz2FCNBrERXtaTtNX6iimR1UJ5JSDxvdHM93", .bakerName = "Stake.fish"}, + {.bakerAccount = "tz1MXFrtZoaXckE41bjUCSjAjAap3AFDSr3N", .bakerName = "Everstake Legacy"}, + {.bakerAccount = "tz1XhnCdVENzgko5x1MMswLHSoQbJ5NPwLZ6", .bakerName = "Anonstake"}, + {.bakerAccount = "tz2PdGc7U5tiyqPgTSgqCDct94qd6ovQwP6u", .bakerName = "Tezos Capital"}, + {.bakerAccount = "tz1KtvGSYU5hdKD288a1koTBURWYuADJGrLE", .bakerName = "Ø Crypto Pool"}, + {.bakerAccount = "tz1ei4WtWEMEJekSv8qDnu9PExG6Q8HgRGr3", .bakerName = "Bake Tz"}, + {.bakerAccount = "tz1TcH4Nb3aHNDJ7CGZhU7jgAK1BkSP4Lxds", .bakerName = "XTZ Antipodes"}, + {.bakerAccount = "tz1fZ767VDbqx4DeKiFswPSHh513f51mKEUZ", .bakerName = "Tezos Bakery"}, + {.bakerAccount = "tz1SohptP53wDPZhzTWzDUFAUcWF6DMBpaJV", .bakerName = "Hayek Lab"}, + {.bakerAccount = "tz1go7f6mEQfT2xX2LuHAqgnRGN6c2zHPf5c", .bakerName = "Stakery"}, + {.bakerAccount = "tz1NpWrAyDL9k2Lmnyxcgr9xuJakbBxdq7FB", .bakerName = "Gate.io"}, + {.bakerAccount = "tz1NRGxXV9h6SdNaZLcgmjuLx3hyy2f8YoGN", .bakerName = "Bake ꜩ For Me"}, + {.bakerAccount = "tz1cb8xcmJWcdVU7cNAd93MfEReorvP52P8x", .bakerName = "Mint Capital"}, + {.bakerAccount = "tz1MQJPGNMijnXnVoBENFz9rUhaPt3S7rWoz", .bakerName = "Tezmania"}, + {.bakerAccount = "tz1Z1tMai15JWUWeN2PKL9faXXVPMuWamzJj", .bakerName = "XTZ Land"}, + {.bakerAccount = "tz1YKh8T79LAtWxX29N5VedCSmaZGw9LNVxQ", .bakerName = "TezosBr"}, + {.bakerAccount = "tz1S1Aew75hMrPUymqenKfHo8FspppXKpW7h", .bakerName = "Tezos Mars"}, + {.bakerAccount = "tz1aiYKXmSRckyJ9EybKmpVry373rfyngJU8", .bakerName = "View Nodes"}, + {.bakerAccount = "tz1Kf25fX1VdmYGSEzwFy1wNmkbSEZ2V83sY", .bakerName = "Tezos Seoul"}, + {.bakerAccount = "tz1MJx9vhaNRSimcuXPK2rW4fLccQnDAnVKJ", .bakerName = "AirGap"}, + {.bakerAccount = "tz1b9MYGrbN1NAxphLEsPPNT9JC7aNFc5nA4", .bakerName = "TezosRUs"}, + {.bakerAccount = "tz1bLwpPfr3xqy1gWBF4sGvv8bLJyPHR11kx", .bakerName = "Tezos Hot Bakery"}, + {.bakerAccount = "tz1LLNkQK4UQV6QcFShiXJ2vT2ELw449MzAA", .bakerName = "TezoSteam"}, + {.bakerAccount = "tz1hThMBD8jQjFt78heuCnKxJnJtQo9Ao25X", .bakerName = "Tezos Chef"}, + {.bakerAccount = "tz1bkg7rynMXVcjomoe3diB4URfv8GU2GAcw", .bakerName = "Tz Bank"}, + {.bakerAccount = "tz1KzSC1J9aBxKp7u8TUnpN8L7S65PBRkgdF", .bakerName = "HashQuark"}, + {.bakerAccount = "tz1iMAHAVpkCVegF9FLGWUpQQeiAHh4ffdLQ", .bakerName = "Wetez"}, + {.bakerAccount = "tz1YhNsiRRU8aHNGg7NK3uuP6UDAyacJernB", .bakerName = "Tez Baguette"}, + {.bakerAccount = "tz1bkKTY9Y3rTsHbpr2fbGUCRm736LLquQfM", .bakerName = "Tezos Tacos"}, + {.bakerAccount = "tz1cX93Q3KsiTADpCC4f12TBvAmS5tw7CW19", .bakerName = "Tz Bakery"}, + {.bakerAccount = "tz1Lhf4J9Qxoe3DZ2nfe8FGDnvVj7oKjnMY6", .bakerName = "Tez Baker"}, + {.bakerAccount = "tz1KfEsrtDaA1sX7vdM4qmEPWuSytuqCDp5j", .bakerName = "XTZ Master"}, + {.bakerAccount = "tz1Pwgj6j55akKCyvTwwr9X4np1RskSXpQY4", .bakerName = "Validators.com"}, + {.bakerAccount = "tz1aKxnrzx5PXZJe7unufEswVRCMU9yafmfb", .bakerName = "Tezos Canada"}, + {.bakerAccount = "tz1X1fpAZtwQk94QXUgZwfgsvkQgyc2KHp9d", .bakerName = "ownBLOCK (OLD)"}, + {.bakerAccount = "tz1PWCDnz783NNGGQjEFFsHtrcK5yBW4E2rm", .bakerName = "Melange"}, + {.bakerAccount = "tz1gk3TDbU7cJuiBRMhwQXVvgDnjsxuWhcEA", .bakerName = "Airfoil"}, + {.bakerAccount = "tz1P9GwUWeAyPoT3ZwBc6gWCTP9exEPaVU3w", .bakerName = "XTZ Bakery I"}, + {.bakerAccount = "tz1iZEKy4LaAjnTmn2RuGDf2iqdAQKnRi8kY", .bakerName = "Tezzigator Legacy"}, + {.bakerAccount = "tz1TaLYBeGZD3yKVHQGBM857CcNnFFNceLYh", .bakerName = "Tezocracy"}, + {.bakerAccount = "tz1c7pVR4w3KSQarJdBeh4NS2WxMUFBy1rHQ", .bakerName = "MyBakerSpace"}, + {.bakerAccount = "tz1W1f1JrE7VsqgpUpj1iiDobqP5TixgZhDk", .bakerName = "Elite Tezos"}, + {.bakerAccount = "tz1fUjvVhJrHLZCbhPNvDRckxApqbkievJHN", .bakerName = "Tezzieland"}, + {.bakerAccount = "tz1Z7bxn1M4ewEWUekPaZfiwtKQRFroezUjY", .bakerName = "Tezos Bay"}, + {.bakerAccount = "tz1WBfwbT66FC6BTLexc2BoyCCBM9LG7pnVW", .bakerName = "888 XTZ"}, + {.bakerAccount = "tz1eEnQhbwf6trb8Q8mPb2RaPkNk2rN7BKi8", .bakerName = "Cryptium Labs"}, + {.bakerAccount = "tz1RCFbB9GpALpsZtu6J58sb74dm8qe6XBzv", .bakerName = "Staked"}, + {.bakerAccount = "tz1Lc87p6zRaDwzJs9kHvdpm7XzeWE8QTwVB", .bakerName = "Dash Master"}, + {.bakerAccount = "tz1fb7c66UwePkkfDXz4ajFaBP9hVNLdS7JJ", .bakerName = "Tezos.nu"}, + {.bakerAccount = "tz1b7YSEeNRqgmjuX4d4aiai2sQTF4A7WBZf", .bakerName = "Tezos Japan"}, + {.bakerAccount = "tz1LmaFsWRkjr7QMCx5PtV6xTUz3AmEpKQiF", .bakerName = "Blockpower"}, + {.bakerAccount = "tz1UUgPwikRHW1mEyVZfGYy6QaxrY6Y7WaG5", .bakerName = "Tez Patisserie"}, + {.bakerAccount = "tz1Zhv3RkfU2pHrmaiDyxp7kFZpZrUCu1CiF", .bakerName = "TZ Bake"}, + {.bakerAccount = "tz1irJKkXS2DBWkU1NnmFQx1c1L7pbGg4yhk", .bakerName = "Coinbase Custody"}, + {.bakerAccount = "tz1R6Ej25VSerE3MkSoEEeBjKHCDTFbpKuSX", .bakerName = "TezosSEAsia"}, + {.bakerAccount = "tz1dhwJY5B1jKdkF7zcyu1v6EBEQjpGmAp1E", .bakerName = "Tezzz"}, + {.bakerAccount = "tz1Zcxkfa5jKrRbBThG765GP29bUCU3C4ok5", .bakerName = "Tezz City"}, + {.bakerAccount = "tz1VYQpZvjVhv1CdcENuCNWJQXu1TWBJ8KTD", .bakerName = "Tezos Tokyo"}, + {.bakerAccount = "tz1bakeKFwqmtLBzghw8CFnqFvRxLj849Vfg", .bakerName = "Tez Milk"}, + {.bakerAccount = "tz1YdCPrYbksK7HCoYKDyzgfXwY16Fy9rrGa", .bakerName = "Norn Delegate"}, + {.bakerAccount = "tz1PeZx7FXy7QRuMREGXGxeipb24RsMMzUNe", .bakerName = "Tezos Panda"}, + {.bakerAccount = "tz1fvBC1cHJzPtUW3ZKd2GZDj7P4XVuLk9vW", .bakerName = "Steaker"}, + {.bakerAccount = "tz1Vtimi84kLh9RANfRVX2JvYtP4NPCT1aFm", .bakerName = "TezTech Labs"}, + {.bakerAccount = "tz1QLXqnfN51dkjeghXvKHkJfhvGiM5gK4tc", .bakerName = "Fresh Tezos"}, + {.bakerAccount = "tz1ZuxNqUk7odhMC4Bfx2NXXeej9ReXKewa8", .bakerName = "SNZ Holding"}, + {.bakerAccount = "tz1UJvHTgpVzcKWhTazGxVcn5wsHru5Gietg", .bakerName = "Tezry"}, + {.bakerAccount = "tz3bEQoFCZEEfZMskefZ8q8e4eiHH1pssRax", .bakerName = "Ceibo XTZ"}, + {.bakerAccount = "tz1VHFxUuBhwopxC9YC9gm5s2MHBHLyCtvN1", .bakerName = "Hyperblocks"}, + {.bakerAccount = "tz1SYq214SCBy9naR6cvycQsYcUGpBqQAE8d", .bakerName = "Coinone"}, + {.bakerAccount = "tz1V2FYediKBAEaTpXXJBSjuQpjkyCzrTSiE", .bakerName = "Stake House"}, + {.bakerAccount = "tz1bRaSjKZrSrSeQHBDiCqjKXqtZYZM1t8FW", .bakerName = "Imma Baker"}, + {.bakerAccount = "tz1Vyuu4EJ5Nym4JcrfRLnp3hpaq1DSEp1Ke", .bakerName = "POS Bakerz"}, + {.bakerAccount = "tz1hAYfexyzPGG6RhZZMpDvAHifubsbb6kgn", .bakerName = "Tezos Suisse"}, + {.bakerAccount = "tz1RV1MBbZMR68tacosb7Mwj6LkbPSUS1er1", .bakerName = "Baking Tacos"}, + {.bakerAccount = "tz1gg5bjopPcr9agjamyu9BbXKLibNc2rbAq", .bakerName = "Hodl.farm"}, + {.bakerAccount = "tz1djEKk6j1FqigTgbRsunbnY9BB7qsn1aAQ", .bakerName = "Tezos Ninja"}, + {.bakerAccount = "tz1coHzgoQYRu1Ezn5QChfFEjwTrBzGNQT6U", .bakerName = "Clutch Oven"}, + {.bakerAccount = "tz1VceyYUpq1gk5dtp6jXQRtCtY8hm5DKt72", .bakerName = "Tezetetic"}, + {.bakerAccount = "tz1bHzftcTKZMTZgLLtnrXydCm6UEqf4ivca", .bakerName = "Tezos Vote"}, + {.bakerAccount = "tz1LBEKXaxQbd5Gtzbc1ATCwc3pppu81aWGc", .bakerName = "Tez-Baking"}, + {.bakerAccount = "tz1TnYeuR4HhUTapQiXvzcjmcpvZYwR1B5S3", .bakerName = "XTZ Bakery II"}, + {.bakerAccount = "tz1iJ4qgGTzyhaYEzd1RnC6duEkLBd1nzexh", .bakerName = "Tz Envoy"}, + {.bakerAccount = "tz1Nn14BBsDULrPXtkM9UQeXaE4iqJhmqmK5", .bakerName = "Tezos Kitchen"}, + {.bakerAccount = "tz1V4qCyvPKZ5UeqdH14HN42rxvNPQfc9UZg", .bakerName = "Shake 'n Bake"}, + {.bakerAccount = "tz1LH4L6XYT2JNPhvWYC4Zq3XEiGgEwzNRvo", .bakerName = "Stir Delegate"}, + {.bakerAccount = "tz1Z3KCf8CLGAYfvVWPEr562jDDyWkwNF7sT", .bakerName = "Stake Capital"}, + {.bakerAccount = "tz1Scdr2HsZiQjc7bHMeBbmDRXYVvdhjJbBh", .bakerName = "Chorus One - 2"}, + {.bakerAccount = "tz1isXamBXpTUgbByQ6gXgZQg4GWNW7r6rKE", .bakerName = "TEZWHALE"}, + {.bakerAccount = "tz1egbN6RK2bM5vt4aAZw6r9j4nL8z49bPdS", + .bakerName = "Money every 3 days (OLD)"}, + {.bakerAccount = "tz1NEKxGEHsFufk87CVZcrqWu8o22qh46GK6", .bakerName = "Money every 3 days"}, + {.bakerAccount = "tz1aEsrxrhTYNcg897HjSWnJ5yjR95pxVD1d", .bakerName = "mamabaker"}, + {.bakerAccount = "tz1V3yg82mcrPJbegqVCPn6bC8w1CSTRp3f8", .bakerName = "TezoShop"}, + {.bakerAccount = "tz1RSWMYKGAykpizFteowByYMueCYv9TMn1L", .bakerName = "Tezos Alliance"}, + {.bakerAccount = "tz1dbfppLAAxXZNtf2SDps7rch3qfUznKSoK", + .bakerName = "Coinhouse Staking Services"}, + {.bakerAccount = "tz1dNVDWPf3Q59SdJqnjdnu277iyvReiRS9M", .bakerName = "Steak.and.Bake"}, + {.bakerAccount = "tz1UdeKoMJivgqRgRUNzroMwRJYmJY8BtaWe", .bakerName = "AlphaTezos"}, + {.bakerAccount = "tz1ijdEfmUoQXJfSiKCLRioeCfSrKP3sVsff", .bakerName = "Tezos Japan"}, + {.bakerAccount = "tz1hgjLqCZWCtarByUMYd81F4FKRY5t1V978", .bakerName = "Tez Dispensery"}, + {.bakerAccount = "tz1ZcTRk5uxD86EFEn1vvNffWWqJy7q5eVhc", .bakerName = "Ateza"}, + {.bakerAccount = "tz1Q8QkSBS63ZQnH3fBTiAMPes9R666Rn6Sc", .bakerName = "YieldWallet.io"}, + {.bakerAccount = "tz1STeamwbp68THcny9zk3LsbG3H36DMvbRK", .bakerName = "Staking Team"}, + {.bakerAccount = "tz1MWhSr4oT8W67CKdxduqp4bkVyF32qsERK", .bakerName = "Morpheus Tezos"}, + {.bakerAccount = "tz1fJHFn6sWEd3NnBPngACuw2dggTv6nQZ7g", .bakerName = "Baking Team"}, + {.bakerAccount = "tz1aRoaRhSpRYvFdyvgWLL6TGyRoGF51wDjM", .bakerName = "Everstake"}, + {.bakerAccount = "tz1NEKxGEHsFufk87CVZcrqWu8o22qh46GK6", .bakerName = "Money Every 3 Days"}, + {.bakerAccount = "tz3e7LbZvUtoXhpUD1yb6wuFodZpfYRb9nWJ", .bakerName = "Eco Tez"}, + {.bakerAccount = "tz3LV9aGKHDnAZHCtC9SjNtTrKRu678FqSki", .bakerName = "Ledger Live by Kiln"}, +}; diff --git a/src/globals.h b/src/globals.h index 0ff19f72..b4bd4ee3 100644 --- a/src/globals.h +++ b/src/globals.h @@ -106,7 +106,7 @@ typedef struct { blake2b_hash_state_t hash_state; ///< current blake2b hash state uint8_t final_hash[SIGN_HASH_SIZE]; ///< buffer to hold hash of all the message - uint8_t magic_byte; ///< current magic byte read + magic_byte_t magic_byte; ///< current magic byte read struct parse_state parse_state; ///< current parser state } apdu_sign_state_t; diff --git a/src/types.h b/src/types.h index e10e1600..f0ea63eb 100644 --- a/src/types.h +++ b/src/types.h @@ -68,6 +68,17 @@ typedef enum { BAKING_TYPE_PREATTESTATION } baking_type_t; +/** + * @brief magic byte of operations + * See: https://tezos.gitlab.io/user/key-management.html#signer-requests + */ +typedef enum { + MAGIC_BYTE_UNSAFE_OP = 0x03u, /// magic byte of an operation + MAGIC_BYTE_BLOCK = 0x11u, /// magic byte of a block + MAGIC_BYTE_PREATTESTATION = 0x12u, /// magic byte of a pre-attestation + MAGIC_BYTE_ATTESTATION = 0x13u, /// magic byte of an attestation +} magic_byte_t; + typedef uint32_t level_t; typedef uint32_t round_t;