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:
Java Program to do a Breadth First Search/Traversal on a graph non-recursively
Recommended Package Structure of a Spring Boot Project
Adding a Newline Character to a String in Java
Spring Boot - Tomcat Port Number
Jackson Date
Java Program to Implement First Fit Decreasing for 1-D Objects and M Bins
Java Program to Implement Jarvis Algorithm
Inheritance with Jackson
HttpClient with SSL
Sử dụng CountDownLatch trong Java
Java Program to Implement Hash Tree
Hướng dẫn sử dụng Java Annotation
Lớp Collections trong Java (Collections Utility Class)
Java Program to Implement WeakHashMap API
Java Program to Implement Binomial Tree
Java Program to Implement the Hill Cypher
TreeSet và sử dụng Comparable, Comparator trong java
REST Web service: Upload và Download file với Jersey 2.x
Debug a JavaMail Program
Java Program to Perform Searching Based on Locality of Reference
A Guide to the ResourceBundle
Java – String to Reader
Java Program to Check Whether Topological Sorting can be Performed in a Graph
Assertions in JUnit 4 and JUnit 5
Java Program to Implement Range Tree
Java Program to implement Sparse Vector
Java Program to implement Associate Array
Java 8 Stream findFirst() vs. findAny()
Java Program to Find SSSP (Single Source Shortest Path) in DAG (Directed Acyclic Graphs)
Java Program to Implement Uniform-Cost Search
Java Program to Implement Max-Flow Min-Cut Theorem
Java Program to Implement Sparse Array