Skip to content

Commit

Permalink
c backend rewrite, ecc more3
Browse files Browse the repository at this point in the history
  • Loading branch information
smurfd committed Jan 12, 2025
1 parent bf10699 commit b9f16f5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lotordb/src/rewrite/lotordb/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ static inline uint32_t bits2int(const uint8_t *q, const uint32_t blen, const uin
memset(ret, 0, qlen - blen);
memcpy(ret + (qlen - blen), q, qlen);
}
for (int i = qlen - 1; i >= 0; i--) {
r += ret[i - (qlen - 1)] * (2 ^ i);
for (int co = 0, i = qlen - 1; i >= 0; i--) {
r += ret[co++] * (2 ^ i);
//r += ret[i - (qlen - 1)] * (2 ^ i);
}
return r;
}
Expand Down Expand Up @@ -94,7 +95,7 @@ static inline void ecc_signgen(uint32_t r, uint32_t s, const char *msg) {
r = MOD(bits2int(gg, 32, 32), q); // TODO: fix length
uint32_t s1 = (h + x * r)/k;
s = MOD(s1, q);
printf("sig: %lu, %lu\n", r, s);
//printf("sig: %lu, %lu\n", r, s); // TODO: overflow of r, s?
}

// montgomerys ladder
Expand Down Expand Up @@ -202,7 +203,7 @@ void ecc_sign_gen(void) {
}
uint32_t r1 = 0, s1 = 0;
ecc_signgen(r1, s1, "some string to hash");
printf("sig: %lu, %lu\n", r1, s1);
//printf("sig: %lu, %lu\n", r1, s1);
}
// ECDSA
// https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm
Expand Down

0 comments on commit b9f16f5

Please sign in to comment.