Pseudorandom Number Generator (PRNG)

Neso Academy
4 Oct 202311:36

Summary

TLDRThis presentation delves into the concept of pseudo random number generators (PRNGs), emphasizing their importance in generating sequences that appear random but are deterministic. It explains that true randomness can only be found in the physical world, whereas PRNGs produce predictable, repeatable sequences. The session covers how PRNGs are used in stream ciphers for secure communication, with Alice and Bob exemplifying the process of encryption and decryption using a shared key or seed. The lecture also touches on the theoretical aspects of stream ciphers and the Shannon notion of perfect secrecy, highlighting the practical challenges of achieving true randomness and the role of pseudo randomness in enhancing security.

Takeaways

  • πŸ”‘ The presentation discusses the concept of Pseudo Random Number Generators (PRNGs) and their importance in generating random sequences.
  • πŸ“š By the end of the session, learners will understand the necessity of pseudo random sequences and how they are generated using PRNGs.
  • 🌱 A keystream generator is introduced as a device that takes a seed or key to produce a sequence of bits, which are expected to be random in nature.
  • 🎲 The script clarifies that true randomness can only be achieved through physical phenomena, such as natural fluctuations or noise, which are unpredictable and non-deterministic.
  • πŸ’» In contrast, PRNGs generate numbers that are deterministic and predictable, hence they produce pseudo-randomness rather than true randomness.
  • πŸ”„ Pseudo-randomness is characterized by repeating patterns after a certain period, which distinguishes it from true randomness.
  • πŸ”‘ The size of the key or seed used in the keystream generator affects the length and quality of the pseudo-random sequence generated.
  • πŸ” The script uses the example of a stream cipher to illustrate how Alice and Bob can use a PRNG to securely exchange messages, with the key being the output from the keystream generator.
  • πŸ”’ For secure communication, both sender and receiver must use the same seed or key to ensure they generate the same pseudo-random sequence.
  • 🎯 The script emphasizes the theoretical aspects of stream ciphers and the conditions under which a sequence can be considered truly random, highlighting the impracticality of generating truly random sequences with machines.
  • πŸ“ˆ The concept of perfect secrecy, as per Shannon's notion, is tied to the use of one-time pads, which rely on truly random sequences for maximum security.

Q & A

  • What is the main focus of the presentation?

    -The presentation focuses on the concept of the Pseudo Random Number Generator (PRNG), explaining its necessity and how it generates pseudo random numbers.

  • What are the two main outcomes the learner is expected to achieve after the session?

    -The learner will understand the need for having a pseudo random sequence and will know how pseudo random numbers can be generated using a PRNG.

  • What is a keystream generator and what role does it play in generating pseudo random numbers?

    -A keystream generator is an algorithm that takes a seed or key as input and generates a sequence of bits that are expected to be random in nature, which are used as a keystream.

  • Why are the numbers generated by a keystream generator not truly random?

    -The numbers generated by a keystream generator are not truly random because they are predictable and deterministic, unlike the non-deterministic randomness found in the physical world.

  • How can truly random numbers be generated?

    -Truly random numbers can be generated by measuring random fluctuations or noise in the physical world, such as from a tree, forest, sky, or the universe.

  • What is the difference between truly random and pseudo random numbers?

    -Truly random numbers are unpredictable and non-deterministic, generated by natural phenomena, while pseudo random numbers are generated by algorithms and are deterministic and repeatable.

  • Why is the size of the key or seed important in PRNGs?

    -The size of the key or seed is important because it affects the length and quality of the pseudo random sequence generated. A larger key size results in a longer and more complex sequence.

  • What is a stream cipher and how does it relate to PRNGs?

    -A stream cipher is a method of encryption where a pseudo random binary sequence (generated by a PRNG) is combined with plaintext to produce ciphertext, ensuring security in communication.

  • Can you explain the process of encryption and decryption using a stream cipher?

    -In encryption, plaintext bits are XORed with pseudo random keystream bits to produce ciphertext. In decryption, the ciphertext is XORed with the same keystream to retrieve the original plaintext.

  • What is the significance of the one-time pad in the context of PRNGs?

    -The one-time pad is a theoretical encryption technique where a truly random key is used only once. It is considered to provide perfect secrecy, but in practice, PRNGs are used to approximate this level of security.

  • How can the randomness of a sequence generated by a PRNG be measured?

    -The randomness of a sequence can be measured by assessing its unpredictability, lack of pattern, and the equal probability of zeros and ones. This will be covered in more detail in a subsequent lecture.

  • What is the practical implication of using pseudo random numbers in security?

    -Pseudo random numbers are used to achieve security by creating a level of unpredictability that is close to true randomness. This helps protect against certain types of attacks and ensures the confidentiality of communications.

Outlines

00:00

πŸ” Introduction to Pseudo Random Number Generators

This paragraph introduces the concept of Pseudo Random Number Generators (PRNGs) and sets the stage for the session's learning outcomes. It explains that by the end of the session, learners will understand the necessity of pseudo random sequences and learn how to generate pseudo random numbers using PRNGs. The paragraph begins with an example of a keystream generator, which takes a seed or key to produce a sequence of bits that appear random but are not truly so, as they are predictable and deterministic. The distinction between true randomness found in the physical world and pseudo randomness generated by machines is highlighted, emphasizing the need for pseudo randomness in achieving perfect secrecy in cryptographic applications.

05:00

πŸ”‘ Stream Ciphers and Pseudo Randomness in Cryptography

This paragraph delves into the practical application of pseudo randomness in stream ciphers, a cryptographic method where a plaintext is combined with a keystream to produce ciphertext. It describes the process where Alice, as the sender, uses a keystream generator with a given seed to create a ciphertext stream, which she then sends to Bob. Bob, upon receiving the ciphertext, uses the same keystream generator with the same seed to regenerate the keystream and decrypt the message back to plaintext. The paragraph underscores the importance of both parties having the same seed to ensure the security of the communication. It also touches on the theoretical aspects of stream ciphers, the concept of perfect secrecy as per Shannon's notion, and the difference between truly random and pseudo random sequences in achieving this level of security.

10:01

πŸ“Š Measuring Pseudo Randomness and Achieving Security

In this final paragraph, the focus shifts to the measurement of randomness and the role of pseudo random number generators in ensuring security. It raises the question of how to confirm the completeness of randomness in a sequence generated by a PRNG. The paragraph concludes the session by summarizing the importance of pseudo random sequences in achieving security and the mutual agreement on a common key or seed between the sender and receiver. It also reiterates the inevitability of randomness in security, as per Shannon's notion of perfect secrecy, and leaves the audience with the understanding that while true randomness may be impractical, a good pseudo random sequence can be close enough for effective security measures.

Mindmap

Keywords

πŸ’‘Pseudo Random Number Generator (PRNG)

A Pseudo Random Number Generator (PRNG) is an algorithm that produces a sequence of numbers that approximate the properties of random numbers, but are actually deterministic. In the context of the video, PRNGs are used to generate sequences that, while not truly random, are sufficiently unpredictable for various applications, including security and cryptography. The script discusses the importance of PRNGs in creating pseudo random sequences for achieving security, emphasizing that while they are not truly random, they are close enough for practical purposes.

πŸ’‘Randomness

Randomness refers to the lack of pattern or predictability in events. In the video, true randomness is contrasted with pseudo randomness. True randomness is found in the physical world, where events are non-deterministic and unpredictable, such as fluctuations in nature. Pseudo randomness, on the other hand, is generated by machines and algorithms and can be predictable. The script explains that while true randomness is desirable for perfect secrecy in cryptography, pseudo randomness is often used because it is practical and can be made to appear sufficiently random for most applications.

πŸ’‘Keystream Generator

A keystream generator is a component of a stream cipher that generates a keystream, which is a sequence of bits used to encrypt data. In the video, the keystream generator is described as taking a seed or key as input and producing a sequence of bits that are expected to be random. However, since this randomness is generated by a deterministic machine, it is actually pseudo random. The script uses the keystream generator to illustrate how pseudo random sequences are created and used in encryption.

πŸ’‘Seed

In the context of PRNGs and keystream generators, a seed is an initial value provided as input to the algorithm to produce a sequence of numbers. The script mentions that the seed is used to initiate the keystream generator, which then produces a sequence of bits that appear random. The importance of the seed is highlighted in ensuring that the same sequence can be regenerated by both the sender and receiver when using a stream cipher for secure communication.

πŸ’‘Stream Cipher

A stream cipher is a method of encryption where plaintext bits are combined with a pseudo random keystream bit-by-bit to produce ciphertext. The video explains that stream ciphers use a keystream generator to create a sequence of bits that are XORed with plaintext bits to generate ciphertext. The security of the cipher depends on the unpredictability of the keystream, which is why PRNGs and the concept of pseudo randomness are crucial.

πŸ’‘XOR Operation

The XOR (exclusive OR) operation is a binary operation used in the context of the video to combine bits from the plaintext and the keystream to produce ciphertext. The script describes how Alice uses the XOR operation to encrypt her message by combining plaintext bits with keystream bits generated by the keystream generator. Bob can then decrypt the message by applying the XOR operation again using the same keystream, demonstrating the importance of the shared seed or key for secure communication.

πŸ’‘Perfect Secrecy

Perfect secrecy is a concept in cryptography where the ciphertext provides no information about the plaintext to an unauthorized party. The video references the notion of perfect secrecy by Shannon and explains that it can be achieved with a one-time pad, which uses a truly random keystream that is as long as the message itself. The script contrasts this with pseudo random sequences, which are used in practice because generating truly random sequences is impractical.

πŸ’‘One-Time Pad

A one-time pad is a type of encryption technique that is theoretically unbreakable if used correctly. The video explains that a one-time pad uses a truly random key that is as long as the message and is used only once. The script mentions that when a truly random keystream is used in a stream cipher, it can achieve perfect secrecy, which is the ideal scenario in cryptography.

πŸ’‘Ciphertext

Ciphertext is the result of encrypting plaintext using an encryption algorithm. In the video, ciphertext is generated by Alice through the XOR operation between her plaintext bits and the keystream bits produced by the keystream generator. The script illustrates that the ciphertext is then sent to Bob, who uses the same keystream generator with the same seed to decrypt the message back into plaintext.

πŸ’‘Plaintext

Plaintext refers to the original message or data before it has been encrypted. The video script describes how Alice has a plaintext message that she wishes to send securely to Bob. She encrypts this plaintext using a keystream generated by a PRNG to produce ciphertext. The plaintext is then securely transmitted, and Bob is able to decrypt it back into its original form using the same keystream sequence.

Highlights

The presentation focuses on the concept and application of Pseudo Random Number Generators (PRNGs).

Learners will understand the necessity of pseudo random sequences and how they are generated by PRNGs.

A keystream generator is introduced as a device that produces a sequence of bits from a given seed or key.

The generated keystream is expected to be random but is not truly random due to its predictability.

Truly random numbers can only be obtained from the physical world's random fluctuations.

Pseudo randomness is defined as a sequence that repeats itself after a certain period.

The size of the key or seed influences the length and quality of the pseudo random sequence.

Stream ciphers use keystream generators to produce sequences expected to be random but are actually pseudo random.

Alice and Bob are used as examples to demonstrate the use of stream ciphers in secure communication.

The importance of both sender and receiver knowing the same seed for generating the same pseudo random sequence is emphasized.

The concept of perfect secrecy in cryptography is linked to the use of truly random sequences.

A one-time pad, which uses truly random sequences, is mentioned as an example of perfect secrecy.

The impracticality of generating truly random sequences from machines is discussed.

The expectation that a good stream cipher should closely approximate true randomness for better security is highlighted.

The theoretical aspects of stream ciphers, including the probability of zeros and ones being equal, are covered.

The session concludes with the understanding that pseudo random sequences are essential for security and achieving the notion of perfect secrecy.

Transcripts

play00:06

hello everyone welcome back in this

play00:08

presentation we are going to focus on

play00:11

the pseudo random number generator P RNG

play00:14

let's start the session with the

play00:16

outcomes upon the completion of the

play00:18

session the learner will be able to

play00:20

outcome number one we will understand

play00:22

the need for having Pudo random sequence

play00:25

and outcome number two we will know how

play00:27

pseudo random numbers can be generated

play00:29

using pseudo random number generator

play00:32

let's dive into the topic of the day the

play00:34

pseudo random number generator before

play00:37

understanding about Randomness let's

play00:39

take a scenario let's say there is a

play00:42

keystream generator where this keystream

play00:44

generator is going to Generate random

play00:47

numbers for example if we are giving an

play00:50

input this input that we are giving to

play00:52

the keystream generator is referred as a

play00:55

seed or key let's assume this is a key

play00:58

that is given as an input to to this

play01:00

keystream generator now what the

play01:02

keystream generator is going to do it is

play01:04

going to generate a key stream now what

play01:07

this key stream is going to contain this

play01:10

key stream is going to generate a

play01:12

sequence of bits obviously they are

play01:14

going to be zeros and once now what has

play01:17

actually happened is the keyst stream

play01:19

generator has taken a key or a seed and

play01:22

it has generated a sequence of bids

play01:25

which are expected to be random in

play01:28

nature I'll put my question this way is

play01:31

it truly random I mean is the numbers

play01:33

are completely random for this the

play01:36

answer is no because only physical world

play01:40

can have complete Randomness or truly

play01:42

Randomness say if you take an entity in

play01:45

the physical world it may be a tree or

play01:48

forest or sky or universe or whatever

play01:50

entity you want to take but take the

play01:53

example from the physical world only in

play01:55

physical world we can witness random

play01:57

fluctuations everywhere and we can

play02:00

generate truly random numbers by

play02:02

measuring these random fluctuations

play02:04

known as noise when we sample this noise

play02:07

then we can get some numbers and these

play02:10

numbers are truly random why because the

play02:13

next value will be unpredictable because

play02:16

this Randomness that is generated by the

play02:18

physical world is

play02:20

non-deterministic the next value or the

play02:22

next move is unpredictable and that is

play02:25

why we refer this Randomness that is

play02:27

generated by the physical world is not

play02:29

deterministic and it is truly random but

play02:33

this key stream generator that we are

play02:35

talking about in computers they are

play02:37

actually generated by machines and the

play02:40

numbers or random numbers that are

play02:41

generated by this machines or the

play02:43

keystream generator performed by the

play02:45

machine they are predictable and they

play02:48

are deterministic we need truly random

play02:51

numbers in order to achieve perfect

play02:53

secrecy isn't it now it's clear that

play02:56

what we generate from the machines are

play02:58

not truly random then then what kind of

play03:00

Randomness it is it should be close

play03:02

enough to the truly Randomness then we

play03:04

call it as pseudo Randomness because

play03:07

this Randomness will be repeating itself

play03:09

there will be a period the length of the

play03:12

randomness will be repeated for example

play03:14

if we have 1,000 bits that are random

play03:17

and if the next 1,000 bits are the same

play03:20

as that of the previous 1,000 bits then

play03:22

it means the randomness is repeated and

play03:25

we cannot call this as truly random and

play03:28

we need to call it as Pudo random

play03:30

so what we understood from this is that

play03:32

when we input a seed or a key then this

play03:35

is accepted by the keyst stream

play03:36

generator and it produces a key stream

play03:38

which is expected to be random to be

play03:41

precise they are pseudo random now how

play03:44

far they are random it is actually

play03:46

depending on the size of the key if you

play03:48

give a bigger key size or a larger key

play03:51

size then the randomness is also a

play03:53

larger Randomness the larger the key

play03:55

size or the seed size the randomness

play03:57

will be larger let's see the the

play03:59

theoretical aspects now basically we are

play04:02

talking about stream ciphers basically

play04:05

it's going to contain a binary sequence

play04:07

which contain zeros and ones so we are

play04:09

talking about stream Cipher in stream

play04:12

Cipher we are going to use the key

play04:14

stream generator and what this keyst

play04:16

stream generator is going to do that's

play04:18

what we have seen previously it's going

play04:20

to take a key or a seed as an input and

play04:22

it is going to generate a sequence of

play04:24

output which is expected to be random

play04:27

but is it truly random no we cannot say

play04:30

that it will be a truly random sequence

play04:32

because there will be repetion of the

play04:34

sequence and that is why we cannot

play04:37

guarantee that the key stream that is

play04:38

generated by the machines are truly

play04:41

random then what kind of Randomness it

play04:43

is it is pseudo random we will

play04:46

understand things with an example let's

play04:48

bring in our popular characters let's

play04:50

say we have Alice here and we have Bob

play04:53

here now what Alice and Bob are going to

play04:55

do is that they are going to use a

play04:58

stream Cipher and they they are going to

play05:00

exchange the messages obviously if it is

play05:02

a stream Cipher then exort operation is

play05:04

going to be carried out and they will

play05:06

have the plain text which is exal with

play05:08

the key and we get the cipher text now

play05:11

what is the key here the key is the

play05:13

output they get from the keyst stream

play05:15

generator what we have discussed

play05:16

recently let's say Alice is actually

play05:19

wanted to send Cipher text to Bob

play05:21

because she doesn't want to send the

play05:22

plain text so what she is doing is that

play05:25

she's taking the plain text sequence

play05:27

let's say X1 X2 X3 X for all these are

play05:31

bits this may be 0 1 0 1 1 0 1 1 so some

play05:35

sequence of zeros and ones as the

play05:37

playing text now what she's going to do

play05:39

is she's going to generate the key

play05:41

stream how she will be doing that she

play05:43

will be taking a keyst stream generator

play05:46

she will be giving the input seed to the

play05:48

keystream generator and that keystream

play05:50

generator will be giving the random

play05:52

sequence now all the random sequence

play05:54

bits are placed here and she's going to

play05:56

perform an exort operation between X1

play05:59

and and K1 the exor between X1 and K1

play06:02

will be y1 this is a binary bit likewise

play06:05

when she performs the exor operation for

play06:07

all the BDS she will be getting a

play06:09

sequence of bits which we call as the

play06:11

cipher text stream now this Cipher text

play06:14

stream is actually generated by Alys and

play06:16

it is then given to Bob now how Bob will

play06:19

get the plain text back now Bob is going

play06:22

to adopt the same method he's also

play06:24

bringing the same keystream generator

play06:26

that was used by Alice and Bob needs to

play06:29

give the same key or the seed that Alice

play06:31

has fed into the machine in order to

play06:33

generate this sequence this K1 K2 K3

play06:36

isn't it so please be noted that Bob is

play06:39

using the same Key Street generator he's

play06:41

going to give the same input key or the

play06:44

seed what Alice has given in order to

play06:46

generate the same sequence because he

play06:48

also needs the same sequence in order to

play06:50

get the playing text back how Bob will

play06:53

be getting the playing text he received

play06:55

the cipher text stream isn't it so y1 Y2

play06:57

Y3 up to YN he he has received all the

play07:00

cipher text streams he is going to

play07:02

generate the key streams with the help

play07:03

of the key stream generator by inputting

play07:05

the seed or the key the same key which

play07:07

is used by both Alice and Bob and he

play07:10

will be getting the playing text back

play07:12

how a simple Exar operation again

play07:15

because when you exert the cipher text

play07:17

with the keyst stream it gives back the

play07:18

playing text isn't it so this is

play07:21

actually now done by Bob now Bob is able

play07:24

to generate the playing text back even

play07:26

though we are using the randomness as

play07:28

the key this is Possible only when the

play07:31

input key or the seed is known to both

play07:33

Alice and Bob when the input or seed is

play07:36

given to the key stream generator it

play07:38

gives the same random sequence and this

play07:41

random sequence cannot be truly random

play07:43

it is pseudo random because this random

play07:46

sequence will be repeatable after the

play07:48

period ends so the next period will be

play07:51

having the same set of sequence as the

play07:53

previous period let's come to the

play07:55

theoretical points what operation we did

play07:58

previously we are taking making the

play07:59

plain text bit XI this XI is exor with

play08:03

the keystream bit Ki in order to

play08:05

generate the cipher text bit Yi so what

play08:08

happened in the encryption the xib bit

play08:11

is exort with the Ki bit in order to

play08:13

generate Yi and what is the decryption

play08:15

part we will be getting XI by merely

play08:18

exhorting this Yi with the keybard Ki

play08:21

when we generate this key stream which

play08:23

is non repeatable then only we will call

play08:26

this Ki as a truly random bit when we

play08:30

have such kind of truly random sequence

play08:32

in our algorithm then this kind of

play08:34

stream Cipher is referred to as a

play08:36

onetime pad which is referred to as

play08:39

perfect secrecy I hope you can recollect

play08:41

the things which we have dealt in the

play08:43

chapter one the shenon notion of perfect

play08:46

secrecy and this one time pad that what

play08:48

we are getting using this kind of

play08:50

algorithm is referred as perfect secrecy

play08:53

but remember in reality we need to

play08:55

understand whether what we are getting

play08:57

is truly random or pseudo random random

play09:00

let's see the theoretical points now so

play09:02

we have already seen about the stream

play09:04

Cipher the key stream generator and the

play09:06

truly random sequence when we will call

play09:09

this as a truly random sequence

play09:10

obviously we are going to have only two

play09:12

bits in our sequence one is zero and

play09:14

other one is one so the probability of

play09:17

the number of zeros is equal to the

play09:19

probability of number of ones so this

play09:21

should be one of the important criterias

play09:23

for being a truly random sequence

play09:26

because the number of zeros and number

play09:27

of ones are used equally

play09:29

at the same time when we have such

play09:31

concept then our algorithm is actually

play09:34

following the shanon's notion of perfect

play09:37

secrecy but do you think it is

play09:39

practically possible to generate a truly

play09:41

random sequence generating a truly

play09:43

random sequence is Impractical we are

play09:46

getting this Randomness from machines

play09:48

where machines are predictable and

play09:50

deterministic we want truly random

play09:52

sequence but we are ending up with the

play09:54

pseudo random sequence but what we

play09:56

expect is this pseudo random sequence or

play09:59

a good stream Cipher should be close to

play10:01

the truly random sequence though we are

play10:03

not able to get the exact truly random

play10:06

sequence so when we get such kind of

play10:08

Randomness then this is good enough for

play10:10

achieving better security let's say we

play10:13

have generated a random sequence through

play10:15

a pseudo random generator now the

play10:17

important question is how to measure

play10:19

this Randomness how to confirm that

play10:21

there is complete Randomness with the

play10:23

sequence that we have obtained from the

play10:25

pseudo random number generator so that's

play10:27

what we are going to see in the next

play10:29

lecture so anyway from this lecture we

play10:31

understood that pseudo random number

play10:33

generator generates a random sequence

play10:36

and this is going to be used for

play10:38

achieving security and this pseudo

play10:40

random number generator is going to be

play10:42

used by both sender and the receiver the

play10:44

only thing is they need to mutually

play10:46

agree upon the common key or the seed

play10:49

only when they use the same seed they

play10:51

will be getting the same random sequence

play10:54

and also we confirmed that Randomness is

play10:57

inevitable as far as security is

play10:59

concerned in order to achieve the

play11:01

shanon's notion of perfect secrecy no

play11:03

other goal we need Randomness but the

play11:06

thing is whether it is truly random or

play11:08

pseudo random and that's it guys I hope

play11:12

now you understood the need for having

play11:13

pseudo random sequence and we also have

play11:16

come to know how pseudo random numbers

play11:18

can be generated using pseudo random

play11:20

number generator I hope the session is

play11:22

informative and thank you for

play11:25

[Music]

play11:25

[Applause]

play11:27

watching

play11:36

[Music]

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Pseudo RNGCryptographic SecurityRandomnessKeystream GeneratorStream CipherPerfect SecrecyShannon NotionEncryptionDecryptionOne-Time Pad