diff options
author | Jason Gross <jgross@mit.edu> | 2017-10-16 01:16:24 -0400 |
---|---|---|
committer | Jason Gross <jasongross9@gmail.com> | 2017-10-18 23:01:29 -0400 |
commit | 3963ad55fada5c6df6c52e82ee483da9a085c9a9 (patch) | |
tree | 50f5831e0608a6a48873ebdd9226460866cb9a86 /src/Specific/montgomery32_2e205m45x2e198m1 | |
parent | 228b9c35ae331ac30b5829689d9a9320612edb67 (diff) |
Remake some curves
Diffstat (limited to 'src/Specific/montgomery32_2e205m45x2e198m1')
13 files changed, 140 insertions, 0 deletions
diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/CurveParameters.v b/src/Specific/montgomery32_2e205m45x2e198m1/CurveParameters.v new file mode 100644 index 000000000..1374b29d2 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/CurveParameters.v @@ -0,0 +1,35 @@ +Require Import Crypto.Specific.Framework.RawCurveParameters. +Require Import Crypto.Util.LetIn. + +(*** +Modulus : 2^205 - 45*2^198 - 1 +Base: 32 +***) + +Definition curve : CurveParameters := + {| + sz := 7%nat; + base := 32; + bitwidth := 32; + s := 2^205; + c := [(1, 1); (45, 2^198)]; + carry_chains := None; + + a24 := None; + coef_div_modulus := None; + + goldilocks := Some false; + montgomery := true; + + mul_code := None; + + square_code := None; + + upper_bound_of_exponent := 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/montgomery32_2e205m45x2e198m1/Synthesis.v b/src/Specific/montgomery32_2e205m45x2e198m1/Synthesis.v new file mode 100644 index 000000000..cbcef2a10 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/Synthesis.v @@ -0,0 +1,9 @@ +Require Import Crypto.Specific.Framework.SynthesisFramework. +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.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/montgomery32_2e205m45x2e198m1/compiler.sh b/src/Specific/montgomery32_2e205m45x2e198m1/compiler.sh new file mode 100755 index 000000000..518f95765 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/compiler.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +gcc -fno-peephole2 `#GCC BUG 81300` -march=native -mtune=native -std=gnu11 -O3 -flto -fomit-frame-pointer -fwrapv -Wno-attributes -Wno-incompatible-pointer-types -fno-strict-aliasing "$@" diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/feadd.v b/src/Specific/montgomery32_2e205m45x2e198m1/feadd.v new file mode 100644 index 000000000..d86390d7e --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/feadd.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition add : + { add : feBW_small -> feBW_small -> feBW_small + | forall a b, phiM_small (add a b) = F.add (phiM_small a) (phiM_small b) }. +Proof. + Set Ltac Profiling. + Time synthesize_add (). + Show Ltac Profile. +Time Defined. + +Print Assumptions add. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/feaddDisplay.v b/src/Specific/montgomery32_2e205m45x2e198m1/feaddDisplay.v new file mode 100644 index 000000000..4c141eaa3 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/feaddDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.feadd. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display add. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/femul.v b/src/Specific/montgomery32_2e205m45x2e198m1/femul.v new file mode 100644 index 000000000..eb03610f7 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/femul.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition mul : + { mul : feBW_small -> feBW_small -> feBW_small + | forall a b, phiM_small (mul a b) = F.mul (phiM_small a) (phiM_small b) }. +Proof. + Set Ltac Profiling. + Time synthesize_mul (). + Show Ltac Profile. +Time Defined. + +Print Assumptions mul. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/femulDisplay.v b/src/Specific/montgomery32_2e205m45x2e198m1/femulDisplay.v new file mode 100644 index 000000000..f51bb90df --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/femulDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.femul. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display mul. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/fenz.v b/src/Specific/montgomery32_2e205m45x2e198m1/fenz.v new file mode 100644 index 000000000..dde9441c0 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/fenz.v @@ -0,0 +1,16 @@ +Require Import Coq.ZArith.ZArith. +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.Synthesis. +Local Open Scope Z_scope. + +(* TODO : change this to field once field isomorphism happens *) +Definition nonzero : + { nonzero : feBW_small -> BoundedWord.BoundedWord 1 adjusted_bitwidth bound1 + | forall a, (BoundedWord.BoundedWordToZ _ _ _ (nonzero a) =? 0) = (if Decidable.dec (phiM_small a = F.of_Z m 0) then true else false) }. +Proof. + Set Ltac Profiling. + Time synthesize_nonzero (). + Show Ltac Profile. +Time Defined. + +Print Assumptions nonzero. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/fenzDisplay.v b/src/Specific/montgomery32_2e205m45x2e198m1/fenzDisplay.v new file mode 100644 index 000000000..44965faef --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/fenzDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.fenz. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display nonzero. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/feopp.v b/src/Specific/montgomery32_2e205m45x2e198m1/feopp.v new file mode 100644 index 000000000..0c0ffd4b8 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/feopp.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition opp : + { opp : feBW_small -> feBW_small + | forall a, phiM_small (opp a) = F.opp (phiM_small a) }. +Proof. + Set Ltac Profiling. + Time synthesize_opp (). + Show Ltac Profile. +Time Defined. + +Print Assumptions opp. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/feoppDisplay.v b/src/Specific/montgomery32_2e205m45x2e198m1/feoppDisplay.v new file mode 100644 index 000000000..eba98ca57 --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/feoppDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.feopp. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display opp. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/fesub.v b/src/Specific/montgomery32_2e205m45x2e198m1/fesub.v new file mode 100644 index 000000000..2b2f35c4d --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/fesub.v @@ -0,0 +1,14 @@ +Require Import Crypto.Arithmetic.PrimeFieldTheorems. +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.Synthesis. + +(* TODO : change this to field once field isomorphism happens *) +Definition sub : + { sub : feBW_small -> feBW_small -> feBW_small + | forall a b, phiM_small (sub a b) = F.sub (phiM_small a) (phiM_small b) }. +Proof. + Set Ltac Profiling. + Time synthesize_sub (). + Show Ltac Profile. +Time Defined. + +Print Assumptions sub. diff --git a/src/Specific/montgomery32_2e205m45x2e198m1/fesubDisplay.v b/src/Specific/montgomery32_2e205m45x2e198m1/fesubDisplay.v new file mode 100644 index 000000000..643f85d2d --- /dev/null +++ b/src/Specific/montgomery32_2e205m45x2e198m1/fesubDisplay.v @@ -0,0 +1,4 @@ +Require Import Crypto.Specific.montgomery32_2e205m45x2e198m1.fesub. +Require Import Crypto.Specific.Framework.IntegrationTestDisplayCommon. + +Check display sub. |