Q4 8 points] Let G(s)l-(ls) for some t. Consider the following experiment: The P
ID: 3757240 • Letter: Q
Question
Q4 8 points] Let G(s)l-(ls) for some t. Consider the following experiment: The PRG indistinguishability experiment PRGA,G(n): (a) A uniform bit b {0, 1} is chosen. If b = 0 then choose a uniform r {0,1}en), if b-1 then choose a uniform s 0,1) and set r: G(s). (b) The adversary A is given r, and outputs a bit b'. (c) The output of the experiment is defined to be 1 f b b, and 0 otherwise. Provide a definition of a pseudorandom generator based on this experiment, and prove that your definition is equivalent to the definition discussed in class (See slide titled Pseudo Random Number Generator: Definition) (That is, show that G satisfies your definition if and only if it satisfies the definition discussed in the class.)Explanation / Answer
As per the question given, we need output as r belongs to {0,1}^l(n) when b=0 and s belongs to {0,1}^n when b=1 and set r:=G(s)
I am writing C code for the problem, please try to understand the code written below and try to debug if found any error else provide feedback:
a.)
#include<stdio.h>
int s_functio(int r, int G,int i);
int r_function();
int adversary_function(int x, int A[30],int i, int r)
int main()
{
int b,r,s,i,n,k,r;
int G[30],L[30]; //Arrays containing desired values
printf(" Please enter the number of elements in G(s) : ");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&G[i]);
printf(" Please enter the number of elements in L(s): ");
scanf("%d",&k);
for(i=0;i<k;i++)
scanf("%d",&L[i]);
printf(" Please enter the |b| value either 0 or 1: ");
scanf("%d",&x);
if(x!=0)// if b=1 thne it will return function s
{
return s_Function;
}
else //if b=0 then it will return r_function
{
return r_function;
}
return adversary_function();
return 0;
}
int s_function(int r, int G, int i)
{
printf(" The function |s| belongs to {0,1}^n ");
r=0; //initialize r as 0
for(i=0;i<n;i++)
r=r+G[i]; //r is set to equal G(s)
return 0;
}
int r_function( )
{
printf(" The function |r| belongs to {0,1}^L(s) ");
return 0;
}
int adversary_function(int x, int A[30],int i, int r)
{
for(i=0;i<r;i++)
{
r=r+A[i];
printf(" Value is b' ");
}
if(x!=0)
{
printf(" |b'| is %d ",x);
}
else
{
printf(" Exp output is 0 ");
}
return 0;
}
//Do not forget to Thumbs up. Comment if you need any help. Thank you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.