first hack at sign:ed jet

This commit is contained in:
~hatteb-mitlyd 2014-04-10 18:05:59 -07:00
parent 8ba9d052f3
commit c3c3c1c709
3 changed files with 80 additions and 3 deletions

View File

@ -53,7 +53,6 @@ endif
LIBS=-lssl -lcrypto -lgmp -lncurses -lsigsegv $(OSLIBS)
INCLUDE=include
GENERATED=generated
MDEFINES=-DU2_OS_$(OS) -DU2_OS_ENDIAN_$(ENDIAN) -D U2_LIB=\"$(LIB)\"
CFLAGS= -O2 -g \
@ -63,7 +62,7 @@ CFLAGS= -O2 -g \
-Ioutside/libuv/include \
-Ioutside/re2 \
-Ioutside/cre2/src/src \
-I $(GENERATED) \
-Ioutside/ed25519/src \
$(DEFINES) \
$(MDEFINES)
@ -163,6 +162,7 @@ J164_4_OFILES=\
J164_5_OFILES=\
gen164/5/cue.o \
gen164/5/ed.o \
gen164/5/jam.o \
gen164/5/mat.o \
gen164/5/mink.o \
@ -176,6 +176,9 @@ J164_5_OFILES=\
gen164/5/tape.o \
gen164/5/trip.o
J164_5_OFILES_ED=\
gen164/5/ed_sign.o
J164_6_OFILES=\
gen164/6/al.o \
gen164/6/ap.o \
@ -234,6 +237,7 @@ J164_OFILES=\
$(J164_3_OFILES) \
$(J164_4_OFILES) \
$(J164_5_OFILES) \
$(J164_5_OFILES_ED) \
$(J164_6_OFILES) \
$(J164_6_OFILES_UT) \
gen164/watt.o
@ -303,7 +307,7 @@ etags:
etags -f .etags $$(find -name '*.c' -or -name '*.h')
clean:
$(RM) $(VERE_OFILES) $(BIN)/vere $(BIN)/eyre
$(RM) $(VERE_OFILES) $(BIN)/vere
$(MAKE) -C outside/libuv clean
$(MAKE) -C outside/re2 clean
$(MAKE) -C outside/ed25519 clean

22
gen164/5/ed.c Normal file
View File

@ -0,0 +1,22 @@
/* gen164/5/ed.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* declarations
*/
extern u2_ho_jet j2_mcj(Pt5, ed, sign)[];
/* structures
*/
u2_ho_driver
j2_mbd(Pt5, ed)[] = {
{ j2_sc(Pt5, ed, sign), j2_mcj(Pt5, ed, sign), 0, 0, u2_none },
{}
};
u2_ho_driver
j2_db(Pt5, ed) =
{ j2_sb(Pt5, ed), 0, j2_mbd(Pt5, ed), 0, u2_none };

51
gen164/5/ed_sign.c Normal file
View File

@ -0,0 +1,51 @@
/* gen164/5/ed_sign.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
#include <ed25519.h>
/* functions
*/
u2_weak // transfer
j2_mc(Pt5, ed, sign)(u2_wire wir_r,
u2_noun a, // retain
u2_noun b, // retain
u2_noun c) // retain
{
c3_y sig_y[64];
c3_y sec_y[64];
c3_y pub_y[32];
c3_w secm_w = u2_met(3, b);
c3_w pubm_w = u2_met(3, c);
c3_w mesm_w = u2_met(3, a);
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);
}
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);
ed25519_sign(sig_y, mes_y, mesm_w, pub_y, sec_y);
free(mes_y);
return u2_ci_bytes(64, sig_y);
}
/* 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 },
{ }
};