aboutsummaryrefslogtreecommitdiff
path: root/p384_32.c
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2019-02-01 18:50:00 -0500
committerGravatar Jason Gross <jasongross9@gmail.com>2019-02-02 18:22:15 -0500
commitce583d76bdb8f15148fc4222d8bdec096547682a (patch)
treeffb083673e6be283d7f67ad857bc2f30af892767 /p384_32.c
parent069e5cce23669707f11e59d9f68a31ad24990fe0 (diff)
Use Preconditions: Postconditions:, rather than /\ and ->
Diffstat (limited to 'p384_32.c')
-rw-r--r--p384_32.c109
1 files changed, 73 insertions, 36 deletions
diff --git a/p384_32.c b/p384_32.c
index 1ac5b5804..c9591bdfc 100644
--- a/p384_32.c
+++ b/p384_32.c
@@ -18,8 +18,10 @@ typedef signed char fiat_p384_int1;
/*
* The function fiat_p384_addcarryx_u32 is an addition with carry.
- * out1 = (arg1 + arg2 + arg3) mod 2^32
- * ∧ out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋
+ * Postconditions:
+ * out1 = (arg1 + arg2 + arg3) mod 2^32
+ * out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffff]
@@ -38,8 +40,10 @@ static void fiat_p384_addcarryx_u32(uint32_t* out1, fiat_p384_uint1* out2, fiat_
/*
* The function fiat_p384_subborrowx_u32 is a subtraction with borrow.
- * out1 = (-arg1 + arg2 + -arg3) mod 2^32
- * ∧ out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋
+ * Postconditions:
+ * out1 = (-arg1 + arg2 + -arg3) mod 2^32
+ * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffff]
@@ -58,8 +62,10 @@ static void fiat_p384_subborrowx_u32(uint32_t* out1, fiat_p384_uint1* out2, fiat
/*
* The function fiat_p384_mulx_u32 is a multiplication, returning the full double-width result.
- * out1 = (arg1 * arg2) mod 2^32
- * ∧ out2 = ⌊arg1 * arg2 / 2^32⌋
+ * Postconditions:
+ * out1 = (arg1 * arg2) mod 2^32
+ * out2 = ⌊arg1 * arg2 / 2^32⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0xffffffff]
* arg2: [0x0 ~> 0xffffffff]
@@ -77,7 +83,9 @@ static void fiat_p384_mulx_u32(uint32_t* out1, uint32_t* out2, uint32_t arg1, ui
/*
* The function fiat_p384_cmovznz_u32 is a single-word conditional move.
- * out1 = (if arg1 = 0 then arg2 else arg3)
+ * Postconditions:
+ * out1 = (if arg1 = 0 then arg2 else arg3)
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0xffffffff]
@@ -94,10 +102,13 @@ static void fiat_p384_cmovznz_u32(uint32_t* out1, fiat_p384_uint1 arg1, uint32_t
/*
* The function fiat_p384_mul multiplies two field elements in the Montgomery domain.
- * 0 ≤ eval arg1 < m →
- * 0 ≤ eval arg2 < m →
- * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * 0 ≤ eval arg2 < m
+ * Postconditions:
+ * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
@@ -2677,9 +2688,12 @@ static void fiat_p384_mul(uint32_t out1[12], const uint32_t arg1[12], const uint
/*
* The function fiat_p384_square squares a field element in the Montgomery domain.
- * 0 ≤ eval arg1 < m →
- * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * Postconditions:
+ * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* Output Bounds:
@@ -5258,10 +5272,13 @@ static void fiat_p384_square(uint32_t out1[12], const uint32_t arg1[12]) {
/*
* The function fiat_p384_add adds two field elements in the Montgomery domain.
- * 0 ≤ eval arg1 < m →
- * 0 ≤ eval arg2 < m →
- * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * 0 ≤ eval arg2 < m
+ * Postconditions:
+ * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
@@ -5384,10 +5401,13 @@ static void fiat_p384_add(uint32_t out1[12], const uint32_t arg1[12], const uint
/*
* The function fiat_p384_sub subtracts two field elements in the Montgomery domain.
- * 0 ≤ eval arg1 < m →
- * 0 ≤ eval arg2 < m →
- * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * 0 ≤ eval arg2 < m
+ * Postconditions:
+ * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
@@ -5485,9 +5505,12 @@ static void fiat_p384_sub(uint32_t out1[12], const uint32_t arg1[12], const uint
/*
* The function fiat_p384_opp negates a field element in the Montgomery domain.
- * 0 ≤ eval arg1 < m →
- * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * Postconditions:
+ * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* Output Bounds:
@@ -5584,9 +5607,12 @@ static void fiat_p384_opp(uint32_t out1[12], const uint32_t arg1[12]) {
/*
* The function fiat_p384_from_montgomery translates a field element out of the Montgomery domain.
- * 0 ≤ eval arg1 < m →
- * eval out1 mod m = (eval arg1 * ((2^32)⁻¹ mod m)^12) mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * Postconditions:
+ * eval out1 mod m = (eval arg1 * ((2^32)⁻¹ mod m)^12) mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* Output Bounds:
@@ -7221,8 +7247,11 @@ static void fiat_p384_from_montgomery(uint32_t out1[12], const uint32_t arg1[12]
/*
* The function fiat_p384_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise.
- * 0 ≤ eval arg1 < m →
- * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * Postconditions:
+ * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* Output Bounds:
@@ -7235,7 +7264,9 @@ static void fiat_p384_nonzero(uint32_t* out1, const uint32_t arg1[12]) {
/*
* The function fiat_p384_selectznz is a multi-limb conditional select.
- * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3)
+ * Postconditions:
+ * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3)
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
@@ -7284,8 +7315,11 @@ static void fiat_p384_selectznz(uint32_t out1[12], fiat_p384_uint1 arg1, const u
/*
* The function fiat_p384_to_bytes serializes a field element in the Montgomery domain to bytes in little-endian order.
- * 0 ≤ eval arg1 < m →
- * out1 = map (λ x, ⌊(eval arg1 mod m) mod 2^(8 * (x + 1)) / 2^(8 * x)⌋) [0..47]
+ * Preconditions:
+ * 0 ≤ eval arg1 < m
+ * Postconditions:
+ * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..47]
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
* Output Bounds:
@@ -7439,9 +7473,12 @@ static void fiat_p384_to_bytes(uint8_t out1[48], const uint32_t arg1[12]) {
/*
* The function fiat_p384_from_bytes deserializes a field element in the Montgomery domain from bytes in little-endian order.
- * 0 ≤ bytes_eval arg1 < m →
- * eval out1 mod m = bytes_eval arg1 mod m
- * ∧ 0 ≤ eval out1 < m
+ * Preconditions:
+ * 0 ≤ bytes_eval arg1 < m
+ * Postconditions:
+ * eval out1 mod m = bytes_eval arg1 mod m
+ * 0 ≤ eval out1 < m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]]
* Output Bounds: