diff options
Diffstat (limited to 'src/Specific/solinas32_2e255m765_13limbs')
15 files changed, 150 insertions, 0 deletions
diff --git a/src/Specific/solinas32_2e255m765_13limbs/CurveParameters.v b/src/Specific/solinas32_2e255m765_13limbs/CurveParameters.v new file mode 100644 index 000000000..aaaed21cd --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/CurveParameters.v @@ -0,0 +1,39 @@ +Require Import Crypto.Specific.Framework.RawCurveParameters. +Require Import Crypto.Util.LetIn. + +(*** +Modulus : 2^255 - 765 +Base: 19 + 8/13 +***) + +Definition curve : CurveParameters := + {| + sz := 13%nat; + base := 19 + 8/13; + bitwidth := 32; + s := 2^255; + c := [(1, 765)]; + carry_chains := Some [seq 0 (pred 13); [0; 1]]%nat; + + a24 := None; + coef_div_modulus := Some 2%nat; + + goldilocks := None; + karatsuba := None; + montgomery := false; + freeze := Some true; + ladderstep := false; + + mul_code := None; + + square_code := None; + + upper_bound_of_exponent_loose := None; + upper_bound_of_exponent_tight := None; + allowable_bit_widths := None; + freeze_extra_allowable_bit_widths := None; + modinv_fuel := None + |}. + +Ltac extra_prove_mul_eq _ := idtac. +Ltac extra_prove_square_eq _ := idtac. diff --git a/src/Specific/solinas32_2e255m765_13limbs/Synthesis.v b/src/Specific/solinas32_2e255m765_13limbs/Synthesis.v new file mode 100644 index 000000000..9dcde15b4 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/Synthesis.v @@ -0,0 +1,9 @@ +Require Import Crypto.Specific.Framework.SynthesisFramework. +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.CurveParameters. + +Module P <: PrePackage. + Definition package : Tag.Context. + Proof. make_Synthesis_package curve extra_prove_mul_eq extra_prove_square_eq. Defined. +End P. + +Module Export S := PackageSynthesis P. diff --git a/src/Specific/solinas32_2e255m765_13limbs/compiler.sh b/src/Specific/solinas32_2e255m765_13limbs/compiler.sh new file mode 100755 index 000000000..7eee4f520 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/compiler.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +clang -fbracket-depth=999999 -march=native -mtune=native -std=gnu11 -O3 -flto -fuse-ld=lld -fomit-frame-pointer -fwrapv -Wno-attributes -fno-strict-aliasing -Da24_hex='0x3039' -Da24_val='12345' -Da_minus_two_over_four_array='{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x39}' -Dbitwidth='32' -Dlimb_weight_gaps_array='{20,20,19,20,20,19,20,19,20,20,19,20,19}' -Dmodulus_array='{0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x03}' -Dmodulus_bytes_val='32' -Dmodulus_limbs='13' -Dq_mpz='(1_mpz<<255) - 765' "$@" diff --git a/src/Specific/solinas32_2e255m765_13limbs/compilerxx.sh b/src/Specific/solinas32_2e255m765_13limbs/compilerxx.sh new file mode 100755 index 000000000..6dc09b5d5 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/compilerxx.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +clang++ -fbracket-depth=999999 -march=native -mtune=native -std=gnu++11 -O3 -flto -fuse-ld=lld -fomit-frame-pointer -fwrapv -Wno-attributes -fno-strict-aliasing -Da24_hex='0x3039' -Da24_val='12345' -Da_minus_two_over_four_array='{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x39}' -Dbitwidth='32' -Dlimb_weight_gaps_array='{20,20,19,20,20,19,20,19,20,20,19,20,19}' -Dmodulus_array='{0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x03}' -Dmodulus_bytes_val='32' -Dmodulus_limbs='13' -Dq_mpz='(1_mpz<<255) - 765' "$@" diff --git a/src/Specific/solinas32_2e255m765_13limbs/feadd.v b/src/Specific/solinas32_2e255m765_13limbs/feadd.v new file mode 100644 index 000000000..8e5e66697 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/feadd.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition add : + { add : feBW_tight -> feBW_tight -> feBW_loose + | forall a b, phiBW_loose (add a b) = F.add (phiBW_tight a) (phiBW_tight b) }. +Proof. + Set Ltac Profiling. + Time synthesize_add (). + Show Ltac Profile. +Time Defined. + +Print Assumptions add. diff --git a/src/Specific/solinas32_2e255m765_13limbs/feaddDisplay.v b/src/Specific/solinas32_2e255m765_13limbs/feaddDisplay.v new file mode 100644 index 000000000..822686565 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/feaddDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.feadd. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display add. diff --git a/src/Specific/solinas32_2e255m765_13limbs/femul.v b/src/Specific/solinas32_2e255m765_13limbs/femul.v new file mode 100644 index 000000000..f787b6148 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/femul.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition mul : + { mul : feBW_loose -> feBW_loose -> feBW_tight + | forall a b, phiBW_tight (mul a b) = F.mul (phiBW_loose a) (phiBW_loose b) }. +Proof. + Set Ltac Profiling. + Time synthesize_mul (). + Show Ltac Profile. +Time Defined. + +Print Assumptions mul. diff --git a/src/Specific/solinas32_2e255m765_13limbs/femulDisplay.v b/src/Specific/solinas32_2e255m765_13limbs/femulDisplay.v new file mode 100644 index 000000000..0a9fd5275 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/femulDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.femul. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display mul. diff --git a/src/Specific/solinas32_2e255m765_13limbs/fesquare.v b/src/Specific/solinas32_2e255m765_13limbs/fesquare.v new file mode 100644 index 000000000..cb42bedcc --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/fesquare.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition square : + { square : feBW_loose -> feBW_tight + | forall a, phiBW_tight (square a) = F.mul (phiBW_loose a) (phiBW_loose a) }. +Proof. + Set Ltac Profiling. + Time synthesize_square (). + Show Ltac Profile. +Time Defined. + +Print Assumptions square. diff --git a/src/Specific/solinas32_2e255m765_13limbs/fesquareDisplay.v b/src/Specific/solinas32_2e255m765_13limbs/fesquareDisplay.v new file mode 100644 index 000000000..4b1c7ef1b --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/fesquareDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.fesquare. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display square. diff --git a/src/Specific/solinas32_2e255m765_13limbs/fesub.v b/src/Specific/solinas32_2e255m765_13limbs/fesub.v new file mode 100644 index 000000000..1fa1b54da --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/fesub.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition sub : + { sub : feBW_tight -> feBW_tight -> feBW_loose + | forall a b, phiBW_loose (sub a b) = F.sub (phiBW_tight a) (phiBW_tight b) }. +Proof. + Set Ltac Profiling. + Time synthesize_sub (). + Show Ltac Profile. +Time Defined. + +Print Assumptions sub. diff --git a/src/Specific/solinas32_2e255m765_13limbs/fesubDisplay.v b/src/Specific/solinas32_2e255m765_13limbs/fesubDisplay.v new file mode 100644 index 000000000..f1a295ecf --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/fesubDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.fesub. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display sub. diff --git a/src/Specific/solinas32_2e255m765_13limbs/freeze.v b/src/Specific/solinas32_2e255m765_13limbs/freeze.v new file mode 100644 index 000000000..b62642c57 --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/freeze.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition freeze : + { freeze : feBW_tight -> feBW_limbwidths + | forall a, phiBW_limbwidths (freeze a) = phiBW_tight a }. +Proof. + Set Ltac Profiling. + Time synthesize_freeze (). + Show Ltac Profile. +Time Defined. + +Print Assumptions freeze. diff --git a/src/Specific/solinas32_2e255m765_13limbs/freezeDisplay.v b/src/Specific/solinas32_2e255m765_13limbs/freezeDisplay.v new file mode 100644 index 000000000..142cdf11a --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/freezeDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.solinas32_2e255m765_13limbs.freeze. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display freeze. diff --git a/src/Specific/solinas32_2e255m765_13limbs/py_interpreter.sh b/src/Specific/solinas32_2e255m765_13limbs/py_interpreter.sh new file mode 100755 index 000000000..a54dd225e --- /dev/null +++ b/src/Specific/solinas32_2e255m765_13limbs/py_interpreter.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +/usr/bin/env python3 "$@" -Dq='2**255 - 765' -Dmodulus_bytes='19 + 8/13' -Da24='121665' |