Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
random_walks3 Namespace Reference

Functions

 to_model (A, xP)
 isogeny3 (alpha, a1, a3)
 random_walk3 (a1, a3, path, setup)
 get_order3_points (A, setup)
 cgl_hash3 (message, setup, verbose=True)
 Charles-Goren-Lauter (CGL) Hash function concerning 3-isogeny walks.

Function Documentation

◆ cgl_hash3()

cgl_hash3 ( message,
setup,
verbose = True )

Charles-Goren-Lauter (CGL) Hash function concerning 3-isogeny walks.

Definition at line 81 of file random_walks3.py.

81def cgl_hash3(message, setup, verbose=True):
82 p = setup['Fq'].characteristic()
83
84 # SHAKE_256 algorithm from the hashlib module.
85 s = hashlib.shake_256()
86 s.update(message)
87 length = int(floor((p.bit_length() / log(3, 2)) + 0.5))
88 digest = s.hexdigest(p.bit_length() // 8)
89 path = base_repr(int(digest, 16), base=3)[:length]
90
91 if verbose:
92 print('\nCGL Hash function over the 3-isogeny graph (CGLHash3)')
93 print(f'Symmetric primitive:\t{s.name}')
94 print(f'Message digest size:\t{len(digest) // 2} bytes')
95 print(f'Random path of size:\t{len(path)} steps')
96
97 P = get_order3_points(setup['A'], setup) # We determinstically take the first order-3 point
98 for xP in P:
99 assert(not (xP**2 * (3 * xP**2 + 4 * setup['A'] * xP + 6) - 1))
100
101 # Recall, input and output of random_walk3() determines elliptic curves
102 # of the form y² + a₁xy + a₃y = x³ − 5a₁a₃x − (a₁³)a₃ − 7(a₃)²
103 xP = P[0] # We determinstically take the first x-coordinate point
104 a1, a3 = to_model(setup['A'], xP)
105 a1, a3 = random_walk3(a1, a3, [ int(b) for b in path ], setup)
106 return EllipticCurve(setup['Fq'], [a1, 0, a3, -5 * a1 * a3, -a1**3 * a3 - 7 * a3**2]).j_invariant()
assert(var1 eq var2)

References assert(), get_order3_points(), random_walk3(), and to_model().

Here is the call graph for this function:

◆ get_order3_points()

get_order3_points ( A,
setup )

Definition at line 42 of file random_walks3.py.

42def get_order3_points(A, setup):
43 Fq = setup['Fq']
44 # Constants
45 one_half = 1 / Fq(2)
46 one_third = 1 / Fq(3)
47 one_ninth = one_third**2
48 one_by_27 = one_third * one_ninth
49
50 A_times_one_third = A * one_third # M𝒸
51 A_squared = A**2 # S
52 t = (Fq(3) - A_squared) * one_ninth # M𝒸 + A
53 r = 16 * (A_squared * A) * one_by_27 # M + M𝒸 + 4A
54 s = 8 * A_times_one_third # 3A
55 u = r - s # A
56
57 y = t + \
58 one_third * \
59 setup['curt'](-2 * A_squared + 8) # M𝒸 + 3A + CURT
60
61 r = 2 * y # A
62 s = 6 * t # 3A
63
64 s0 = setup['sqrt'](r - s) # A + SQRT
65 i0 = 1 / s0 # I
66 v = -(r + s) # 2A
67 s1 = setup['sqrt'](v + u * i0) # M + A + SQRT
68 s2 = setup['sqrt'](v - u * i0) # M + A + SQRT
69
70 z = []
71 z.append((-s0 + s1) * one_half) # M𝒸 + A
72 z.append((-s0 - s1) * one_half) # M𝒸 + 2A
73 z.append((s0 + s2) * one_half) # M𝒸 + A
74 z.append((s0 - s2) * one_half) # M𝒸 + A
75
76 x = [zk-A_times_one_third for zk in z] # 4A
77 return x # Total cost: I + 3M + S + 8M𝒸 + 30A + CURT + 3SQRT
78
79

Referenced by cgl_hash3().

Here is the caller graph for this function:

◆ isogeny3()

isogeny3 ( alpha,
a1,
a3 )

Definition at line 20 of file random_walks3.py.

20def isogeny3(alpha, a1, a3):
21 _a1 = -6 * alpha + a1
22 _a3 = 3 * a1 * alpha**2 - a1**2 * alpha + 9 * a3
23 return _a1, _a3
24
25

Referenced by random_walk3().

Here is the caller graph for this function:

◆ random_walk3()

random_walk3 ( a1,
a3,
path,
setup )

Definition at line 27 of file random_walks3.py.

27def random_walk3(a1, a3, path, setup):
28 # This function assumes the input and output determines elliptic
29 # curves of form y² + a₁xy + a₃y = x³ − 5a₁a₃x − (a₁³)a₃ − 7(a₃)²
30 Fq = setup['Fq']
31 a1_ = deepcopy(a1)
32 a3_ = deepcopy(a3)
33 for k in range(0, len(path), 1):
34 alpha = [Fq(1), setup['ζ₃'], setup['ζ₃']**2][path[k]] * setup['curt'](-a3_)
35 assert alpha**3 == -a3_
36 a1_, a3_ = isogeny3(alpha, a1_, a3_)
37
38 return a1_, a3_
39
40

References isogeny3().

Referenced by cgl_hash3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_model()

to_model ( A,
xP )

Definition at line 13 of file random_walks3.py.

13def to_model(A, xP):
14 a1 = (3 * xP**2 + 2 * A * xP + 1)
15 a3 = 2 * (xP**3 + A * xP**2 + xP)**2
16 return a1, a3
17
18

Referenced by cgl_hash3().

Here is the caller graph for this function: