Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch_int -> from_integer; integer_representation -> to_integer #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions utilities.sage
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ implode_dict = { explode_table[i]:i for i in range(256)}

def decode_vec(t, l):
t = [(t[i//2] >> i % 2 * 4) & 0xf for i in range(2 * len(t))]
v = vector(map(F16.fetch_int, t))
v = vector(map(F16.from_integer, t))

if l % 2 == 1:
v = v[:-1]
Expand All @@ -21,8 +21,8 @@ def encode_vec(v):
v = vector(F16, v.list() + [ F16(0) ])
bs = []
for i in range(len(v)//2):
bs += [v[i*2].integer_representation() |
(v[i*2 + 1].integer_representation() << 4)]
bs += [v[i*2].to_integer() |
(v[i*2 + 1].to_integer() << 4)]
return bytes(bs)

def decode_matrix(t, rows, columns):
Expand Down Expand Up @@ -182,7 +182,7 @@ def bitsliced_add(veca, vecb):
def bitsliced_mul_add(In, a, Out):
In0, In1, In2, In3 = In
Out0, Out1, Out2, Out3 = Out
a_int = a.integer_representation()
a_int = a.to_integer()

if a_int & 1:
Out0 ^^= In0
Expand Down
Loading