really still wip

This commit is contained in:
2025-12-28 12:23:11 +01:00
parent a48ef9d5e0
commit 31dda62474
33 changed files with 1721 additions and 589 deletions

View File

@@ -75,3 +75,38 @@ int ed25519_verify(const unsigned char *signature, const unsigned char *message,
return 1;
}
int ed25519_verify_ad(const FrameStruct *frame) {
unsigned char h[64];
unsigned char checker[32];
sha512_context hash;
ge_p3 A;
ge_p2 R;
const unsigned char *signature = &(frame->payload[36]);
if (signature[63] & 224) {
return 0;
}
if (ge_frombytes_negate_vartime(&A, frame->payload) != 0) { //pubkey is at start
return 0;
}
sha512_init(&hash);
sha512_update(&hash, signature, 32);
sha512_update(&hash, frame->payload, 32);
sha512_update(&hash, frame->payload, 36); // pubkey and timestamp combined (32 bytes pubkey, 4 bytes timestamp)
sha512_update(&hash, &(frame->payload[100]), frame->payloadLen - 100);
sha512_final(&hash, h);
sc_reduce(h);
ge_double_scalarmult_vartime(&R, h, &A, signature + 32);
ge_tobytes(checker, &R);
if (!consttime_equal(checker, signature)) {
return 0;
}
return 1;
}