v128.store_lane<u64>(td, v128.bitselect(v128.neg<i32>(d2), d2, n), 0, 32)
}
+const ge_frombytes_negate_vartime_u: FieldElement = fe()
+const ge_frombytes_negate_vartime_v: FieldElement = fe()
+const ge_frombytes_negate_vartime_v3: FieldElement = fe()
+const ge_frombytes_negate_vartime_vxx: FieldElement = fe()
+const ge_frombytes_negate_vartime_m_root_check: FieldElement = fe()
+const ge_frombytes_negate_vartime_p_root_check: FieldElement = fe()
const ge_frombytes_negate_vartime_u8x32_scratch = new StaticArray<u8>(32)
const ge_frombytes_negate_vartime_fe_scratch_0: FieldElement = fe()
const ge_frombytes_negate_vartime_fe_scratch_1: FieldElement = fe()
const ge_frombytes_negate_vartime_fe_scratch_2: FieldElement = fe()
-const u: FieldElement = fe()
-const v: FieldElement = fe()
-const v3: FieldElement = fe()
-const vxx: FieldElement = fe()
-const m_root_check: FieldElement = fe()
-const p_root_check: FieldElement = fe()
/**
* Variable-time point negation converted from byte representation.
*
* @returns {i32} 0 if `s` decodes to a valid point, else -1
*/
export function ge_frombytes_negate_vartime (h: ge_p3, s: StaticArray<u8>): i32 {
+ const u = ge_frombytes_negate_vartime_u
+ const v = ge_frombytes_negate_vartime_v
+ const v3 = ge_frombytes_negate_vartime_v3
+ const vxx = ge_frombytes_negate_vartime_vxx
+ const m_root_check = ge_frombytes_negate_vartime_m_root_check
+ const p_root_check = ge_frombytes_negate_vartime_p_root_check
+
const u8x32_scratch = ge_frombytes_negate_vartime_u8x32_scratch
const fe_scratch_0 = ge_frombytes_negate_vartime_fe_scratch_0
const fe_scratch_1 = ge_frombytes_negate_vartime_fe_scratch_1
const fe_scratch_2 = ge_frombytes_negate_vartime_fe_scratch_2
+
fe_frombytes(h.Y, s)
fe_1(h.Z)
return 0
}
-const ge_frombytes_u8x32_scratch = new StaticArray<u8>(32)
-const ge_frombytes_fe_scratch_0: FieldElement = fe()
-const ge_frombytes_fe_scratch_1: FieldElement = fe()
-const ge_frombytes_fe_scratch_2: FieldElement = fe()
const ge_frombytes_u: FieldElement = fe()
const ge_frombytes_v: FieldElement = fe()
const ge_frombytes_vxx: FieldElement = fe()
const ge_frombytes_m_root_check: FieldElement = fe()
const ge_frombytes_p_root_check: FieldElement = fe()
const ge_frombytes_negx: FieldElement = fe()
-const x_sqrtm1: FieldElement = fe()
+const ge_frombytes_x_sqrtm1: FieldElement = fe()
+const ge_frombytes_u8x32_scratch = new StaticArray<u8>(32)
+const ge_frombytes_fe_scratch_0: FieldElement = fe()
+const ge_frombytes_fe_scratch_1: FieldElement = fe()
+const ge_frombytes_fe_scratch_2: FieldElement = fe()
/**
* Constant-time point negation converted from byte representation.
*
* @returns {i32} 0 if `s` decodes to a valid point, else -1
*/
export function ge_frombytes (h: ge_p3, s: StaticArray<u8>): i32 {
- const u8x32_scratch = ge_frombytes_u8x32_scratch
- const fe_scratch_0 = ge_frombytes_fe_scratch_0
- const fe_scratch_1 = ge_frombytes_fe_scratch_1
- const fe_scratch_2 = ge_frombytes_fe_scratch_2
const u = ge_frombytes_u
const v = ge_frombytes_v
const vxx = ge_frombytes_vxx
const m_root_check = ge_frombytes_m_root_check
const p_root_check = ge_frombytes_p_root_check
const negx = ge_frombytes_negx
+ const x_sqrtm1 = ge_frombytes_x_sqrtm1
+
+ const u8x32_scratch = ge_frombytes_u8x32_scratch
+ const fe_scratch_0 = ge_frombytes_fe_scratch_0
+ const fe_scratch_1 = ge_frombytes_fe_scratch_1
+ const fe_scratch_2 = ge_frombytes_fe_scratch_2
+
let has_m_root: u8
let has_p_root: u8
return i32(has_m_root | has_p_root) - 1
}
+const ge_has_small_order_y_sqrtm1: FieldElement = fe()
+const ge_has_small_order_c: FieldElement = fe()
const ge_has_small_order_u8x32_scratch = new StaticArray<u8>(32)
const ge_has_small_order_fe_scratch: FieldElement = fe()
-const y_sqrtm1: FieldElement = fe()
-const c: FieldElement = fe()
-/** return 1 if p has small order else return 0 */
+/**
+ * @param {ge_p3} p
+ * @returns 1 if `p` has small order, else 0
+ */
export function ge_has_small_order (p: ge_p3): i32 {
+ const y_sqrtm1 = ge_has_small_order_y_sqrtm1
+ const c = ge_has_small_order_c
+
const u8x32_scratch = ge_has_small_order_u8x32_scratch
const fe_scratch = ge_has_small_order_fe_scratch
+
let ret: i32 = 0
ret |= fe_iszero(p.X, u8x32_scratch, fe_scratch)