From 6ceeb199181d64031f4173cfbffa066f5b9796b8 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 10 Sep 2017 22:12:47 -0400 Subject: Added identifying hash to Pokémon data structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose of this hash is described in detail in pokemon.h. The hash is computed using an implementation of SHA-224. To allow the GBA sufficient time to compute this hash, a delay of 5 milliseconds was introduced on the GC side before reading a Pokémon. --- include/pokemon.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/pokemon.h b/include/pokemon.h index d8a7265..bd311c4 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -20,8 +20,23 @@ enum PokemonLanguage { Spanish = 7 }; -struct PokemonIntermediate { - u32 otId; +struct __attribute__((aligned(4))) PokemonIntermediate { + // a hash that can be used to identify the Pokémon. because the games do not + // naturally generate unique identifiers for Pokémon, this hash is generated + // from parts of the Pokémon's data that are guaranteed never to change. the + // parts used are the trainer ID and secret ID of the Pokémon's original + // trainer, the personality value, and the IVs. almost all of this data is + // secret, and should not be derivable from the identifier, which is why the + // identifier is hashed. while this identifier is not guaranteed to be unique, + // probability of collision is astronomically small given that the + // personality value and IVs provide essentially 52 bits of randomness + // (technically less because the IVs of bred Pokémon are not uniformly + // random, but this variation is statistically insignificant). the OT ID, + // while not uniformly random (amongst Pokémon), is included as a sort of + // "namespace", in that any Pokémon with matching PVs and IVs must also have + // the same OT, thus preventing collaboratively finding PV and IV collisions. + u32 key[7]; + u32 experience; // the stats are calculated from the base stats, IVs, EVs, and Nature, before @@ -36,6 +51,7 @@ struct PokemonIntermediate { u16 species; u16 heldItem; u16 moves[4]; + u16 otId; // only the lower 2 bytes, because the upper 2 are secret u8 ppBonuses; u8 otGender:1; -- cgit 1.4.1