mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-31 18:40:56 +00:00
cleanup
This commit is contained in:
parent
df79a330e6
commit
d958d8a90e
8
ecdsa.c
8
ecdsa.c
@ -39,7 +39,7 @@ void mod(bignum256 *x, bignum256 const *prime)
|
|||||||
int i = 8;
|
int i = 8;
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
// compare numbers
|
// compare numbers
|
||||||
while (i >= 0 && prime->val[i] == x->val[i]) --i;
|
while (i >= 0 && prime->val[i] == x->val[i]) i--;
|
||||||
// if equal
|
// if equal
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
// set x to zero
|
// set x to zero
|
||||||
@ -620,7 +620,7 @@ int is_zero(const bignum256 *a)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bignum256_less(const bignum256 *a, const bignum256 *b)
|
int is_less(const bignum256 *a, const bignum256 *b)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 8; i >= 0; i--) {
|
for (i = 8; i >= 0; i--) {
|
||||||
@ -654,8 +654,8 @@ int ecdsa_verify(uint8_t *pub_key, uint8_t *signature, uint8_t *msg, uint32_t ms
|
|||||||
|
|
||||||
if (is_zero(&r) ||
|
if (is_zero(&r) ||
|
||||||
is_zero(&s) ||
|
is_zero(&s) ||
|
||||||
(!bignum256_less(&r,&order256k1)) ||
|
(!is_less(&r, &order256k1)) ||
|
||||||
(!bignum256_less(&s,&order256k1))) return 1;
|
(!is_less(&s, &order256k1))) return 1;
|
||||||
|
|
||||||
inverse(&s, &order256k1); // s^-1
|
inverse(&s, &order256k1); // s^-1
|
||||||
multiply(&s, &z, &order256k1); // z*s^-1
|
multiply(&s, &z, &order256k1); // z*s^-1
|
||||||
|
Loading…
Reference in New Issue
Block a user