From 43d8d88e6b0e2b2337cb2d03b5ba7bd845de50f4 Mon Sep 17 00:00:00 2001 From: ziffee Date: Wed, 11 Dec 2024 22:52:56 +0700 Subject: [PATCH] zif/ed-reform: remove punts, clean up bails --- pkg/noun/jets/e/ed_add_scalarmult_scalarmult_base.c | 3 +-- pkg/noun/jets/e/ed_point_add.c | 2 +- pkg/noun/jets/e/ed_point_neg.c | 2 +- pkg/noun/jets/e/ed_scalarmult_base.c | 1 + pkg/noun/jets/e/ed_shar.c | 13 +++++-------- pkg/noun/jets/e/ed_sign.c | 12 ++++++------ 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/pkg/noun/jets/e/ed_add_scalarmult_scalarmult_base.c b/pkg/noun/jets/e/ed_add_scalarmult_scalarmult_base.c index ed71a803e1..39eda5392b 100644 --- a/pkg/noun/jets/e/ed_add_scalarmult_scalarmult_base.c +++ b/pkg/noun/jets/e/ed_add_scalarmult_scalarmult_base.c @@ -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); } } diff --git a/pkg/noun/jets/e/ed_point_add.c b/pkg/noun/jets/e/ed_point_add.c index f097f15102..70fe563c20 100644 --- a/pkg/noun/jets/e/ed_point_add.c +++ b/pkg/noun/jets/e/ed_point_add.c @@ -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); diff --git a/pkg/noun/jets/e/ed_point_neg.c b/pkg/noun/jets/e/ed_point_neg.c index 5f0cacc0c0..5a1a5bd237 100644 --- a/pkg/noun/jets/e/ed_point_neg.c +++ b/pkg/noun/jets/e/ed_point_neg.c @@ -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); diff --git a/pkg/noun/jets/e/ed_scalarmult_base.c b/pkg/noun/jets/e/ed_scalarmult_base.c index 923ed1f629..61935846f2 100644 --- a/pkg/noun/jets/e/ed_scalarmult_base.c +++ b/pkg/noun/jets/e/ed_scalarmult_base.c @@ -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 { diff --git a/pkg/noun/jets/e/ed_shar.c b/pkg/noun/jets/e/ed_shar.c index becff5909a..ed293f777a 100644 --- a/pkg/noun/jets/e/ed_shar.c +++ b/pkg/noun/jets/e/ed_shar.c @@ -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 { @@ -37,7 +36,7 @@ { return u3m_bail(c3__exit); } else { - return u3l_punt("shar", _cqee_shar(pub, sed)); + return _cqee_shar(pub, sed); } } @@ -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 { @@ -72,6 +69,6 @@ { return u3m_bail(c3__exit); } else { - return u3l_punt("slar", _cqee_slar(pub, sek)); + return _cqee_slar(pub, sek); } } diff --git a/pkg/noun/jets/e/ed_sign.c b/pkg/noun/jets/e/ed_sign.c index dc5b75bdeb..cd1797d4dd 100644 --- a/pkg/noun/jets/e/ed_sign.c +++ b/pkg/noun/jets/e/ed_sign.c @@ -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) ) { @@ -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) ) { @@ -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 { @@ -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 {