Encryption Valididy
Reported by candidates from Goldman Sachs's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're looking at a Goldman Sachs August 2023 OA question on encryption validity. The setup sounds like a crypto thought experiment, but it's actually a math problem. You're given an attacker's processing power (keys tested per second), the total key space, and a validity period. Your job is to determine whether an encryption scheme can protect data long enough before the attacker cracks it. This is a straightforward comparison: if the time to brute-force exceeds the validity period, the encryption holds. If not, it fails. StealthCoder can spot the pattern instantly if you freeze up, but the logic is clean once you see it.
The problem
Encryption is the process of converting information algorithmically so that a valid recipient can read the information before it is no longer a valuable secret. This is its validity period. An attacker has limited processing power and can only test a certain number of keys per second. This is the instruction count. The size of the universe of keys divided by the instruction count gives the average time to find a message key. To achieve a balance between the processing power for encryption/ decryption and the strength of the encryption, the validity period of the message must be taken into consideration. Given the number of keys, a hijacker can test per second, determine if the encrypted information should remain confidential throughout its validity period. Each test will return two items of information as integers: The strength of the encryption is determined as follows: Function Description Complete the function encryptionValidity. encryptionValidity has the following parameter(s):
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern here is math with a timing element. You'll get the key space size and the attacker's processing speed (instructions per second). Divide key space by speed to get average crack time. Compare that against the validity period. If crack time greater than or equal to validity period, return true (valid encryption). Otherwise, false. The trap candidates hit: integer overflow with large key spaces, or confusing whether it's average time or worst-case time. The problem statement hints average. Another gotcha: reading the parameter names wrong and swapping which value is which. Walk through the sample data methodically, not fast. StealthCoder provides the formula instantly if you blank on the math setup.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Encryption Valididy cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Goldman Sachs's OA.
Goldman Sachs reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Encryption Valididy FAQ
Is this a string manipulation problem or a math problem?+
Pure math. No string parsing or encryption algorithms. You're comparing numbers: time-to-crack versus validity-period. The encryption story is window dressing. Focus on the numerical comparison and you're done.
What's the trick with large numbers?+
Integer overflow. The key space can be very large. Depending on your language, use 64-bit integers or BigInteger. Do the division carefully. Some languages will silently wrap; others won't. Test with the examples first to catch this.
Do I need to round the crack time up or down?+
The problem says average time, not worst-case. Exact rounding usually doesn't matter because the test cases are clear-cut. But read the expected return type carefully: boolean, integer, or float. Adjust your comparison logic accordingly.
How much time do I have to solve this?+
Not specified in the problem text, but Goldman Sachs OAs typically allow 30-45 minutes per question. This one is short. You should write, test, and verify in under 10 minutes if you understand the logic.
Is validity period in seconds, or can it be other units?+
The problem doesn't specify units, only that it's compared to average crack time. Assume both are in the same unit (likely seconds). The exact unit doesn't matter as long as you're consistent. Read the parameter descriptions carefully in the full problem.