Skip to content

Commit

Permalink
zif/ed-reform: remove punts, clean up bails
Browse files Browse the repository at this point in the history
  • Loading branch information
xiphiness committed Dec 11, 2024
1 parent f151884 commit 43d8d88
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
3 changes: 1 addition & 2 deletions pkg/noun/jets/e/ed_add_scalarmult_scalarmult_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
{
return u3m_bail(c3__exit);
} else {
return u3l_punt("add-scalarmult-scalarmult-base",
_cqee_add_scalarmult_scalarmult_base(a, b, c));
return _cqee_add_scalarmult_scalarmult_base(a, b, c);
}
}
2 changes: 1 addition & 1 deletion pkg/noun/jets/e/ed_point_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if ( (0 != u3r_bytes_fit(32, a_y, a)) ||
(0 != u3r_bytes_fit(32, b_y, b)) ||
(0 != urcrypt_ed_point_add(a_y, b_y, out_y)) ) {
return u3_none;
return u3m_bail(c3__exit);
}
else {
return u3i_bytes(32, out_y);
Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/jets/e/ed_point_neg.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

if ( (0 != u3r_bytes_fit(32, a_y, a)) ||
(0 != urcrypt_ed_point_neg(a_y)) ) {
return u3_none;
return u3m_bail(c3__exit);
}
else {
return u3i_bytes(32, a_y);
Expand Down
1 change: 1 addition & 0 deletions pkg/noun/jets/e/ed_scalarmult_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
}

if (0 != urcrypt_ed_scalarmult_base(a_y, out_y)) {
// should be unreachable, as scalar already reduced
return u3m_bail(c3__exit);
}
else {
Expand Down
13 changes: 5 additions & 8 deletions pkg/noun/jets/e/ed_shar.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
c3_y pub_y[32], sed_y[32];

if ( 0 != u3r_bytes_fit(32, pub_y, pub) ) {
// pub is not size checked in the hoon
return u3_none;
return u3m_bail(c3__exit);
}
else if ( 0 != u3r_bytes_fit(32, sed_y, sed) ) {
// sed explicitly bails through suck
// hoon calls luck, which crashes
return u3m_bail(c3__exit);
}
else {
Expand All @@ -37,7 +36,7 @@
{
return u3m_bail(c3__exit);
} else {
return u3l_punt("shar", _cqee_shar(pub, sed));
return _cqee_shar(pub, sed);
}
}

Expand All @@ -47,11 +46,9 @@
c3_y pub_y[32], sek_y[64];

if ( 0 != u3r_bytes_fit(32, pub_y, pub) ) {
// pub is not size checked in the hoon
return u3_none;
return u3m_bail(c3__exit);
}
else if ( 0 != u3r_bytes_fit(64, sek_y, sek) ) {
// sek explicitly bails through suck
return u3m_bail(c3__exit);
}
else {
Expand All @@ -72,6 +69,6 @@
{
return u3m_bail(c3__exit);
} else {
return u3l_punt("slar", _cqee_slar(pub, sek));
return _cqee_slar(pub, sek);
}
}
12 changes: 6 additions & 6 deletions pkg/noun/jets/e/ed_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
c3_y sed_y[32];
c3_w len_w;
if ( 0 != u3r_bytes_fit(32, sed_y, sed) ) {
// hoon calls suck, which calls luck, which crashes
// hoon calls luck, which crashes
return u3m_bail(c3__exit);
}
else if ( !u3r_word_fit(&len_w, len) ) {
Expand Down Expand Up @@ -51,11 +51,11 @@
c3_y pub_y[32], sek_y[64];
c3_w len_w;
if ( 0 != u3r_bytes_fit(32, pub_y, pub) ) {
// hoon calls suck, which calls luck, which crashes
// hoon asserts size
return u3m_bail(c3__exit);
}
if ( 0 != u3r_bytes_fit(64, sek_y, sek) ) {
// hoon calls suck, which calls luck, which crashes
// hoon asserts size
return u3m_bail(c3__exit);
}
else if ( !u3r_word_fit(&len_w, len) ) {
Expand Down Expand Up @@ -94,7 +94,7 @@
c3_y sed_y[32];

if ( 0 != u3r_bytes_fit(32, sed_y, sed) ) {
// hoon calls suck, which calls luck, which crashes
// hoon calls luck, which crashes
return u3m_bail(c3__exit);
}
else {
Expand Down Expand Up @@ -131,11 +131,11 @@
c3_y pub_y[32], sek_y[64];

if ( 0 != u3r_bytes_fit(32, pub_y, pub) ) {
// hoon calls suck, which calls luck, which crashes
// hoon asserts size
return u3m_bail(c3__exit);
}
if ( 0 != u3r_bytes_fit(64, sek_y, sek) ) {
// hoon calls suck, which calls luck, which crashes
// hoon asserts size
return u3m_bail(c3__exit);
}
else {
Expand Down

0 comments on commit 43d8d88

Please sign in to comment.