Notes - MCS
Applied Cryptography
Notes - MCS
Applied Cryptography
  • Applied Cryptography
  • Classical (Symmetric) Cryptography
    • Terminology
    • The Players
    • Use Cases
    • Information-Theoretic Security
    • Computational Security
    • Cryptanalysis
    • Practical Approaches
    • Cryptographic Robustness
    • Ciphers
      • Mono-Alphabetic
      • Polylphabetic
    • Rotor Machines
    • Stream Ciphers
  • Modern Symmetric Cryptography
    • Types
    • Symmetric Ciphers
    • Symmetric Block Ciphers
    • Feistel Networks
    • DES (Data Encryption Standard)
    • AES (Advanced Encryption Standard)
    • Stream Ciphers
    • Uniform Random Access
    • Linear Feedback Shift Register (LFSR)
  • Cipher Modes
    • Deployment of (Symmetric) Block Ciphers
    • Stream Cipher Modes
    • Security Reinforcement
  • Cryptographic Hashing
    • Digest functions
    • Rainbow Tables
    • Message Authentication Codes (MAC)
    • Authenticated Encryption
    • Encryption + Authentication
  • RSA & Related Subjects
    • Modular Arithmetic
    • Fast Modular Multiplication
    • The Extended Euclid's Algorithm
    • Linear Maps
    • Fermat's Little Theorem
    • Chinese Remainder Theorem
    • Fermat's Little Theorem
    • Modular Exponentiation
    • Multiplicative Order
    • The Discrete Logarithm Problem
    • Primality tests
    • The Diffie-Hellman Key Exchange Protocol
    • ElGamal Public Key Cryptosystem
    • The Rivest-Shamir-Adleman Cryptosystem
    • Finite Fields
    • Elliptic Curves
    • Diffie-Hellman using elliptic curves
    • Can we do RSA-like things with elliptic curves?
    • The discrete logarithm problem for elliptic curves
    • Secret sharing
    • Quadratic Residues
    • Zero-Knowledge proofs
      • One of two oblivious transfer
      • Coin flipping
      • Zero-knowledge proofs of identity
    • Homomorphic encryption
  • Asymmetric Key Management
    • Design Principles
    • Exploitation of private keys
    • Distribution of public keys
    • Public key (digital) certificates
    • Key pair usage
    • Certification Authorities (CA)
    • Certification Hierarchies
    • Refreshing of asymmetric key pairs
    • Certificate revocation lists (CRL)
    • Validity of signatures
    • Distribution of public key certificates
    • Time Stamping Authority (TSA)
    • PKI (Public Key Infrastructure)
  • Digital Signatures
    • Fundamental Approach
    • Signature Schemes
    • Key Elements
    • The document to sign
    • The signature date
    • The identity of the signatory
    • Optional elements of a digital signature
    • Algorithms
    • RSA signatures
    • ASN.1 digest algorithm prefixes
    • Digital Signature Standard (DSS)
    • Blind Signatures
    • Chaum Blind Signatures
    • Qualified electronic signature
      • Signature devices
    • PKCS #11
    • Microsoft Cryptographic API (CAPI)
    • Long-Term Validation (LTV)
    • LTV Advanced Electronic Signatures (AdES)
Powered by GitBook
On this page
  • Legendre Symbol
  • Jacobi Symbol
  • Counts
  • Square Roots
  • Factorization
  1. RSA & Related Subjects

Quadratic Residues

Last updated 1 year ago

Let nnn be a positive integer and let aaa be an integer such that gcd(a,n)=1gcd(a, n) = 1gcd(a,n)=1.

aaa is said to be a quadratic residue modulo nnn if and only if there exists a xxx such that: x2≡a(modn)x² \equiv a (mod n)x2≡a(modn)

When nnn is a prime number (n=p)(n = p)(n=p) there exist three cases:

  1. either aaa is a multiple of ppp, or

  2. aaa is a quadratic residue, or

  3. aaa is not a quadratic residue.

The Legendre symbol (ap)(\frac{a}{p})(pa​) captures this as follows.

Legendre Symbol

Jacobi Symbol

Counts

a(n)=local(v,s);v=vector(eulerphi(n));s=0;\
for(k=1,n,if(gcd(k,n)==1,s=s+1;v[s]=k;););return(v);
qr(n)=local(v);v=a(n); /* number (#) of true quadratic residues */\
return(length(Set(vector(length(v),k,(v[k]^2)%n))));
j(n)=local(v,c);v=a(n); /* # of true or fake quadratic residues */\
return(sum(k=1,length(v),kronecker(v[k],n)==1));
f(n)=return([eulerphi(n),qr(n),j(n)]);
f(101) /* returns [100,50,50] */
f(103) /* returns [102,51,51] */
f(107) /* returns [106,53,53] */
f(109) /* returns [108,54,54] */

How about composite numbers that are the product of two distinct prime numbers?

f(13*17) /* returns [192,48,96] --- half are fakes! */
f(11*13) /* returns [120,30,60] --- half are fakes! */
f(11*19) /* returns [180,45,90] --- half are fakes! */

Square Roots

Example:

p=11; q=19; n=p*q; r=20; a=lift(Mod(r^2,n));
rp=lift(Mod(a,p)^((p+1)/4)); rq=lift(Mod(a,q)^((q+1)/4));
r1=lift(chinese(Mod( rp,p),Mod( rq,q))); /* 20, (r1/p)=+1, (r1/q)=+1 */
r2=lift(chinese(Mod( rp,p),Mod(-rq,q))); /* 75, (r2/p)=+1, (r2/q)=-1 */
r3=lift(chinese(Mod(-rp,p),Mod( rq,q))); /* 134, (r3/p)=-1, (r3/q)=+1 */
r4=lift(chinese(Mod(-rp,p),Mod(-rq,q))); /* 189, (r4/p)=-1, (r4/q)=-1 */

Factorization

Example (continuation of the code of the previous slide):

p=11; q=19; n=p*q;
r1=20; r2=75; r3=134; r4=189; /* square roots of 191 */
gcd(r1-r2,n);                 /* 11 */
gcd(r1+r2,n);                 /* 19 */

pari-gp can only compute square roots when the modulus is prime:

sqrt(Mod(5,11))    /* ok (because 5 is a quadratic residue)     */
sqrt(Mod(9,14))    /* error (because the modulus is not prime)  */

For a prime ppp, the number of integers belonging to the set [1,2,...,p−1][1, 2, . . . , p − 1][1,2,...,p−1] that are quadratic residues is exactly (p−1)/2(p − 1)/2(p−1)/2.