From ce583d76bdb8f15148fc4222d8bdec096547682a Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Fri, 1 Feb 2019 18:50:00 -0500 Subject: Use Preconditions: Postconditions:, rather than /\ and -> --- curve25519_64.c | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) (limited to 'curve25519_64.c') diff --git a/curve25519_64.c b/curve25519_64.c index fef38dfa5..5341181f6 100644 --- a/curve25519_64.c +++ b/curve25519_64.c @@ -18,8 +18,10 @@ typedef unsigned __int128 fiat_25519_uint128; /* * The function fiat_25519_addcarryx_u51 is an addition with carry. - * out1 = (arg1 + arg2 + arg3) mod 2^51 - * ∧ out2 = ⌊(arg1 + arg2 + arg3) / 2^51⌋ + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^51 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^51⌋ + * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0x7ffffffffffff] @@ -38,8 +40,10 @@ static void fiat_25519_addcarryx_u51(uint64_t* out1, fiat_25519_uint1* out2, fia /* * The function fiat_25519_subborrowx_u51 is a subtraction with borrow. - * out1 = (-arg1 + arg2 + -arg3) mod 2^51 - * ∧ out2 = -⌊(-arg1 + arg2 + -arg3) / 2^51⌋ + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^51 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^51⌋ + * * Input Bounds: * arg1: [0x0 ~> 0x1] * arg2: [0x0 ~> 0x7ffffffffffff] @@ -58,7 +62,9 @@ static void fiat_25519_subborrowx_u51(uint64_t* out1, fiat_25519_uint1* out2, fi /* * The function fiat_25519_cmovznz_u64 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 ~> 0xffffffffffffffff] @@ -75,7 +81,9 @@ static void fiat_25519_cmovznz_u64(uint64_t* out1, fiat_25519_uint1 arg1, uint64 /* * The function fiat_25519_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 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] * arg2: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] @@ -144,7 +152,9 @@ static void fiat_25519_carry_mul(uint64_t out1[5], const uint64_t arg1[5], const /* * The function fiat_25519_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 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] * Output Bounds: @@ -210,7 +220,9 @@ static void fiat_25519_carry_square(uint64_t out1[5], const uint64_t arg1[5]) { /* * The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result. - * eval out1 mod m = (121666 * eval arg1) mod m + * Postconditions: + * eval out1 mod m = (121666 * eval arg1) mod m + * * Input Bounds: * arg1: [[0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] * Output Bounds: @@ -253,7 +265,9 @@ static void fiat_25519_carry_scmul_121666(uint64_t out1[5], const uint64_t arg1[ /* * The function fiat_25519_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 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664], [0x0 ~> 0x1a666666666664]] * Output Bounds: @@ -281,7 +295,9 @@ static void fiat_25519_carry(uint64_t out1[5], const uint64_t arg1[5]) { /* * The function fiat_25519_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 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] * arg2: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] @@ -303,7 +319,9 @@ static void fiat_25519_add(uint64_t out1[5], const uint64_t arg1[5], const uint6 /* * The function fiat_25519_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 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] * arg2: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] @@ -325,7 +343,9 @@ static void fiat_25519_sub(uint64_t out1[5], const uint64_t arg1[5], const uint6 /* * The function fiat_25519_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 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] * Output Bounds: @@ -346,7 +366,9 @@ static void fiat_25519_opp(uint64_t out1[5], const uint64_t arg1[5]) { /* * The function fiat_25519_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 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] @@ -374,7 +396,9 @@ static void fiat_25519_selectznz(uint64_t out1[5], fiat_25519_uint1 arg1, const /* * The function fiat_25519_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..31] + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * * Input Bounds: * arg1: [[0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc], [0x0 ~> 0x8cccccccccccc]] * Output Bounds: @@ -519,7 +543,9 @@ static void fiat_25519_to_bytes(uint8_t out1[32], const uint64_t arg1[5]) { /* * The function fiat_25519_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 ~> 0x7f]] * Output Bounds: -- cgit v1.2.3