From 8d9df7cc26ef86c7af1d4aa6fd4633667bb3a743 Mon Sep 17 00:00:00 2001
From: Kelly Rauchenberger <fefferburbia@gmail.com>
Date: Sun, 24 Sep 2017 19:54:16 -0400
Subject: Fixed Shedinja hash collision
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A Shedinja will always have the same IVs, personality value, and
original trainer as the Nincada that generated it, meaning that it is
guaranteed to have the same hash as the Ninjask that the Nincada evolved
into. To cirvument this, there is now a boolean field in the hash
determiner that is set if and only if the Pokémon is a Shedinja. This
allows the Ninjask to be considered the same Pokémon as the Nincada it
evolved from, but for the Shedinja to be considered a new Pokémon.

Because the hash determiner has changed, all old hashes are now invalid.
---
 include/pokemon.h | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'include')

diff --git a/include/pokemon.h b/include/pokemon.h
index 95af35e..dbf0d41 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -35,6 +35,13 @@ struct __attribute__((aligned(4))) PokemonIntermediate {
   // 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.
+  // there is one deterministic way that two Pokémon can have the same hash:
+  // when a Nincada evolves into a Ninjask and a Shedinja is generated, the
+  // Shedinja is guaranteed to have the same IVs and personality value as the
+  // Ninjask. we circumvent this by also including a boolean in the hash which
+  // is set to true if the Pokémon is a Shedinja, and false otherwise. this
+  // differentiates a Shedinja from the Ninjask it came from, but also allows
+  // the Ninjask to be associated with the Nincada it used to be.
   u32 key[7];
 
   u32 experience;
-- 
cgit 1.4.1