sort-of fix jets for Ed25519

puck:ed is correct for at least the single test-point i tried.

sign:ed is still wrong.
This commit is contained in:
~hatteb-mitlyd 2014-04-11 17:02:10 -07:00
parent c3c3c1c709
commit 7000bdda2f
5 changed files with 74 additions and 14 deletions

View File

@ -34,7 +34,7 @@ RM=rm -f
CC=gcc
CXX=g++
CXXFLAGS=$(CFLAGS)
CLD=g++ -O2 -g -L/usr/local/lib -L/opt/local/lib
CLD=g++ -O0 -g -L/usr/local/lib -L/opt/local/lib
YACC=bison -v -b$(GENERATED)/y
LEX=lex
@ -55,7 +55,7 @@ LIBS=-lssl -lcrypto -lgmp -lncurses -lsigsegv $(OSLIBS)
INCLUDE=include
MDEFINES=-DU2_OS_$(OS) -DU2_OS_ENDIAN_$(ENDIAN) -D U2_LIB=\"$(LIB)\"
CFLAGS= -O2 -g \
CFLAGS= -O0 -g \
-I/usr/local/include \
-I/opt/local/include \
-I$(INCLUDE) \
@ -177,6 +177,7 @@ J164_5_OFILES=\
gen164/5/trip.o
J164_5_OFILES_ED=\
gen164/5/ed_puck.o \
gen164/5/ed_sign.o
J164_6_OFILES=\

View File

@ -7,16 +7,20 @@
/* declarations
*/
extern u2_ho_jet j2_mcj(Pt5, ed, sign)[];
extern u2_ho_jet j2_mdj(Pt5, coed, ed, sign)[];
extern u2_ho_jet j2_mdj(Pt5, coed, ed, puck)[];
u2_ho_driver
j2_mcd(Pt5, coed, ed)[] = {
{ j2_sd(Pt5, coed, ed, sign), j2_mdj(Pt5, coed, ed, sign), 0, 0, u2_none },
{ j2_sd(Pt5, coed, ed, puck), j2_mdj(Pt5, coed, ed, puck), 0, 0, u2_none },
{}
};
/* structures
*/
u2_ho_driver
j2_mbd(Pt5, ed)[] = {
{ j2_sc(Pt5, ed, sign), j2_mcj(Pt5, ed, sign), 0, 0, u2_none },
j2_mbd(Pt5, coed)[] = {
{ j2_sc(Pt5, coed, ed), 0, j2_mcd(Pt5, coed, ed), 0, 0, u2_none },
{}
};
u2_ho_driver
j2_db(Pt5, ed) =
{ j2_sb(Pt5, ed), 0, j2_mbd(Pt5, ed), 0, u2_none };

36
gen164/5/ed_puck.c Normal file
View File

@ -0,0 +1,36 @@
/* gen164/5/ed_sign.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
#include <ed25519.h>
/* functions
*/
u2_weak
j2_md(Pt5, coed, ed, puck)(u2_wire wir_r,
u2_noun cor)
{
c3_y pub_y[32];
c3_y sec_y[64];
c3_y sed_y[32];
u2_noun a = u2_frag(u2_cv_sam, cor);
if ( (u2_none == a) || (u2_no == u2_stud(a)) ) {
return u2_bl_bail(wir_r, c3__exit);
}
u2_cr_bytes(0, 32, sed_y, a);
ed25519_create_keypair(pub_y, sec_y, sed_y);
return u2_ci_bytes(32, pub_y);
}
/* structures
*/
u2_ho_jet
j2_mdj(Pt5, coed, ed, puck)[] = {
{ ".2", c3__lite, j2_md(Pt5, coed, ed, puck),
u2_jet_test|u2_jet_live, u2_none, u2_none },
{ }
};

View File

@ -10,7 +10,7 @@
/* functions
*/
u2_weak // transfer
j2_mc(Pt5, ed, sign)(u2_wire wir_r,
j2_mcc(Pt5, ed, sign)(u2_wire wir_r,
u2_noun a, // retain
u2_noun b, // retain
u2_noun c) // retain
@ -26,26 +26,43 @@
c3_y* mes_y = 0;
if ( 64 < secm_w ) {
return u2_bl_bail(wir_r, c3__exit);
}
if ( 32 < pubm_w ) {
return u2_bl_bail(wir_r, c3__exit);
}
memset(&sig_y, 64, 0);
memset(&pub_y, 32, 0);
mes_y = c3_malloc(mesm_w);
u2_cr_bytes(0, mesm_w, mes_y, a);
u2_cr_bytes(0, 64, sec_y, b);
u2_cr_bytes(0, 32, pub_y, c);
u2_cr_bytes(0, secm_w, sec_y, b);
u2_cr_bytes(0, pubm_w, pub_y, c);
ed25519_sign(sig_y, mes_y, mesm_w, pub_y, sec_y);
free(mes_y);
return u2_ci_bytes(64, sig_y);
}
u2_weak
j2_md(Pt5, coed, ed, sign)(u2_wire wir_r,
u2_noun cor)
{
u2_noun a, b, c;
if ( u2_no == u2_mean(cor,
u2_cv_sam_2, &a, u2_cv_sam_6, &b,
u2_cv_sam_7, &c, 0) ) {
return u2_bl_bail(wir_r, c3__fail);
} else {
return j2_mcc(Pt5, ed, sign)(wir_r, a, b, c);
}
}
/* structures
*/
u2_ho_jet
j2_mcj(Pt5, ed, sign)[] = {
{ ".2", c3__lite, j2_mc(Pt5, ed, sign), u2_jet_test|u2_jet_live, u2_none, u2_none },
j2_mdj(Pt5, coed, ed, sign)[] = {
{ ".2", c3__lite, j2_md(Pt5, coed, ed, sign), u2_jet_test|u2_jet_live, u2_none, u2_none },
{ }
};

View File

@ -100,6 +100,7 @@
extern u2_ho_driver j2_mbd(Pt5, comp)[];
extern u2_ho_driver j2_mbd(Pt5, cook)[];
extern u2_ho_driver j2_mbd(Pt5, easy)[];
extern u2_ho_driver j2_mbd(Pt5, coed)[];
extern u2_ho_driver j2_mbd(Pt5, glue)[];
extern u2_ho_driver j2_mbd(Pt5, here)[];
extern u2_ho_driver j2_mbd(Pt5, just)[];
@ -213,6 +214,7 @@
{ j2_sb(Pt4, in), 0, j2_mbd(Pt4, in), 0, u2_none },
{ j2_sb(Pt4, by), 0, j2_mbd(Pt4, by), 0, u2_none },
{ j2_sb(Pt5, bend), 0, j2_mbd(Pt5, bend), 0, u2_none },
{ j2_sb(Pt5, coed), 0, j2_mbd(Pt5, coed), 0, u2_none },
{ j2_sb(Pt5, cold), 0, j2_mbd(Pt5, cold), 0, u2_none },
{ j2_sb(Pt5, comp), 0, j2_mbd(Pt5, comp), 0, u2_none },
{ j2_sb(Pt5, cook), 0, j2_mbd(Pt5, cook), 0, u2_none },