id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-encryption > apcsaEncryptFindPrivateKey
prev  |  next  |  chance

Given a public key exponent and the "totient," the result of multiplying (prime1-1)*(prime2-1) from the two primes used to create the public key, discover the private key exponent. The private key is the smallest number x such that (publicKey * x) % totient == 1.


The public key exponent is available to anyone, as is the modulus (prime1*prime2), but the totient number is kept secret as are the two primes themselves.

This problem is based on, and helps to construct, the simplified public key encryption algorithm found at https://en.wikibooks.org/wiki/Cryptography/A_Basic_Public_Key_Example

apcsaEncryptFindPrivateKey(7, 12) → 7
apcsaEncryptFindPrivateKey(7, 24) → 7
apcsaEncryptFindPrivateKey(3, 40) → 27

...Save, Compile, Run (ctrl-enter)

public int apcsaEncryptFindPrivateKey(int publicKey, int totient) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 320

Copyright Nick Parlante 2017 - privacy