This is a java program generate pseudo-random numbers using Naor-Reingold Pseudo-Random function. Let p and l be prime numbers with l |p-1. Select an element g in Fp of multiplicative order l. Then for each n-dimensional vector a = (a1, …, an). Fa(x) = g^(a1^x1 * a2^x2 …).
Here is the source code of the Java Program to Implement Naor-Reingold Pseudo Random Function. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is a java program to generate a random numbers using Naor-Reingold Psedurandom Function import java.util.Random; public class Naor_Reingold { public static void main(String args[]) { int p=7, l=3, g=2, n=4, x; int []a = {1,2,2,1}; int []bin = new int[4]; Random random = new Random(); System.out.println("The Random numbers are: "); for(int i=0; i<10; i++) { x = random.nextInt(17); for(int j=3; j>=0; j--) { bin[j] = x%2; x/=2; } int mul = 1; for(int k=0; k<4; k++) mul *= Math.pow(a[k], bin[k]); System.out.println(Math.pow(g, mul)); } } }
Output:
$ javac Naor_Reingold.java $ java Naor_Reingold The Random numbers are: 2.0 4.0 2.0 2.0 2.0 16.0 4.0 16.0 16.0 4.0
Related posts:
Changing Annotation Parameters At Runtime
Quick Intro to Spring Cloud Configuration
Guide to Dynamic Tests in Junit 5
Logging a Reactive Sequence
New in Spring Security OAuth2 – Verify Claims
Spring Boot - Application Properties
Java Program to Implement Knapsack Algorithm
Transactions with Spring and JPA
ExecutorService – Waiting for Threads to Finish
Most commonly used String methods in Java
Java Program to Implement the Binary Counting Method to Generate Subsets of a Set
OAuth 2.0 Resource Server With Spring Security 5
Java – File to Reader
Spring Boot Configuration with Jasypt
Simplify the DAO with Spring and Java Generics
Java Program to Implement Double Ended Queue
Java Program to Perform Preorder Recursive Traversal of a Given Binary Tree
Java – Combine Multiple Collections
Java Program to Generate Date Between Given Range
Spring Security Logout
Giới thiệu Google Guice – Dependency injection (DI) framework
Java Program to Implement wheel Sieve to Generate Prime Numbers Between Given Range
Guava – Join and Split Collections
Multipart Upload with HttpClient 4
Deploy a Spring Boot WAR into a Tomcat Server
Java Program to Perform LU Decomposition of any Matrix
Deploy a Spring Boot App to Azure
Guide to the Java TransferQueue
Java Program to Generate a Random Subset by Coin Flipping
Java Program to Implement ConcurrentSkipListMap API
Converting Between an Array and a Set in Java
Java Program to Create a Minimal Set of All Edges Whose Addition will Convert it to a Strongly Conne...