1 /* j/5/shar.c 2 ** 3 */ 4 #include "all.h" 5 6 #include <ed25519.h> 7 8 u3_noun u3qee_shar(u3_atom pub,u3_atom sek)9 u3qee_shar(u3_atom pub, u3_atom sek) 10 { 11 c3_y pub_y[32], sek_y[32], self_y[32], exp_y[64], shr_y[32]; 12 c3_w met_pub_w, met_sek_w; 13 14 met_pub_w = u3r_met(3, pub); 15 met_sek_w = u3r_met(3, sek); 16 17 if ( (met_pub_w > 32) || (met_sek_w > 32) ) { 18 return u3m_bail(c3__exit); 19 } 20 21 u3r_bytes(0, 32, pub_y, pub); 22 u3r_bytes(0, 32, sek_y, sek); 23 24 memset(self_y, 0, 32); 25 memset(exp_y, 0, 64); 26 memset(shr_y, 0, 32); 27 28 ed25519_create_keypair(self_y, exp_y, sek_y); 29 ed25519_key_exchange(shr_y, pub_y, exp_y); 30 31 return u3i_bytes(32, shr_y); 32 } 33 34 u3_noun u3wee_shar(u3_noun cor)35 u3wee_shar(u3_noun cor) 36 { 37 u3_noun pub, sek; 38 39 if ( (c3n == u3r_mean(cor, u3x_sam_2, &pub, u3x_sam_3, &sek, 0)) || 40 (c3n == u3ud(pub)) || 41 (c3n == u3ud(sek)) ) 42 { 43 return u3m_bail(c3__exit); 44 } else { 45 return u3qee_shar(pub, sek); 46 } 47 } 48