-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday25.html
91 lines (88 loc) · 8.34 KB
/
day25.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<html>
<head>
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="../assets/application.css" />
<link rel="stylesheet" type="text/css" href="../assets/easter-egg.css" />
<link rel="shortcut icon" href="../assets/favicon.png" />
</head>
<body>
<header>
<div>
<h1 class="title-global"><a href="https://adventofcode.com/2020" target="_blank">Advent of Code</a></h1>
<div class="user">John Dugan</div>
</div>
<div>
<h1 class="title-event"> <span class="title-event-wrap">{year=></span><a href="https://adventofcode.com/2020" target="_blank">2020</a><span class="title-event-wrap">}</span></h1>
<nav>
<ul>
<li><a href="index.html">[Calendar]</a></li>
<li><a href="https://adventofcode.com/2020/leaderboard/private/view/251766" target="_blank">[Memphis]</a></li>
<li><a href="https://adventofcode.com/2020/leaderboard/private/view/371961" target="_blank">[Oslo]</a></li>
<li><a href="https://adventofcode.com/2020/leaderboard/self" target="_blank">[Personal Stats]</a></li>
<li><a href="https://adventofcode.com/2020/stats" target="_blank">[Stats]</a></li>
</ul>
</nav>
</div>
</header>
<main>
<article class="day-desc">
<h2>--- Day 25: Combo Breaker ---</h2>
<p>You finally reach the check-in desk. Unfortunately, their registration systems are currently offline, and they cannot check you in. Noticing the look on your face, they quickly add that tech support is already on the way! They even created
all the room keys this morning; you can take yours now and give them your room deposit once the registration system comes back online.</p>
<p>The room key is a small <a href="https://en.wikipedia.org/wiki/Radio-frequency_identification" target="_blank">RFID</a> card. Your room is on the 25th floor and the elevators are also temporarily out of service, so it takes what little
energy you have left to even climb the stairs and navigate the halls. You finally reach the door to your room, swipe your card, and - <em>beep</em> - the light turns red.</p>
<p>Examining the card more closely, you discover a phone number for tech support.</p>
<p>"Hello! How can we help you today?" You explain the situation.</p>
<p>"Well, it sounds like the card isn't sending the right command to unlock the door. If you go back to the check-in desk, surely someone there can reset it for you." Still catching your breath, you describe the status of the elevator and the
exact number of stairs you just had to climb.</p>
<p>"I see! Well, your only other option would be to reverse-engineer the cryptographic handshake the card does with the door and then inject your own commands into the data stream, but that's definitely impossible." You thank them for their
time.</p>
<p>Unfortunately for the door, you know a thing or two about cryptographic handshakes.</p>
<p>The handshake used by the card and the door involves an operation that <em>transforms</em> a <em>subject number</em>. To transform a subject number, start with the value <code>1</code>. Then, a number of times called the <em>loop size</em>,
perform the following steps:</p>
<ul>
<li>Set the value to itself multiplied by the <em>subject number</em>.</li>
<li>Set the value to the remainder after dividing the value by <em><code>20201227</code></em>.</li>
</ul>
<p>The card always uses a specific, secret <em>loop size</em> when it transforms a subject number. The door always uses a different, secret loop size.</p>
<p>The cryptographic handshake works like this:</p>
<ul>
<li>The <em>card</em> transforms the subject number of <em><code>7</code></em> according to the <em>card's</em> secret loop size. The result is called the <em>card's public key</em>.</li>
<li>The <em>door</em> transforms the subject number of <em><code>7</code></em> according to the <em>door's</em> secret loop size. The result is called the <em>door's public key</em>.</li>
<li>The card and door use the wireless RFID signal to transmit the two public keys (your puzzle input) to the other device. Now, the <em>card</em> has the <em>door's</em> public key, and the <em>door</em> has the <em>card's</em> public key.
Because you can eavesdrop on the signal, you have both public keys, but neither device's loop size.</li>
<li>The <em>card</em> transforms the subject number of <em>the door's public key</em> according to the <em>card's</em> loop size. The result is the <em>encryption key</em>.</li>
<li>The <em>door</em> transforms the subject number of <em>the card's public key</em> according to the <em>door's</em> loop size. The result is the same <em>encryption key</em> as the <em>card</em> calculated.</li>
</ul>
<p>If you can use the two public keys to determine each device's loop size, you will have enough information to calculate the secret <em>encryption key</em> that the card and door use to communicate; this would let you send the <code>unlock</code>
command directly to the door!</p>
<p>For example, suppose you know that the card's public key is <code>5764801</code>. With a little trial and error, you can work out that the card's loop size must be <em><code>8</code></em>, because transforming the initial subject number of
<code>7</code> with a loop size of <code>8</code> produces <code>5764801</code>.</p>
<p>Then, suppose you know that the door's public key is <code>17807724</code>. By the same process, you can determine that the door's loop size is <em><code>11</code></em>, because transforming the initial subject number of <code>7</code> with
a loop size of <code>11</code> produces <code>17807724</code>.</p>
<p>At this point, you can use either device's loop size with the other device's public key to calculate the <em>encryption key</em>. Transforming the subject number of <code>17807724</code> (the door's public key) with a loop size of <code>8</code>
(the card's loop size) produces the encryption key, <em><code>14897079</code></em>. (Transforming the subject number of <code>5764801</code> (the card's public key) with a loop size of <code>11</code> (the door's loop size) produces the same
encryption key: <em><code>14897079</code></em>.)</p>
<p><em>What encryption key is the handshake trying to establish?</em></p>
</article>
<p>Your puzzle answer was <code>1478097</code>.</p>
<article class="day-desc">
<h2 id="part2">--- Part Two ---</h2>
<p><span title="You notice the brand written on the side of the lock: Diffie, Hellman, and Merkle.">The light turns green and the door unlocks.</span> As you collapse onto the bed in your room, your pager goes off!</p>
<p>"It's an emergency!" the Elf calling you explains. "The <a href="https://en.wikipedia.org/wiki/Soft_serve" target="_blank">soft serve</a> machine in the cafeteria on sub-basement 7 just failed and you're the only one that knows how to fix
it! We've already dispatched a reindeer to your location to pick you up."</p>
<p>You hear the sound of hooves landing on your balcony.</p>
<p>The reindeer carefully explores the contents of your room while you figure out how you're going to pay the <em class="star">50 stars</em> you owe the resort before you leave. Noticing that you look concerned, the reindeer wanders over to
you; you see that it's carrying a small pouch.</p>
<p>"Sorry for the trouble," a note in the pouch reads. Sitting at the bottom of the pouch is a gold coin with a little picture of a starfish on it.</p>
<p>Looks like you only needed <em class="star">49 stars</em> after all.</p>
</article>
<form method="post" action="25/answer"><input type="hidden" name="level" value="2" /><input type="hidden" name="answer" value="0" />
<p>If you like, you can <input type="submit" value="[Check On Your Deposit]" />.</p>
</form>
<p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
<p>At this point, all that is left is for you to <a href="index.html">admire your Advent calendar</a>.</p>
<p>If you still want to see it, you can <a href="../data/day25/input.txt" target="_blank">get your puzzle input</a>.</p>
</main>
</body>
</html>