From 54dc140629b3af5de2043f52ba9dc36aff6b949d Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Thu, 29 Jan 2026 18:17:06 +0100 Subject: [PATCH] Add opcodes for ML-DSA verify functions --- rebar.lock | 12 ++++++------ src/gmb_fate_generate_ops.erl | 4 ++++ test/gmbytecode_SUITE.erl | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/rebar.lock b/rebar.lock index 3fc7485..6f34c07 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,9 +1,5 @@ {"1.2.0", -[{<<"gmserialization">>, - {git,"https://git.qpq.swiss/QPQ-AG/gmserialization.git", - {ref,"9d2ecc00d32ea295309563e54a81636ecb597e96"}}, - 0}, - {<<"base58">>, +[{<<"base58">>, {git,"https://git.qpq.swiss/QPQ-AG/erl-base58.git", {ref,"e6aa62eeae3d4388311401f06e4b939bf4e94b9c"}}, 1}, @@ -12,7 +8,11 @@ {git,"https://git.qpq.swiss/QPQ-AG/enacl.git", {ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}}, 1}, - {<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0}]}. + {<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0}, + {<<"gmserialization">>, + {git,"https://git.qpq.swiss/QPQ-AG/gmserialization.git", + {ref,"9d2ecc00d32ea295309563e54a81636ecb597e96"}}, + 0}]}. [ {pkg_hash,[ {<<"eblake2">>, <<"EC8AD20E438AAB3F2E8D5D118C366A0754219195F8A0F536587440F8F9BCF2EF">>}, diff --git a/src/gmb_fate_generate_ops.erl b/src/gmb_fate_generate_ops.erl index 6025546..0ab1589 100644 --- a/src/gmb_fate_generate_ops.erl +++ b/src/gmb_fate_generate_ops.erl @@ -247,6 +247,10 @@ ops_defs() -> , { 'INT_TO_BYTES', 16#b4, false, true, true, ?GAS(10), [a, a, a], int_to_bytes, {integer, integer}, bytes, "Arg0 := turn integer Arg1 into a byte array (big endian) length Arg2 (truncating if not fit)."} , { 'STR_TO_BYTES', 16#b5, false, true, true, ?GAS(10), [a, a], str_to_bytes, {integer}, bytes, "Arg0 := turn string Arg1 into the corresponding byte array."} , { 'NETWORK_ID', 16#b6, false, true, true, ?GAS(10), [a], network_id, {}, string, "Arg0 := The network_id of the chain."} + %% Gas estimates based on simple verify benchmarks: ed25519 (?GAS(1300)): 41µs, mldsa44: 75µs, mldsa65: 113µs, mldsa87: 179µs + , { 'VERIFY_SIG_MLDSA44', 16#b7, false, true, true, ?GAS(2340), [a,a,a,a], verify_sig_mldsa44, {bytes, bytes, bytes}, boolean, "Arg0 := verify_sig_mldsa44(Hash, Pubkey, Signature)"} + , { 'VERIFY_SIG_MLDSA65', 16#b8, false, true, true, ?GAS(3640), [a,a,a,a], verify_sig_mldsa65, {bytes, bytes, bytes}, boolean, "Arg0 := verify_sig_mldsa65(Hash, Pubkey, Signature)"} + , { 'VERIFY_SIG_MLDSA87', 16#b9, false, true, true, ?GAS(5720), [a,a,a,a], verify_sig_mldsa87, {bytes, bytes, bytes}, boolean, "Arg0 := verify_sig_mldsa87(Hash, Pubkey, Signature)"} , { 'DBG_LOC', 16#f0, false, true, true, ?GAS(0), [a, a], dbg_loc, {string, integer}, none, "Debug Op: Execution location. Args = {file_name, line_num}" } , { 'DBG_DEF', 16#f1, false, true, true, ?GAS(0), [a, a], dbg_def, {string, any}, none, "Debug Op: Define a variable. Args = {var_name, register}" } diff --git a/test/gmbytecode_SUITE.erl b/test/gmbytecode_SUITE.erl index e53a753..acd6245 100644 --- a/test/gmbytecode_SUITE.erl +++ b/test/gmbytecode_SUITE.erl @@ -13,7 +13,7 @@ all() -> roundtrip_identy(_Cfg) -> CodeDir = code:lib_dir(gmbytecode, test), - FileName = filename:join(CodeDir, "asm_code/identity.gmsm"), + FileName = filename:join(CodeDir, "asm_code/identity.aesm"), Code = gmb_asm:file(FileName, []), ct:log("Code ~p:~n~s~n", [FileName, gmb_disassemble:format(Code, fun io:format/2)]), ok.