Unique, Pseudo Random Numbers

Slides:



Advertisements
Similar presentations
Euclidean Algorithm Applied Symbolic Computation CS 567 Jeremy Johnson.
Advertisements

BCH Codes Hsin-Lung Wu NTPU.
Generating Random Numbers
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
CSC2110 Discrete Mathematics Tutorial 5 GCD and Modular Arithmetic
The Algebra of Encryption CS 6910 Semester Research and Project University of Colorado at Colorado Springs By Cliff McCullough 20 July 2011.
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Improving performance of Multiple Sequence Alignment in Multi-client Environments Aaron Zollman CMSC 838 Presentation.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
BY MISS FARAH ADIBAH ADNAN IMK
Mathematics of Cryptography Part I: Modular Arithmetic
MATH 224 – Discrete Mathematics
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
Mathematics of Cryptography Modular Arithmetic, Congruence,
10.2 – Arithmetic Sequences and Series. An introduction … describe the pattern Arithmetic Sequences ADD To get next term Geometric Sequences MULTIPLY.
Written by Margo Seltzer Presented by Mark Simko.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
1 Wenguang WangRichard B. Bunt Department of Computer Science University of Saskatchewan November 14, 2000 Simulating DB2 Buffer Pool Management.
Michael Still Google Inc. October, Managing Unix servers the slack way Tools and techniques for managing large numbers of Unix machines Michael.
Math 3121 Abstract Algebra I Lecture 9 Finish Section 10 Section 11.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Rational Numbers and Fields
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
Cryptography and Network Security Chapter 4. Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
CS480 Cryptography and Information Security Huiping Guo Department of Computer Science California State University, Los Angeles 3. Mathematics of Cryptography.
CS480 Cryptography and Information Security
Discrete Math II Howon Kim
Mathematical Background for Cryptography: Modular arithmetic and gcd
Greatest Common Divisor
B504/I538: Introduction to Cryptography
Greatest Common Divisor
Mathematics of Cryptography
Cryptography and Information Security
Query Performance Tuning: Start to Finish
CS 2210:0001Discrete Structures Modular Arithmetic and Cryptography
FIRST REVIEW.
Did your feature got in, out or planned?
Cryptology Design Fundamentals
Cryptology Design Fundamentals
CSE 311 Foundations of Computing I
Multiplication Inverse
Number Theory (Chapter 7)
Introducing the SQL Server 2016 Query Store
Chapter 1: Introduction to Computers and Programming
Random numbers Taken from notes by Dr. Neil Moore
Modular Arithmetic II Lecture 10: Oct 6.
Mathematics Common Math Approaches
Section 6.4 Multiplicative Inverses of Matices and Matrix Equations
Inverse Wavelet Transform
CS 240 – Lecture 9 Bit Shift Operations, Assignment Expressions, Modulo Operator, Converting Numeric Types to Strings.
SharePoint data access and LINQ to SharePoint
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
刘振 上海交通大学 计算机科学与工程系 电信群楼3-509
Lecture 2 – Monte Carlo method in finance
or: How I Learned to Stop Using EXECUTE AS and Love Certificates
CS Introduction to Operating Systems
Parallel Analytic Systems
In Memory OLTP Not Just for OLTP.
༂རཱི⿻⍰〄ポשׁ⍰ꬤᆱ◬Ꮡ⯑☠o̐̈́̈́̈́͢ㅴ
Section 9.4 Multiplicative Inverses of Matices and Matrix Equations
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Copyright © Zeph Grunschlag,
Microsoft Azure for SQL Server Professionals
Modular Inverses Recall the simple encryption function
Cryptography Lecture 19.
Presentation transcript:

Unique, Pseudo Random Numbers Generate without using RAM, Disk, CPU, I/O, or even time  Version: 1.1 (20170619)

C:\> whoami Working in IT and with databases since 1996 SQL Server since 2002 SQLCLR since 2006 Variety of Roles, OSes, Languages, and DBs Articles: SQL Server Central (incl. Stairway to SQLCLR series) Simple-Talk Founder of Sql Quantum Lift: SQL# (SQLsharp) : SQLCLR library of functions OmniExec : Multi-threaded, multi-server & DB query tool �

Agenda Why? What is Random? Randomization Options Unique-“Random” Options The Maths The Code The Examples

Why? Hide “ID” values from external uses Cryptography: Mathematics of Cryptography ( http://highered.mheducation.com/sites/dl/free/0072870222/385983/ch02.pdf ) Generating test data “Shuffle” finite data set Cool party trick / impress others 😎 ????

What is Random? Unpredictable order? Unique? Both? If unique is required, need to give up “pure” unpredictability Similar to NoSQL vs ACID-compliant SQL

Randomization Options RAND(seed) NEWID() CRYPT_GEN_RANDOM(length) CRYPT_GEN_RANDOM(length, seed)

( http://pastebin.com/vuK1Aiiv ) (example code) Randomizing Tests UniquePseudoRandomNumbers_01_RandomizingTests.sql ( http://pastebin.com/vuK1Aiiv )

Unique-“Random” Options Pre-generate list Can have no pattern Requires lots of memory and/or disk Requires lots of I/O Pseudo-random Uses very little RAM, Disk, or I/O Pattern, but not discernible

The Maths Modular multiplicative inverse ( https://en.wikipedia.org/wiki/Modular_multiplicative_inverse ) Bézout's identity ( https://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity ) Extended Euclidean algorithm ( https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm ) Greatest common divisor ( https://en.wikipedia.org/wiki/Greatest_common_divisor )

( http://pastebin.com/edit/n6k8DeyC ) (example code) Create Objects UniquePseudoRandomNumbers_02_CreateObjects.sql ( http://pastebin.com/edit/n6k8DeyC )

How to Use Pick upper limit (this will be the Modulo) Try GCD until = 1 (this will be the "base" value) Find MMI with Modulo and Base value Encode with Modulo and base value If / when necessary, decode with Modulo and MMI

(example code) Multiplicative Inverse Tests UniquePseudoRandomNumbers_03_MultiplicativeInverseTests.sql ( http://pastebin.com/7u2NzYtd )

Also See Generate different random time in the given interval ( https://stackoverflow.com/a/27826049/577765 ) Generating a random, non-repeating sequence of all integers in .NET ( https://stackoverflow.com/a/35103941/577765 ) Khan Academy: Modular inverses ( https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/modular-inverses ) Algorithm in many languages: http://rosettacode.org/wiki/Modular_inverse Online Calculator: http://planetcalc.com/3311/ Eric Lippert: A practical use of multiplicative inverses ( https://ericlippert.com/2013/11/14/a-practical-use-of-multiplicative-inverses/ ) generate seemingly random unique numeric ID in SQL Server ( https://stackoverflow.com/q/26967215/577765 )

Hiding in Plain Sight Blog Articles SQLsharp.com http://www.SqlQuantumLeap.com/ Articles http://www.SqlServerCentral.com/Authors/Articles/Solomon_Rutzky/294002/ http://www.SqlServerCentral.com/stairway/105855/ ( Stairway to SQLCLR ) https://www.Simple-Talk.com/author/solomon-rutzky/ SQLsharp.com http://www.SQLsharp.com/ StackOverflow.com & DBA.StackExchange.com https://StackExchange.com/users/281451/srutzky LinkedIn http://www.LinkedIn.com/in/srutzky/ Contact: SRutzky@gmail.com