• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
        • R1cs
        • Interfaces
        • Sha-2
        • Keccak
        • Kdf
        • Mimc
        • Padding
        • Hmac
        • Elliptic-curves
          • Secp256k1-attachment
          • Twisted-edwards
          • Montgomery
            • Montgomery-mul
            • Montgomery-add
            • Montgomery-point-orderp
            • Montgomery-add-commutativity
            • Montgomery-mul-distributivity-over-scalar-addition
            • Montgomery-add-associativity
            • Birational-montgomery-twisted-edwards
            • Montgomery-curve
              • Montgomery-curve-fix
                • Montgomery-curve-equiv
                • Make-montgomery-curve
                • Montgomery-curvep
                • Change-montgomery-curve
                • Montgomery-curve->b
                • Montgomery-curve->a
                • Montgomery-curve->p
              • Montgomery-mul-nonneg
              • Montgomery-not-point-with-x-minus1-when-a-minus-2-over-b-not-square
              • Point-on-montgomery-p
              • Montgomery-neg
              • Montgomery-sub
              • Montgomery-add-closure
              • Montgomery-only-point-with-y-0-when-aa-minus-4-non-square
              • Montgomery-point-order-leastp
              • Montgomery-distinct-x-when-nonzero-mul-in-order-range
              • Montgomery-add-inverse-uniqueness
              • Montgomery-distributivity-of-neg-over-add
              • Montgomery-mul-associativity
              • Montgomery-points-with-same-x-have-same-or-neg-y
              • Montgomery-zero
              • Montgomery-points-with-same-x-are-same-or-neg-point
              • Montgomery-mul-of-mod-order
              • Montgomery-neg-inverse
              • Montgomery-zero-identity
              • Point-on-montgomery-finite-when-not-zero
            • Short-weierstrass-curves
            • Birational-montgomery-twisted-edwards
            • Has-square-root?-satisfies-pfield-squarep
            • Secp256k1
            • Secp256k1-domain-parameters
            • Secp256k1-types
            • Pfield-squarep
            • Secp256k1-interface
            • Prime-field-extra-rules
            • Points
          • Attachments
          • Elliptic-curve-digital-signature-algorithm
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Montgomery-curve

    Montgomery-curve-fix

    Fixing function for montgomery-curve structures.

    Signature
    (montgomery-curve-fix x) → new-x
    Arguments
    x — Guard (montgomery-curvep x).
    Returns
    new-x — Type (montgomery-curvep new-x).

    Definitions and Theorems

    Function: montgomery-curve-fix$inline

    (defun montgomery-curve-fix$inline (x)
      (declare (xargs :guard (montgomery-curvep x)))
      (let ((acl2::__function__ 'montgomery-curve-fix))
        (declare (ignorable acl2::__function__))
        (mbe :logic
             (b* ((p (cdr (std::da-nth 0 x)))
                  (a (cdr (std::da-nth 1 x)))
                  (b (cdr (std::da-nth 2 x))))
               (let ((p (if (and (dm::primep p) (> p 2)) p 3))
                     (a (if (and (dm::primep p)
                                 (> p 2)
                                 (fep a p)
                                 (not (equal a 2))
                                 (not (equal a (mod -2 p))))
                            a
                          0))
                     (b (if (and (dm::primep p)
                                 (fep b p)
                                 (not (equal b 0)))
                            b
                          1)))
                 (list (cons 'p p)
                       (cons 'a a)
                       (cons 'b b))))
             :exec x)))

    Theorem: montgomery-curvep-of-montgomery-curve-fix

    (defthm montgomery-curvep-of-montgomery-curve-fix
      (b* ((new-x (montgomery-curve-fix$inline x)))
        (montgomery-curvep new-x))
      :rule-classes :rewrite)

    Theorem: montgomery-curve-fix-when-montgomery-curvep

    (defthm montgomery-curve-fix-when-montgomery-curvep
      (implies (montgomery-curvep x)
               (equal (montgomery-curve-fix x) x)))

    Function: montgomery-curve-equiv$inline

    (defun montgomery-curve-equiv$inline (acl2::x acl2::y)
      (declare (xargs :guard (and (montgomery-curvep acl2::x)
                                  (montgomery-curvep acl2::y))))
      (equal (montgomery-curve-fix acl2::x)
             (montgomery-curve-fix acl2::y)))

    Theorem: montgomery-curve-equiv-is-an-equivalence

    (defthm montgomery-curve-equiv-is-an-equivalence
      (and (booleanp (montgomery-curve-equiv x y))
           (montgomery-curve-equiv x x)
           (implies (montgomery-curve-equiv x y)
                    (montgomery-curve-equiv y x))
           (implies (and (montgomery-curve-equiv x y)
                         (montgomery-curve-equiv y z))
                    (montgomery-curve-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: montgomery-curve-equiv-implies-equal-montgomery-curve-fix-1

    (defthm montgomery-curve-equiv-implies-equal-montgomery-curve-fix-1
      (implies (montgomery-curve-equiv acl2::x x-equiv)
               (equal (montgomery-curve-fix acl2::x)
                      (montgomery-curve-fix x-equiv)))
      :rule-classes (:congruence))

    Theorem: montgomery-curve-fix-under-montgomery-curve-equiv

    (defthm montgomery-curve-fix-under-montgomery-curve-equiv
      (montgomery-curve-equiv (montgomery-curve-fix acl2::x)
                              acl2::x)
      :rule-classes (:rewrite :rewrite-quoted-constant))

    Theorem: equal-of-montgomery-curve-fix-1-forward-to-montgomery-curve-equiv

    (defthm
      equal-of-montgomery-curve-fix-1-forward-to-montgomery-curve-equiv
      (implies (equal (montgomery-curve-fix acl2::x)
                      acl2::y)
               (montgomery-curve-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: equal-of-montgomery-curve-fix-2-forward-to-montgomery-curve-equiv

    (defthm
      equal-of-montgomery-curve-fix-2-forward-to-montgomery-curve-equiv
      (implies (equal acl2::x (montgomery-curve-fix acl2::y))
               (montgomery-curve-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: montgomery-curve-equiv-of-montgomery-curve-fix-1-forward

    (defthm montgomery-curve-equiv-of-montgomery-curve-fix-1-forward
      (implies (montgomery-curve-equiv (montgomery-curve-fix acl2::x)
                                       acl2::y)
               (montgomery-curve-equiv acl2::x acl2::y))
      :rule-classes :forward-chaining)

    Theorem: montgomery-curve-equiv-of-montgomery-curve-fix-2-forward

    (defthm montgomery-curve-equiv-of-montgomery-curve-fix-2-forward
     (implies
         (montgomery-curve-equiv acl2::x (montgomery-curve-fix acl2::y))
         (montgomery-curve-equiv acl2::x acl2::y))
     :rule-classes :forward-chaining)