# The sage example in Crypto (Stallings)

When I doing the exercise of the textbook in Append -C I confront a question, it says " Write a function that takes a bitlength n and generates a modulus N of bitlength n and g less than N and relatively prime to it. "

I am confused about the meaning

does is mean that I have to use the bitlength n and generate the modulus N? ( len(bin(n)) % N)?

edit retag close merge delete

Could you give the precise reference of the exercise in appendix C ?

( 2013-05-11 08:18:47 -0500 )edit

I got it... exercise 11.1 in the 5th edition.

( 2013-05-11 08:22:29 -0500 )edit

Sort by ยป oldest newest most voted

You need to output a couple (N,g) where N is an integer whose bitlength is n (in other words it has n digits in base 2) and g is an integer relatively prime to N. I guess that your N should be a product of two primes p and q as in the description above. You may use the function random_prime of Sage for that purpose.

I confess that I do not understand this first question as it is not used in the next items...

more