CSIDH ref
This commit is contained in:
parent
67c6788ad9
commit
e57ad23ba3
@ -28,6 +28,7 @@ $(BUILD_DIR)/%.o: %.s
|
||||
all: $(CODE_OBJ)
|
||||
$(AR) $(BUILD_DIR)/libcsidh.a $^
|
||||
$(RANLIB) $(BUILD_DIR)/libcsidh.a
|
||||
$(CC) -o $(BUILD_DIR)/test test/main.c -L$(BUILD_DIR) -lcsidh
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
40
csidh/test/main.c
Normal file
40
csidh/test/main.c
Normal file
@ -0,0 +1,40 @@
|
||||
#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);
|
||||
}
|
||||
|
||||
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);
|
||||
fp_print(&shA.A);
|
||||
assert(memcmp(&shA, &shB, sizeof(shB))==0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user