really still wip
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "ed_25519.h"
|
||||
#include "lib/config.h"
|
||||
#include "sha512.h"
|
||||
#include "ge.h"
|
||||
#include "sc.h"
|
||||
@@ -29,3 +30,35 @@ void ed25519_sign(unsigned char *signature, const unsigned char *message, size_t
|
||||
sc_reduce(hram);
|
||||
sc_muladd(signature + 32, hram, private_key, r);
|
||||
}
|
||||
|
||||
void ed25519_sign_ad(FrameStruct *frame) {
|
||||
sha512_context hash;
|
||||
unsigned char hram[64];
|
||||
unsigned char r[64];
|
||||
ge_p3 R;
|
||||
|
||||
unsigned char *signature = &(frame->payload[36]);
|
||||
|
||||
|
||||
sha512_init(&hash);
|
||||
sha512_update(&hash, persistent.privkey + 32, 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, r);
|
||||
|
||||
sc_reduce(r);
|
||||
ge_scalarmult_base(&R, r);
|
||||
ge_p3_tobytes(signature, &R);
|
||||
|
||||
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, hram);
|
||||
|
||||
sc_reduce(hram);
|
||||
sc_muladd(signature + 32, hram, persistent.privkey, r);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user