Skip to content

Commit

Permalink
Slight improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Oct 24, 2024
1 parent bf76520 commit 2b82dc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion bench/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(void) {
uint8_t verification_key[VERIFICATION_KEY_SIZE];
uint8_t signing_key[SIGNING_KEY_SIZE];

uint8_t message[SIGNATURE_SIZE] = {0};
uint8_t message[64] = {0};
uint8_t signature[SIGNATURE_SIZE];

uint64_t observations[DATA_POINTS], i;
Expand Down
33 changes: 10 additions & 23 deletions ml_dsa_65/ref/ml_dsa.jazz
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,17 @@ require "verify.jinc"
// at 5 arguments for signing, and Jasmin does not currently support functions
// that take more than 6 arguments.

// TODO: Replace reg with reg ptr
export fn ml_dsa_65_keygen(reg u64 verification_key_out signing_key_out randomness)
export fn ml_dsa_65_keygen(
reg u64 verification_key_out signing_key_out,
reg ptr u8[32] randomness)
{
stack u8[32] randomness_on_stack;

stack u8[VERIFICATION_KEY_SIZE] verification_key;
stack u8[SIGNING_KEY_SIZE] signing_key;

reg u8 c;
reg u64 i;

i = 0;
while (i < 32) {
c = (u8)[randomness + i];
randomness_on_stack[i] = c;
i += 1;
}

verification_key, signing_key = keygen_internal(randomness_on_stack);
verification_key, signing_key = keygen_internal(randomness);

i = 0;
while (i < VERIFICATION_KEY_SIZE) {
Expand All @@ -46,32 +38,27 @@ export fn ml_dsa_65_keygen(reg u64 verification_key_out signing_key_out randomne
}
}

export fn ml_dsa_65_sign(reg u64 signature_out signing_key message message_size randomness) -> reg u16
export fn ml_dsa_65_sign(
reg u64 signature_out signing_key message message_size,
reg ptr u8[32] randomness
) -> reg u32
{
stack u8[32] randomness_on_stack;
stack u8[SIGNING_KEY_SIZE] signing_key_on_stack;

stack u8[SIGNATURE_SIZE] signature;
reg u16 signing_attempts;
reg u32 signing_attempts;

reg u8 c;
reg u64 i;

i = 0;
while (i < 32) {
c = (u8)[randomness + i];
randomness_on_stack[i] = c;
i += 1;
}

i = 0;
while(i < SIGNING_KEY_SIZE) {
c = (u8)[signing_key + i];
signing_key_on_stack[i] = c;
i += 1;
}

signature, signing_attempts = sign_internal(signing_key_on_stack, message, message_size, randomness_on_stack);
signature, signing_attempts = sign_internal(signing_key_on_stack, message, message_size, randomness);

i = 0;
while(i < SIGNATURE_SIZE) {
Expand Down
4 changes: 2 additions & 2 deletions ml_dsa_65/ref/sign.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn sign_internal(
reg u64 message_size,
reg ptr u8[32] randomness
)
-> stack u8[SIGNATURE_SIZE], reg u16
-> stack u8[SIGNATURE_SIZE], reg u32
{
stack u8[SIGNATURE_SIZE] signature_encoded;

Expand Down Expand Up @@ -94,7 +94,7 @@ fn sign_internal(
stack u8 exit_rejection_sampling_loop;

// Count and return signing attempts; this is useful for testing.
stack u16 signing_attempts;
stack u32 signing_attempts;

stack u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] mask;
stack u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] w;
Expand Down

0 comments on commit 2b82dc5

Please sign in to comment.