Wednesday, November 5, 2025

Innovation, Integrity and Excellence Happening at Morgan Computer Science.

The new Ph.D. in Advanced Computing program admitted 20 students in fall 2025. The BS in Computer Science and MS in Advanced Computing have the steadfast growth in recent years.


Three doctoral students joined my team this semester. They conduct research on quantum algorithms and quantum machine learning (QML). 


Tuesday, July 30, 2024

Bell's Theorem - Bell Inequality

Classical computing:

For binary bits measurements: 

a0b0 + a0b1 + a1b0 - a1b1 <=2

In quantum mechanics 

For using qubits, it can violate the the inequlity:

At Bell state / entanglement 


The average of four measures can be over 2 sqrt(2) = 2.828..., exceed two! This can be proofed in the lab setting:

Experiment to show the violation of Bell Inequality

Tuesday, January 30, 2024

AES Algorithm

A quantum-safe symmetric key encryption, and fast due to the block cipher techniques used. 
  • Convert to State Array
  • Transformations (and inverses)
    • AddRoundKey
    • SubBytes
    • ShiltRows
    • MixColumns
  • Key Expansion
1. Convert to state array

2a. AddRoundKey






2b. SubBytes (S-box)



for index 55, the s-box value is fc


2c. ShiftRows


2d. MixColumns






3. Key Expansion (new round key)



#AES round key (128 bits)
current round key = w0, w1, w2, w3 (column, vertical)
w0=column 1, w1 = c.2, w2 = c.3, w3 = c.4
g(w3) calculation:
   1) shift left, 2) apply s-box,
   3) add round constant (01,00,00,00)
new roundkey: w4, w5, w6, w7
   w4 = w0 xor g(w3), w5 = w4 xor w1,
   w6 = w5 xor w2,    w7 = w6 xor w3 
 

Example


Calculation of round key (round 1)
w3 = 01 02 14 13, shift left = 02 14 13 01, after s-box 77 fa 7b 7c, after + 1000h = 76 fa 7b 7c.
so g(w3) = 76 fa 7b 7c, then w4 = wo xor g(w3) = 74, fb 6a 7c (column one of round 1 key)
 

Algorithm



10 round = 128-bit keys
12 round = 196-bit keys
14 round = 256-bit keys 

AES-256 is considered to be quantum resistant. 







References:
1. Rijndael-Inspector - Rijndael_Animation_v4-eng.exe|swf - A flash application
2. AES-example.pdf
3. Zhou-Xuan-fulltext.pdf (Univ. of Manchester)


























Sunday, November 14, 2021

AWS Polly - Text to Speech Service

Online service (browser-based)

https://console.aws.amazon.com/polly/home/SynthesizeSpeech

(Log on to aws, go to Polly. Very simple)


Command Line interface (CLI) service

1 Log on to aws and create an IAM user

  • add a user with username: administrator with management console access
  • create an admin group with admin access policy. add user to the group
  • create an access key ID and secret access key
    sign in: https://console.aws.amazon.com/iam/
    user - security credentials - access keys - create access key
    download the key pair file (.csv) to your local computer 
2. install application: https://awscli.amazonaws.com/AWSCLIV2.msi
  • check after installation: c:\> aws --version
3. configure aws CLI
  • aws configure
    copy/paster key id, access key, input default region
4 start using Polly from command line. Examples:

aws polly synthesize-speech ^
    --output-format mp3 ^
    --voice-id Joanna ^
    --text "Hello, my name is Joanna. I learned about the W3C on 10/3 of last year." ^
    hello.mp3

hello.mp3

aws polly synthesize-speech^ // load text from a file
  --output-format mp3 ^
  --voice-id Brian^
  --text file://war1.txt ^
  war1.mp3

aws polly start-speech-synthesis-task ^ //save to S3
  --engine neural ^
  --region us-west-2 ^
  --endpoint-url "https://polly.us-eest-1.amazonaws.com/" ^
  --output-format mp3 ^
  --output-s3-bucket-name chris.hare ^
  --voice-id Joanna ^
  --text file://war1.txt

 With SSML (synthesis markup language), you add tags such as news, conversational, lexicon and add break, emphasis, etc. 

Monday, July 19, 2021

Quantum Computing for Beginners

There are three important properties of quantum mechanics:

Superposition, Entanglement, and Interferences 

Superposition

For colors, b/w has 2 colors, gif has 256 colors, same as VGA (2^8), SVGA has 2^16=65536 colors, true color (24bit) has 2^24 = 16 million, deep color has 2^30 = 1 billon colors. Now we are using digital computer. The binary system has two numbers 0 and 1. So we are at b/w stage. 

For music, bugle has 5 notes (or may be three), march/pop songs/national anthem uses mostly 7 notes, opera/orchestra/Mozart uses 12 notes. As we know, orchestra has more details and rich melody than bugles. You can consider using a digital computer is kind of listening bugle instead of orchestra music. 

The superposition property enables quantum computers to represent more information in each unit (qubit) therefore a vast amount of data can be processed in one step. 

Entanglement

We know that twin brothers or sisters can somehow "communicate" even though they are physically apart. It seems there is something (or someone) that sends information between each other. 

Players in Matching bands synchronize with the conductor. This means, one move, all follows. 

The entanglement property "sends" information from one particle to another without delay. It seems there is a super force (God?) to control the particles' rotations with the identical angles along XYZ axes. Once entangled, one can control all qubits by just manipulating one qubit. (The others will follow). It functions like a lever. 

Interferences

Throwing two rocks in still water you will see waves and when two waves meet, they add or cancel base on the phases of the waves. 

A clock (minute hand) is a good example to explain phases. 12 o'clock is considered phase = 0, at 5 minute phase = 15 (degree), at 15 minute phase = 90. After one hour, the minute hand goes back to phase =0.

---------------

Summary

Entangled qubits have a vast number of different phases (considering distributing on a clock), most of them cancel each other (eg. 5 minute and 35 minute cancel each other). Some add up (remember waves). In the end, a few that with same phase become much larger (fit) than the rest. They are the solutions to the problem. 

If you know genetic algorithm or evolutionary computation, it functions similar, same is true comparing to the human evolution. The fit species remain and get better (more fit). Unfit species disappear.

[This explanation uses a form of story teller rather than Einstein level scientific definitions and quantum theory.]

Sunday, February 7, 2021

Forensic Analyzing Memory Image - Bulk-extractor

Bulk_extractor is a program that extracts features such as email addresses, credit card numbers, URLs, and other types of information from digital evidence files. It is a useful forensic investigation tool for many tasks such as malware and intrusion investigations, identity investigations and cyber investigations, as well as analyzing imagery and pass-word cracking.

  1. Start Kali Linux and download memdump.mem [512 MB]
  2. Run bulk_extractor -o bulk wordlist memdump.mem. The results will be placed in the "bulk" folder. 
  3. Run cd bulk and then ls -l you will see a list of files
  4. Use nano to view the files
    • nano domain_histogram.txt. You will see domains visited on this computer and the number of times. You can use ctrl+W to search term, eg. ccsf.edu
    • ctrl+X to close nano.
    • nano ccn_historam.txt You will see the credit card numbers found. 
    • nano wordlist.txt. You will see the words and the frequency. Useful for cracking encrypted files.

Note: Copy files from host to VM: you need to shutdown the guest and setup the "shared folder" so VM can access files on a folder on the host. Or you can enable USB on VM so you can access files through USB on guest. 








Reference: https://samsclass.info/121/proj/p4-Bulk.htm

Wednesday, November 25, 2020

Tensor Product

Tensor product is an outer product of two vectors. Here are some examples:

For two qubits:


For three qubits:


In "general",




Saturday, November 14, 2020

Develop a static website on AWS

1. Have your webfiles ready. Such as index.html 
2. Sign in to the AWS Console 
3. Add a bucket under S3, eg. cs590.bucket 
3.1 unckeck "block all public access" so people can access your website. 
4. Click the "cs590.bucket" and copy the ARN 

5. Under "Objects", upload the webfiles. Note that the index.html file should be in the root folder. 
6. Go to the "Properties", edit the "Static website hosting" 
6.1 enable static website hosting 
6.2 choose "host a static website" 
6.3 type index.html as the index document. 
6.4 type error.html in error document. (Don't worry for now if you don't have this file.) 6.5 save changes.

7. Go to the "Permissions" tab, add a "bucket policy" 
7.1 click "Edit" button
7.2 click the "policy generator" button and then select "S3 bucket policy" 
7.3 type "*" in the Principal 
7.4 select "all actions" checkbox 
7.5 paste the ARN you copied in step 4. Something like this "arn:aws:s3:::cosc590.bucket". 
7.6 click "add statement" 

7.7 Click "Generate Policy" button 
7.8 Copy the JAON policy document. Something like this: 
{
  "Id": "Policy1605400973864",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1605400930003",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::cosc590.bucket",
      "Principal": "*"
    }
  ]
}
7.9 add "\*" at the end of the resource line. So the policy should like this:
{
  "Id": "Policy1605400973864",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1605400930003",
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::cosc590.bucket\*",
      "Principal": "*"
    }
  ]
}
7.10 paste the policy to the "bucket policy" (step 7.1)

8. Go back to the "Properties" tab
9. Scroll down to the bottom 
10. Click the link to launch your website. The URL is something like this:
http://cosc590.bucket.s3-website-us-east-1.amazonaws.com

-------------------
Optional:
a. Add logs.cs590.bucket to store logs and enable under "properties". 
b. Add www.cs590.bucket and to redirect to cs590.bucket. 

Q: Why adding a policy (step 7)?
A: For security reason, the bucket access is disabled by default. This follows the "least privilege" security policy. 

Monday, September 21, 2020

CNOT Gate

 Controlled NOT gate: 

⏐x, y → ⏐x, x ⨂ y

Matrix:  

The CNOT maps 

⏐0 0  ⏐0 0
⏐0 1  ⏐0 1 
⏐1 0  ⏐1 1
⏐1 1  ⏐1 0

Proof:

⏐00 = [1 0 0 0], ⏐01 = [0 1 0 0], ⏐10 = [0 0 1 0], ⏐11 = [0 0 0 1], all vectors transposed for easy typing. 

Here ⏐0 == [1 0] and ⏐1 == [0 1] and ⏐ab = ⏐a ⨂ ⏐b

Apply matrix multiplications: 

CNOT × ⏐00  ⏐00
CNOT × ⏐01  ⏐01
CNOT × ⏐10  ⏐11
CNOT × ⏐11  ⏐10

#

In math, left Kronecker product ⨂ is


For example: 




Qubit Operation (2)

CNOT gate: to flip iff  (if and only if) the control quit is |1>, otherwise it does nothing. 


Entanglement:


⏐+ == [1/sqrt (2) * (|0> + |1>) == 0.707 |0> + 0.707 |1>

⏐- == [1/sqrt (2)] * (|0> - |1>)

X (a, b) = (b, a), NOT gate

|a, b> == |b, a>, see below qubit swap:


[a |0> + b |1>] |0> == a|00> + b|10>

|𝝍> == a |0> + b |1>

|𝝍>|𝝍> == a^2|00> + ab|01> + ab|10> + b^2|11>

Bell state (entanglement):







Linear Algebra - Qubit Operations

Vectors are commonly written in column format. Sometimes, we also use shorthand format such as (3, 4).

In quantum computing, the state |0> corresponds to vector (1, 0), and |1> corresponds to vector (0, 1). 

Commonly used quantum gates, quantum circuit symbols, and math representations: 


The Bloch sphere representation of X (NOT), H (Hadamard), and Z, S, T (phase) gates. 



We can see that 
  • X gate rotates along X axis 180 degree (or less depending on the initial angle to Z axis). (NOT) 
  • H gate rotates along Y  axis 90 degree (or less). 
  • Z, S, T gates rotate along Z axis at certain degree. (phase)


Monday, September 7, 2020

PGP Encryption

Developed by Phil Zimmerman in 1991. It combines symmetric, asymmetric (public key) encryption, hash, and digital signature all together providing confidentiality, integrity, and authentication. Good for email. The algorithm:

At the sender (Alice) side: 

  1. Alice: Message M is hashed
  2. Sign (encrypt) the hash value with her private key (EP)
  3. Compress (zip) the message + signed hash value
  4. Use a session key Ks to encrypt zipped output (ES)
  5. Use Bob's public key to encrypt session key (EP)
  6. Send encrypted message and encrypted session key 
At the recipient (Bob) side:
  1. Use Bob's private key to decrypt session key (DP)
  2. Use session key Ks to decrypt the zipped message
  3. unzip, got message and signed hash value
  4. Use Alice's public key to decrypt the hash value 
  5. Computing hash value for the message received
  6. Compare with hash value Alice computed.
Below are the PGP diagram:


Mathematically:

Note:
Image copyright: Author of this post. Free to use but reference is required. 

Tuesday, September 1, 2020

Quantum Circuit

 A quantum circuit is a computational routine consisting of coherent quantum operations on quantum data, such as qubits, and concurrent real-time classical computation. It is an ordered sequence of quantum gates, measurements, and resets, which may be conditioned on and use data from the real-time classical computation. A set of quantum gates is said to be universal if any unitary transformation of the quantum data can be efficiently approximated arbitrarily well as a sequence of gates in the set. Any quantum program can be represented by a sequence of quantum circuits and non-concurrent classical computation.

A quantum gate is a reversible (unitary) operation applied to one or more qubits.

Electronic computer: program --> instructions (operand and data) - binary bits
Quantum computer: program --> quantum circuits (quantum gate and quantum data) - qubits


Friday, August 28, 2020

Hashcat - Password Cracking

The labs shows how to crack hashed passwords using dictionary and brute-force methods on Kali Linux. 

Download hashcat-exercise-files.zip

sudo mkdir hashcat-exercise

unzip hashcat-exercise-files.zip

./view-sample-password.sh

echo -n salt [password] | md5sum

man crypt

man mkpasswd

A: Dictionary attack

Create text file test-dictionary with three words hello, wtaddtsbtk, dog in three lines. 

hashcat -m 500 -a 0 crack-these-please-md5 test-dictionary --force (cracked with 3 passwords)
hashcat -m 1800 -a 0 crack-these-please-sha512 test-dictionary (cracked with 3 passwords)

hashcat -m 500   -a 0 crack-these-please-md5     500_passwords.txt (cracked with 7 different)
hashcat -m 1800 -a 0 crack-these-please-sha512 500_passwords.txt (cracked with 7 different)

B: Brute force attack

openssl speed md5
openssl speed sha512

This shows md5 processes more data than sha512 in the same amount of time. 

hashcat -m 500 -a 3 crack-these-please-md5 ?l?l (mask ?l means one lowercase letter) return: w, ww
hashcat  -m  500  -a  3  crack-these-please-md5  ?a?a (?a all 95 characters on keyboards instead of 26)

Core attack modes

  • Dictionary attack - trying all words in a list; also called “straight” mode (attack mode 0, -a 0)
  • Combinator attack - concatenating words from multiple wordlists (mode 1)
  • Brute-force attack and Mask attack - trying all characters from given charsets, per position (mode 3)
  • Hybrid attack - combining wordlists+masks (mode 6) and masks+wordlists (mode 7); can also be done with rules
http://www-scf.usc.edu/~csci530l/instructions/lab-authentication-instructions-hashcat.htm

Saturday, June 20, 2020

The Rise and Fall of BlackBerry (phones)

Blackberry with its iconic on device full keyboard was a symbol of c-suite executives and other business professionals, the list also include the US Presidents. The reason for the wide adoption (some 10 years ago) was not only the beautiful design but also its security. 

Blackberry uses an end-to-end encryption called PGP. The servers are managed by a company (or a third party). When Alice sends a message, the message is firstly compressed. PGP then creates a (one time) random session key to encrypt the compressed message. The session key is then encrypted using Bob's public key and send to Bob. Bob uses his private key to decrypt the session key and uses it to decrypt the message. 

It is important to note that the encryption and decryption are done on Blackberry devices, we call end-to-end. Since PGP is strong encryption, men in the middle cannot decipher and read the message. Due to the strong security feature, Blackberry quickly gained the market popularity. 

Because PGP is too strong to break up, it prevents some countries or regimes to spy on their citizens. As a result, many countries banned to bring Blackberry to those countries. As a result, this beautiful device was quickly faded away. 

Some scientists believe the fall of Blackberry was not because its business malpractice. It was because the strong security and no back door. Technology may not always win. 

Final comments: 
1. The good news is PGP technology is still here and people can choose to use.  
2. Random number generation (RNG) is very important for the security of encryption key. Quantum RNG (QRNG) can guarantee the truly randomness. 
3. Compression is a form of encryption, usually symmetric, due to its fast speed. 
4. Learn more about PGP, visit Philip Zimmermann's website


Friday, June 5, 2020

Quantum Cryptography

Quantum cryptography is to address issues in crypto key distribution by using a principle guaranteed by the fundamental laws of physics. Once a recipient receives the temper-proof key, She can then use conventional crypto method to encrypt/decrypt the message. So quantum cryptography is the hybrid approach of modern cryptography but the keys are exchanged via the quantum channel commonly called quantum key distribution (QKD). 
Fig. Quantum Cryptography

According to physics, a quantum state is unobservant. If an eavesdropper observes a quantum sate, it changes so as to cause errors at the destination. So the sending and receiving parties know the communication was compromised. Only validated keys are secure and used for further encryption/decryption. 

Image copyright: Author of this post. Free to use but reference is required. 

Quantum-safe Cryptography

The current public key encryption is mostly based on prime numbers. With the advancement of computer especial quantum computers, the threat to the existing crypto algorithms is becoming imminent. 

The need to increase the key length keeps growing. A new type of post-quantum or quantum resistant algorithms is under-development. 

Why should people worry about the existing encryption algorithms?

In WWII, German mathematicians claimed that the Enigma machine, based on simple substitution method, would require 100 years to solve. Alan Turing used less than 6 months built a Bombe at Bletchley Park. Bombe was able to crack 3,000 German encrypted message a day initially and later amounted to 2.5 million encrypted messages. 
Fig. Alan Turing's Bombe 

Today, those messages can be deciphered in a fraction of microseconds running a small program using the statistical analysis method. (The author has programmed one in Python.)

In 1977, RSA issued a challenge in an article "A new kind of cipher that would take millions of years to break". The so-called 40 quadrillion years problem (428 bit key) was solved in 1994 after a 6 months of work. 

RSA algorithm with key length 1024 bit to 4096 bit is considered strong and "unbreakable" today. Peter Shor @MIT proposed an algorithm that can solve such "unsolvable" programs on quantum computers. 

Imagine people store the encrypted data now and wait 10 years or so to decrypt when the powerful quantum computers are ready. Should you worry?

Crypto Keys and Key Exchange

In Crypto, encryption and decryption keys need to be well guided. In classical cryptography, A secret key is used. Key distribution is difficult.

British GCHQ (now NCSC) introduced the public key cryptography concept. A third party (CA) is responsible for key creation and distribution. This makes key exchange convenient. 

Fig. Public Key Cryptography

RSA public key encryption is based on two large prime numbers. Factor the product of those numbers seems simple but requires tremendous amount of time, or in many cases important. 

Since public key algorithms such as RSA require complex computations, it is slow. As a result, people usually do not use it directly for encrypting message (a large amount of data). Instead, use it to exchange short session keys for secret key algorithms (aka symmetric algorithms) such as AES. 

Note:
Image copyright: Author of this post. Free to use but reference is required. 

Thursday, June 4, 2020

Cryptography Basics



Cryptography is to hide information before sending and reveal it at recipient. Figure 1 is an illustration of encryption and decryption process.  
Fig. Crypto Basics

Alice uses an encryption key to encryption the plaintext. The encrypted text (ciphertext) is then sent to Bob. Bob decrypts the ciphertext with a key to reveal the plaintext Alice sent to him. 

Here the encryption key and decryption key (could be one) are important. They need to be strong and convenient. 

Common secret key (one key) encryption algorithm: DES (1976, 56 bits key length, vulnerabilities exist), AES (256-bit key length, current).

Common public key (two keys) encryption algorithm: RSA (current).

Ideally, keys should keep changing to make them impossible to guess or deduce. Random numbers are used to generate keys but only truly random number are considered ideal. 

Quantum Random Number Generators (RNG) use the randomness of photons, it is impossible for observing or predicting the outcome.   

Note:
Image copyright: Author of this post. Free to use but reference is required.