aboutsummaryrefslogtreecommitdiff
path: root/p521_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 /p521_32.c
parent069e5cce23669707f11e59d9f68a31ad24990fe0 (diff)
Use Preconditions: Postconditions:, rather than /\ and ->
Diffstat (limited to 'p521_32.c')
-rw-r--r--p521_32.c64
1 files changed, 46 insertions, 18 deletions
diff --git a/p521_32.c b/p521_32.c
index 9d7fc2515..aa8416aa9 100644
--- a/p521_32.c
+++ b/p521_32.c
@@ -18,8 +18,10 @@ typedef unsigned __int128 fiat_p521_uint128;
/*
* The function fiat_p521_addcarryx_u30 is an addition with carry.
- * out1 = (arg1 + arg2 + arg3) mod 2^30
- * ∧ out2 = ⌊(arg1 + arg2 + arg3) / 2^30⌋
+ * Postconditions:
+ * out1 = (arg1 + arg2 + arg3) mod 2^30
+ * out2 = ⌊(arg1 + arg2 + arg3) / 2^30⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0x3fffffff]
@@ -38,8 +40,10 @@ static void fiat_p521_addcarryx_u30(uint32_t* out1, fiat_p521_uint1* out2, fiat_
/*
* The function fiat_p521_subborrowx_u30 is a subtraction with borrow.
- * out1 = (-arg1 + arg2 + -arg3) mod 2^30
- * ∧ out2 = -⌊(-arg1 + arg2 + -arg3) / 2^30⌋
+ * Postconditions:
+ * out1 = (-arg1 + arg2 + -arg3) mod 2^30
+ * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^30⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0x3fffffff]
@@ -58,8 +62,10 @@ static void fiat_p521_subborrowx_u30(uint32_t* out1, fiat_p521_uint1* out2, fiat
/*
* The function fiat_p521_addcarryx_u31 is an addition with carry.
- * out1 = (arg1 + arg2 + arg3) mod 2^31
- * ∧ out2 = ⌊(arg1 + arg2 + arg3) / 2^31⌋
+ * Postconditions:
+ * out1 = (arg1 + arg2 + arg3) mod 2^31
+ * out2 = ⌊(arg1 + arg2 + arg3) / 2^31⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0x7fffffff]
@@ -78,8 +84,10 @@ static void fiat_p521_addcarryx_u31(uint32_t* out1, fiat_p521_uint1* out2, fiat_
/*
* The function fiat_p521_subborrowx_u31 is a subtraction with borrow.
- * out1 = (-arg1 + arg2 + -arg3) mod 2^31
- * ∧ out2 = -⌊(-arg1 + arg2 + -arg3) / 2^31⌋
+ * Postconditions:
+ * out1 = (-arg1 + arg2 + -arg3) mod 2^31
+ * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^31⌋
+ *
* Input Bounds:
* arg1: [0x0 ~> 0x1]
* arg2: [0x0 ~> 0x7fffffff]
@@ -98,7 +106,9 @@ static void fiat_p521_subborrowx_u31(uint32_t* out1, fiat_p521_uint1* out2, fiat
/*
* The function fiat_p521_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]
@@ -115,7 +125,9 @@ static void fiat_p521_cmovznz_u32(uint32_t* out1, fiat_p521_uint1 arg1, uint32_t
/*
* The function fiat_p521_carry_mul multiplies two field elements and reduces the result.
- * eval out1 mod m = (eval arg1 * eval arg2) mod m
+ * Postconditions:
+ * eval out1 mod m = (eval arg1 * eval arg2) mod m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332]]
* arg2: [[0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332]]
@@ -507,7 +519,9 @@ static void fiat_p521_carry_mul(uint32_t out1[17], const uint64_t arg1[17], cons
/*
* The function fiat_p521_carry_square squares a field element and reduces the result.
- * eval out1 mod m = (eval arg1 * eval arg1) mod m
+ * Postconditions:
+ * eval out1 mod m = (eval arg1 * eval arg1) mod m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332]]
* Output Bounds:
@@ -794,7 +808,9 @@ static void fiat_p521_carry_square(uint32_t out1[17], const uint64_t arg1[17]) {
/*
* The function fiat_p521_carry reduces a field element.
- * eval out1 mod m = eval arg1 mod m
+ * Postconditions:
+ * eval out1 mod m = eval arg1 mod m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332], [0x0 ~> 0x1a6666664], [0x0 ~> 0xd3333332]]
* Output Bounds:
@@ -858,7 +874,9 @@ static void fiat_p521_carry(uint32_t out1[17], const uint64_t arg1[17]) {
/*
* The function fiat_p521_add adds two field elements.
- * eval out1 mod m = (eval arg1 + eval arg2) mod m
+ * Postconditions:
+ * eval out1 mod m = (eval arg1 + eval arg2) mod m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666]]
* arg2: [[0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666]]
@@ -904,7 +922,9 @@ static void fiat_p521_add(uint64_t out1[17], const uint32_t arg1[17], const uint
/*
* The function fiat_p521_sub subtracts two field elements.
- * eval out1 mod m = (eval arg1 - eval arg2) mod m
+ * Postconditions:
+ * eval out1 mod m = (eval arg1 - eval arg2) mod m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666]]
* arg2: [[0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666]]
@@ -950,7 +970,9 @@ static void fiat_p521_sub(uint64_t out1[17], const uint32_t arg1[17], const uint
/*
* The function fiat_p521_opp negates a field element.
- * eval out1 mod m = -eval arg1 mod m
+ * Postconditions:
+ * eval out1 mod m = -eval arg1 mod m
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666]]
* Output Bounds:
@@ -995,7 +1017,9 @@ static void fiat_p521_opp(uint32_t out1[17], const uint32_t arg1[17]) {
/*
* The function fiat_p521_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], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]]
@@ -1059,7 +1083,9 @@ static void fiat_p521_selectznz(uint32_t out1[17], fiat_p521_uint1 arg1, const u
/*
* The function fiat_p521_to_bytes serializes a field element to bytes in little-endian order.
- * out1 = map (λ x, ⌊(eval arg1 mod m) mod 2^(8 * (x + 1)) / 2^(8 * x)⌋) [0..65]
+ * Postconditions:
+ * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..65]
+ *
* Input Bounds:
* arg1: [[0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666], [0x0 ~> 0x8ccccccc], [0x0 ~> 0x46666666]]
* Output Bounds:
@@ -1396,7 +1422,9 @@ static void fiat_p521_to_bytes(uint8_t out1[66], const uint32_t arg1[17]) {
/*
* The function fiat_p521_from_bytes deserializes a field element from bytes in little-endian order.
- * eval out1 mod m = bytes_eval arg1 mod m
+ * Postconditions:
+ * eval out1 mod m = bytes_eval arg1 mod 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], [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 ~> 0x1]]
* Output Bounds: