more unpacks

This commit is contained in:
Paul Driver 2020-08-04 13:42:10 -07:00
parent 84c959313d
commit 4218308d04
5 changed files with 25 additions and 59 deletions

View File

@ -18,8 +18,7 @@
(0 == u3r_unpack(32, b_y, b)) &&
(0 == u3r_unpack(32, c_y, c)) &&
(0 == u3r_unpack(32, d_y, d)) &&
(0 == urcrypt_ed_add_double_scalarmult(a_y, b_y, c_y, d_y, out_y)) )
{
(0 == urcrypt_ed_add_double_scalarmult(a_y, b_y, c_y, d_y, out_y)) ) {
return u3i_bytes(32, out_y);
}
else {

View File

@ -11,27 +11,16 @@
u3_atom b,
u3_atom c)
{
c3_w ate_w, bet_w, get_w;
if ( ((ate_w = u3r_met(3, a)) > 32) ||
((bet_w = u3r_met(3, b)) > 32) ||
((get_w = u3r_met(3, c)) > 32) ) {
return u3_none;
}
else {
c3_y a_y[32], b_y[32], c_y[32], out_y[32];
memset(a_y, 0, 32);
memset(b_y, 0, 32);
memset(c_y, 0, 32);
u3r_bytes(0, ate_w, a_y, a);
u3r_bytes(0, bet_w, b_y, b);
u3r_bytes(0, get_w, c_y, c);
return
( 0 == urcrypt_ed_add_scalarmult_scalarmult_base(a_y, b_y, c_y, out_y) )
? u3i_bytes(32, out_y)
: u3_none;
if ( (0 == u3r_unpack(32, a_y, a)) &&
(0 == u3r_unpack(32, b_y, b)) &&
(0 == u3r_unpack(32, c_y, c)) &&
(0 == urcrypt_ed_add_scalarmult_scalarmult_base(a_y, b_y, c_y, out_y)) ) {
return u3i_bytes(32, out_y);
}
else {
return u3_none;
}
}

View File

@ -11,23 +11,15 @@
_cqee_point_add(u3_atom a,
u3_atom b)
{
c3_w ate_w, bet_w;
if ( ((ate_w = u3r_met(3, a)) > 32) ||
((bet_w = u3r_met(3, b)) > 32) ) {
return u3_none;
}
else {
c3_y a_y[32], b_y[32], out_y[32];
memset(a_y, 0, 32);
memset(b_y, 0, 32);
u3r_bytes(0, ate_w, a_y, a);
u3r_bytes(0, bet_w, b_y, b);
return ( 0 == urcrypt_ed_point_add(a_y, b_y, out_y) )
? u3i_bytes(32, out_y)
: u3_none;
if ( (0 == u3r_unpack(32, a_y, a)) &&
(0 == u3r_unpack(32, b_y, b)) &&
(0 == urcrypt_ed_point_add(a_y, b_y, out_y)) ) {
return u3i_bytes(32, out_y);
}
else {
return u3_none;
}
}

View File

@ -12,16 +12,14 @@
c3_y sed_y[32], pub_y[32];
c3_w met_w;
if ( (met_w = u3r_met(3, sed)) > 32 ) {
if ( 0 == u3r_unpack(32, sed_y, sed) ) {
urcrypt_ed_puck(sed_y, pub_y);
return u3i_bytes(32, pub_y);
}
else {
// hoon explicitly crashes on mis-size
return u3m_bail(c3__exit);
}
memset(sed_y, 0, 32);
u3r_bytes(0, met_w, sed_y, sed);
urcrypt_ed_puck(sed_y, pub_y);
return u3i_bytes(32, pub_y);
}
u3_noun

View File

@ -10,29 +10,17 @@
_cqee_scalarmult(u3_atom a,
u3_atom b)
{
c3_w ate_w, bet_w;
c3_y a_y[32], b_y[32], out_y[32];
if ( (ate_w = u3r_met(3, a)) > 32 ) {
if ( (0 == u3r_unpack(32, a_y, a)) &&
(0 == u3r_unpack(32, b_y, b)) &&
(0 == urcrypt_ed_scalarmult(a_y, b_y, out_y)) ) {
return u3i_bytes(32, out_y);
}
else {
// hoon does not check size of inputs
return u3_none;
}
if ( (bet_w = u3r_met(3, b)) > 32 ) {
return u3_none;
}
memset(a_y, 0, 32);
memset(b_y, 0, 32);
u3r_bytes(0, ate_w, a_y, a);
u3r_bytes(0, bet_w, b_y, b);
if ( 0 != urcrypt_ed_scalarmult(a_y, b_y, out_y) ) {
// this is unlikely to happen, but there is a return code.
return u3_none;
}
return u3i_bytes(32, out_y);
}
u3_noun