48 lines
968 B
C
48 lines
968 B
C
#include <string.h>
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include "../ref/csidh/csidh.h"
|
|
|
|
static void u512_print(u512 const *x)
|
|
{
|
|
for (size_t i = 63; i < 64; --i)
|
|
printf("%02hhx", i[(unsigned char *) x->c]);
|
|
printf("\n");
|
|
}
|
|
|
|
static void fp_print(fp const *x)
|
|
{
|
|
u512 y;
|
|
fp_dec(&y, x);
|
|
u512_print(&y);
|
|
}
|
|
|
|
static void int_print(const int8_t v[37]) {
|
|
for (size_t i = 0; i<37; i++)
|
|
printf("%02hhx", v[i]);
|
|
printf("\n");
|
|
}
|
|
|
|
int main() {
|
|
for(size_t i=0; i<1000; i++) {
|
|
private_key prA, prB;
|
|
public_key pkA, pkB;
|
|
public_key shA, shB;
|
|
|
|
// private key
|
|
csidh_private(&prA);
|
|
csidh_private(&prB);
|
|
|
|
// public key
|
|
csidh(&pkA, &base, &prA);
|
|
csidh(&pkB, &base, &prB);
|
|
|
|
//csidh
|
|
csidh(&shA, &pkA, &prB);
|
|
csidh(&shB, &pkB, &prA);
|
|
int_print(prA.e);
|
|
fp_print(&pkA.A);
|
|
assert(memcmp(&shA, &shB, sizeof(shB))==0);
|
|
}
|
|
}
|