Editing
Abstract Algebra
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Abstract algebra in cryptography and coding:''' <syntaxhighlight lang="python"> # Abstract algebra provides the foundations of modern cryptography. # We implement key group/field operations. # === Group Theory: Modular Arithmetic Group === class ModularGroup: """The additive group β€/nβ€.""" def __init__(self, n: int): self.n = n self.elements = list(range(n)) self.identity = 0 def operation(self, a: int, b: int) -> int: return (a + b) % self.n def inverse(self, a: int) -> int: return (self.n - a) % self.n def order_of_element(self, a: int) -> int: """Order of a: smallest k > 0 such that a*k β‘ 0 (mod n).""" current = a for k in range(1, self.n + 1): if current % self.n == 0: return k current += a return -1 # Should never reach here def subgroups(self) -> list: """All subgroups of β€/nβ€ are generated by divisors of n (by Lagrange).""" from math import gcd return [d for d in range(1, self.n + 1) if self.n % d == 0] g = ModularGroup(12) print(f"β€/12β€ subgroups (orders): {g.subgroups()}") # [1, 2, 3, 4, 6, 12] print(f"Order of element 3 in β€/12β€: {g.order_of_element(3)}") # 4 # === Field Theory: Galois Fields === class GF2: """Galois Field GF(2) = {0, 1} with XOR as addition, AND as multiplication.""" @staticmethod def add(a: int, b: int) -> int: return a ^ b # XOR @staticmethod def mul(a: int, b: int) -> int: return a & b # AND @staticmethod def inverse_add(a: int) -> int: return a # a + a = 0 in GF(2) # GF(2^8) for AES β polynomial arithmetic mod irreducible polynomial # x^8 + x^4 + x^3 + x + 1 (AES uses 0x11b) AES_IRREDUCIBLE = 0x11b def gf256_mul(a: int, b: int) -> int: """Multiplication in GF(2^8) β the core of AES MixColumns.""" p = 0 while b > 0: if b & 1: p ^= a hi_bit = a & 0x80 a = (a << 1) & 0xFF if hi_bit: a ^= 0x1b # x^8 mod (irreducible poly) reduction b >>= 1 return p # Demonstrate: in GF(2^8), multiplication is done mod the irreducible polynomial print(f"GF(2^8): 0x57 Γ 0x83 = 0x{gf256_mul(0x57, 0x83):02x}") # Expected: 0xc1 # === Elliptic Curve Group (over finite field) === class EllipticCurve: """ Elliptic curve: yΒ² = xΒ³ + ax + b (mod p) Points form an abelian group β the basis of ECC cryptography. """ def __init__(self, a: int, b: int, p: int): self.a, self.b, self.p = a, b, p assert (4*a_'3 + 27*b_'2) % p != 0, "Singular curve" def point_add(self, P, Q): """Add two points on the elliptic curve (group operation).""" if P is None: return Q # Point at infinity is identity if Q is None: return P x1, y1 = P; x2, y2 = Q if x1 == x2 and y1 != y2: return None # P + (-P) = point at infinity if P == Q: if y1 == 0: return None lam = (3*x1**2 + self.a) * pow(2*y1, -1, self.p) % self.p else: lam = (y2 - y1) * pow(x2 - x1, -1, self.p) % self.p x3 = (lam**2 - x1 - x2) % self.p y3 = (lam*(x1 - x3) - y1) % self.p return (x3, y3) def scalar_mul(self, k: int, P) -> tuple: """Double-and-add: compute kP efficiently β core of ECC.""" R = None Q = P while k > 0: if k & 1: R = self.point_add(R, Q) Q = self.point_add(Q, Q) k >>= 1 return R </syntaxhighlight> ; Key texts and theorists : '''Group theory''' β Cauchy, Galois, Sylow, Burnside (''Theory of Groups''), Hall : '''Rings and ideals''' β Dedekind, Noether (''Theory of Ideals''), van der Waerden (''Modern Algebra'') : '''Galois theory''' β Γvariste Galois, Emil Artin (''Galois Theory'') : '''Finite fields''' β Galois; Moore; applications: Reed-Solomon, AES, elliptic curves : '''Modern texts''' β Dummit & Foote (''Abstract Algebra''), Herstein (''Topics in Algebra''), Lang (''Algebra'') </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information