mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-10 18:21:34 +03:00
Jet shar:ed curve25519 shared secret arm
This commit is contained in:
parent
e8ab61be7f
commit
4a9d61607f
3
Makefile
3
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 \
|
||||
|
@ -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);
|
||||
|
47
jets/e/ed_shar.c
Normal file
47
jets/e/ed_shar.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* j/5/shar.c
|
||||
**
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
#include <ed25519.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -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[] =
|
||||
|
Loading…
Reference in New Issue
Block a user