diff --git a/Makefile b/Makefile index 83ea4eb0e..57658c7c4 100644 --- a/Makefile +++ b/Makefile @@ -268,7 +268,8 @@ J_E_OFILES=\ J_E_OFILES_ED=\ jets/e/ed_puck.o \ jets/e/ed_sign.o \ - jets/e/ed_veri.o + jets/e/ed_veri.o \ + jets/e/ed_shar.o J_F_OFILES=\ jets/f/al.o \ diff --git a/include/jets/w.h b/include/jets/w.h index ebe70213f..7075c6047 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -132,6 +132,7 @@ u3_noun u3wee_puck(u3_noun); u3_noun u3wee_sign(u3_noun); u3_noun u3wee_veri(u3_noun); + u3_noun u3wee_shar(u3_noun); u3_noun u3we_bend_fun(u3_noun); u3_noun u3we_cold_fun(u3_noun); diff --git a/jets/e/ed_shar.c b/jets/e/ed_shar.c new file mode 100644 index 000000000..d67110699 --- /dev/null +++ b/jets/e/ed_shar.c @@ -0,0 +1,47 @@ +/* j/5/shar.c +** +*/ +#include "all.h" + +#include + + u3_noun + u3qee_shar(u3_atom pub, u3_atom sek) + { + c3_y pub_y[32], sek_y[32], self_y[32], exp_y[64], shr_y[32]; + c3_w met_pub_w, met_sek_w; + + met_pub_w = u3r_met(3, pub); + met_sek_w = u3r_met(3, sek); + + if ( (met_pub_w > 32) || (met_sek_w > 32) ) { + return u3m_bail(c3__exit); + } + + u3r_bytes(0, 32, pub_y, pub); + u3r_bytes(0, 32, sek_y, sek); + + memset(self_y, 0, 32); + memset(exp_y, 0, 64); + memset(shr_y, 0, 32); + + ed25519_create_keypair(self_y, exp_y, sek_y); + ed25519_key_exchange(shr_y, pub_y, exp_y); + + return u3i_bytes(32, shr_y); + } + + u3_noun + u3wee_shar(u3_noun cor) + { + u3_noun pub, sek; + + if ( (c3n == u3r_mean(cor, u3x_sam_2, &pub, u3x_sam_3, &sek, 0)) || + (c3n == u3ud(pub)) || + (c3n == u3ud(sek)) ) + { + return u3m_bail(c3__exit); + } else { + return u3qee_shar(pub, sek); + } + } diff --git a/jets/tree.c b/jets/tree.c index 1f9bc6b96..d7bb3a6b4 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -300,10 +300,13 @@ static u3j_core _mood__hoon__rq_d[] = static u3j_harm _mood__hoon__coed__ed_puck_a[] = {{".2", u3wee_puck}, {}}; static u3j_harm _mood__hoon__coed__ed_sign_a[] = {{".2", u3wee_sign}, {}}; static u3j_harm _mood__hoon__coed__ed_veri_a[] = {{".2", u3wee_veri}, {}}; +static u3j_harm _mood__hoon__coed__ed_shar_a[] = {{".2", u3wee_shar}, {}}; + static u3j_core _mood__hoon__coed__ed_d[] = { { "sign", _mood__hoon__coed__ed_sign_a }, { "puck", _mood__hoon__coed__ed_puck_a }, { "veri", _mood__hoon__coed__ed_veri_a }, + { "shar", _mood__hoon__coed__ed_shar_a }, {} }; static u3j_core _mood__hoon__coed_d[] =