| 1 |
From Coq Require Import BinPosDef. |
| 2 |
Require Import Crypto.Algebra.Field. |
| 3 |
Require Import Crypto.Spec.MontgomeryCurve Crypto.Curves.Montgomery.Affine. |
| 4 |
Require Import Crypto.Spec.WeierstrassCurve Crypto.Curves.Weierstrass.Affine. |
| 5 |
Require Import Crypto.Curves.Weierstrass.AffineProofs. |
| 6 |
Require Import Crypto.Curves.Montgomery.AffineProofs. |
| 7 |
From Coq Require Import RelationClasses. |
| 8 |
|
| 9 |
Module M. |
| 10 |
Section MontgomeryCurve. |
| 11 |
Import BinNat. |
| 12 |
Context {F Feq Fzero Fone Fopp Fadd Fsub Fmul Finv Fdiv} |
| 13 |
{field:@Algebra.Hierarchy.field F Feq Fzero Fone Fopp Fadd Fsub Fmul Finv Fdiv} |
| 14 |
{Feq_dec:Decidable.DecidableRel Feq}. |
| 15 |
Local Infix "=" := Feq : type_scope. Local Notation "a <> b" := (not (a = b)) : type_scope. |
| 16 |
Local Infix "+" := Fadd. Local Infix "*" := Fmul. |
| 17 |
Local Infix "-" := Fsub. Local Infix "/" := Fdiv. |
| 18 |
Local Notation "- x" := (Fopp x). |
| 19 |
Local Notation "x ^ 2" := (x*x) (at level 30). |
| 20 |
Local Notation "0" := Fzero. |
| 21 |
Local Notation "1" := Fone. |
| 22 |
Local Notation "4" := (1+1+1+1). |
| 23 |
|
| 24 |
Global Instance MontgomeryWeierstrassIsomorphism |
| 25 |
{a b: F} |
| 26 |
(b_nonzero : b <> 0) |
| 27 |
(discriminant_nonzero: a^2 - 4 <> 0) |
| 28 |
{char_ge_3:@Ring.char_ge F Feq Fzero Fone Fopp Fadd Fsub Fmul 3} |
| 29 |
{char_ge_12:@Ring.char_ge F Feq Fzero Fone Fopp Fadd Fsub Fmul 12} |
| 30 |
{char_ge_28:@Ring.char_ge F Feq Fzero Fone Fopp Fadd Fsub Fmul 28} (* XXX: this is a workaround for nsatz assuming arbitrary characteristic *) |
| 31 |
: |
| 32 |
@Group.isomorphic_commutative_groups |
| 33 |
(@W.point F Feq Fadd Fmul _ _) |
| 34 |
W.eq |
| 35 |
(@W.add F Feq Fzero Fone Fopp Fadd Fsub Fmul Finv Fdiv field _ char_ge_3 _ _) |
| 36 |
W.zero |
| 37 |
(@W.opp F Feq Fzero Fone Fopp Fadd Fsub Fmul Finv Fdiv _ _ field _) |
| 38 |
|
| 39 |
(@M.point F Feq Fadd Fmul a b) |
| 40 |
M.eq |
| 41 |
(M.add(char_ge_3:=char_ge_3)(b_nonzero:=b_nonzero)) |
| 42 |
M.zero |
| 43 |
(M.opp(b_nonzero:=b_nonzero)) |
| 44 |
|
| 45 |
(M.of_Weierstrass(Haw:=reflexivity _)(Hbw:=reflexivity _)(b_nonzero:=b_nonzero)) |
| 46 |
(M.to_Weierstrass(Haw:=reflexivity _)(Hbw:=reflexivity _)(b_nonzero:=b_nonzero)). |
| 47 |
Proof. |
| 48 |
eapply @AffineProofs.M.MontgomeryWeierstrassIsomorphism; try assumption; cbv [id]; fsatz. |
| 49 |
Qed. |
| 50 |
End MontgomeryCurve. |
| 51 |
End M. |