}
/**
- * For the cofactored equation in `crypto_verify_sodium`, where small order means
- * the signature is valid: a malformed point must not pass.
+ * Used by the cofactored equation in `crypto_verify_sodium` where well-formed
+ * small order means the signature is valid.
* @param {ge_p3} p
- * @returns 1 if `p` is small order and not malformed, else 0
+ * @returns 0 if `p` is not malformed and has small order, else -1
*/
export function ge_accept_small_order (p: ge_p3, t_fe: FieldElement, t_u8x32: StaticArray<u8>): i32 {
- const small_order = ge_has_small_order(p, t_fe, t_u8x32)
const malformed = ge_is_malformed(p, t_fe, t_u8x32)
-
- return small_order & (malformed ^ 1)
+ const small_order = ge_has_small_order(p, t_fe, t_u8x32)
+ return 0 - (malformed | (small_order ^ 1))
}
/**
- * For the checks on the key and `R`, where small order means reject: a
- * malformed point must not pass either.
+ * Used by verify checks on `A` and `R` where a malformed or small order point
+ * means the signature is invalid.
* @param {ge_p3} p
- * @returns 0 if `p` is not small order and not malformed, else -1
+ * @returns 0 if `p` is not malformed and not small order, else -1
*/
export function ge_reject_small_order (p: ge_p3, t_fe: FieldElement, t_u8x32: StaticArray<u8>): i32 {
- const small_order = ge_has_small_order(p, t_fe, t_u8x32)
const malformed = ge_is_malformed(p, t_fe, t_u8x32)
-
- return 0 - (small_order | malformed)
+ const small_order = ge_has_small_order(p, t_fe, t_u8x32)
+ return 0 - (malformed | small_order)
}
/**