Skip to content

Commit

Permalink
Incorporated last feedback from Julia
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernMHaase committed Oct 8, 2024
1 parent 52dc9d2 commit 45270cc
Show file tree
Hide file tree
Showing 9 changed files with 1,028 additions and 1,813 deletions.
956 changes: 404 additions & 552 deletions draft-irtf-cfrg-cpace.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions poc/CPace_coffee.sage
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class G_CoffeeEcosystem():
result_dict["encoded generator g"] = byte_string_to_json(result.encode())

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)



Expand Down Expand Up @@ -149,7 +149,7 @@ def output_coffee_invalid_point_test_cases(G, file = sys.stdout):
result_dict["Invalid Y2"] = byte_string_to_json(G.I)

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)


return result_dict
Expand Down
2 changes: 1 addition & 1 deletion poc/CPace_montgomery.sage
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ is a valid u-coordinate of a Montgomery curve with curve parameter A.
result_dict["generator g"] = byte_string_to_json(result)

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)

return result

Expand Down
32 changes: 16 additions & 16 deletions poc/CPace_string_utils.sage
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ def tv_output_byte_array(data, test_vector_name = "", line_prefix = " ", max_le
return

def byte_string_to_json(bytestring):
return base64.b16encode(bytestring).decode("ASCII")
return base64.b64encode(bytestring).decode("ASCII")

def tv_output_python_dictionary_as_json_base64(dictionary, line_prefix = " ", max_len = 63, file = sys.stdout):
def tv_output_python_dictionary_as_json_base64(dictionary, line_prefix = " ", max_len = 66, file = sys.stdout):
json_text = json.dumps(dictionary).encode("ASCII")
json_string = base64.standard_b64encode(json_text).decode("ASCII")

result = "\n~~~ test-vectors"
base64_header = "\n" + line_prefix + "##"
base64_header = "\n" + line_prefix + "#"

offset = 0;
while offset < len(json_string):
Expand Down Expand Up @@ -109,7 +109,7 @@ def lv_cat(*args):


def lexiographically_larger(bytes1,bytes2):
"Returns True if bytes1 > bytes2 for lexiographical ordering."
"Returns True if bytes1>bytes2 for lexiographical ordering."
min_len = min (len(bytes1), len(bytes2))
for m in range(min_len):
if bytes1[m] > bytes2[m]:
Expand Down Expand Up @@ -196,7 +196,7 @@ def prepend_len(data):
result_dict["prepend_len(bytes(range(128)))"] = byte_string_to_json(prepend_len(bytes(range(128))))

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)


print ("\n\n### lv\\_cat function\n", file = file)
Expand All @@ -215,20 +215,20 @@ def prepend_len(data):

print ("\n### Testvector for lv\\_cat()\n", file = file)
print ("~~~", file = file)
tv_output_byte_array(lv_cat(b"1234",b"5",b"",b"6789"),
test_vector_name = 'lv_cat(b"1234",b"5",b"",b"6789")',
tv_output_byte_array(lv_cat(b"1234",b"5",b"",b"678"),
test_vector_name = 'lv_cat(b"1234",b"5",b"",b"678")',
line_prefix = " ", max_len = 60, file = file);

print ("~~~", file = file)

result_dict = {}
result_dict["ba1"] = byte_string_to_json(b"1234")
result_dict["ba2"] = byte_string_to_json(b"5")
result_dict["ba3"] = byte_string_to_json(b"6789")
result_dict["lv_cat(ba1,ba2,ba3)"] = byte_string_to_json(lv_cat(b"1234",b"5",b"",b"6789"))
result_dict['b"1234"'] = byte_string_to_json(b"1234")
result_dict['b"5"'] = byte_string_to_json(b"5")
result_dict['b"678"'] = byte_string_to_json(b"678")
result_dict['lv_cat(b"1234",b"5",b"",b"678")'] = byte_string_to_json(lv_cat(b"1234",b"5",b"",b"678"))

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)


print ("\n## Definition of generator\\_string function.\n\n" +
Expand All @@ -252,7 +252,7 @@ def generator_string(DSI,PRS,CI,sid,s_in_bytes):
"""
~~~ python
def lexiographically_larger(bytes1,bytes2):
"Returns True if bytes1 > bytes2 using lexiographical ordering."
"Returns True if bytes1>bytes2 using lexiographical ordering."
min_len = min (len(bytes1), len(bytes2))
for m in range(min_len):
if bytes1[m] > bytes2[m]:
Expand Down Expand Up @@ -305,7 +305,7 @@ With the above definition of lexiographical ordering ordered concatenation is sp
result_dict['o_cat(b"BCD",b"ABCDE")'] = byte_string_to_json(o_cat(b"BCD",b"ABCDE"))

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)


print ("""
Expand Down Expand Up @@ -342,7 +342,7 @@ def transcript_ir(Ya,ADa,Yb,ADb):
result_dict['transcript_ir(b"3456",b"PartyA",b"2345",b"PartyB")'] = byte_string_to_json(transcript_ir(b"3456",b"PartyA",b"2345",b"PartyB"))

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)


print ("""
Expand Down Expand Up @@ -378,7 +378,7 @@ def transcript_oc(Ya,ADa,Yb,ADb):
result_dict['transcript_oc(b"3456",b"PartyA",b"2345",b"PartyB")'] = byte_string_to_json(transcript_oc(b"3456",b"PartyA",b"2345",b"PartyB"))

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)



Expand Down
4 changes: 2 additions & 2 deletions poc/CPace_testvectors.sage
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def generate_test_vector(H,G, with_ANSI_C_initializers = True,file=sys.stdout, p
line_prefix = " ", max_len = 60, file=file)

if (print_negated_Y):
tv_output_byte_array(G.scalar_mult_negated_result(ya, g), test_vector_name = "Alternative correct value for Ya: g*(-ya)",
tv_output_byte_array(G.scalar_mult_negated_result(ya, g), test_vector_name = "Alternative correct value for Ya: (-ya)*g",
line_prefix = " ", max_len = 60, file=file)

print ("~~~", file=file)
Expand All @@ -95,7 +95,7 @@ def generate_test_vector(H,G, with_ANSI_C_initializers = True,file=sys.stdout, p
tv_output_byte_array(Yb, test_vector_name = "Yb",
line_prefix = " ", max_len = 60, file=file)
if (print_negated_Y):
tv_output_byte_array(G.scalar_mult_negated_result(yb, g), test_vector_name = "Alternative correct value for Yb: g*(-yb)",
tv_output_byte_array(G.scalar_mult_negated_result(yb, g), test_vector_name = "Alternative correct value for Yb: (-yb)*g",
line_prefix = " ", max_len = 60, file=file)

print ("~~~", file=file)
Expand Down
4 changes: 2 additions & 2 deletions poc/CPace_weierstrass.sage
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class G_ShortWeierstrass():
result_dict["generator g"] = byte_string_to_json(self.point_to_octets(result))

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)

return self.point_to_octets(result)

Expand Down Expand Up @@ -190,7 +190,7 @@ def output_weierstrass_invalid_point_test_cases(G, file = sys.stdout):
result_dict["Invalid Y2"] = byte_string_to_json(Y_inv2)

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)

return result_dict

Expand Down
4 changes: 2 additions & 2 deletions poc/test_vectors_X448_X25519.sage
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def output_test_vectors_for_weak_points_255(file = sys.stdout):
print ("~~~\n", file = file)

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)

return result_dict

Expand Down Expand Up @@ -201,7 +201,7 @@ def output_test_vectors_for_weak_points_448(file = sys.stdout):
print ("~~~\n", file = file)

print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file)
tv_output_python_dictionary_as_json_base64(result_dict,line_prefix = " ",file=file)
tv_output_python_dictionary_as_json_base64(result_dict,file=file)

return result_dict

Expand Down
Loading

0 comments on commit 45270cc

Please sign in to comment.