Cryptography in Blockchain
Cryptography in Blockchain
Blockchain
Lecture 3
by
y2=x3+ax+b mod p
y2=x3+ax+b mod p
△ = 4𝑎3 + 27𝑏 2 ≠ 0
Calculating Points on an Elliptic Curve ( y2=x3+ax+b mod p )
If 𝑥1 ≠ 𝑥2 If 𝑥1 = 𝑥2
𝑦2 −𝑦1 𝟑𝒙𝟐𝟏 −𝒂
m = m=
𝟐𝒚𝟏
𝑥2 −𝑥1
Group Law
Commutative: P + Q = Q +P
Identity: P+O = O+P
Inverse P + (-P) = O
Associative: (P+Q) + R = P + ( Q + R)
𝐸𝑝 𝑥, 𝑦 − 𝑝 + 1 ≤ 2 𝑝
:
Equivalent key sizes
Four primitives/protocols
Secp256k1 is the name of the elliptic curve used by Bitcoin to implement its
public key cryptography. All points on this curve are valid Bitcoin public keys.
Bitcoin and ECC
•Bitcoin Address (A): Generated from the public key (K) using a one-way
cryptographic hash function.
Bitcoin and ECC
•Private Key: A randomly chosen number that provides control over all
funds associated with the corresponding Bitcoin address.
•Ownership and Control: The private key grants the owner control over
Bitcoin by allowing them to sign transactions and prove ownership.
•Range of Private Keys: A private key can be any number between 1 and
p−1, where p=1.158×1077 defined by Bitcoin’s elliptic curve.
•Validation: If the number is less than p−1, it’s a valid private key. If not,
the process repeats until a valid key is found.
Public Key Generation
The public key is derived from the private key using elliptic curve
multiplication.
𝐾=𝑘×𝐺, where
𝑘 = Private key
𝐺 = Generator point (a fixed point)
𝐾 = Resulting public key
This process is irreversible, meaning you cannot derive the private key
from the public key.
Security of Public Keys
Brute-Force Search:
The only way to solve for 𝑘 from 𝐾 is to try all possible values of 𝑘,
making it computationally infeasible.
Public key in Bitcoin
Example: for p = 17
The secp256k1 bitcoin elliptic curve can be
thought of as a much more complex pattern
of dots on a unfathomably large grid.
Example: The following is a point P = (x,y)
with coordinates (x,y) that is a point on the secp256k1
curve:
x
=(5506626302227734366957871889516853432625060345
3777594175500187360389116729240,
y=3267051002075881697808308513050704318447127338
0659243275938904335757337482424)
Generating a Public Key
Result:
The result is the public key 𝐾, which is a point on the elliptic curve.
Public key in Bitcoin
Visualizing Elliptic Curve Multiplication
Elliptic Curve Multiplication Involves adding the generator point G to
itself repeatedly.
Multiplication Concept:
To calculate kG, we add G to itself k times.
Geometric Visualization
•Tangent
. Line Method: Adding a point to
itself involves drawing a tangent line to the
point on the curve.
•Intersection: The tangent line intersects the
curve at another point.
•Reflection: Reflect the resulting point across
the x-axis to get the sum of the points.
Public key cryptography
K = 1E99423A4ED27608A15A2616A2B0E9E52CED330AC530EDCC32C8FFC6A526AEDD * G
x = F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A
y = 07CF33DA18BD734C600B96A72BBC4749D5141C90EC8AC328AE52DDFE2E505BDB
Deriving a Bitcoin Address from a Public Key
One-Way Cryptographic Hashing:
• A Bitcoin address is created using two cryptographic hashing
algorithms, ensuring the public key cannot be reversed to reveal the
private key.
• Hash functions provide a digital "fingerprint" of the public key,
making Bitcoin addresses compact and secure.
A= RIPEMD160(SHA256(K))
• K is the public key derived from the private key using elliptic
curve multiplication.
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
What is Base58?Base58:
A text-based encoding format developed specifically for Bitcoin and used by other
cryptocurrencies.
Character Set: Base58 uses 58 characters, omitting symbols and letters that could cause
confusion when viewed in certain fonts.
•Omitted Characters:
• 0 (zero)
• O (uppercase "o")
• l (lowercase "L")
• I (uppercase "i")
• Symbols "+" and "/"
Base58
Why Base58?
• Common Prefixes:
• 0x00 for Bitcoin addresses
• 0x80 for private keys
• These prefixes ensure that data types can be easily identified
when decoding.
Base58Check Encoding Process
checksum=SHA256(SHA256(prefix + data))
From the resulting hash, take only the first four bytes. This becomes
the error-checking code (checksum).
Security Features of Hash Algorithms:
x = F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A
y = 07CF33DA18BD734C600B96A72BBC4749D5141C90EC8AC328AE52DDFE2E505BDB
Example: (uncompressed)
Here’s the same public key shown as a 520-bit number (130 hex digits) with the prefix
04 followed by x and then y coordinates, as 04 x y:
K = 04F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2FFF579DC341A↵
07CF33DA18BD734C600B96A72BBC4749D5141C90EC8AC328AE52DDFE2E505BDB
Compressed and uncompressed Public keys
K=
03F028892BAD7ED57D2FB57BF33081D5CFCF6F9ED3D3D7F159C2E2F
FF579DC341A
Compressed and uncompressed Public Keys