LeetArxiv

LeetArxiv

Share this post

LeetArxiv
LeetArxiv
Paper Implementation : SHA-256 NSA Patent Whitepaper

Paper Implementation : SHA-256 NSA Patent Whitepaper

Implementing the patented National Security Agency official SHA 256 paper

Murage Kibicho's avatar
Murage Kibicho
Jan 18, 2025
∙ Paid
2

Share this post

LeetArxiv
LeetArxiv
Paper Implementation : SHA-256 NSA Patent Whitepaper
Share
Official SHA-256 Paper Frontpage

Apologies for the Paywall
LeetArxiv and the Finite Field Assembly (FF-asm) programming language are entirely funded by our Substack readers. Thank you for your understanding and support!

Introduction

It’s 2025, and the President of the United States has just launched a Solana meme coin called $TRUMP. Bitcoin is making a comeback, and so it’s time to dive into the SHA-256 hash function, the backbone of Bitcoin’s value.

$TRUMP Meme Coin from Donald Trump’s Official Twitter Account

SHA-256, or Secure Hash Algorithm 256-bit, was developed in 2001 by the National Security Agency (NSA). The official patent for SHA-256 is held by Glenn Lilly, who served as the director of the NSA’s mathematical research group.

Official Patent for SHA-256 awarded to NSA Director Glenn M. Lilly

Part 1 : Important Definitions

Definitions from the SHA-256 white paper

From the paper, SHA-256 utilizes these boolean and arithmetic operations:

  • AND denoted by ∧.

  • XOR denoted by ⊕.

  • OR denoted by∨.

  • Bitwise complement denoted by ¯.

  • Integer addition denoted by A + B.

  • Circular Right Shift of A by n bits. RotR(A, n)

  • Regular Right Shift of A by n bits. ShR(A, n)

  • Concatenation of Integers denoted by A || B

SHA-256 makes use of thse contants:

  • The first 32 bits of the fractional parts of the cube roots of the first 64 prime numbers.

NOTE

  • All integer operations are perfomed within the range 0 and 2^32. Upo overflow, the operations wrap around like a finite field


Section goals

  1. Implement Regular Right Shift.

  2. Implement Circular Right Shift.

  3. Create an array of constants.

  4. Implement LittleToBig endian conversion function

Function 1 : RegularRightShift Coding Guide + Solution

  1. Write a function called RegularRightShift.

  2. The function takes two inputs.

  • An unsigned integer called A.

  • An unsigned integer called n.

  1. The function should return an unsigned integer.

  2. The function shifts an integer A to the right, by n bits .

  • Depending on your language choice, this could be a simple >> or integer division by 2 for n times.

Keep reading with a 7-day free trial

Subscribe to LeetArxiv to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Murage Kibicho
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share