mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-05-01 05:02:29 +02:00
Add eddsa from ref10 implementation (with some modifications).
This commit is contained in:
parent
2fcc91a755
commit
93d60152d5
84 changed files with 5798 additions and 567 deletions
40
core/crypto/ed25519/open.cpp
Normal file
40
core/crypto/ed25519/open.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <string.h>
|
||||
#include "crypto_sign.h"
|
||||
#include "crypto_hash_sha512.h"
|
||||
#include "crypto_verify_32.h"
|
||||
#include "ge.h"
|
||||
#include "sc.h"
|
||||
|
||||
int crypto_sign_open(
|
||||
const unsigned char* sig,
|
||||
const unsigned char* m, unsigned long long mlen,
|
||||
const unsigned char* pk
|
||||
)
|
||||
{
|
||||
unsigned char pkcopy[32];
|
||||
unsigned char rcopy[32];
|
||||
unsigned char scopy[32];
|
||||
unsigned char h[64];
|
||||
unsigned char rcheck[32];
|
||||
ge_p3 A;
|
||||
ge_p2 R;
|
||||
|
||||
if (sig[63] & 224) goto badsig;
|
||||
if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig;
|
||||
|
||||
memmove(pkcopy,pk,32);
|
||||
memmove(rcopy, sig, 32);
|
||||
memmove(scopy, sig + 32,32);
|
||||
|
||||
crypto_hash_sha512_3(h, rcopy, 32, pkcopy, 32, m, mlen);
|
||||
sc_reduce(h);
|
||||
|
||||
ge_double_scalarmult_vartime(&R,h,&A,scopy);
|
||||
ge_tobytes(rcheck,&R);
|
||||
if (crypto_verify_32(rcheck,rcopy) == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
badsig:
|
||||
return -1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue