SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
Relations, Functions, and Matrices




                    Mathematical
                    Structures for
                  Computer Science
                               Chapter 4




    Section 4.5 © 2006 W.H. Freeman & Co.
     Copyright                               MSCS Slides
   
                                                            The Mighty Mod Function Mod Function
                                                                         The Mighty
Wednesday, March 24, 2010
The Mighty Mod Function
        ●     We define the modulo n function as follows:
              If x = qn + r, 0 ≤ r ≤ n, then x mod n = r.
        ●     In other words, x mod n is the nonnegative remainder
              (also called the residue of x modulo n) when x is
              divided by the positive integer n.




    Section 4.5                      The Mighty Mod Function         2
Wednesday, March 24, 2010
Hashing
        ●     A hash function h: S → T, where the domain S is a set
              of text strings or integer values and the codomain T is
              the set of integers {0, 1, … , t − 1}, where t is some
              relatively small positive integer.
        ●     If the domain S consists of text strings, we can
              imagine them encoded in some way into integer
              values.
        ●     For example, an algorithm as simple as converting
              each individual letter of a text string into its position
              in the alphabet and adding up the resulting list.
        ●     The function h therefore maps a potentially large set
              of values S into a relatively small window of integer
              values T. Consequently h isn’t likely to be a one-to-
              one function.
    Section 4.5                       The Mighty Mod Function         3
Wednesday, March 24, 2010
Hashing
        ●     A hash function is often used as part of a search algorithm.
        ●     In a search using a hash function, n elements are stored in an
              array (a one-dimensional table) called a hash table, where the
              array is indexed from 0 through t − 1; the table is of size t.
        ●     The element x is passed as the argument to the hash function,
              and the resulting h(x) value gives the array index at which the
              element is then stored.
        ●     Later, when a search is carried out, the target value is run
              through the same hash function, giving an index location in the
              hash table, which is where to look for the matching stored
              element.




    Section 4.5                          The Mighty Mod Function                4
Wednesday, March 24, 2010
Hashing
        ●     However, because the hash function is not one-to-one,
              things are not quite that simple.
        ●     Different values may hash to the same array index,
              producing a collision.
        ●     Here are several collision resolution algorithms
              available. One is called linear probing.
                  ■
                      Keep going in the array and store element x in the next
                      available empty slot.
        ●     Another method, called chaining, builds a linked list
              for each array index.




    Section 4.5                            The Mighty Mod Function              5
Wednesday, March 24, 2010
Hashing
        ●         The following are the desirable properties of a hash
                  function:
                  1.   Given an argument value x, h(x) can be computed
                       quickly.
                  2.   The number of collisions will be reduced because h(x)
                       does a good job of distributing values throughout the
                       hash table.
        ●         Use of a modulo function as the hash function
                  accomplishes goal 1.
        ●         Goal 2 is harder to achieve, but distribution seems to
                  work better on the average if the table size (the
                  modulo value) is a prime number.


    Section 4.5                           The Mighty Mod Function          6
Wednesday, March 24, 2010
Hashing
        ●     The average number of comparisons required to
              search for an element using hashing depends on the
              ratio of n to the total table size t.
        ●     If this ratio is low, then (using linear probing) there
              are lots of empty slots, so you won’t have to look very
              far to find a place to insert a new element into the
              table.
        ●     If this ratio is low and chaining is used, the average
              length of any linked list you may have to
              (sequentially) search for a target element should be
              short.
        ●     This ratio n/t is called the load factor of the hash
              table.

    Section 4.5                      The Mighty Mod Function        7
Wednesday, March 24, 2010
Computer Security
        ●     The mod function plays a part in many aspects of
              security.
        ●     Military information, financial information, and
              company proprietary information that must be
              transmitted securely uses some encoding/decoding
              scheme.
        ●     The original information (called the plaintext) is
              encrypted using an encryption key, resulting in coded
              text called the ciphertext.
        ●     The ciphertext is transmitted, and when it is received,
              it can be decoded using the corresponding decryption
              key. Encryption and decryption are inverse functions
              in the sense that:
                  ■
                      decryption(encryption(plaintext)) = plaintext
    Section 4.5                            The Mighty Mod Function      8
Wednesday, March 24, 2010
Computer Security
        ●     Cryptography is the study of various encryption/
              decryption schemes.
        ●     Military use of cryptographic techniques can be traced
              back to Julius Caesar, who sent messages to his
              generals in the field using a scheme now known as the
              Caesar cipher.
        ●     Let us assume that plaintext messages use only the 26
              capital letters of the alphabet, that spaces between
              words are suppressed, and that each letter is first
              mapped to its corresponding position in the alphabet.




    Section 4.5                     The Mighty Mod Function        9
Wednesday, March 24, 2010
Computer Security
        ●     We’ll denote this mapping as the bijection g: {A, … ,
              Z} → {0, … , 25}.
        ●     Then a positive integer key value k is chosen that
              shifts each number k positions to the right with a
              “wrap-around” back to the beginning if needed (this is
              the mod function).
        ●     Finally, the function g−1 is applied to translate the
              resulting number back into a letter.
        ●     The encoding function is given by:
                  ■
                      f(p) = g−1([g(p) + k] mod 26)
        ●     The decoding function is:
                  ■   f −1(c) = g−1([g(c) − k] mod 26)


    Section 4.5                              The Mighty Mod Function   10
Wednesday, March 24, 2010
Computer Security
        ●     The Caesar cipher is a simple substitution cipher,
              meaning that each plaintext character is coded
              consistently into the same single ciphertext character.
        ●     Encryption techniques where a single plaintext
              character contributes to several ciphertext characters
              introduce diffusion. The advantage to diffusion is that
              it hides the frequency statistics of individual letters,
              making analysis of an intercepted ciphertext message
              much more difficult.
        ●     DES (Data Encryption Standard) is an
              internationally standard encryption algorithm
              developed in 1976. DES was developed to safeguard
              the security of digital information, so we may consider
              the plaintext to be a string of bits.

    Section 4.5                      The Mighty Mod Function         11
Wednesday, March 24, 2010
Computer Security
        ●     DES is a block cipher.
        ●     A block of 64 plaintext bits is encoded as a unit using
              a 56-bit key.
        ●     This results in a block of 64 ciphertext bits.
        ●     Changing one bit in the plaintext or one bit in the key
              changes about half the resulting 64 ciphertext bits, so
              DES exhibits high diffusion.
        ●     Because the DES algorithm is well known, the only
              “secret” part is the 56-bit key that is used.




    Section 4.5                      The Mighty Mod Function        12
Wednesday, March 24, 2010
Computer Security
        ●     AES (Advanced Encryption Standard) is also a
              block encryption scheme, but it uses a key length of
              128 bits or more.
        ●     AES also uses a form of the Euclidean algorithm.
        ●     Disadvantage of both DES and AES is that they are
              symmetric encryption (also called private key
              encryption) schemes. The same key is used to both
              encode and decode the message.
        ●     In a private key encryption scheme, both the sender
              and receiver must know the key. The problem of
              securely transmitting a message turns into the problem
              of securely transmitting the key to be used for the
              encryption and decryption.

    Section 4.5                     The Mighty Mod Function        13
Wednesday, March 24, 2010
Computer Security
        ●    Asymmetric encryption (public key encryption)
             schemes use different keys for encoding and decoding.
        ●    The decryption key cannot be derived in any practical
             way from the encryption key, so the encryption key
             can be made public.
        ●    Anyone can send a message to the intended receiver in
             encrypted form using the receiver’s public key, but
             only the intended receiver, who has the decryption key,
             can decode it.
        ●    The best-known asymmetric encryption scheme is the
             RSA public key encryption algorithm.



    Section 4.5                     The Mighty Mod Function        14
Wednesday, March 24, 2010
Hashing for Password Encryption

        ●     A cryptographic hash function is a form of
              encryption that does not require storing an encryption
              key.
        ●     A hash function is often used to encrypt passwords.
              The ideal cryptographic hash function h has two
              characteristics:
                  ■
                      Given x, it is easy to compute the hashed value h(x).
                  ■
                      Given a hashed value z, it is difficult to find a value x
                      for which h(x) = z.
        ●     Because of these characteristics, a hash function is
              also called a one-way encryption.



    Section 4.5                             The Mighty Mod Function             15
Wednesday, March 24, 2010
Generating and Decomposing Integers

        ●     The modulo function provides an easy way to generate
              integer values within some range 0 through n − 1 for some
              positive integer n.
        ●     Take any positive integer m and compute m mod n.
        ●     If you have a function to generate a random (or
              pseudorandom) integer m, this process generates a random
              (or pseudorandom) integer within the desired range.
        ●     You may also want to cycle through the integers in this
              range in a controlled fashion.
        ●     Addition modulo n is defined on the set of integers {0, 1,
              2, … , n - 1} by:
                  x +n y = (x + y) mod n
                  ■




    Section 4.5                       The Mighty Mod Function         16
Wednesday, March 24, 2010

Contenu connexe

Tendances

Interpolation wikipedia
Interpolation   wikipediaInterpolation   wikipedia
Interpolation wikipediahort34
 
A probabilistic data encryption scheme (pdes)
A probabilistic data encryption scheme (pdes)A probabilistic data encryption scheme (pdes)
A probabilistic data encryption scheme (pdes)Alexander Decker
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103Sure Interview
 
PYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSPYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSAniruddha Paul
 
Deep Learning: Recurrent Neural Network (Chapter 10)
Deep Learning: Recurrent Neural Network (Chapter 10) Deep Learning: Recurrent Neural Network (Chapter 10)
Deep Learning: Recurrent Neural Network (Chapter 10) Larry Guo
 
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Hector Zenil
 
Fractal dimension versus Computational Complexity
Fractal dimension versus Computational ComplexityFractal dimension versus Computational Complexity
Fractal dimension versus Computational ComplexityHector Zenil
 
Neural collaborative filtering-발표
Neural collaborative filtering-발표Neural collaborative filtering-발표
Neural collaborative filtering-발표hyunsung lee
 
IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...
IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...
IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...IRJET Journal
 
Catching co occurrence information using word2vec-inspired matrix factorization
Catching co occurrence information using word2vec-inspired matrix factorizationCatching co occurrence information using word2vec-inspired matrix factorization
Catching co occurrence information using word2vec-inspired matrix factorizationhyunsung lee
 
Template Protection with Homomorphic Encryption
Template Protection with Homomorphic EncryptionTemplate Protection with Homomorphic Encryption
Template Protection with Homomorphic EncryptionTolun Tosun
 
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...zaidinvisible
 
Image encryption technique incorporating wavelet transform and hash integrity
Image encryption technique incorporating wavelet transform and hash integrityImage encryption technique incorporating wavelet transform and hash integrity
Image encryption technique incorporating wavelet transform and hash integrityeSAT Journals
 
RNN & LSTM: Neural Network for Sequential Data
RNN & LSTM: Neural Network for Sequential DataRNN & LSTM: Neural Network for Sequential Data
RNN & LSTM: Neural Network for Sequential DataYao-Chieh Hu
 
L05 language model_part2
L05 language model_part2L05 language model_part2
L05 language model_part2ananth
 
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming ProblemPenalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problempaperpublications3
 

Tendances (17)

Interpolation wikipedia
Interpolation   wikipediaInterpolation   wikipedia
Interpolation wikipedia
 
A probabilistic data encryption scheme (pdes)
A probabilistic data encryption scheme (pdes)A probabilistic data encryption scheme (pdes)
A probabilistic data encryption scheme (pdes)
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
 
PYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMSPYTHON FULL TUTORIAL WITH PROGRAMMS
PYTHON FULL TUTORIAL WITH PROGRAMMS
 
Deep Learning: Recurrent Neural Network (Chapter 10)
Deep Learning: Recurrent Neural Network (Chapter 10) Deep Learning: Recurrent Neural Network (Chapter 10)
Deep Learning: Recurrent Neural Network (Chapter 10)
 
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
 
Algoritmic Information Theory
Algoritmic Information TheoryAlgoritmic Information Theory
Algoritmic Information Theory
 
Fractal dimension versus Computational Complexity
Fractal dimension versus Computational ComplexityFractal dimension versus Computational Complexity
Fractal dimension versus Computational Complexity
 
Neural collaborative filtering-발표
Neural collaborative filtering-발표Neural collaborative filtering-발표
Neural collaborative filtering-발표
 
IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...
IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...
IRJET- Bidirectional Graph Search Techniques for Finding Shortest Path in Ima...
 
Catching co occurrence information using word2vec-inspired matrix factorization
Catching co occurrence information using word2vec-inspired matrix factorizationCatching co occurrence information using word2vec-inspired matrix factorization
Catching co occurrence information using word2vec-inspired matrix factorization
 
Template Protection with Homomorphic Encryption
Template Protection with Homomorphic EncryptionTemplate Protection with Homomorphic Encryption
Template Protection with Homomorphic Encryption
 
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
Aes cryptography algorithm based on intelligent blum blum-shub prn gs publica...
 
Image encryption technique incorporating wavelet transform and hash integrity
Image encryption technique incorporating wavelet transform and hash integrityImage encryption technique incorporating wavelet transform and hash integrity
Image encryption technique incorporating wavelet transform and hash integrity
 
RNN & LSTM: Neural Network for Sequential Data
RNN & LSTM: Neural Network for Sequential DataRNN & LSTM: Neural Network for Sequential Data
RNN & LSTM: Neural Network for Sequential Data
 
L05 language model_part2
L05 language model_part2L05 language model_part2
L05 language model_part2
 
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming ProblemPenalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problem
 

En vedette

En vedette (7)

Cpsc125 Ch4 Sec1
Cpsc125 Ch4 Sec1Cpsc125 Ch4 Sec1
Cpsc125 Ch4 Sec1
 
Computer science-and-information-technology
Computer science-and-information-technologyComputer science-and-information-technology
Computer science-and-information-technology
 
Lecture 06
Lecture 06Lecture 06
Lecture 06
 
Cpsc125 Ch4 Sec4
Cpsc125 Ch4 Sec4Cpsc125 Ch4 Sec4
Cpsc125 Ch4 Sec4
 
CPSC 125 Ch 4 Sec 4
CPSC 125 Ch 4 Sec 4CPSC 125 Ch 4 Sec 4
CPSC 125 Ch 4 Sec 4
 
Computer security
Computer security Computer security
Computer security
 
CPSC 125 Ch 3 Sec 3
CPSC 125 Ch 3 Sec 3CPSC 125 Ch 3 Sec 3
CPSC 125 Ch 3 Sec 3
 

Similaire à Relations, Functions, and the Mighty Mod

Building graphs to discover information by David Martínez at Big Data Spain 2015
Building graphs to discover information by David Martínez at Big Data Spain 2015Building graphs to discover information by David Martínez at Big Data Spain 2015
Building graphs to discover information by David Martínez at Big Data Spain 2015Big Data Spain
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptxAgonySingh
 
358 33 powerpoint-slides_15-hashing-collision_chapter-15
358 33 powerpoint-slides_15-hashing-collision_chapter-15358 33 powerpoint-slides_15-hashing-collision_chapter-15
358 33 powerpoint-slides_15-hashing-collision_chapter-15sumitbardhan
 
C interview question answer 1
C interview question answer 1C interview question answer 1
C interview question answer 1Amit Kapoor
 
Pairwise Keys Generation Using Prime Number Function in Wireless Sensor Networks
Pairwise Keys Generation Using Prime Number Function in Wireless Sensor NetworksPairwise Keys Generation Using Prime Number Function in Wireless Sensor Networks
Pairwise Keys Generation Using Prime Number Function in Wireless Sensor NetworksIDES Editor
 
Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...eSAT Publishing House
 
Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...eSAT Journals
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashingAkhil Prem
 
Data streaming algorithms
Data streaming algorithmsData streaming algorithms
Data streaming algorithmsSandeep Joshi
 
Hashing.pptx
Hashing.pptxHashing.pptx
Hashing.pptxkratika64
 
Supervised Quantization for Similarity Search (camera-ready)
Supervised Quantization for Similarity Search (camera-ready)Supervised Quantization for Similarity Search (camera-ready)
Supervised Quantization for Similarity Search (camera-ready)Xiaojuan (Kathleen) WANG
 
Skiena algorithm 2007 lecture06 sorting
Skiena algorithm 2007 lecture06 sortingSkiena algorithm 2007 lecture06 sorting
Skiena algorithm 2007 lecture06 sortingzukun
 
Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfJaithoonBibi
 

Similaire à Relations, Functions, and the Mighty Mod (20)

Building graphs to discover information by David Martínez at Big Data Spain 2015
Building graphs to discover information by David Martínez at Big Data Spain 2015Building graphs to discover information by David Martínez at Big Data Spain 2015
Building graphs to discover information by David Martínez at Big Data Spain 2015
 
Hashing 1
Hashing 1Hashing 1
Hashing 1
 
Hashing .pptx
Hashing .pptxHashing .pptx
Hashing .pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
358 33 powerpoint-slides_15-hashing-collision_chapter-15
358 33 powerpoint-slides_15-hashing-collision_chapter-15358 33 powerpoint-slides_15-hashing-collision_chapter-15
358 33 powerpoint-slides_15-hashing-collision_chapter-15
 
C interview question answer 1
C interview question answer 1C interview question answer 1
C interview question answer 1
 
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
AD3251-Data Structures  Design-Notes-Searching-Hashing.pdfAD3251-Data Structures  Design-Notes-Searching-Hashing.pdf
AD3251-Data Structures Design-Notes-Searching-Hashing.pdf
 
Bigdata analytics
Bigdata analyticsBigdata analytics
Bigdata analytics
 
Pairwise Keys Generation Using Prime Number Function in Wireless Sensor Networks
Pairwise Keys Generation Using Prime Number Function in Wireless Sensor NetworksPairwise Keys Generation Using Prime Number Function in Wireless Sensor Networks
Pairwise Keys Generation Using Prime Number Function in Wireless Sensor Networks
 
Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...
 
Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...Stegnography of high embedding efficiency by using an extended matrix encodin...
Stegnography of high embedding efficiency by using an extended matrix encodin...
 
introduction to trees,graphs,hashing
introduction to trees,graphs,hashingintroduction to trees,graphs,hashing
introduction to trees,graphs,hashing
 
Data streaming algorithms
Data streaming algorithmsData streaming algorithms
Data streaming algorithms
 
Hashing.pptx
Hashing.pptxHashing.pptx
Hashing.pptx
 
Supervised Quantization for Similarity Search (camera-ready)
Supervised Quantization for Similarity Search (camera-ready)Supervised Quantization for Similarity Search (camera-ready)
Supervised Quantization for Similarity Search (camera-ready)
 
Skiena algorithm 2007 lecture06 sorting
Skiena algorithm 2007 lecture06 sortingSkiena algorithm 2007 lecture06 sorting
Skiena algorithm 2007 lecture06 sorting
 
Js2517181724
Js2517181724Js2517181724
Js2517181724
 
Js2517181724
Js2517181724Js2517181724
Js2517181724
 
Hashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdfHashing and File Structures in Data Structure.pdf
Hashing and File Structures in Data Structure.pdf
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 

Plus de David Wood

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainDavid Wood
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?David Wood
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...David Wood
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 KeynoteDavid Wood
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221David Wood
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart CityDavid Wood
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software DevelopmentDavid Wood
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsDavid Wood
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelDavid Wood
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301David Wood
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601David Wood
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors KillDavid Wood
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in AustraliaDavid Wood
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsDavid Wood
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social mediaDavid Wood
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's JourneyDavid Wood
 
Open by Default
Open by DefaultOpen by Default
Open by DefaultDavid Wood
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926David Wood
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426David Wood
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesDavid Wood
 

Plus de David Wood (20)

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchain
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 Keynote
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart City
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software Development
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable Claims
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data model
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors Kill
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in Australia
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social media
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's Journey
 
Open by Default
Open by DefaultOpen by Default
Open by Default
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF Vocabularies
 

Relations, Functions, and the Mighty Mod

  • 1. Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Section 4.5 © 2006 W.H. Freeman & Co. Copyright MSCS Slides The Mighty Mod Function Mod Function The Mighty Wednesday, March 24, 2010
  • 2. The Mighty Mod Function ● We define the modulo n function as follows: If x = qn + r, 0 ≤ r ≤ n, then x mod n = r. ● In other words, x mod n is the nonnegative remainder (also called the residue of x modulo n) when x is divided by the positive integer n. Section 4.5 The Mighty Mod Function 2 Wednesday, March 24, 2010
  • 3. Hashing ● A hash function h: S → T, where the domain S is a set of text strings or integer values and the codomain T is the set of integers {0, 1, … , t − 1}, where t is some relatively small positive integer. ● If the domain S consists of text strings, we can imagine them encoded in some way into integer values. ● For example, an algorithm as simple as converting each individual letter of a text string into its position in the alphabet and adding up the resulting list. ● The function h therefore maps a potentially large set of values S into a relatively small window of integer values T. Consequently h isn’t likely to be a one-to- one function. Section 4.5 The Mighty Mod Function 3 Wednesday, March 24, 2010
  • 4. Hashing ● A hash function is often used as part of a search algorithm. ● In a search using a hash function, n elements are stored in an array (a one-dimensional table) called a hash table, where the array is indexed from 0 through t − 1; the table is of size t. ● The element x is passed as the argument to the hash function, and the resulting h(x) value gives the array index at which the element is then stored. ● Later, when a search is carried out, the target value is run through the same hash function, giving an index location in the hash table, which is where to look for the matching stored element. Section 4.5 The Mighty Mod Function 4 Wednesday, March 24, 2010
  • 5. Hashing ● However, because the hash function is not one-to-one, things are not quite that simple. ● Different values may hash to the same array index, producing a collision. ● Here are several collision resolution algorithms available. One is called linear probing. ■ Keep going in the array and store element x in the next available empty slot. ● Another method, called chaining, builds a linked list for each array index. Section 4.5 The Mighty Mod Function 5 Wednesday, March 24, 2010
  • 6. Hashing ● The following are the desirable properties of a hash function: 1. Given an argument value x, h(x) can be computed quickly. 2. The number of collisions will be reduced because h(x) does a good job of distributing values throughout the hash table. ● Use of a modulo function as the hash function accomplishes goal 1. ● Goal 2 is harder to achieve, but distribution seems to work better on the average if the table size (the modulo value) is a prime number. Section 4.5 The Mighty Mod Function 6 Wednesday, March 24, 2010
  • 7. Hashing ● The average number of comparisons required to search for an element using hashing depends on the ratio of n to the total table size t. ● If this ratio is low, then (using linear probing) there are lots of empty slots, so you won’t have to look very far to find a place to insert a new element into the table. ● If this ratio is low and chaining is used, the average length of any linked list you may have to (sequentially) search for a target element should be short. ● This ratio n/t is called the load factor of the hash table. Section 4.5 The Mighty Mod Function 7 Wednesday, March 24, 2010
  • 8. Computer Security ● The mod function plays a part in many aspects of security. ● Military information, financial information, and company proprietary information that must be transmitted securely uses some encoding/decoding scheme. ● The original information (called the plaintext) is encrypted using an encryption key, resulting in coded text called the ciphertext. ● The ciphertext is transmitted, and when it is received, it can be decoded using the corresponding decryption key. Encryption and decryption are inverse functions in the sense that: ■ decryption(encryption(plaintext)) = plaintext Section 4.5 The Mighty Mod Function 8 Wednesday, March 24, 2010
  • 9. Computer Security ● Cryptography is the study of various encryption/ decryption schemes. ● Military use of cryptographic techniques can be traced back to Julius Caesar, who sent messages to his generals in the field using a scheme now known as the Caesar cipher. ● Let us assume that plaintext messages use only the 26 capital letters of the alphabet, that spaces between words are suppressed, and that each letter is first mapped to its corresponding position in the alphabet. Section 4.5 The Mighty Mod Function 9 Wednesday, March 24, 2010
  • 10. Computer Security ● We’ll denote this mapping as the bijection g: {A, … , Z} → {0, … , 25}. ● Then a positive integer key value k is chosen that shifts each number k positions to the right with a “wrap-around” back to the beginning if needed (this is the mod function). ● Finally, the function g−1 is applied to translate the resulting number back into a letter. ● The encoding function is given by: ■ f(p) = g−1([g(p) + k] mod 26) ● The decoding function is: ■ f −1(c) = g−1([g(c) − k] mod 26) Section 4.5 The Mighty Mod Function 10 Wednesday, March 24, 2010
  • 11. Computer Security ● The Caesar cipher is a simple substitution cipher, meaning that each plaintext character is coded consistently into the same single ciphertext character. ● Encryption techniques where a single plaintext character contributes to several ciphertext characters introduce diffusion. The advantage to diffusion is that it hides the frequency statistics of individual letters, making analysis of an intercepted ciphertext message much more difficult. ● DES (Data Encryption Standard) is an internationally standard encryption algorithm developed in 1976. DES was developed to safeguard the security of digital information, so we may consider the plaintext to be a string of bits. Section 4.5 The Mighty Mod Function 11 Wednesday, March 24, 2010
  • 12. Computer Security ● DES is a block cipher. ● A block of 64 plaintext bits is encoded as a unit using a 56-bit key. ● This results in a block of 64 ciphertext bits. ● Changing one bit in the plaintext or one bit in the key changes about half the resulting 64 ciphertext bits, so DES exhibits high diffusion. ● Because the DES algorithm is well known, the only “secret” part is the 56-bit key that is used. Section 4.5 The Mighty Mod Function 12 Wednesday, March 24, 2010
  • 13. Computer Security ● AES (Advanced Encryption Standard) is also a block encryption scheme, but it uses a key length of 128 bits or more. ● AES also uses a form of the Euclidean algorithm. ● Disadvantage of both DES and AES is that they are symmetric encryption (also called private key encryption) schemes. The same key is used to both encode and decode the message. ● In a private key encryption scheme, both the sender and receiver must know the key. The problem of securely transmitting a message turns into the problem of securely transmitting the key to be used for the encryption and decryption. Section 4.5 The Mighty Mod Function 13 Wednesday, March 24, 2010
  • 14. Computer Security ● Asymmetric encryption (public key encryption) schemes use different keys for encoding and decoding. ● The decryption key cannot be derived in any practical way from the encryption key, so the encryption key can be made public. ● Anyone can send a message to the intended receiver in encrypted form using the receiver’s public key, but only the intended receiver, who has the decryption key, can decode it. ● The best-known asymmetric encryption scheme is the RSA public key encryption algorithm. Section 4.5 The Mighty Mod Function 14 Wednesday, March 24, 2010
  • 15. Hashing for Password Encryption ● A cryptographic hash function is a form of encryption that does not require storing an encryption key. ● A hash function is often used to encrypt passwords. The ideal cryptographic hash function h has two characteristics: ■ Given x, it is easy to compute the hashed value h(x). ■ Given a hashed value z, it is difficult to find a value x for which h(x) = z. ● Because of these characteristics, a hash function is also called a one-way encryption. Section 4.5 The Mighty Mod Function 15 Wednesday, March 24, 2010
  • 16. Generating and Decomposing Integers ● The modulo function provides an easy way to generate integer values within some range 0 through n − 1 for some positive integer n. ● Take any positive integer m and compute m mod n. ● If you have a function to generate a random (or pseudorandom) integer m, this process generates a random (or pseudorandom) integer within the desired range. ● You may also want to cycle through the integers in this range in a controlled fashion. ● Addition modulo n is defined on the set of integers {0, 1, 2, … , n - 1} by: x +n y = (x + y) mod n ■ Section 4.5 The Mighty Mod Function 16 Wednesday, March 24, 2010