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

[ECC] missing reduction operation on hashed message #221

Closed
mojtaba-bisheh opened this issue Sep 20, 2023 · 2 comments
Closed

[ECC] missing reduction operation on hashed message #221

mojtaba-bisheh opened this issue Sep 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@mojtaba-bisheh
Copy link
Contributor

To sign or verify a message, the input hash must be reduced modulo q, as specified in RFC6979 page 9. This step was missing in the ECC implementation and caused a discrepancy with the HMAC_DRBG output. This error was not detected by our random tests because the chance of getting a random number larger than q is very low.
We need to add a new test vector with a message that exceeds q to verify this step.

@mojtaba-bisheh mojtaba-bisheh self-assigned this Sep 20, 2023
@mojtaba-bisheh mojtaba-bisheh added the bug Something isn't working label Sep 20, 2023
@mojtaba-bisheh
Copy link
Contributor Author

mojtaba-bisheh commented Sep 20, 2023

The fix has been implemented as follows, and a set of test vectors (with message greater than q) has been added to ecc testbench to verify this.

    //transformed msg into modulo q 
    always_ff @(posedge clk or negedge reset_n) 
    begin : reduced_msg
        if (!reset_n)
            msg_reduced_reg <= '0;
        else if (zeroize_reg)
            msg_reduced_reg <= '0;
        else begin
            if (msg_reg >= GROUP_ORDER)
                msg_reduced_reg <= msg_reg - GROUP_ORDER;
            else
                msg_reduced_reg <= msg_reg;
        end
    end

@mojtaba-bisheh
Copy link
Contributor Author

#240 sync fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant