diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,49 @@
 All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/),
+in which the first two numbers together are the major version.
+
+## [3.1.0] - 2026-12-02
+
+### Added
+- `Crypto.Secp256k1.EllSwift`: the ElligatorSwift encoding of public keys
+  (`EllSwift`, `ellSwift`, `ellSwiftCreate`, `ellSwiftCreateIO`,
+  `ellSwiftEncode`, `ellSwiftDecode`) and the x-only Diffie-Hellman exchange
+  of BIP 324 (`Party`, `ellSwiftXdhBip324`), through the `ellswift` module of
+  libsecp256k1, for the encrypted transport of the Bitcoin network. The
+  internal module `Crypto.Secp256k1.Internal.EllSwift` has the raw
+  constructor.
+- The flag `ellswift`, on by default: the module needs libsecp256k1 0.4.0 or
+  later, which the package then asks pkg-config for, so that an older
+  library stops the build at the configure step with its version. Ubuntu
+  24.04 ships 0.2.0, without it; turn the flag off there.
+- Tests with every vector of BIP 324 that the API can reach: the 76 of
+  `ellswift_decode_test_vectors.csv`, the 98 values of t of
+  `xswiftec_inv_test_vectors.csv` (decoded back to x: the inverse map itself
+  is not in the API of libsecp256k1), and the keys and shared secrets of the
+  7 rows of `packet_encoding_test_vectors.csv`, copied into `test/data`.
+
+This release breaks the API: a record update of a value of the package no
+longer compiles. It needs a major version: 3.1 is one under the Package
+Versioning Policy.
+
+### Changed
+- `Msg`, `SecKey`, `PubKey`, `Sig`, `CompactSig`, `Tweak`, `SchnorrSig` and
+  `RecSig` have no field `get`. `x.get` still gives the bytes, through an
+  instance of `HasField` in `Crypto.Secp256k1.Internal.Base` and
+  `Crypto.Secp256k1.Internal.Recovery`. The constructors were hidden so
+  that every value is checked, but the field was exported, and a record
+  update such as `key {get = bytes}` replaced the bytes with no check: a
+  secret key of zeros, or a `PubKey` that is no point of the curve. Only an
+  update, or an import list that names `SecKey (get)`, has to change:
+  import the type alone.
+- CI runs through the workflow that the Haskell packages of jprupp share in
+  [jprupp/tools](https://github.com/jprupp/tools), with the check of
+  `stack.yaml` for local paths (`check-stack-paths`) and the cache of the
+  Nix build kept per release of nixpkgs.
+- `scripts/format` is gone: `haskell-format`, from jprupp/tools, formats
+  every Haskell file.
 
 ## [3.0.0] - 2026-11-15
 
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -87,6 +87,7 @@
 | Taproot (BIP-341)    | Tweaking an x-only public key and its secret key                                               |
 | Key arithmetic       | Add or multiply secret and public keys by a tweak, negate, combine public keys                 |
 | Recovery             | Recoverable ECDSA signatures and public key recovery, as Bitcoin signed messages use           |
+| ElligatorSwift       | Public keys encoded as 64 random-looking bytes, and the x-only Diffie-Hellman exchange of BIP 324 |
 | Safety               | Validated values, no aborts, length checks before every C call, one read-only context for all threads |
 | Testing              | QuickCheck `Arbitrary` instances for secret keys, hashes and tweaks                            |
 
@@ -94,8 +95,9 @@
 
 - No hashing. Pass a 32-byte hash you computed with a hash library, such as
   `cryptohash-sha256` or haskoin-core.
-- No ECDH, MuSig2 or adaptor signatures, although libsecp256k1 or its
-  forks offer some of them.
+- No plain ECDH, MuSig2 or adaptor signatures, although libsecp256k1 or its
+  forks offer some of them. The one Diffie-Hellman exchange bound is that of
+  BIP 324, on ElligatorSwift encodings.
 - No secure erasure of secret keys from memory. See [Security notes](#security-notes).
 
 ## Installation
@@ -142,6 +144,13 @@
 `cabal build -f -recovery`. Everything except `Crypto.Secp256k1.Recovery` still
 works.
 
+ElligatorSwift (`Crypto.Secp256k1.EllSwift`) needs libsecp256k1 **0.4.0 or
+later**, built with its `ellswift` module, which is on by default. Ubuntu 24.04
+ships 0.2.0, which does not have it; Ubuntu 26.04, Fedora, Homebrew and Nixpkgs
+ship versions that do. With an older library, build this package with the
+`ellswift` flag off: `stack build --flag secp256k1-haskell:-ellswift`, or
+`cabal build -f -ellswift`.
+
 ### Step by step with Stack
 
 1. Install [Stack](https://docs.haskellstack.org/) and the library above.
@@ -158,7 +167,7 @@
 
    ```yaml
    extra-deps:
-     - secp256k1-haskell-3.0.0
+     - secp256k1-haskell-3.1.0
      - base16-2.0
    ```
 
@@ -301,7 +310,10 @@
 | `RecSig`     | ECDSA signature with its recovery id                     | `signRecMsg`, `importCompactRecSig`     |
 
 Here n is the order of the curve. The raw constructors are hidden, so these
-are the only ways to build values. Each type has a `get` field with its bytes.
+are the only ways to build values. `x.get` gives the bytes of a value, with
+`OverloadedRecordDot`. It is not a field, so a record update such as
+`key {get = bytes}` does not compile: an update would replace the bytes
+without the checks.
 `Show` prints hex, except for `SecKey`, which it redacts. See
 [Security notes](#security-notes).
 
@@ -387,6 +399,21 @@
 recover r m -- Just the signer's PubKey
 ```
 
+### ElligatorSwift and BIP 324
+
+```haskell
+import Crypto.Secp256k1.EllSwift
+
+-- each side makes its encoded key with fresh randomness and sends the 64 bytes
+ours <- ellSwiftCreateIO key
+-- the initiator of the connection is party A, the responder party B
+let secret = ellSwiftXdhBip324 ours theirs key PartyA -- 32 bytes
+ellSwiftDecode theirs -- the PubKey behind an encoding, if one needs it
+```
+
+The exchange is unauthenticated: it stops a passive observer, not a man in the
+middle. See the module header.
+
 ### Testing with QuickCheck
 
 `SecKey`, `Msg` and `Tweak` have `Arbitrary` instances, so properties can
@@ -415,12 +442,13 @@
 | --------------------------------------- | --------------------------------------------------------- |
 | `Crypto.Secp256k1`                      | The public API: keys, ECDSA, Schnorr, tweaks              |
 | `Crypto.Secp256k1.Recovery`             | Recoverable signatures and public key recovery            |
+| `Crypto.Secp256k1.EllSwift`             | ElligatorSwift encodings and the BIP 324 key exchange     |
 | `Crypto.Secp256k1.Internal.*`           | Raw constructors and helpers; no stability promise        |
 
-The exposed internal modules are `Base`, `Recovery`, `ForeignTypes` and
-`Util`. The modules that hold the global context (`Context`), create contexts
-(`ContextOps`) or bind the C functions, which all take a context (`BaseOps`,
-`RecoveryOps`), are hidden. Nothing a program can import makes, takes or names
+The exposed internal modules are `Base`, `Recovery`, `EllSwift`, `ForeignTypes`
+and `Util`. The modules that hold the global context (`Context`), create
+contexts (`ContextOps`) or bind the C functions, which all take a context
+(`BaseOps`, `RecoveryOps`, `EllSwiftOps`), are hidden. Nothing a program can import makes, takes or names
 a context, so the raw foreign imports cannot be called from outside the
 package. The tests reach them by compiling the sources of the library
 themselves.
diff --git a/secp256k1-haskell.cabal b/secp256k1-haskell.cabal
--- a/secp256k1-haskell.cabal
+++ b/secp256k1-haskell.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           secp256k1-haskell
-version:        3.0.0
+version:        3.1.0
 synopsis:       Bindings for secp256k1
 description:    Sign and verify signatures using the secp256k1 library.
 category:       Crypto
@@ -19,11 +19,19 @@
 extra-source-files:
     CHANGELOG.md
     README.md
+    test/data/ellswift_decode_test_vectors.csv
+    test/data/packet_encoding_test_vectors.csv
+    test/data/xswiftec_inv_test_vectors.csv
 
 source-repository head
   type: git
   location: https://github.com/jprupp/secp256k1-haskell
 
+flag ellswift
+  description: Bind the ElligatorSwift module of libsecp256k1, which BIP 324 uses. The library must be version 0.4.0 or later, built with the module, which is the default; Ubuntu 24.04 ships 0.2.0, without it. Turn the flag off for a library without it.
+  manual: True
+  default: True
+
 flag recovery
   description: Bind the ECDSA public key recovery module of libsecp256k1. The library must have been built with it (--enable-module-recovery), as the packages of the Linux distributions, Homebrew and Nixpkgs are. Turn the flag off for a library built without it.
   manual: True
@@ -65,11 +73,20 @@
         Crypto.Secp256k1.Recovery
     other-modules:
         Crypto.Secp256k1.Internal.RecoveryOps
+  if flag(ellswift)
+    exposed-modules:
+        Crypto.Secp256k1.EllSwift
+        Crypto.Secp256k1.Internal.EllSwift
+    other-modules:
+        Crypto.Secp256k1.Internal.EllSwiftOps
+    pkgconfig-depends:
+        libsecp256k1 >= 0.4.0
 
 test-suite spec
   type: exitcode-stdio-1.0
   main-is: Spec.hs
   other-modules:
+      Crypto.Secp256k1.EllSwiftSpec
       Crypto.Secp256k1.Fixtures
       Crypto.Secp256k1.InternalSpec
       Crypto.Secp256k1.RecoverySpec
@@ -112,4 +129,12 @@
         Crypto.Secp256k1.Internal.RecoveryOps
         Crypto.Secp256k1.Recovery
     cpp-options: -DRECOVERY
+  if flag(ellswift)
+    other-modules:
+        Crypto.Secp256k1.EllSwift
+        Crypto.Secp256k1.Internal.EllSwift
+        Crypto.Secp256k1.Internal.EllSwiftOps
+    cpp-options: -DELLSWIFT
+    pkgconfig-depends:
+        libsecp256k1 >= 0.4.0
   build-tool-depends: hspec-discover:hspec-discover
diff --git a/src/Crypto/Secp256k1.hs b/src/Crypto/Secp256k1.hs
--- a/src/Crypto/Secp256k1.hs
+++ b/src/Crypto/Secp256k1.hs
@@ -57,11 +57,14 @@
 -- * 'SchnorrSig': a 64-byte BIP-340 signature ('schnorrSig' checks the
 --   length, 'verifySchnorr' the values).
 --
--- The @get@ field of each type gives its bytes. For 'SecKey', 'Msg', 'Tweak',
--- 'CompactSig' and 'SchnorrSig' these are the standard big-endian bytes. For 'PubKey' and
--- 'Sig' they are the internal representation of libsecp256k1, which is
--- opaque and not portable. Use 'exportPubKey', 'exportSig' and
--- 'exportCompactSig' to serialize those.
+-- @x.get@ gives the bytes of a value, with @OverloadedRecordDot@. For
+-- 'SecKey', 'Msg', 'Tweak', 'CompactSig' and 'SchnorrSig' these are the
+-- standard big-endian bytes. For 'PubKey' and 'Sig' they are the internal
+-- representation of libsecp256k1, which is opaque and not portable. Use
+-- 'exportPubKey', 'exportSig' and 'exportCompactSig' to serialize those.
+-- @get@ is not a field, so a record update cannot replace the bytes of a
+-- value without the checks: see the instances of
+-- "Crypto.Secp256k1.Internal.Base".
 --
 -- 'Show', 'Read' and 'Data.String.IsString' use hex of a standard encoding: compressed
 -- SEC1 for 'PubKey', compact for 'Sig', and the plain bytes for the others.
@@ -149,22 +152,22 @@
 -- the package is on, which is the default.
 module Crypto.Secp256k1
   ( -- * Messages
-    Msg (get),
+    Msg,
     msg,
 
     -- * Secret Keys
-    SecKey (get),
+    SecKey,
     secKey,
     derivePubKey,
 
     -- * Public Keys
-    PubKey (get),
+    PubKey,
     pubKey,
     importPubKey,
     exportPubKey,
 
     -- * Signatures
-    Sig (get),
+    Sig,
     sig,
     signMsg,
     signMsgLowR,
@@ -178,13 +181,13 @@
     exportSig,
 
     -- ** Compact
-    CompactSig (get),
+    CompactSig,
     compactSig,
     exportCompactSig,
     importCompactSig,
 
     -- * Addition & Multiplication
-    Tweak (get),
+    Tweak,
     tweak,
     tweakAddSecKey,
     tweakMulSecKey,
@@ -194,7 +197,7 @@
     tweakNegate,
 
     -- * Schnorr Signatures (BIP-340)
-    SchnorrSig (get),
+    SchnorrSig,
     schnorrSig,
     signSchnorr,
     signSchnorrWithAux,
diff --git a/src/Crypto/Secp256k1/EllSwift.hs b/src/Crypto/Secp256k1/EllSwift.hs
new file mode 100644
--- /dev/null
+++ b/src/Crypto/Secp256k1/EllSwift.hs
@@ -0,0 +1,67 @@
+-- | ElligatorSwift encoding of public keys and the x-only Diffie-Hellman
+-- exchange of BIP 324, through the @ellswift@ module of
+-- <https://github.com/bitcoin-core/secp256k1 libsecp256k1>.
+--
+-- == What it is for
+--
+-- A public key on the wire is easy to spot: an x coordinate is a field
+-- element for which a square root exists, and a compressed key starts with 2
+-- or 3. A censor that looks for such bytes can tell an encrypted Bitcoin
+-- connection from other traffic. ElligatorSwift (Chávez-Saab,
+-- Rodríguez-Henríquez and Tibouchi, <https://eprint.iacr.org/2022/759>)
+-- encodes a point as 64 bytes that are indistinguishable from uniformly
+-- random bytes. The encoding is not unique: it is chosen at random among the
+-- many that decode to the point. BIP 324, the encrypted transport of the
+-- Bitcoin network, sends each side's key this way.
+--
+-- 'ellSwiftCreate' makes the encoded public key of a secret key,
+-- 'ellSwiftEncode' encodes a public key one already has, and
+-- 'ellSwiftDecode' gives back the point. 'ellSwiftXdhBip324' is the
+-- Diffie-Hellman exchange of BIP 324 on two encodings, which is all a
+-- transport needs: it never has to decode a key.
+--
+-- == What it does not do
+--
+-- The encoding hides that a key is a key; it does not say whose key it is.
+-- A Diffie-Hellman exchange on keys that nobody vouches for is
+-- unauthenticated: a man in the middle can run one exchange with each side.
+-- BIP 324 accepts that and says so; it only makes passive observation
+-- impossible and active interception detectable afterwards, by comparing the
+-- session ids out of band.
+--
+-- == The ellswift module of libsecp256k1
+--
+-- The module is in libsecp256k1 from version 0.4.0 on, and the build turns
+-- it on by default. Ubuntu 24.04 ships 0.2.0, which does not have it; Fedora,
+-- Arch, Homebrew, Nixpkgs and Ubuntu 26.04 ship versions that do. This
+-- package binds it when its @ellswift@ flag is on, which is the default,
+-- and then asks pkg-config for libsecp256k1 0.4.0 or later: with an older
+-- library the build stops at the configure step and names the version it
+-- found. Build the package with @-f -ellswift@ then, and this module is not
+-- available. A library of 0.4.0 or later built without the module (it is
+-- on by default) fails later, at the link, with an undefined reference to
+-- @secp256k1_ellswift_create@.
+--
+-- == Values
+--
+-- t'EllSwift' holds the 64 bytes of an encoding, which are standard and
+-- portable, unlike the @get@ field of a 'Crypto.Secp256k1.PubKey'. Any 64
+-- bytes are valid, so 'ellSwift' only checks the length. The raw constructor
+-- is in "Crypto.Secp256k1.Internal.EllSwift", which has no API stability
+-- guarantee.
+module Crypto.Secp256k1.EllSwift
+  ( -- * Encodings
+    EllSwift (get),
+    ellSwift,
+    ellSwiftCreate,
+    ellSwiftCreateIO,
+    ellSwiftEncode,
+    ellSwiftDecode,
+
+    -- * Diffie-Hellman exchange of BIP 324
+    Party (..),
+    ellSwiftXdhBip324,
+  )
+where
+
+import Crypto.Secp256k1.Internal.EllSwift
diff --git a/src/Crypto/Secp256k1/Internal/Base.hs b/src/Crypto/Secp256k1/Internal/Base.hs
--- a/src/Crypto/Secp256k1/Internal/Base.hs
+++ b/src/Crypto/Secp256k1/Internal/Base.hs
@@ -1,7 +1,10 @@
+{-# LANGUAGE DataKinds #-}
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE DuplicateRecordFields #-}
+{-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-# LANGUAGE ImportQualifiedPost #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedRecordDot #-}
 {-# LANGUAGE NoFieldSelectors #-}
 
@@ -94,6 +97,7 @@
   )
 import Foreign.C (CUChar)
 import GHC.Generics (Generic)
+import GHC.Records (HasField (..))
 import System.Entropy (getEntropy)
 import System.IO.Unsafe (unsafePerformIO)
 import Test.QuickCheck
@@ -118,7 +122,7 @@
 --
 -- 'Show', 'Read' and 'IsString' use the compressed SEC1 encoding in hex.
 -- 'Read' and 'IsString' also accept the uncompressed and hybrid encodings.
-newtype PubKey = PubKey {get :: ByteString}
+newtype PubKey = PubKey ByteString
   deriving (Eq, Generic, Hashable, NFData)
 
 -- | 32-byte message hash to sign or verify.
@@ -128,7 +132,7 @@
 -- produce a signature that verifies without knowing the secret key.
 --
 -- 'Show', 'Read' and 'IsString' use hex.
-newtype Msg = Msg {get :: ByteString}
+newtype Msg = Msg ByteString
   deriving (Eq, Generic, Hashable, NFData)
 
 -- | ECDSA signature in the internal representation of libsecp256k1 (64
@@ -141,7 +145,7 @@
 --
 -- 'Show', 'Read' and 'IsString' use the compact encoding in hex: r and s as
 -- 32-byte big-endian numbers.
-newtype Sig = Sig {get :: ByteString}
+newtype Sig = Sig ByteString
   deriving (Eq, Generic, Hashable, NFData)
 
 -- | 32-byte secret key as a big-endian number in the range 1 to n−1, where n
@@ -152,26 +156,57 @@
 -- line or an error message without revealing it. Read the bytes from @get@
 -- when you mean to write a key out. They live in an ordinary 'ByteString', so
 -- the garbage collector copies them and nothing ever clears them from memory.
-newtype SecKey = SecKey {get :: ByteString}
+newtype SecKey = SecKey ByteString
   deriving (Eq, Generic, Hashable, NFData)
 
 -- | 32-byte scalar as a big-endian number in the range 0 to n−1, to add to or
 -- multiply with a key. 'Show', 'Read' and 'IsString' use hex.
-newtype Tweak = Tweak {get :: ByteString}
+newtype Tweak = Tweak ByteString
   deriving (Eq, Generic, Hashable, NFData)
 
 -- | Compact signature encoding: r and s as 32-byte big-endian numbers.
 -- 'compactSig' only checks the length. 'importCompactSig' checks the values.
 -- 'Show', 'Read' and 'IsString' use hex.
-newtype CompactSig = CompactSig {get :: ByteString}
+newtype CompactSig = CompactSig ByteString
   deriving (Eq, Generic, Hashable, NFData)
 
 -- | BIP-340 Schnorr signature. Unlike 'Sig', the 64 bytes in @get@ are the
 -- serialized form that BIP-340 defines, r‖s as 32-byte big-endian numbers,
 -- which is the same on every platform. 'schnorrSig' only checks the length.
 -- 'verifySchnorr' checks the values. 'Show', 'Read' and 'IsString' use hex.
-newtype SchnorrSig = SchnorrSig {get :: ByteString}
+newtype SchnorrSig = SchnorrSig ByteString
   deriving (Eq, Generic, Hashable, NFData)
+
+-- | The bytes of a value, read as @x.get@ with @OverloadedRecordDot@.
+--
+-- @get@ is not a field, on purpose. A field that a module exports reads the
+-- bytes, but it also lets a record update replace them, as in
+-- @key {get = bytes}@, even where the constructor is hidden, and an update
+-- checks nothing. A 'PubKey' that is no point of the curve would then reach
+-- the functions of the package, and an address made of it could never be
+-- spent. These instances give the reading without the update. The one way
+-- around the checks left is @to@ of 'GHC.Generics.Generic', which no
+-- program calls by accident, and the constructors of this module.
+instance HasField "get" PubKey ByteString where
+  getField (PubKey bytes) = bytes
+
+instance HasField "get" Msg ByteString where
+  getField (Msg bytes) = bytes
+
+instance HasField "get" Sig ByteString where
+  getField (Sig bytes) = bytes
+
+instance HasField "get" SecKey ByteString where
+  getField (SecKey bytes) = bytes
+
+instance HasField "get" Tweak ByteString where
+  getField (Tweak bytes) = bytes
+
+instance HasField "get" CompactSig ByteString where
+  getField (CompactSig bytes) = bytes
+
+instance HasField "get" SchnorrSig ByteString where
+  getField (SchnorrSig bytes) = bytes
 
 instance Read PubKey where
   readPrec = parens $ do
diff --git a/src/Crypto/Secp256k1/Internal/EllSwift.hs b/src/Crypto/Secp256k1/Internal/EllSwift.hs
new file mode 100644
--- /dev/null
+++ b/src/Crypto/Secp256k1/Internal/EllSwift.hs
@@ -0,0 +1,190 @@
+{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE DuplicateRecordFields #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE ImportQualifiedPost #-}
+{-# LANGUAGE OverloadedRecordDot #-}
+{-# LANGUAGE NoFieldSelectors #-}
+
+-- | Internal module. Everything is exported, including the raw v'EllSwift'
+-- constructor that "Crypto.Secp256k1.EllSwift" hides, and there is no API
+-- stability guarantee. This module is only built when the @ellswift@ flag of
+-- the package is on.
+--
+-- Every 64 bytes are the encoding of some point, so the only thing the raw
+-- constructor can get wrong is the length. Every function here checks it
+-- before calling the C library and raises an 'Control.Exception.ErrorCall'
+-- when it is wrong.
+--
+-- As in "Crypto.Secp256k1.Internal.Base", every function uses the global
+-- context of the package and none takes one.
+module Crypto.Secp256k1.Internal.EllSwift where
+
+import Control.DeepSeq (NFData)
+import Control.Exception (evaluate)
+import Control.Monad.IO.Class (MonadIO (..))
+import Crypto.Secp256k1.Internal.Base (PubKey (..), SecKey (..))
+import Crypto.Secp256k1.Internal.Context (globalContext)
+import Crypto.Secp256k1.Internal.EllSwiftOps qualified as Ops
+import Crypto.Secp256k1.Internal.ForeignTypes (isSuccess)
+import Crypto.Secp256k1.Internal.Util
+  ( decodeHex,
+    showsHex,
+    useFixedByteString,
+    withOutput,
+  )
+import Data.ByteString (ByteString)
+import Data.ByteString qualified as BS
+import Data.Hashable (Hashable)
+import Data.Maybe (fromMaybe)
+import Data.String (IsString (..))
+import Foreign (castPtr, nullPtr, peek)
+import GHC.Generics (Generic)
+import System.Entropy (getEntropy)
+import System.IO.Unsafe (unsafePerformIO)
+import Text.Read
+  ( Lexeme (String),
+    lexP,
+    parens,
+    pfail,
+    readPrec,
+  )
+
+-- | ElligatorSwift encoding of a public key: 64 bytes, two field elements u
+-- and t as 32-byte big-endian numbers. Unlike the @get@ field of a 'PubKey',
+-- these bytes are a standard encoding, the same on every platform, and they
+-- are what BIP 324 sends on the wire.
+--
+-- Any 64 bytes are a valid encoding: each decodes to a point of the curve,
+-- including values of u or t at or above the field size, which are taken
+-- modulo p. A point has many encodings, chosen at random when it is encoded,
+-- so 'Eq' compares encodings, not points.
+--
+-- 'Show', 'Read' and 'IsString' use hex.
+newtype EllSwift = EllSwift {get :: ByteString}
+  deriving (Eq, Ord, Generic, Hashable, NFData)
+
+instance Read EllSwift where
+  readPrec = parens $ do
+    String str <- lexP
+    maybe pfail return $ ellSwift =<< decodeHex str
+
+instance IsString EllSwift where
+  fromString = fromMaybe e . (ellSwift =<<) . decodeHex
+    where
+      e = error "Could not decode ElligatorSwift encoding from hex string"
+
+instance Show EllSwift where
+  showsPrec _ (EllSwift bs) = showsHex bs
+
+-- | Which side of an x-only Diffie-Hellman exchange a party is. The two
+-- encodings are hashed in the order A then B, so both sides must agree on
+-- who is who. In BIP 324 the initiator of the connection is A and the
+-- responder is B.
+data Party = PartyA | PartyB
+  deriving (Eq, Ord, Show, Read, Enum, Bounded, Generic)
+
+instance NFData Party
+
+-- | An encoding from its 64 bytes. 'Nothing' only for another length: every
+-- 64 bytes encode a point.
+ellSwift :: ByteString -> Maybe EllSwift
+ellSwift bs
+  | BS.length bs == 64 = Just (EllSwift bs)
+  | otherwise = Nothing
+
+-- | Encode a public key with 32 bytes of randomness. 'Nothing' unless the
+-- randomness is 32 bytes long.
+--
+-- The randomness picks one of the many encodings of the point. It should be
+-- uniformly random and unknown to anyone who tries to tell the encoding from
+-- random bytes, and it must not be a function of the public key alone. The
+-- encoding of a given key and randomness may change between versions of
+-- libsecp256k1. Runs in variable time, which is harmless for a public key.
+-- Prefer 'ellSwiftCreate' when the secret key is at hand.
+ellSwiftEncode :: PubKey -> ByteString -> Maybe EllSwift
+ellSwiftEncode (PubKey pub_key) rnd
+  | BS.length rnd /= 32 = Nothing
+  | otherwise =
+      Just . unsafePerformIO $
+        useFixedByteString "PubKey" 64 pub_key $ \(pub_key_ptr, _) ->
+          useFixedByteString "randomness" 32 rnd $ \(rnd_ptr, _) -> do
+            out <- withOutput 64 $ \ell_ptr ->
+              isSuccess <$> Ops.ellSwiftEncode globalContext ell_ptr pub_key_ptr rnd_ptr
+            -- libsecp256k1 documents that this function always succeeds.
+            maybe (error "could not encode public key") (return . EllSwift) out
+
+-- | The public key of a secret key, encoded with ElligatorSwift. The secret
+-- key itself is a source of randomness for the choice of the encoding, and
+-- the optional 32 bytes of auxiliary randomness add to it, as
+-- @EllSwiftCreate@ does in Bitcoin Core. 'Nothing' when the auxiliary
+-- randomness is given and is not 32 bytes long.
+--
+-- Without auxiliary randomness the encoding is a function of the secret key,
+-- and still looks uniformly random to anyone who does not know the key. BIP
+-- 324 recommends fresh randomness: see 'ellSwiftCreateIO'. Constant time in
+-- the secret key and the randomness, but not in the resulting public key.
+ellSwiftCreate :: SecKey -> Maybe ByteString -> Maybe EllSwift
+ellSwiftCreate (SecKey sec_key) aux = case aux of
+  Just a | BS.length a /= 32 -> Nothing
+  _ ->
+    Just . unsafePerformIO $
+      useFixedByteString "SecKey" 32 sec_key $ \(sec_key_ptr, _) ->
+        withAux $ \aux_ptr -> do
+          out <- withOutput 64 $ \ell_ptr ->
+            isSuccess <$> Ops.ellSwiftCreate globalContext ell_ptr sec_key_ptr aux_ptr
+          -- It fails only for a secret key out of range, which a 'SecKey' is
+          -- not.
+          maybe (error "could not create ElligatorSwift public key") (return . EllSwift) out
+  where
+    withAux f = case aux of
+      Nothing -> f nullPtr
+      Just a -> useFixedByteString "auxiliary randomness" 32 a $ f . castPtr . fst
+
+-- | 'ellSwiftCreate' with 32 bytes of fresh auxiliary randomness from the
+-- operating system, as Bitcoin Core does for every connection.
+ellSwiftCreateIO :: (MonadIO m) => SecKey -> m EllSwift
+ellSwiftCreateIO key = liftIO $ do
+  aux <- getEntropy 32
+  evaluate . fromMaybe (error "getEntropy gave the wrong length") $ ellSwiftCreate key (Just aux)
+
+-- | The public key that an encoding stands for. Every encoding decodes to a
+-- point, so this is total. The y coordinate of the point has the parity of
+-- t. Runs in variable time.
+ellSwiftDecode :: EllSwift -> PubKey
+ellSwiftDecode (EllSwift ell) =
+  unsafePerformIO $
+    useFixedByteString "EllSwift" 64 ell $ \(ell_ptr, _) -> do
+      out <- withOutput 64 $ \pub_key_ptr ->
+        isSuccess <$> Ops.ellSwiftDecode globalContext pub_key_ptr ell_ptr
+      -- libsecp256k1 documents that this function always succeeds.
+      maybe (error "could not decode ElligatorSwift encoding") (return . PubKey) out
+
+-- | The shared secret of BIP 324: x-only Diffie-Hellman between our secret key
+-- and the other party's encoded public key, hashed with the tagged hash
+-- @bip324_ellswift_xonly_ecdh@ of the encoding of A, the encoding of B and the
+-- shared x coordinate. The first two arguments are the encodings of A and B,
+-- in that order; the secret key is that of the party named by the last
+-- argument, whose encoding must be the one that comes from that key. That
+-- correspondence is not checked: a wrong one gives a secret that the other
+-- side does not share.
+--
+-- This is @CKey::ComputeBIP324ECDHSecret@ of Bitcoin Core, which passes the
+-- initiator as A. It is faster than decoding the other key and doing the
+-- Diffie-Hellman exchange by hand, and constant time in the secret key.
+ellSwiftXdhBip324 :: EllSwift -> EllSwift -> SecKey -> Party -> ByteString
+ellSwiftXdhBip324 (EllSwift ell_a) (EllSwift ell_b) (SecKey sec_key) party =
+  unsafePerformIO $
+    useFixedByteString "EllSwift" 64 ell_a $ \(a_ptr, _) ->
+      useFixedByteString "EllSwift" 64 ell_b $ \(b_ptr, _) ->
+        useFixedByteString "SecKey" 32 sec_key $ \(sec_key_ptr, _) -> do
+          hash_fun <- peek Ops.ellSwiftXdhHashFunctionBip324
+          out <- withOutput 32 $ \out_ptr ->
+            isSuccess
+              <$> Ops.ellSwiftXdh globalContext out_ptr a_ptr b_ptr sec_key_ptr side hash_fun nullPtr
+          -- It fails only for a secret key out of range, or when the hash
+          -- function fails, which the BIP 324 one never does.
+          maybe (error "could not compute ElligatorSwift shared secret") return out
+  where
+    side = case party of
+      PartyA -> 0
+      PartyB -> 1
diff --git a/src/Crypto/Secp256k1/Internal/EllSwiftOps.hs b/src/Crypto/Secp256k1/Internal/EllSwiftOps.hs
new file mode 100644
--- /dev/null
+++ b/src/Crypto/Secp256k1/Internal/EllSwiftOps.hs
@@ -0,0 +1,73 @@
+-- | Foreign imports of the @ellswift@ module of libsecp256k1, which the
+-- library has from version 0.4.0 on when it was built with it, as it is by
+-- default. See "Crypto.Secp256k1.EllSwift". This module is only built when
+-- the @ellswift@ flag of the package is on.
+--
+-- Like "Crypto.Secp256k1.Internal.BaseOps", it is hidden, because every
+-- binding takes a context pointer and the package exposes nothing that makes,
+-- takes or names a context.
+module Crypto.Secp256k1.Internal.EllSwiftOps where
+
+import Crypto.Secp256k1.Internal.ContextOps (LCtx)
+import Crypto.Secp256k1.Internal.ForeignTypes
+  ( EllSwift64,
+    PubKey64,
+    Ret,
+    SecKey32,
+    XdhHashFun,
+  )
+import Foreign (FunPtr, Ptr)
+import Foreign.C (CInt (..), CUChar)
+
+-- | Binding to @secp256k1_ellswift_encode@.
+foreign import ccall safe "secp256k1_ellswift.h secp256k1_ellswift_encode"
+  ellSwiftEncode ::
+    Ptr LCtx ->
+    Ptr EllSwift64 ->
+    Ptr PubKey64 ->
+    -- | 32 bytes of randomness
+    Ptr CUChar ->
+    IO Ret
+
+-- | Binding to @secp256k1_ellswift_decode@.
+foreign import ccall safe "secp256k1_ellswift.h secp256k1_ellswift_decode"
+  ellSwiftDecode ::
+    Ptr LCtx ->
+    Ptr PubKey64 ->
+    Ptr EllSwift64 ->
+    IO Ret
+
+-- | Binding to @secp256k1_ellswift_create@.
+foreign import ccall safe "secp256k1_ellswift.h secp256k1_ellswift_create"
+  ellSwiftCreate ::
+    Ptr LCtx ->
+    Ptr EllSwift64 ->
+    Ptr SecKey32 ->
+    -- | 32 bytes of auxiliary randomness, or null
+    Ptr CUChar ->
+    IO Ret
+
+-- | Binding to @secp256k1_ellswift_xdh@.
+foreign import ccall safe "secp256k1_ellswift.h secp256k1_ellswift_xdh"
+  ellSwiftXdh ::
+    Ptr LCtx ->
+    -- | output, filled by the hash function
+    Ptr CUChar ->
+    -- | encoding of party A
+    Ptr EllSwift64 ->
+    -- | encoding of party B
+    Ptr EllSwift64 ->
+    Ptr SecKey32 ->
+    -- | party: 0 for A, 1 for B
+    CInt ->
+    FunPtr (XdhHashFun a) ->
+    -- | data passed to the hash function
+    Ptr a ->
+    IO Ret
+
+-- | Address of @secp256k1_ellswift_xdh_hash_function_bip324@, a constant
+-- that holds the hash function of BIP 324: the tagged hash with tag
+-- @bip324_ellswift_xonly_ecdh@ of the encodings of A and B and the shared x
+-- coordinate. It ignores its data argument.
+foreign import ccall "secp256k1_ellswift.h &secp256k1_ellswift_xdh_hash_function_bip324"
+  ellSwiftXdhHashFunctionBip324 :: Ptr (FunPtr (XdhHashFun a))
diff --git a/src/Crypto/Secp256k1/Internal/ForeignTypes.hs b/src/Crypto/Secp256k1/Internal/ForeignTypes.hs
--- a/src/Crypto/Secp256k1/Internal/ForeignTypes.hs
+++ b/src/Crypto/Secp256k1/Internal/ForeignTypes.hs
@@ -46,6 +46,24 @@
 -- | Auxiliary randomness for BIP-340 signing, 32 bytes.
 data AuxRand32
 
+-- | ElligatorSwift encoding of a public key, 64 bytes: two field elements u
+-- and t as 32-byte big-endian numbers.
+data EllSwift64
+
+-- | Hash function of @secp256k1_ellswift_xdh@, as
+-- @secp256k1_ellswift_xdh_hash_function@: it writes the shared secret from
+-- the shared x coordinate and the two encoded public keys. The bindings only
+-- pass the one that libsecp256k1 defines for BIP 324. The arguments are the
+-- output, the shared x coordinate (32 bytes), the encodings of party A and
+-- party B (64 bytes each) and the data pointer.
+type XdhHashFun a =
+  Ptr CUChar ->
+  Ptr CUChar ->
+  Ptr CUChar ->
+  Ptr CUChar ->
+  Ptr a ->
+  IO CInt
+
 -- | Flags passed to @secp256k1_ec_pubkey_serialize@.
 type SerFlags = CUInt
 
diff --git a/src/Crypto/Secp256k1/Internal/Recovery.hs b/src/Crypto/Secp256k1/Internal/Recovery.hs
--- a/src/Crypto/Secp256k1/Internal/Recovery.hs
+++ b/src/Crypto/Secp256k1/Internal/Recovery.hs
@@ -1,7 +1,10 @@
+{-# LANGUAGE DataKinds #-}
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE DuplicateRecordFields #-}
+{-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-# LANGUAGE ImportQualifiedPost #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedRecordDot #-}
 {-# LANGUAGE NoFieldSelectors #-}
 
@@ -56,6 +59,7 @@
 import Data.Word (Word8)
 import Foreign (alloca, allocaBytes, nullFunPtr, nullPtr, peek)
 import GHC.Generics (Generic)
+import GHC.Records (HasField (..))
 import System.IO.Unsafe (unsafePerformIO)
 import Text.Read
   ( Lexeme (String),
@@ -78,8 +82,14 @@
 -- 'Show', 'Read' and 'IsString' use hex of the 65-byte encoding that
 -- 'exportCompactRecSig' gives: r and s as 32-byte big-endian numbers, then
 -- the recovery id as one byte.
-newtype RecSig = RecSig {get :: ByteString}
+newtype RecSig = RecSig ByteString
   deriving (Eq, Generic, Hashable, NFData)
+
+-- | The bytes of a 'RecSig', read as @x.get@. @get@ is not a field, so no
+-- record update can replace them: see the instances of
+-- "Crypto.Secp256k1.Internal.Base".
+instance HasField "get" RecSig ByteString where
+  getField (RecSig bytes) = bytes
 
 instance Read RecSig where
   readPrec = parens $ do
diff --git a/src/Crypto/Secp256k1/Recovery.hs b/src/Crypto/Secp256k1/Recovery.hs
--- a/src/Crypto/Secp256k1/Recovery.hs
+++ b/src/Crypto/Secp256k1/Recovery.hs
@@ -49,15 +49,15 @@
 --
 -- 'RecSig' is built through 'signRecMsg', 'importCompactRecSig' or 'recSig',
 -- which validate it, so a 'RecSig' always has both components in the range 1
--- to n−1 and an id of 0 to 3. Its @get@ field gives the internal
--- representation of libsecp256k1, which is opaque and not portable. 'Show',
+-- to n−1 and an id of 0 to 3. @x.get@ gives the internal representation
+-- of libsecp256k1, which is opaque and not portable. 'Show',
 -- 'Read' and 'Data.String.IsString' use hex of r and s as 32-byte big-endian
 -- numbers followed by the id as one byte. The raw constructor is in
 -- "Crypto.Secp256k1.Internal.Recovery", which has no API stability
 -- guarantee.
 module Crypto.Secp256k1.Recovery
   ( -- * Recoverable signatures
-    RecSig (get),
+    RecSig,
     recSig,
     signRecMsg,
     recover,
diff --git a/test/Crypto/Secp256k1/EllSwiftSpec.hs b/test/Crypto/Secp256k1/EllSwiftSpec.hs
new file mode 100644
--- /dev/null
+++ b/test/Crypto/Secp256k1/EllSwiftSpec.hs
@@ -0,0 +1,178 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE ImportQualifiedPost #-}
+{-# LANGUAGE OverloadedRecordDot #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+-- | ElligatorSwift and the Diffie-Hellman exchange of BIP 324. The module
+-- under test only exists when the @ellswift@ flag of the package is on, so
+-- the whole specification is behind the same flag. This module avoids string
+-- gaps, because CPP would join their lines.
+--
+-- The vectors are the files of BIP 324, copied unchanged into @test/data@
+-- from <https://github.com/bitcoin/bips/tree/master/bip-0324> at commit
+-- 8455d73ddfd763c1057e176d4919b0b061c786f6.
+module Crypto.Secp256k1.EllSwiftSpec (spec) where
+
+import Test.Hspec
+
+#ifdef ELLSWIFT
+
+import Control.Exception (evaluate)
+import Control.Monad (forM_, unless)
+import Crypto.Secp256k1
+import Crypto.Secp256k1.EllSwift
+import Crypto.Secp256k1.Internal.EllSwift (EllSwift (EllSwift))
+import Crypto.Secp256k1.Internal.Util (decodeHex)
+import Data.ByteString (ByteString)
+import Data.ByteString qualified as BS
+import Data.ByteString.Char8 qualified as C
+import Data.Maybe (fromJust, isNothing)
+import Data.String (fromString)
+import Test.QuickCheck
+import Text.Read (readMaybe)
+
+spec :: Spec
+spec = describe "ElligatorSwift" $ do
+  vectorSpec
+  propertySpec
+  valueSpec
+
+-- * The files of BIP 324
+
+-- | The rows of a CSV file of the BIP, each as a list of fields by name. The
+-- files have no quoted fields.
+readCsv :: FilePath -> IO [[(ByteString, ByteString)]]
+readCsv path = do
+  ls <- filter (not . BS.null) . C.lines . C.filter (/= '\r') <$> BS.readFile path
+  case ls of
+    [] -> fail ("empty file " <> path)
+    hdr : rows -> return [zip (C.split ',' hdr) (C.split ',' r) | r <- rows]
+
+field :: ByteString -> [(ByteString, ByteString)] -> ByteString
+field name row = maybe (error ("no field " <> C.unpack name)) id (lookup name row)
+
+hexField :: ByteString -> [(ByteString, ByteString)] -> ByteString
+hexField name = fromJust . decodeHex . field name
+
+-- | The x coordinate of a public key, from its compressed encoding.
+xOf :: PubKey -> ByteString
+xOf = BS.drop 1 . exportPubKey True
+
+vectorSpec :: Spec
+vectorSpec = describe "vectors of BIP 324" $ do
+  it "decodes the 76 encodings of ellswift_decode_test_vectors.csv" $ do
+    rows <- readCsv "test/data/ellswift_decode_test_vectors.csv"
+    length rows `shouldBe` 76
+    forM_ rows $ \row -> do
+      let ell = fromJust (ellSwift (hexField "ellswift" row))
+      (field "comment" row, xOf (ellSwiftDecode ell))
+        `shouldBe` (field "comment" row, hexField "x" row)
+  -- libsecp256k1 does not expose the inverse map xswiftec_inv, so which of
+  -- the eight cases gives which t, and that the empty cases have none,
+  -- cannot be checked through it. Every t that the file gives is checked
+  -- the other way: u and t decode to the point of x.
+  it "decodes u and each of the 98 values of t of xswiftec_inv_test_vectors.csv to x" $ do
+    rows <- readCsv "test/data/xswiftec_inv_test_vectors.csv"
+    length rows `shouldBe` 32
+    let pairs =
+          [ (hexField "u" row <> t, hexField "x" row)
+          | row <- rows,
+            c <- [0 .. 7 :: Int],
+            let name = "case" <> C.pack (show c) <> "_t",
+            not (BS.null (field name row)),
+            let t = hexField name row
+          ]
+    length pairs `shouldBe` 98
+    forM_ pairs $ \(ell, x) -> xOf (ellSwiftDecode (fromJust (ellSwift ell))) `shouldBe` x
+  it "computes the keys and secrets of the 7 rows of packet_encoding_test_vectors.csv" $ do
+    rows <- readCsv "test/data/packet_encoding_test_vectors.csv"
+    length rows `shouldBe` 7
+    forM_ rows $ \row -> do
+      let priv = fromJust (secKey (hexField "in_priv_ours" row))
+          ours = fromJust (ellSwift (hexField "in_ellswift_ours" row))
+          theirs = fromJust (ellSwift (hexField "in_ellswift_theirs" row))
+          initiating = field "in_initiating" row == "1"
+          shared
+            | initiating = ellSwiftXdhBip324 ours theirs priv PartyA
+            | otherwise = ellSwiftXdhBip324 theirs ours priv PartyB
+          point = fromJust (tweakMulPubKey (ellSwiftDecode theirs) (fromJust (tweak priv.get)))
+      xOf (derivePubKey priv) `shouldBe` hexField "mid_x_ours" row
+      xOf (ellSwiftDecode ours) `shouldBe` hexField "mid_x_ours" row
+      xOf (ellSwiftDecode theirs) `shouldBe` hexField "mid_x_theirs" row
+      xOf point `shouldBe` hexField "mid_x_shared" row
+      shared `shouldBe` hexField "mid_shared_secret" row
+
+propertySpec :: Spec
+propertySpec = describe "properties" $ do
+  it "decodes the encoding of a secret key to its public key (key_ellswift of Bitcoin Core)" $
+    property $ \key aux -> do
+      let ell = fromJust (ellSwiftCreate key (Just (bytes32 aux)))
+      ellSwiftDecode ell `shouldBe` derivePubKey key
+  it "decodes the encoding of a secret key made without randomness" $
+    property $ \key ->
+      ellSwiftDecode (fromJust (ellSwiftCreate key Nothing)) `shouldBe` derivePubKey key
+  it "decodes an encoded public key to the same key" $
+    property $ \key rnd -> do
+      let pub = derivePubKey key
+      ellSwiftDecode (fromJust (ellSwiftEncode pub (bytes32 rnd))) `shouldBe` pub
+  it "gives both parties the same secret, and another secret to a third key" $
+    property $ \a b c auxA auxB -> do
+      let ellA = fromJust (ellSwiftCreate a (Just (bytes32 auxA)))
+          ellB = fromJust (ellSwiftCreate b (Just (bytes32 auxB)))
+          secretA = ellSwiftXdhBip324 ellA ellB a PartyA
+          secretB = ellSwiftXdhBip324 ellA ellB b PartyB
+      secretA `shouldBe` secretB
+      BS.length secretA `shouldBe` 32
+      unless (c == a) $ ellSwiftXdhBip324 ellA ellB c PartyA `shouldNotBe` secretA
+  it "gives another secret when the parties swap their roles" $
+    property $ \a b -> do
+      let ellA = fromJust (ellSwiftCreate a Nothing)
+          ellB = fromJust (ellSwiftCreate b Nothing)
+      ellSwiftXdhBip324 ellB ellA a PartyB `shouldNotBe` ellSwiftXdhBip324 ellA ellB a PartyA
+  it "decodes any 64 bytes" $
+    property $ \(Bytes64 bs) ->
+      BS.length (exportPubKey True (ellSwiftDecode (fromJust (ellSwift bs)))) `shouldBe` 33
+
+valueSpec :: Spec
+valueSpec = describe "values" $ do
+  it "refuses an encoding of another length than 64 bytes" $
+    forM_ [0, 1, 32, 63, 65, 128] $ \n ->
+      ellSwift (BS.replicate n 0) `shouldSatisfy` isNothing
+  it "refuses randomness of another length than 32 bytes" $ do
+    let key = fromJust (secKey (BS.replicate 31 0 <> "\1"))
+    forM_ [0, 16, 31, 33] $ \n -> do
+      ellSwiftCreate key (Just (BS.replicate n 0)) `shouldSatisfy` isNothing
+      ellSwiftEncode (derivePubKey key) (BS.replicate n 0) `shouldSatisfy` isNothing
+  it "makes a fresh encoding each time with ellSwiftCreateIO" $ do
+    let key = fromJust (secKey (BS.replicate 31 0 <> "\2"))
+    e1 <- ellSwiftCreateIO key
+    e2 <- ellSwiftCreateIO key
+    e1 `shouldNotBe` e2
+    ellSwiftDecode e1 `shouldBe` ellSwiftDecode e2
+  it "shows, reads and parses hex" $
+    property $ \(Bytes64 bs) -> do
+      let e = EllSwift bs
+      readMaybe (show e) `shouldBe` Just e
+      fromString (read (show e)) `shouldBe` e
+      e.get `shouldBe` bs
+  it "raises an error for a raw encoding of the wrong length" $
+    evaluate (ellSwiftDecode (EllSwift "short")) `shouldThrow` anyErrorCall
+
+-- | 32 bytes from a list of arbitrary bytes, padded or cut.
+bytes32 :: [Word] -> ByteString
+bytes32 ws = BS.pack (take 32 (map fromIntegral ws ++ repeat 0))
+
+-- | 64 arbitrary bytes.
+newtype Bytes64 = Bytes64 ByteString
+  deriving (Show)
+
+instance Arbitrary Bytes64 where
+  arbitrary = Bytes64 . BS.pack <$> vectorOf 64 arbitrary
+
+#else
+
+spec :: Spec
+spec = describe "ElligatorSwift" $
+  it "is not built: the ellswift flag is off" (pendingWith "flag ellswift off")
+
+#endif
diff --git a/test/data/ellswift_decode_test_vectors.csv b/test/data/ellswift_decode_test_vectors.csv
new file mode 100644
--- /dev/null
+++ b/test/data/ellswift_decode_test_vectors.csv
@@ -0,0 +1,77 @@
+ellswift,x,comment
+00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,edd1fd3e327ce90cc7a3542614289aee9682003e9cf7dcc9cf2ca9743be5aa0c,u%p=0;t%p=0;valid_x(x2)
+000000000000000000000000000000000000000000000000000000000000000001d3475bf7655b0fb2d852921035b2ef607f49069b97454e6795251062741771,b5da00b73cd6560520e7c364086e7cd23a34bf60d0e707be9fc34d4cd5fdfa2c,u%p=0;valid_x(x1)
+000000000000000000000000000000000000000000000000000000000000000082277c4a71f9d22e66ece523f8fa08741a7c0912c66a69ce68514bfd3515b49f,f482f2e241753ad0fb89150d8491dc1e34ff0b8acfbb442cfe999e2e5e6fd1d2,u%p=0;valid_x(x3);valid_x(x2);valid_x(x1)
+00000000000000000000000000000000000000000000000000000000000000008421cc930e77c9f514b6915c3dbe2a94c6d8f690b5b739864ba6789fb8a55dd0,9f59c40275f5085a006f05dae77eb98c6fd0db1ab4a72ac47eae90a4fc9e57e0,u%p=0;valid_x(x2)
+0000000000000000000000000000000000000000000000000000000000000000bde70df51939b94c9c24979fa7dd04ebd9b3572da7802290438af2a681895441,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9fffffd6b,u%p=0;(u'^3-t'^2+7)%p=0;valid_x(x3)
+0000000000000000000000000000000000000000000000000000000000000000d19c182d2759cd99824228d94799f8c6557c38a1c0d6779b9d4b729c6f1ccc42,70720db7e238d04121f5b1afd8cc5ad9d18944c6bdc94881f502b7a3af3aecff,u%p=0;valid_x(x3)
+0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,edd1fd3e327ce90cc7a3542614289aee9682003e9cf7dcc9cf2ca9743be5aa0c,u%p=0;t%p=0;valid_x(x2);t>=p
+0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff2664bbd5,50873db31badcc71890e4f67753a65757f97aaa7dd5f1e82b753ace32219064b,u%p=0;valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7028de7d,1eea9cc59cfcf2fa151ac6c274eea4110feb4f7b68c5965732e9992e976ef68e,u%p=0;valid_x(x2);t>=p
+0000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffcbcfb7e7,12303941aedc208880735b1f1795c8e55be520ea93e103357b5d2adb7ed59b8e,u%p=0;valid_x(x1);t>=p
+0000000000000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffff3113ad9,7eed6b70e7b0767c7d7feac04e57aa2a12fef5e0f48f878fcbb88b3b6b5e0783,u%p=0;valid_x(x3);t>=p
+0a2d2ba93507f1df233770c2a797962cc61f6d15da14ecd47d8d27ae1cd5f8530000000000000000000000000000000000000000000000000000000000000000,532167c11200b08c0e84a354e74dcc40f8b25f4fe686e30869526366278a0688,t%p=0;(u'^3+t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1)
+0a2d2ba93507f1df233770c2a797962cc61f6d15da14ecd47d8d27ae1cd5f853fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,532167c11200b08c0e84a354e74dcc40f8b25f4fe686e30869526366278a0688,t%p=0;(u'^3+t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+0ffde9ca81d751e9cdaffc1a50779245320b28996dbaf32f822f20117c22fbd6c74d99efceaa550f1ad1c0f43f46e7ff1ee3bd0162b7bf55f2965da9c3450646,74e880b3ffd18fe3cddf7902522551ddf97fa4a35a3cfda8197f947081a57b8f,valid_x(x3)
+0ffde9ca81d751e9cdaffc1a50779245320b28996dbaf32f822f20117c22fbd6ffffffffffffffffffffffffffffffffffffffffffffffffffffffff156ca896,377b643fce2271f64e5c8101566107c1be4980745091783804f654781ac9217c,valid_x(x2);t>=p
+123658444f32be8f02ea2034afa7ef4bbe8adc918ceb49b12773b625f490b368ffffffffffffffffffffffffffffffffffffffffffffffffffffffff8dc5fe11,ed16d65cf3a9538fcb2c139f1ecbc143ee14827120cbc2659e667256800b8142,(u'^3-t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+146f92464d15d36e35382bd3ca5b0f976c95cb08acdcf2d5b3570617990839d7ffffffffffffffffffffffffffffffffffffffffffffffffffffffff3145e93b,0d5cd840427f941f65193079ab8e2e83024ef2ee7ca558d88879ffd879fb6657,(u'^3+t'^2+7)%p=0;valid_x(x3);t>=p
+15fdf5cf09c90759add2272d574d2bb5fe1429f9f3c14c65e3194bf61b82aa73ffffffffffffffffffffffffffffffffffffffffffffffffffffffff04cfd906,16d0e43946aec93f62d57eb8cde68951af136cf4b307938dd1447411e07bffe1,(u'^3+t'^2+7)%p=0;valid_x(x2);t>=p
+1f67edf779a8a649d6def60035f2fa22d022dd359079a1a144073d84f19b92d50000000000000000000000000000000000000000000000000000000000000000,025661f9aba9d15c3118456bbe980e3e1b8ba2e047c737a4eb48a040bb566f6c,t%p=0;valid_x(x2)
+1f67edf779a8a649d6def60035f2fa22d022dd359079a1a144073d84f19b92d5fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,025661f9aba9d15c3118456bbe980e3e1b8ba2e047c737a4eb48a040bb566f6c,t%p=0;valid_x(x2);t>=p
+1fe1e5ef3fceb5c135ab7741333ce5a6e80d68167653f6b2b24bcbcfaaaff507fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,98bec3b2a351fa96cfd191c1778351931b9e9ba9ad1149f6d9eadca80981b801,t%p=0;(u'^3-t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+4056a34a210eec7892e8820675c860099f857b26aad85470ee6d3cf1304a9dcf375e70374271f20b13c9986ed7d3c17799698cfc435dbed3a9f34b38c823c2b4,868aac2003b29dbcad1a3e803855e078a89d16543ac64392d122417298cec76e,(u'^3-t'^2+7)%p=0;valid_x(x3)
+4197ec3723c654cfdd32ab075506648b2ff5070362d01a4fff14b336b78f963fffffffffffffffffffffffffffffffffffffffffffffffffffffffffb3ab1e95,ba5a6314502a8952b8f456e085928105f665377a8ce27726a5b0eb7ec1ac0286,(u'^3+t'^2+7)%p=0;valid_x(x1);t>=p
+47eb3e208fedcdf8234c9421e9cd9a7ae873bfbdbc393723d1ba1e1e6a8e6b24ffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cd12cb1,d192d52007e541c9807006ed0468df77fd214af0a795fe119359666fdcf08f7c,(u'^3+t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+5eb9696a2336fe2c3c666b02c755db4c0cfd62825c7b589a7b7bb442e141c1d693413f0052d49e64abec6d5831d66c43612830a17df1fe4383db896468100221,ef6e1da6d6c7627e80f7a7234cb08a022c1ee1cf29e4d0f9642ae924cef9eb38,(u'^3+t'^2+7)%p=0;valid_x(x1)
+7bf96b7b6da15d3476a2b195934b690a3a3de3e8ab8474856863b0de3af90b0e0000000000000000000000000000000000000000000000000000000000000000,50851dfc9f418c314a437295b24feeea27af3d0cd2308348fda6e21c463e46ff,t%p=0;valid_x(x1)
+7bf96b7b6da15d3476a2b195934b690a3a3de3e8ab8474856863b0de3af90b0efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,50851dfc9f418c314a437295b24feeea27af3d0cd2308348fda6e21c463e46ff,t%p=0;valid_x(x1);t>=p
+851b1ca94549371c4f1f7187321d39bf51c6b7fb61f7cbf027c9da62021b7a65fc54c96837fb22b362eda63ec52ec83d81bedd160c11b22d965d9f4a6d64d251,3e731051e12d33237eb324f2aa5b16bb868eb49a1aa1fadc19b6e8761b5a5f7b,(u'^3+t'^2+7)%p=0;valid_x(x2)
+943c2f775108b737fe65a9531e19f2fc2a197f5603e3a2881d1d83e4008f91250000000000000000000000000000000000000000000000000000000000000000,311c61f0ab2f32b7b1f0223fa72f0a78752b8146e46107f8876dd9c4f92b2942,t%p=0;valid_x(x3);valid_x(x2);valid_x(x1)
+943c2f775108b737fe65a9531e19f2fc2a197f5603e3a2881d1d83e4008f9125fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,311c61f0ab2f32b7b1f0223fa72f0a78752b8146e46107f8876dd9c4f92b2942,t%p=0;valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+a0f18492183e61e8063e573606591421b06bc3513631578a73a39c1c3306239f2f32904f0d2a33ecca8a5451705bb537d3bf44e071226025cdbfd249fe0f7ad6,97a09cf1a2eae7c494df3c6f8a9445bfb8c09d60832f9b0b9d5eabe25fbd14b9,valid_x(x1)
+a1ed0a0bd79d8a23cfe4ec5fef5ba5cccfd844e4ff5cb4b0f2e71627341f1c5b17c499249e0ac08d5d11ea1c2c8ca7001616559a7994eadec9ca10fb4b8516dc,65a89640744192cdac64b2d21ddf989cdac7500725b645bef8e2200ae39691f2,valid_x(x2)
+ba94594a432721aa3580b84c161d0d134bc354b690404d7cd4ec57c16d3fbe98ffffffffffffffffffffffffffffffffffffffffffffffffffffffffea507dd7,5e0d76564aae92cb347e01a62afd389a9aa401c76c8dd227543dc9cd0efe685a,valid_x(x1);t>=p
+bcaf7219f2f6fbf55fe5e062dce0e48c18f68103f10b8198e974c184750e1be3932016cbf69c4471bd1f656c6a107f1973de4af7086db897277060e25677f19a,2d97f96cac882dfe73dc44db6ce0f1d31d6241358dd5d74eb3d3b50003d24c2b,valid_x(x3);valid_x(x2);valid_x(x1)
+bcaf7219f2f6fbf55fe5e062dce0e48c18f68103f10b8198e974c184750e1be3ffffffffffffffffffffffffffffffffffffffffffffffffffffffff6507d09a,e7008afe6e8cbd5055df120bd748757c686dadb41cce75e4addcc5e02ec02b44,valid_x(x3);valid_x(x2);valid_x(x1);t>=p
+c5981bae27fd84401c72a155e5707fbb811b2b620645d1028ea270cbe0ee225d4b62aa4dca6506c1acdbecc0552569b4b21436a5692e25d90d3bc2eb7ce24078,948b40e7181713bc018ec1702d3d054d15746c59a7020730dd13ecf985a010d7,(u'^3+t'^2+7)%p=0;valid_x(x3)
+c894ce48bfec433014b931a6ad4226d7dbd8eaa7b6e3faa8d0ef94052bcf8cff336eeb3919e2b4efb746c7f71bbca7e9383230fbbc48ffafe77e8bcc69542471,f1c91acdc2525330f9b53158434a4d43a1c547cff29f15506f5da4eb4fe8fa5a,(u'^3-t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1)
+cbb0deab125754f1fdb2038b0434ed9cb3fb53ab735391129994a535d925f6730000000000000000000000000000000000000000000000000000000000000000,872d81ed8831d9998b67cb7105243edbf86c10edfebb786c110b02d07b2e67cd,t%p=0;(u'^3-t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1)
+d917b786dac35670c330c9c5ae5971dfb495c8ae523ed97ee2420117b171f41effffffffffffffffffffffffffffffffffffffffffffffffffffffff2001f6f6,e45b71e110b831f2bdad8651994526e58393fde4328b1ec04d59897142584691,valid_x(x3);t>=p
+e28bd8f5929b467eb70e04332374ffb7e7180218ad16eaa46b7161aa679eb4260000000000000000000000000000000000000000000000000000000000000000,66b8c980a75c72e598d383a35a62879f844242ad1e73ff12edaa59f4e58632b5,t%p=0;valid_x(x3)
+e28bd8f5929b467eb70e04332374ffb7e7180218ad16eaa46b7161aa679eb426fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,66b8c980a75c72e598d383a35a62879f844242ad1e73ff12edaa59f4e58632b5,t%p=0;valid_x(x3);t>=p
+e7ee5814c1706bf8a89396a9b032bc014c2cac9c121127dbf6c99278f8bb53d1dfd04dbcda8e352466b6fcd5f2dea3e17d5e133115886eda20db8a12b54de71b,e842c6e3529b234270a5e97744edc34a04d7ba94e44b6d2523c9cf0195730a50,(u'^3+t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1)
+f292e46825f9225ad23dc057c1d91c4f57fcb1386f29ef10481cb1d22518593fffffffffffffffffffffffffffffffffffffffffffffffffffffffff7011c989,3cea2c53b8b0170166ac7da67194694adacc84d56389225e330134dab85a4d55,(u'^3-t'^2+7)%p=0;valid_x(x3);t>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000000000000000000000000000000000000000000000000000000000000000,edd1fd3e327ce90cc7a3542614289aee9682003e9cf7dcc9cf2ca9743be5aa0c,u%p=0;t%p=0;valid_x(x2);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f01d3475bf7655b0fb2d852921035b2ef607f49069b97454e6795251062741771,b5da00b73cd6560520e7c364086e7cd23a34bf60d0e707be9fc34d4cd5fdfa2c,u%p=0;valid_x(x1);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f4218f20ae6c646b363db68605822fb14264ca8d2587fdd6fbc750d587e76a7ee,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9fffffd6b,u%p=0;(u'^3-t'^2+7)%p=0;valid_x(x3);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f82277c4a71f9d22e66ece523f8fa08741a7c0912c66a69ce68514bfd3515b49f,f482f2e241753ad0fb89150d8491dc1e34ff0b8acfbb442cfe999e2e5e6fd1d2,u%p=0;valid_x(x3);valid_x(x2);valid_x(x1);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8421cc930e77c9f514b6915c3dbe2a94c6d8f690b5b739864ba6789fb8a55dd0,9f59c40275f5085a006f05dae77eb98c6fd0db1ab4a72ac47eae90a4fc9e57e0,u%p=0;valid_x(x2);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fd19c182d2759cd99824228d94799f8c6557c38a1c0d6779b9d4b729c6f1ccc42,70720db7e238d04121f5b1afd8cc5ad9d18944c6bdc94881f502b7a3af3aecff,u%p=0;valid_x(x3);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,edd1fd3e327ce90cc7a3542614289aee9682003e9cf7dcc9cf2ca9743be5aa0c,u%p=0;t%p=0;valid_x(x2);u>=p;t>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fffffffffffffffffffffffffffffffffffffffffffffffffffffffff2664bbd5,50873db31badcc71890e4f67753a65757f97aaa7dd5f1e82b753ace32219064b,u%p=0;valid_x(x3);valid_x(x2);valid_x(x1);u>=p;t>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fffffffffffffffffffffffffffffffffffffffffffffffffffffffff7028de7d,1eea9cc59cfcf2fa151ac6c274eea4110feb4f7b68c5965732e9992e976ef68e,u%p=0;valid_x(x2);u>=p;t>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fffffffffffffffffffffffffffffffffffffffffffffffffffffffffcbcfb7e7,12303941aedc208880735b1f1795c8e55be520ea93e103357b5d2adb7ed59b8e,u%p=0;valid_x(x1);u>=p;t>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3113ad9,7eed6b70e7b0767c7d7feac04e57aa2a12fef5e0f48f878fcbb88b3b6b5e0783,u%p=0;valid_x(x3);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff13cea4a70000000000000000000000000000000000000000000000000000000000000000,649984435b62b4a25d40c6133e8d9ab8c53d4b059ee8a154a3be0fcf4e892edb,t%p=0;valid_x(x1);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff13cea4a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,649984435b62b4a25d40c6133e8d9ab8c53d4b059ee8a154a3be0fcf4e892edb,t%p=0;valid_x(x1);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff15028c590063f64d5a7f1c14915cd61eac886ab295bebd91992504cf77edb028bdd6267f,3fde5713f8282eead7d39d4201f44a7c85a5ac8a0681f35e54085c6b69543374,(u'^3+t'^2+7)%p=0;valid_x(x2);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff2715de860000000000000000000000000000000000000000000000000000000000000000,3524f77fa3a6eb4389c3cb5d27f1f91462086429cd6c0cb0df43ea8f1e7b3fb4,t%p=0;valid_x(x3);valid_x(x2);valid_x(x1);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff2715de86fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,3524f77fa3a6eb4389c3cb5d27f1f91462086429cd6c0cb0df43ea8f1e7b3fb4,t%p=0;valid_x(x3);valid_x(x2);valid_x(x1);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff2c2c5709e7156c417717f2feab147141ec3da19fb759575cc6e37b2ea5ac9309f26f0f66,d2469ab3e04acbb21c65a1809f39caafe7a77c13d10f9dd38f391c01dc499c52,(u'^3-t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff3a08cc1efffffffffffffffffffffffffffffffffffffffffffffffffffffffff760e9f0,38e2a5ce6a93e795e16d2c398bc99f0369202ce21e8f09d56777b40fc512bccc,valid_x(x3);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff3e91257d932016cbf69c4471bd1f656c6a107f1973de4af7086db897277060e25677f19a,864b3dc902c376709c10a93ad4bbe29fce0012f3dc8672c6286bba28d7d6d6fc,valid_x(x3);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff795d6c1c322cadf599dbb86481522b3cc55f15a67932db2afa0111d9ed6981bcd124bf44,766dfe4a700d9bee288b903ad58870e3d4fe2f0ef780bcac5c823f320d9a9bef,(u'^3+t'^2+7)%p=0;valid_x(x1);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff8e426f0392389078c12b1a89e9542f0593bc96b6bfde8224f8654ef5d5cda935a3582194,faec7bc1987b63233fbc5f956edbf37d54404e7461c58ab8631bc68e451a0478,valid_x(x1);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff91192139ffffffffffffffffffffffffffffffffffffffffffffffffffffffff45f0f1eb,ec29a50bae138dbf7d8e24825006bb5fc1a2cc1243ba335bc6116fb9e498ec1f,valid_x(x2);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff98eb9ab76e84499c483b3bf06214abfe065dddf43b8601de596d63b9e45a166a580541fe,1e0ff2dee9b09b136292a9e910f0d6ac3e552a644bba39e64e9dd3e3bbd3d4d4,(u'^3-t'^2+7)%p=0;valid_x(x3);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9b77b7f2c74d99efceaa550f1ad1c0f43f46e7ff1ee3bd0162b7bf55f2965da9c3450646,8b7dd5c3edba9ee97b70eff438f22dca9849c8254a2f3345a0a572ffeaae0928,valid_x(x2);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffff9b77b7f2ffffffffffffffffffffffffffffffffffffffffffffffffffffffff156ca896,0881950c8f51d6b9a6387465d5f12609ef1bb25412a08a74cb2dfb200c74bfbf,valid_x(x3);valid_x(x2);valid_x(x1);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffa2f5cd838816c16c4fe8a1661d606fdb13cf9af04b979a2e159a09409ebc8645d58fde02,2f083207b9fd9b550063c31cd62b8746bd543bdc5bbf10e3a35563e927f440c8,(u'^3+t'^2+7)%p=0;valid_x(x3);valid_x(x2);valid_x(x1);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffb13f75c00000000000000000000000000000000000000000000000000000000000000000,4f51e0be078e0cddab2742156adba7e7a148e73157072fd618cd60942b146bd0,t%p=0;valid_x(x3);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffb13f75c0fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,4f51e0be078e0cddab2742156adba7e7a148e73157072fd618cd60942b146bd0,t%p=0;valid_x(x3);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7bc1f8d0000000000000000000000000000000000000000000000000000000000000000,16c2ccb54352ff4bd794f6efd613c72197ab7082da5b563bdf9cb3edaafe74c2,t%p=0;valid_x(x2);u>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7bc1f8dfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f,16c2ccb54352ff4bd794f6efd613c72197ab7082da5b563bdf9cb3edaafe74c2,t%p=0;valid_x(x2);u>=p;t>=p
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffef64d162750546ce42b0431361e52d4f5242d8f24f33e6b1f99b591647cbc808f462af51,d41244d11ca4f65240687759f95ca9efbab767ededb38fd18c36e18cd3b6f6a9,(u'^3+t'^2+7)%p=0;valid_x(x3);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0e5be52372dd6e894b2a326fc3605a6e8f3c69c710bf27d630dfe2004988b78eb6eab36,64bf84dd5e03670fdb24c0f5d3c2c365736f51db6c92d95010716ad2d36134c8,valid_x(x3);valid_x(x2);valid_x(x1);u>=p
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffffefbb982fffffffffffffffffffffffffffffffffffffffffffffffffffffffff6d6db1f,1c92ccdfcf4ac550c28db57cff0c8515cb26936c786584a70114008d6c33a34b,valid_x(x1);u>=p;t>=p
diff --git a/test/data/packet_encoding_test_vectors.csv b/test/data/packet_encoding_test_vectors.csv
new file mode 100644
--- /dev/null
+++ b/test/data/packet_encoding_test_vectors.csv
@@ -0,0 +1,8 @@
+in_idx,in_priv_ours,in_ellswift_ours,in_ellswift_theirs,in_initiating,in_contents,in_multiply,in_aad,in_ignore,mid_x_ours,mid_x_theirs,mid_x_shared,mid_shared_secret,mid_initiator_l,mid_initiator_p,mid_responder_l,mid_responder_p,mid_send_garbage_terminator,mid_recv_garbage_terminator,out_session_id,out_ciphertext,out_ciphertext_endswith
+1,61062ea5071d800bbfd59e2e8b53d47d194b095ae5a4df04936b49772ef0d4d7,ec0adff257bbfe500c188c80b4fdd640f6b45a482bbc15fc7cef5931deff0aa186f6eb9bba7b85dc4dcc28b28722de1e3d9108b985e2967045668f66098e475b,a4a94dfce69b4a2a0a099313d10f9f7e7d649d60501c9e1d274c300e0d89aafaffffffffffffffffffffffffffffffffffffffffffffffffffffffff8faf88d5,1,8e,1,,0,19e965bc20fc40614e33f2f82d4eeff81b5e7516b12a5c6c0d6053527eba0923,0c71defa3fafd74cb835102acd81490963f6b72d889495e06561375bd65f6ffc,4eb2bf85bd00939468ea2abb25b63bc642e3d1eb8b967fb90caa2d89e716050e,c6992a117f5edbea70c3f511d32d26b9798be4b81a62eaee1a5acaa8459a3592,9a6478b5fbab1f4dd2f78994b774c03211c78312786e602da75a0d1767fb55cf,7d0c7820ba6a4d29ce40baf2caa6035e04f1e1cefd59f3e7e59e9e5af84f1f51,17bc726421e4054ac6a1d54915085aaa766f4d3cf67bbd168e6080eac289d15e,9f0fc1c0e85fd9a8eee07e6fc41dba2ff54c7729068a239ac97c37c524cca1c0,faef555dfcdb936425d84aba524758f3,02cb8ff24307a6e27de3b4e7ea3fa65b,ce72dffb015da62b0d0f5474cab8bc72605225b0cee3f62312ec680ec5f41ba5,7530d2a18720162ac09c25329a60d75adf36eda3c3,
+999,6f312890ec83bbb26798abaadd574684a53e74ccef7953b790fcc29409080246,a8785af31c029efc82fa9fc677d7118031358d7c6a25b5779a9b900e5ccd94aac97eb36a3c5dbcdb2ca5843cc4c2fe0aaa46d10eb3d233a81c3dde476da00eef,fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f0000000000000000000000000000000000000000000000000000000000000000,0,3eb1d4e98035cfd8eeb29bac969ed3824a,1,,0,d4b65faa965b31fe2d9faaeb806c6449a50fe3679555c3518f7a0885f572457f,edd1fd3e327ce90cc7a3542614289aee9682003e9cf7dcc9cf2ca9743be5aa0c,13c1bf6a3ca37da9ffc7f45ec1810fa935c45454c03dc0144c1a9755bb52f81f,a6f79eb08243b6f65dbe42bfe4a6cf3f131d6963fa5d06c770a18f7b9c489b78,efc938c88c925459a9c837238716cfadfb1c3016f60d12923933710b5fcc9b55,91702f3cbd33b3c4a0b29b40548aea1ab01e43582db194afee70637d247aa036,7f457572e4260c611a6858acc8f325d87a3c8af8a59ce1da26ef6041f35715e8,1fe4d56334f5b0a5bd3c71ce4e338f40fc7e194925daa7ee6ce98aecf1766d7c,44737108aec5f8b6c1c277b31bbce9c1,ca29b3a35237f8212bd13ed187a1da2e,b0490e26111cb2d55bbff2ace00f7f644f64006539abb4e7513f05107bb10608,d78adbcba0eebfb15cfbd8142c84dc729d233d0dc11b1d851e46a114122b8d5b96b7d59317,
+0,846a784f1a03dea59cc679754a60a7145542fa130e3efbd815c81e909ce32933,480eacf1536b52257bf8ce78d8f4ce09395d744767c6c129e7838947ee625af3245592c111275e877d5baae22584cb5f1153e67c16bcd7da767726cd0d0c846a,ffffffffffffffffffffffffffffffffffffffffffffffffffffffff22d5e441524d571a52b3def126189d3f416890a99d4da6ede2b0cde1760ce2c3f98457ae,1,054290a6c6ba8d80478172e89d32bf690913ae9835de6dcf206ff1f4d652286fe0ddf74deba41d55de3edc77c42a32af79bbea2c00bae7492264c60866ae5a,1,84932a55aac22b51e7b128d31d9f0550da28e6a3f394224707d878603386b2f9d0c6bcd8046679bfed7b68c517e7431e75d9dd34605727d2ef1c2babbf680ecc8d68d2c4886e9953a4034abde6da4189cd47c6bb3192242cf714d502ca6103ee84e08bc2ca4fd370d5ad4e7d06c7fbf496c6c7cc7eb19c40c61fb33df2a9ba48497a96c98d7b10c1f91098a6b7b16b4bab9687f27585ade1491ae0dba6a79e1e2d85dd9d9d45c5135ca5fca3f0f99a60ea39edbc9efc7923111c937913f225d67788d5f7e8852b697e26b92ec7bfcaa334a1665511c2b4c0a42d06f7ab98a9719516c8fd17f73804555ee84ab3b7d1762f6096b778d3cb9c799cbd49a9e4a325197b4e6cc4a5c4651f8b41ff88a92ec428354531f970263b467c77ed11312e2617d0d53fe9a8707f51f9f57a77bfb49afe3d89d85ec05ee17b9186f360c94ab8bb2926b65ca99dae1d6ee1af96cad09de70b6767e949023e4b380e66669914a741ed0fa420a48dbc7bfae5ef2019af36d1022283dd90655f25eec7151d471265d22a6d3f91dc700ba749bb67c0fe4bc0888593fbaf59d3c6fff1bf756a125910a63b9682b597c20f560ecb99c11a92c8c8c3f7fbfaa103146083a0ccaecf7a5f5e735a784a8820155914a289d57d8141870ffcaf588882332e0bcd8779efa931aa108dab6c3cce76691e345df4a91a03b71074d66333fd3591bff071ea099360f787bbe43b7b3dff2a59c41c7642eb79870222ad1c6f2e5a191ed5acea51134679587c9cf71c7d8ee290be6bf465c4ee47897a125708704ad610d8d00252d01959209d7cd04d5ecbbb1419a7e84037a55fefa13dee464b48a35c96bcb9a53e7ed461c3a1607ee00c3c302fd47cd73fda7493e947c9834a92d63dcfbd65aa7c38c3e3a2748bb5d9a58e7495d243d6b741078c8f7ee9c8813e473a323375702702b0afae1550c8341eedf5247627343a95240cb02e3e17d5dca16f8d8d3b2228e19c06399f8ec5c5e9dbe4caef6a0ea3ffb1d3c7eac03ae030e791fa12e537c80d56b55b764cadf27a8701052df1282ba8b5e3eb62b5dc7973ac40160e00722fa958d95102fc25c549d8c0e84bed95b7acb61ba65700c4de4feebf78d13b9682c52e937d23026fb4c6193e6644e2d3c99f91f4f39a8b9fc6d013f89c3793ef703987954dc0412b550652c01d922f525704d32d70d6d4079bc3551b563fb29577b3aecdc9505011701dddfd94830431e7a4918927ee44fb3831ce8c4513839e2deea1287f3fa1ab9b61a256c09637dbc7b4f0f8fbb783840f9c24526da883b0df0c473cf231656bd7bc1aaba7f321fec0971c8c2c3444bff2f55e1df7fea66ec3e440a612db9aa87bb505163a59e06b96d46f50d8120b92814ac5ab146bc78dbbf91065af26107815678ce6e33812e6bf3285d4ef3b7b04b076f21e7820dcbfdb4ad5218cf4ff6a65812d8fcb98ecc1e95e2fa58e3efe4ce26cd0bd400d6036ab2ad4f6c713082b5e3f1e04eb9e3b6c8f63f57953894b9e220e0130308e1fd91f72d398c1e7962ca2c31be83f31d6157633581a0a6910496de8d55d3d07090b6aa087159e388b7e7dec60f5d8a60d93ca2ae91296bd484d916bfaaa17c8f45ea4b1a91b37c82821199a2b7596672c37156d8701e7352aa48671d3b1bbbd2bd5f0a2268894a25b0cb2514af39c8743f8cce8ab4b523053739fd8a522222a09acf51ac704489cf17e4b7125455cb8f125b4d31af1eba1f8cf7f81a5a100a141a7ee72e8083e065616649c241f233645c5fc865d17f0285f5c52d9f45312c979bfb3ce5f2a1b951deddf280ffb3f370410cffd1583bfa90077835aa201a0712d1dcd1293ee177738b14e6b5e2a496d05220c3253bb6578d6aff774be91946a614dd7e879fb3dcf7451e0b9adb6a8c44f53c2c464bcc0019e9fad89cac7791a0a3f2974f759a9856351d4d2d7c5612c17cfc50f8479945df57716767b120a590f4bf656f4645029a525694d8a238446c5f5c2c1c995c09c1405b8b1eb9e0352ffdf766cc964f8dcf9f8f043dfab6d102cf4b298021abd78f1d9025fa1f8e1d710b38d9d1652f2d88d1305874ec41609b6617b65c5adb19b6295dc5c5da5fdf69f28144ea12f17c3c6fcce6b9b5157b3dfc969d6725fa5b098a4d9b1d31547ed4c9187452d281d0a5d456008caf1aa251fac8f950ca561982dc2dc908d3691ee3b6ad3ae3d22d002577264ca8e49c523bd51c4846be0d198ad9407bf6f7b82c79893eb2c05fe9981f687a97a4f01fe45ff8c8b7ecc551135cd960a0d6001ad35020be07ffb53cb9e731522ca8ae9364628914b9b8e8cc2f37f03393263603cc2b45295767eb0aac29b0930390eb89587ab2779d2e3decb8042acece725ba42eda650863f418f8d0d50d104e44fbbe5aa7389a4a144a8cecf00f45fb14c39112f9bfb56c0acbd44fa3ff261f5ce4acaa5134c2c1d0cca447040820c81ab1bcdc16aa075b7c68b10d06bbb7ce08b5b805e0238f24402cf24a4b4e00701935a0c68add3de090903f9b85b153cb179a582f57113bfc21c2093803f0cfa4d9d4672c2b05a24f7e4c34a8e9101b70303a7378b9c50b6cddd46814ef7fd73ef6923feceab8fc5aa8b0d185f2e83c7a99dcb1077c0ab5c1f5d5f01ba2f0420443f75c4417db9ebf1665efbb33dca224989920a64b44dc26f682cc77b4632c8454d49135e52503da855bc0f6ff8edc1145451a9772c06891f41064036b66c3119a0fc6e80dffeb65dc456108b7ca0296f4175fff3ed2b0f842cd46bd7e86f4c62dfaf1ddbf836263c00b34803de164983d0811cebfac86e7720c726d3048934c36c23189b02386a722ca9f0fe00233ab50db928d3bccea355cc681144b8b7edcaae4884d5a8f04425c0890ae2c74326e138066d8c05f4c82b29df99b034ea727afde590a1f2177ace3af99cfb1729d6539ce7f7f7314b046aab74497e63dd399e1f7d5f16517c23bd830d1fdee810f3c3b77573dd69c4b97d80d71fb5a632e00acdfa4f8e829faf3580d6a72c40b28a82172f8dcd4627663ebf6069736f21735fd84a226f427cd06bb055f94e7c92f31c48075a2955d82a5b9d2d0198ce0d4e131a112570a8ee40fb80462a81436a58e7db4e34b6e2c422e82f934ecda9949893da5730fc5c23c7c920f363f85ab28cc6a4206713c3152669b47efa8238fa826735f17b4e78750276162024ec85458cd5808e06f40dd9fd43775a456a3ff6cae90550d76d8b2899e0762ad9a371482b3e38083b1274708301d6346c22fea9bb4b73db490ff3ab05b2f7f9e187adef139a7794454b7300b8cc64d3ad76c0e4bc54e08833a4419251550655380d675bc91855aeb82585220bb97f03e976579c08f321b5f8f70988d3061f41465517d53ac571dbf1b24b94443d2e9a8e8a79b392b3d6a4ecdd7f626925c365ef6221305105ce9b5f5b6ecc5bed3d702bd4b7f5008aa8eb8c7aa3ade8ecf6251516fbefeea4e1082aa0e1848eddb31ffe44b04792d296054402826e4bd054e671f223e5557e4c94f89ca01c25c44f1a2ff2c05a70b43408250705e1b858bf0670679fdcd379203e36be3500dd981b1a6422c3cf15224f7fefdef0a5f225c5a09d15767598ecd9e262460bb33a4b5d09a64591efabc57c923d3be406979032ae0bc0997b65336a06dd75b253332ad6a8b63ef043f780a1b3fb6d0b6cad98b1ef4a02535eb39e14a866cfc5fc3a9c5deb2261300d71280ebe66a0776a151469551c3c5fa308757f956655278ec6330ae9e3625468c5f87e02cd9a6489910d4143c1f4ee13aa21a6859d907b788e28572fecee273d44e4a900fa0aa668dd861a60fb6b6b12c2c5ef3c8df1bd7ef5d4b0d1cdb8c15fffbb365b9784bd94abd001c6966216b9b67554ad7cb7f958b70092514f7800fc40244003e0fd1133a9b850fb17f4fcafde07fc87b07fb510670654a5d2d6fc9876ac74728ea41593beef003d6858786a52d3a40af7529596767c17000bfaf8dc52e871359f4ad8bf6e7b2853e5229bdf39657e213580294a5317c5df172865e1e17fe37093b585e04613f5f078f761b2b1752eb32983afda24b523af8851df9a02b37e77f543f18888a782a994a50563334282bf9cdfccc183fdf4fcd75ad86ee0d94f91ee2300a5befbccd14e03a77fc031a8cfe4f01e4c5290f5ac1da0d58ea054bd4837cfd93e5e34fc0eb16e48044ba76131f228d16cde9b0bb978ca7cdcd10653c358bdb26fdb723a530232c32ae0a4cecc06082f46e1c1d596bfe60621ad1e354e01e07b040cc7347c016653f44d926d13ca74e6cbc9d4ab4c99f4491c95c76fff5076b3936eb9d0a286b97c035ca88a3c6309f5febfd4cdaac869e4f58ed409b1e9eb4192fb2f9c2f12176d460fd98286c9d6df84598f260119fd29c63f800c07d8df83d5cc95f8c2fea2812e7890e8a0718bb1e031ecbebc0436dcf3e3b9a58bcc06b4c17f711f80fe1dffc3326a6eb6e00283055c6dabe20d311bfd5019591b7954f8163c9afad9ef8390a38f3582e0a79cdf0353de8eeb6b5f9f27b16ffdef7dd62869b4840ee226ccdce95e02c4545eb981b60571cd83f03dc5eaf8c97a0829a4318a9b3dc06c0e003db700b2260ff1fa8fee66890e637b109abb03ec901b05ca599775f48af50154c0e67d82bf0f558d7d3e0778dc38bea1eb5f74dc8d7f90abdf5511a424be66bf8b6a3cacb477d2e7ef4db68d2eba4d5289122d851f9501ba7e9c4957d8eba3be3fc8e785c4265a1d65c46f2809b70846c693864b169c9dcb78be26ea14b8613f145b01887222979a9e67aee5f800caa6f5c4229bdeefc901232ace6143c9865e4d9c07f51aa200afaf7e48a7d1d8faf366023beab12906ffcb3eaf72c0eb68075e4daf3c080e0c31911befc16f0cc4a09908bb7c1e26abab38bd7b788e1a09c0edf1a35a38d2ff1d3ed47fcdaae2f0934224694f5b56705b9409b6d3d64f3833b686f7576ec64bbdd6ff174e56c2d1edac0011f904681a73face26573fbba4e34652f7ae84acfb2fa5a5b3046f98178cd0831df7477de70e06a4c00e305f31aafc026ef064dd68fd3e4252b1b91d617b26c6d09b6891a00df68f105b5962e7f9d82da101dd595d286da721443b72b2aba2377f6e7772e33b3a5e3753da9c2578c5d1daab80187f55518c72a64ee150a7cb5649823c08c9f62cd7d020b45ec2cba8310db1a7785a46ab24785b4d54ff1660b5ca78e05a9a55edba9c60bf044737bc468101c4e8bd1480d749be5024adefca1d998abe33eaeb6b11fbb39da5d905fdd3f611b2e51517ccee4b8af72c2d948573505590d61a6783ab7278fc43fe55b1fcc0e7216444d3c8039bb8145ef1ce01c50e95a3f3feab0aee883fdb94cc13ee4d21c542aa795e18932228981690f4d4c57ca4db6eb5c092e29d8a05139d509a8aeb48baa1eb97a76e597a32b280b5e9d6c36859064c98ff96ef5126130264fa8d2f49213870d9fb036cff95da51f270311d9976208554e48ffd486470d0ecdb4e619ccbd8226147204baf8e235f54d8b1cba8fa34a9a4d055de515cdf180d2bb6739a175183c472e30b5c914d09eeb1b7dafd6872b38b48c6afc146101200e6e6a44fe5684e220adc11f5c403ddb15df8051e6bdef09117a3a5349938513776286473a3cf1d2788bb875052a2e6459fa7926da33380149c7f98d7700528a60c954e6f5ecb65842fde69d614be69eaa2040a4819ae6e756accf936e14c1e894489744a79c1f2c1eb295d13e2d767c09964b61f9cfe497649f712,0,014e5bdbb1d7eb34a88a016ab3dd45e343dc703fafa8266907ab67a76c5eb2d6,568146140669e69646a6ffeb3793e8010e2732209b4c34ec13e209a070109183,10578110283044630bc13a9f12b00eb0af7cba9f53506add2b57ae07b3987ced,e500c670f1b32f60e05009bddcdbfa7153afb19c20479583a54b43d85b3433a8,67b155367abf65d45a60412e16bd5ef5e862aa0a4a7a56366cfcc602072176b8,93f5b4c59038c16c3f09793976c75e522bf994635e3f1ef9f04e628281e0d5f7,08fe46857ab4e62d7463c00ac510e041d28dbfc21853e8f4db971890c7330098,2271d5f5351a91ca768a83c5aa7f45fb2b2742e89351d93a680f51a030f9255c,3ba1f51de6272aa28fd21059b91d3893,faf3b317340de00e29f2181db270ff81,d083d09c1bdf71795b39a9534601cf7c7a7e767e578c44a17dfaf43a3c18f98c,6aa28bc4b6719eca144ac33a3f17859317d5450e4978db9365ce61e7085a617dd386ec18eb436c9056aa1d2d4736c9bffd25803d967fcae916ce1647ccae3d5258b17dfa1cdc7eb99581c48ff2898ef92d3aa1,
+223,c0f15820459f64d98e5c48681d13340572c574533dd9f7161b85fcc8224fdf30,682871104d694baca8b9c7990ae6288f49e1ff4feb21dd5cffad67db7752fdfb6c3608d6996c54be04b35feef037da09ee4d9dca2363b343bc2d4f6d0ea609da,56bd0c06f10352c3a1a9f4b4c92f6fa2b26df124b57878353c1fc691c51abea77c8817daeeb9fa546b77c8daf79d89b22b0e1b87574ece42371f00237aa9d83a,0,7e0e78eb6990b059e6cf0ded66ea93ef82e72aa2f18ac24f2fc6ebab561ae557420729da103f64cecfa20527e15f9fb669a49bbbf274ef0389b3e43c8c44e5f60bf2ac38e2b55e7ec4273dba15ba41d21f8f5b3ee1688b3c29951218caf847a97fb50d75a86515d445699497d968164bf740012679b8962de573be941c62b7ef,1,,1,5d673dd0a75ccacf4e1310e9402ecdacdd474d8bbfa6eeefdde2e1b216d41dbe,2dd7b9cc85524f8670f695c3143ac26b45cebcabb2782a85e0fe15aee3956535,1c229ba46fadced7217df782d410961c1399375135e4aa718fa3424ec36539cc,b764f617cf8c8dcf6018e4f5e8ee603a086498a3732621c9b0fc0a485ea0d2f0,e25747c749e78c7a0102352378f7c15566145b57f082f7e10b10a0606b323996,c0547fbf3082c7a0377b4e709b982ecb4710012dcf3b0c073ed3811a2b7c1309,5bb291885bf5b08a4218c2bf3498d3591be93a47412c770b60299c8e740ac560,fdf5a3e3e75afc15a924373e58af505052731efa75c76a1fa3546954d60b50b1,8461c1dc173be7e6a2316d09710ebd8d,dfa2d33623fe80e2347999e6de0f96fd,279a96e6ce08e5074608fcad77d6a78f90c8b618a4520575435b1a37b1c56df9,,5afbd61f6e989833df2f12ff70c98f1a20ebe84acba2a05429cc6a57238dba87cdc432474f378889b2d0e95ade9f892eb1a1f6b03b73f903682476537f653f738f7a9f1cc9856ed75f3d69122bdeb00af48e66a64872f639a67fc109ee5ca124d0ee183da3c2b8f2da828850b50976b491f1add78d7f01e07565570621266852
+448,96cb391886681d1d3e23948e51987771a8ec3001b640c18fb994a855cea66b6e,ffffffffffffffffffffffffffffffffffffffffffffffffffffffffdde3a077a6fd73711a27250c439ba78ef63d89cd0918c0a0a75f301ed96aa2a43ecf3f61,ffffffffffffffffffffffffffffffffffffffffffffffffffffffffa7730be30000000000000000000000000000000000000000000000000000000000000000,1,00cf68f8f7ac49ffaa02c4864fdf6dfe7bbf2c740b88d98c50ebafe32c92f3427f57601ffcb21a3435979287db8fee6c302926741f9d5e464c647eeb9b7acaeda46e00abd7506fc9a719847e9a7328215801e96198dac141a15c7c2f68e0690dd1176292a0dded04d1f548aad88f1aebdc0a8f87da4bb22df32dd7c160c225b843e83f6525d6d484f502f16d923124fc538794e21da2eb689d18d87406ecced5b9f92137239ed1d37bcfa7836641a83cf5e0a1cf63f51b06f158e499a459ede41c,1,,0,f7561c791f6f4aa73dcef3cac32f2433b4cfa4ab0666e93552b7cbc7249fb2de,5232c4b6bde9d3d45d7b763ebd7495399bb825cc21de51011761cd81a51bdc84,2651a46a622f79e2ab18819587e7f897e3f8351b1e1b66d8ed4543a1e40bc569,779a18107756169a6b369d043f3ef9a90178c7ab8c8c37b4edcd9b5397e41eca,368c7283e088e40b79e6214046beab64cbac30a89940acbc30d430f941fe7d35,224065c728d5cdabbe209cd52621324471ce8dc229907c018cec05781a9c770d,9ce33c019a081e5f8b62e1f12d652f0b036ed65f5de195d931dfcd92043b5eb2,001e576d8828a6d84913b01cb88e8f5532207f34275017b61650ba1383646cbc,7bf55f6b58f73cdff19ee3292607239f,d121874372c61a48fd87da6d01d89da4,e9515794acced50e0550a3ebd95c170d2abd48b5f23fccca73bc597f00c88cf2,,33953941be2682da1c6d1b167cbf180d7cb8159c94c6ea1c52356716f1057af4df53321f18894c285f7b2fd85b2edc44a13c9295f310962fdfc8d944bd77c5500b10ca68ca5d0977d19d183a7def742c41cfeee763dc09ef985c96ab6e74e464f66992f752c9368e42082ad338705062ddfcad4ca1c9c54004b9345d8df25953
+673,4a7065c3ddbf84e29b8e20da0da3aaae1f708eae8ad1af4c4c00f46a7cda7b6b,ffffffffffffffffffffffffffffffffffffffffffffffffffffffff450012ec3aeecf516f4b374af2e7fbb040e92dc3c0f12eafd00c729a137f4e892e5293c3,9652d78baefc028cd37a6a92625b8b8f85fde1e4c944ad3f20e198bef8c02f19fffffffffffffffffffffffffffffffffffffffffffffffffffffffff2e91870,0,5c6272ee55da855bbbf7b1246d9885aa7aa601a715ab86fa46c50da533badf82b97597c968293ae04e,97561,,0,a0ff3dd41ca11036eea75ea08993c938894c7eebca99354ac2e0daa8a1a6b2ca,64c383e0e78ac99476ddff2061683eeefa505e3666673a1371342c3e6c26981d,ca3f58a228c530be63eec8a427d16496776aefb22e693152a3a9394b9a87d097,a993062a328371beecae7e2b05a34355c1cefbad7f855ad48331dcf002972999,24cdf9d8533696a5795cadcf5b94826ddbe5f047ba02c832b3495ac7c1110e31,7b5d1c66668d20d57a4e0a6ba4d9aa3e3ba0f704697aa7edb9ce9471d46647da,e6a808d35ee403b3f4bbcd8fd49fa005a40dfaaf36f9f504318bb94637067060,d6ae42117344fb71cb1817a1dc192a4b5bb35d885005093c3e9bd4576069b217,1fec304dcaacf1f5b088325306272d78,d2d16a8452807baa4f63b059b5804624,dccb606c4f2a0f64bc164dbc00eb0f6cf1474575e89d7928be6346720bb53610,,58daef966f33c036740aeb3f6a4b31c0f0a070b25fd6a1abf82ef56fc2cb3ca8da8c434f23790c69349dd0cb4058f88a7bd0e333c8ceba3c80f21e951b9fdb1c84e2e7f49f43c21087566d58f1bcc42b041e0b462e37e927c0071caa9a2b650dccf448c9f88d73b62e80a3e5d5e4e46992e34b416ceb9590a7c8b7bfaccf37ab
+1024,0f69aeffeff6172647ee5aa80bfb418ee742f4e9f1a51b463ac7c120d620e37d,ffffffffffffffffffffffffffffffffffffffffffffffffffffffff04df0e67f9753e2cdb066b3b588a0069fde936a312e0d3f31acb335026b7072d8f2ad24c,12a50f3fafea7c1eeada4cf8d33777704b77361453afc83bda91eef349ae044d20126c6200547ea5a6911776c05dee2a7f1a9ba7dfbabbbd273c3ef29ef46e46,1,5f67d15d22ca9b2804eeab0a66f7f8e3a10fa5de5809a046084348cbc5304e843ef96f59a59c7d7fdfe5946489f3ea297d941bac326225df316a25fc90f0e65b0d31a9c497e960fdbf8c482516bc8a9c1c77b7f6d0e1143810c737f76f9224e6f2c9af5186b4f7259c7e8d165b6e4fe3d38a60bdbdd4d06ecdcaaf62086070dbb68686b802d53dfd7db14b18743832605f5461ad81e2af4b7e8ff0eff0867a25b93cec7becf15c43131895fed09a83bf1ee4a87d44dd0f02a837bf5a1232e201cb882734eb9643dc2dc4d4e8b5690840766212c7ac8f38ad8a9ec47c7a9b3e022ae3eb6a32522128b518bd0d0085dd81c5,69615,,1,115b298a52a9362706ddd1e493de09443dd8ac2b0c3e4e5e8b6bb295598db05d,eef379db9bd4b1aa90fc347fad33f7d53083389e22e971036f59f4e29d325ac2,32e15c20a09591b6600c778752a582fed444444fd0d3317613555c6509ff4b8d,1756deace376ece25da9825fe49f76a9272a89a7b746c83ca2c4016f5a30ead4,15e26b12238d66ebc4cb72d16a62a8bb404c94d31bbe3b1d22a01b851e935010,c135367f39b24a9cc9b73ad628fba1887737f5686062c4c36146e76849828a50,ffa25ddf7cd4cd10a47f6c3b32a54ee882837058e31677d3958539f4f23e4616,12f9b3ebbf743f6b93c7d0f4f20259fac2a27ea6735fd9ef2e2699049af60fcc,4dfac3b0a99401f6aad1a8df3cd7dd05,e5d4905a8b6a5d18ec6cebbdecd703d3,fc2431beb9a666bf888df0662276a4b6a1af5061072992ef408f2b686c86a2ac,,1a7f3fb83ad2b050b663b8df6b7c2cc2d8e169a869a58bf7ef5ab5db97a505c84a812e100d9445da4fc39a1176d6aed3995f6868631224b86f10603217c8d13270e0c6d054ad9e0d0b7dc0c8e59a37cd05a0a45faa14b4ffc8d12b641f62e6f1b71c1f72b737e9ce3fe74be779b25e70bf11d98766b3876d0fa28d3c669087fc
diff --git a/test/data/xswiftec_inv_test_vectors.csv b/test/data/xswiftec_inv_test_vectors.csv
new file mode 100644
--- /dev/null
+++ b/test/data/xswiftec_inv_test_vectors.csv
@@ -0,0 +1,33 @@
+u,x,case0_t,case1_t,case2_t,case3_t,case4_t,case5_t,case6_t,case7_t,comment
+05ff6bdad900fc3261bc7fe34e2fb0f569f06e091ae437d3a52e9da0cbfb9590,80cdf63774ec7022c89a5a8558e373a279170285e0ab27412dbce510bdfe23fc,,,45654798ece071ba79286d04f7f3eb1c3f1d17dd883610f2ad2efd82a287466b,0aeaa886f6b76c7158452418cbf5033adc5747e9e9b5d3b2303db96936528557,,,ba9ab867131f8e4586d792fb080c14e3c0e2e82277c9ef0d52d1027c5d78b5c4,f51557790948938ea7badbe7340afcc523a8b816164a2c4dcfc24695c9ad76d8,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:info[v=0]&ok;case3:ok;case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:info[v=0]&ok;case7:ok
+1737a85f4c8d146cec96e3ffdca76d9903dcf3bd53061868d478c78c63c2aa9e,39e48dd150d2f429be088dfd5b61882e7e8407483702ae9a5ab35927b15f85ea,1be8cc0b04be0c681d0c6a68f733f82c6c896e0c8a262fcd392918e303a7abf4,605b5814bf9b8cb066667c9e5480d22dc5b6c92f14b4af3ee0a9eb83b03685e3,,,e41733f4fb41f397e2f3959708cc07d3937691f375d9d032c6d6e71bfc58503b,9fa4a7eb4064734f99998361ab7f2dd23a4936d0eb4b50c11f56147b4fc9764c,,,case0:ok;case1:ok;case2:info[v=0]&bad[non_square(s)];case3:bad[non_square(s)];case4:ok;case5:ok;case6:info[v=0]&bad[non_square(s)];case7:bad[non_square(s)]
+1aaa1ccebf9c724191033df366b36f691c4d902c228033ff4516d122b2564f68,c75541259d3ba98f207eaa30c69634d187d0b6da594e719e420f4898638fc5b0,,,,,,,,,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:bad[non_square(q)];case3:bad[non_square(q)];case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:bad[non_square(q)];case7:bad[non_square(q)]
+2323a1d079b0fd72fc8bb62ec34230a815cb0596c2bfac998bd6b84260f5dc26,239342dfb675500a34a196310b8d87d54f49dcac9da50c1743ceab41a7b249ff,f63580b8aa49c4846de56e39e1b3e73f171e881eba8c66f614e67e5c975dfc07,b6307b332e699f1cf77841d90af25365404deb7fed5edb3090db49e642a156b6,,,09ca7f4755b63b7b921a91c61e4c18c0e8e177e145739909eb1981a268a20028,49cf84ccd19660e30887be26f50dac9abfb2148012a124cf6f24b618bd5ea579,,,case0:ok;case1:ok;case2:bad[non_square(q)];case3:bad[non_square(q)];case4:ok;case5:ok;case6:bad[non_square(q)];case7:bad[non_square(q)]
+2dc90e640cb646ae9164c0b5a9ef0169febe34dc4437d6e46acb0e27e219d1e8,d236f19bf349b9516e9b3f4a5610fe960141cb23bbc8291b9534f1d71de62a47,e69df7d9c026c36600ebdf588072675847c0c431c8eb730682533e964b6252c9,4f18bbdf7c2d6c5f818c18802fa35cd069eaa79fff74e4fc837c80d93fece2f8,,,196208263fd93c99ff1420a77f8d98a7b83f3bce37148cf97dacc168b49da966,b0e7442083d293a07e73e77fd05ca32f96155860008b1b037c837f25c0131937,,,case0:ok;case1:info[v=0]&ok;case2:bad[non_square(q)];case3:bad[non_square(q)];case4:ok;case5:info[v=0]&ok;case6:bad[non_square(q)];case7:bad[non_square(q)]
+3edd7b3980e2f2f34d1409a207069f881fda5f96f08027ac4465b63dc278d672,053a98de4a27b1961155822b3a3121f03b2a14458bd80eb4a560c4c7a85c149c,,,b3dae4b7dcf858e4c6968057cef2b156465431526538199cf52dc1b2d62fda30,4aa77dd55d6b6d3cfa10cc9d0fe42f79232e4575661049ae36779c1d0c666d88,,,4c251b482307a71b39697fa8310d4ea9b9abcead9ac7e6630ad23e4c29d021ff,b558822aa29492c305ef3362f01bd086dcd1ba8a99efb651c98863e1f3998ea7,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:ok;case3:ok;case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:ok;case7:ok
+4295737efcb1da6fb1d96b9ca7dcd1e320024b37a736c4948b62598173069f70,fa7ffe4f25f88362831c087afe2e8a9b0713e2cac1ddca6a383205a266f14307,,,,,,,,,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:bad[non_square(s)];case3:bad[non_square(s)];case4:bad[non_square(s)];case5:bad[non_square(s)];case6:bad[non_square(s)];case7:bad[non_square(s)]
+587c1a0cee91939e7f784d23b963004a3bf44f5d4e32a0081995ba20b0fca59e,2ea988530715e8d10363907ff25124524d471ba2454d5ce3be3f04194dfd3a3c,cfd5a094aa0b9b8891b76c6ab9438f66aa1c095a65f9f70135e8171292245e74,a89057d7c6563f0d6efa19ae84412b8a7b47e791a191ecdfdf2af84fd97bc339,475d0ae9ef46920df07b34117be5a0817de1023e3cc32689e9be145b406b0aef,a0759178ad80232454f827ef05ea3e72ad8d75418e6d4cc1cd4f5306c5e7c453,302a5f6b55f464776e48939546bc709955e3f6a59a0608feca17e8ec6ddb9dbb,576fa82839a9c0f29105e6517bbed47584b8186e5e6e132020d507af268438f6,b8a2f51610b96df20f84cbee841a5f7e821efdc1c33cd9761641eba3bf94f140,5f8a6e87527fdcdbab07d810fa15c18d52728abe7192b33e32b0acf83a1837dc,case0:ok;case1:ok;case2:ok;case3:ok;case4:ok;case5:ok;case6:ok;case7:ok
+5fa88b3365a635cbbcee003cce9ef51dd1a310de277e441abccdb7be1e4ba249,79461ff62bfcbcac4249ba84dd040f2cec3c63f725204dc7f464c16bf0ff3170,,,6bb700e1f4d7e236e8d193ff4a76c1b3bcd4e2b25acac3d51c8dac653fe909a0,f4c73410633da7f63a4f1d55aec6dd32c4c6d89ee74075edb5515ed90da9e683,,,9448ff1e0b281dc9172e6c00b5893e4c432b1d4da5353c2ae3725399c016f28f,0b38cbef9cc25809c5b0e2aa513922cd3b39276118bf8a124aaea125f25615ac,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:ok;case3:info[v=0]&ok;case4:bad[non_square(s)];case5:bad[non_square(s)];case6:ok;case7:info[v=0]&ok
+6fb31c7531f03130b42b155b952779efbb46087dd9807d241a48eac63c3d96d6,56f81be753e8d4ae4940ea6f46f6ec9fda66a6f96cc95f506cb2b57490e94260,,,59059774795bdb7a837fbe1140a5fa59984f48af8df95d57dd6d1c05437dcec1,22a644db79376ad4e7b3a009e58b3f13137c54fdf911122cc93667c47077d784,,,a6fa688b86a424857c8041eebf5a05a667b0b7507206a2a82292e3f9bc822d6e,dd59bb2486c8952b184c5ff61a74c0ecec83ab0206eeedd336c9983a8f8824ab,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:ok;case3:info[v=0]&ok;case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:ok;case7:info[v=0]&ok
+704cd226e71cb6826a590e80dac90f2d2f5830f0fdf135a3eae3965bff25ff12,138e0afa68936ee670bd2b8db53aedbb7bea2a8597388b24d0518edd22ad66ec,,,,,,,,,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:bad[non_square(q)];case3:bad[non_square(q)];case4:bad[non_square(s)];case5:bad[non_square(s)];case6:bad[non_square(q)];case7:bad[non_square(q)]
+725e914792cb8c8949e7e1168b7cdd8a8094c91c6ec2202ccd53a6a18771edeb,8da16eb86d347376b6181ee9748322757f6b36e3913ddfd332ac595d788e0e44,dd357786b9f6873330391aa5625809654e43116e82a5a5d82ffd1d6624101fc4,a0b7efca01814594c59c9aae8e49700186ca5d95e88bcc80399044d9c2d8613d,,,22ca8879460978cccfc6e55a9da7f69ab1bcee917d5a5a27d002e298dbefdc6b,5f481035fe7eba6b3a63655171b68ffe7935a26a1774337fc66fbb253d279af2,,,case0:ok;case1:info[v=0]&ok;case2:bad[non_square(s)];case3:bad[non_square(s)];case4:ok;case5:info[v=0]&ok;case6:bad[non_square(s)];case7:bad[non_square(s)]
+78fe6b717f2ea4a32708d79c151bf503a5312a18c0963437e865cc6ed3f6ae97,8701948e80d15b5cd8f72863eae40afc5aced5e73f69cbc8179a33902c094d98,,,,,,,,,case0:bad[non_square(s)];case1:info[v=0]&bad[non_square(s)];case2:bad[non_square(q)];case3:bad[non_square(q)];case4:bad[non_square(s)];case5:info[v=0]&bad[non_square(s)];case6:bad[non_square(q)];case7:bad[non_square(q)]
+7c37bb9c5061dc07413f11acd5a34006e64c5c457fdb9a438f217255a961f50d,5c1a76b44568eb59d6789a7442d9ed7cdc6226b7752b4ff8eaf8e1a95736e507,,,b94d30cd7dbff60b64620c17ca0fafaa40b3d1f52d077a60a2e0cafd145086c2,,,,46b2cf32824009f49b9df3e835f05055bf4c2e0ad2f8859f5d1f3501ebaf756d,,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:info[q=0]&info[X=0]&ok;case3:info[q=0]&bad[r=0];case4:bad[non_square(s)];case5:bad[non_square(s)];case6:info[q=0]&info[X=0]&ok;case7:info[q=0]&bad[r=0]
+82388888967f82a6b444438a7d44838e13c0d478b9ca060da95a41fb94303de6,29e9654170628fec8b4972898b113cf98807f4609274f4f3140d0674157c90a0,,,,,,,,,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:bad[non_square(s)];case3:info[v=0]&bad[non_square(s)];case4:bad[non_square(s)];case5:bad[non_square(s)];case6:bad[non_square(s)];case7:info[v=0]&bad[non_square(s)]
+91298f5770af7a27f0a47188d24c3b7bf98ab2990d84b0b898507e3c561d6472,144f4ccbd9a74698a88cbf6fd00ad886d339d29ea19448f2c572cac0a07d5562,e6a0ffa3807f09dadbe71e0f4be4725f2832e76cad8dc1d943ce839375eff248,837b8e68d4917544764ad0903cb11f8615d2823cefbb06d89049dbabc69befda,,,195f005c7f80f6252418e1f0b41b8da0d7cd189352723e26bc317c6b8a1009e7,7c8471972b6e8abb89b52f6fc34ee079ea2d7dc31044f9276fb6245339640c55,,,case0:ok;case1:ok;case2:bad[non_square(s)];case3:info[v=0]&bad[non_square(s)];case4:ok;case5:ok;case6:bad[non_square(s)];case7:info[v=0]&bad[non_square(s)]
+b682f3d03bbb5dee4f54b5ebfba931b4f52f6a191e5c2f483c73c66e9ace97e1,904717bf0bc0cb7873fcdc38aa97f19e3a62630972acff92b24cc6dda197cb96,,,,,,,,,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:bad[non_square(s)];case3:bad[non_square(s)];case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:bad[non_square(s)];case7:bad[non_square(s)]
+c17ec69e665f0fb0dbab48d9c2f94d12ec8a9d7eacb58084833091801eb0b80b,147756e66d96e31c426d3cc85ed0c4cfbef6341dd8b285585aa574ea0204b55e,6f4aea431a0043bdd03134d6d9159119ce034b88c32e50e8e36c4ee45eac7ae9,fd5be16d4ffa2690126c67c3ef7cb9d29b74d397c78b06b3605fda34dc9696a6,5e9c60792a2f000e45c6250f296f875e174efc0e9703e628706103a9dd2d82c7,,90b515bce5ffbc422fcecb2926ea6ee631fcb4773cd1af171c93b11aa1538146,02a41e92b005d96fed93983c1083462d648b2c683874f94c9fa025ca23696589,a1639f86d5d0fff1ba39daf0d69078a1e8b103f168fc19d78f9efc5522d27968,,case0:ok;case1:ok;case2:info[q=0]&info[X=0]&ok;case3:info[q=0]&bad[r=0];case4:ok;case5:ok;case6:info[q=0]&info[X=0]&ok;case7:info[q=0]&bad[r=0]
+c25172fc3f29b6fc4a1155b8575233155486b27464b74b8b260b499a3f53cb14,1ea9cbdb35cf6e0329aa31b0bb0a702a65123ed008655a93b7dcd5280e52e1ab,,,7422edc7843136af0053bb8854448a8299994f9ddcefd3a9a92d45462c59298a,78c7774a266f8b97ea23d05d064f033c77319f923f6b78bce4e20bf05fa5398d,,,8bdd12387bcec950ffac4477abbb757d6666b06223102c5656d2bab8d3a6d2a5,873888b5d990746815dc2fa2f9b0fcc388ce606dc09487431b1df40ea05ac2a2,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:ok;case3:ok;case4:bad[non_square(s)];case5:bad[non_square(s)];case6:ok;case7:ok
+cab6626f832a4b1280ba7add2fc5322ff011caededf7ff4db6735d5026dc0367,2b2bef0852c6f7c95d72ac99a23802b875029cd573b248d1f1b3fc8033788eb6,,,,,,,,,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:info[v=0]&bad[non_square(s)];case3:bad[non_square(s)];case4:bad[non_square(s)];case5:bad[non_square(s)];case6:info[v=0]&bad[non_square(s)];case7:bad[non_square(s)]
+d8621b4ffc85b9ed56e99d8dd1dd24aedcecb14763b861a17112dc771a104fd2,812cabe972a22aa67c7da0c94d8a936296eb9949d70c37cb2b2487574cb3ce58,fbc5febc6fdbc9ae3eb88a93b982196e8b6275a6d5a73c17387e000c711bd0e3,8724c96bd4e5527f2dd195a51c468d2d211ba2fac7cbe0b4b3434253409fb42d,,,043a014390243651c147756c467de691749d8a592a58c3e8c781fff28ee42b4c,78db36942b1aad80d22e6a5ae3b972d2dee45d0538341f4b4cbcbdabbf604802,,,case0:ok;case1:ok;case2:bad[non_square(s)];case3:bad[non_square(s)];case4:ok;case5:ok;case6:bad[non_square(s)];case7:bad[non_square(s)]
+da463164c6f4bf7129ee5f0ec00f65a675a8adf1bd931b39b64806afdcda9a22,25b9ce9b390b408ed611a0f13ff09a598a57520e426ce4c649b7f94f2325620d,,,,,,,,,case0:bad[non_square(s)];case1:info[v=0]&bad[non_square(s)];case2:bad[non_square(s)];case3:bad[non_square(s)];case4:bad[non_square(s)];case5:info[v=0]&bad[non_square(s)];case6:bad[non_square(s)];case7:bad[non_square(s)]
+dafc971e4a3a7b6dcfb42a08d9692d82ad9e7838523fcbda1d4827e14481ae2d,250368e1b5c58492304bd5f72696d27d526187c7adc03425e2b7d81dbb7e4e02,,,370c28f1be665efacde6aa436bf86fe21e6e314c1e53dd040e6c73a46b4c8c49,cd8acee98ffe56531a84d7eb3e48fa4034206ce825ace907d0edf0eaeb5e9ca2,,,c8f3d70e4199a105321955bc9407901de191ceb3e1ac22fbf1938c5a94b36fe6,327531167001a9ace57b2814c1b705bfcbdf9317da5316f82f120f1414a15f8d,case0:bad[non_square(s)];case1:info[v=0]&bad[non_square(s)];case2:ok;case3:ok;case4:bad[non_square(s)];case5:info[v=0]&bad[non_square(s)];case6:ok;case7:ok
+e0294c8bc1a36b4166ee92bfa70a5c34976fa9829405efea8f9cd54dcb29b99e,ae9690d13b8d20a0fbbf37bed8474f67a04e142f56efd78770a76b359165d8a1,,,dcd45d935613916af167b029058ba3a700d37150b9df34728cb05412c16d4182,,,,232ba26ca9ec6e950e984fd6fa745c58ff2c8eaf4620cb8d734fabec3e92baad,,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:info[q=0]&info[X=0]&ok;case3:info[q=0]&bad[r=0];case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:info[q=0]&info[X=0]&ok;case7:info[q=0]&bad[r=0]
+e148441cd7b92b8b0e4fa3bd68712cfd0d709ad198cace611493c10e97f5394e,164a639794d74c53afc4d3294e79cdb3cd25f99f6df45c000f758aba54d699c0,,,,,,,,,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:bad[non_square(s)];case3:info[v=0]&bad[non_square(s)];case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:bad[non_square(s)];case7:info[v=0]&bad[non_square(s)]
+e4b00ec97aadcca97644d3b0c8a931b14ce7bcf7bc8779546d6e35aa5937381c,94e9588d41647b3fcc772dc8d83c67ce3be003538517c834103d2cd49d62ef4d,c88d25f41407376bb2c03a7fffeb3ec7811cc43491a0c3aac0378cdc78357bee,51c02636ce00c2345ecd89adb6089fe4d5e18ac924e3145e6669501cd37a00d4,205b3512db40521cb200952e67b46f67e09e7839e0de44004138329ebd9138c5,58aab390ab6fb55c1d1b80897a207ce94a78fa5b4aa61a33398bcae9adb20d3e,3772da0bebf8c8944d3fc5800014c1387ee33bcb6e5f3c553fc8732287ca8041,ae3fd9c931ff3dcba132765249f7601b2a1e7536db1ceba19996afe22c85fb5b,dfa4caed24bfade34dff6ad1984b90981f6187c61f21bbffbec7cd60426ec36a,a7554c6f54904aa3e2e47f7685df8316b58705a4b559e5ccc6743515524deef1,case0:ok;case1:ok;case2:ok;case3:info[v=0]&ok;case4:ok;case5:ok;case6:ok;case7:info[v=0]&ok
+e5bbb9ef360d0a501618f0067d36dceb75f5be9a620232aa9fd5139d0863fde5,e5bbb9ef360d0a501618f0067d36dceb75f5be9a620232aa9fd5139d0863fde5,,,,,,,,,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:bad[s=0];case3:bad[s=0];case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:bad[s=0];case7:bad[s=0]
+e6bcb5c3d63467d490bfa54fbbc6092a7248c25e11b248dc2964a6e15edb1457,19434a3c29cb982b6f405ab04439f6d58db73da1ee4db723d69b591da124e7d8,67119877832ab8f459a821656d8261f544a553b89ae4f25c52a97134b70f3426,ffee02f5e649c07f0560eff1867ec7b32d0e595e9b1c0ea6e2a4fc70c97cd71f,b5e0c189eb5b4bacd025b7444d74178be8d5246cfa4a9a207964a057ee969992,5746e4591bf7f4c3044609ea372e908603975d279fdef8349f0b08d32f07619d,98ee67887cd5470ba657de9a927d9e0abb5aac47651b0da3ad568eca48f0c809,0011fd0a19b63f80fa9f100e7981384cd2f1a6a164e3f1591d5b038e36832510,4a1f3e7614a4b4532fda48bbb28be874172adb9305b565df869b5fa71169629d,a8b91ba6e4080b3cfbb9f615c8d16f79fc68a2d8602107cb60f4f72bd0f89a92,case0:ok;case1:info[v=0]&ok;case2:ok;case3:ok;case4:ok;case5:info[v=0]&ok;case6:ok;case7:ok
+f28fba64af766845eb2f4302456e2b9f8d80affe57e7aae42738d7cddb1c2ce6,f28fba64af766845eb2f4302456e2b9f8d80affe57e7aae42738d7cddb1c2ce6,4f867ad8bb3d840409d26b67307e62100153273f72fa4b7484becfa14ebe7408,5bbc4f59e452cc5f22a99144b10ce8989a89a995ec3cea1c91ae10e8f721bb5d,,,b079852744c27bfbf62d9498cf819deffeacd8c08d05b48b7b41305db1418827,a443b0a61bad33a0dd566ebb4ef317676576566a13c315e36e51ef1608de40d2,,,case0:ok;case1:ok;case2:bad[s=0];case3:bad[s=0];case4:ok;case5:ok;case6:bad[s=0];case7:bad[s=0]
+f455605bc85bf48e3a908c31023faf98381504c6c6d3aeb9ede55f8dd528924d,d31fbcd5cdb798f6c00db6692f8fe8967fa9c79dd10958f4a194f01374905e99,,,0c00c5715b56fe632d814ad8a77f8e66628ea47a6116834f8c1218f3a03cbd50,df88e44fac84fa52df4d59f48819f18f6a8cd4151d162afaf773166f57c7ff46,,,f3ff3a8ea4a9019cd27eb527588071999d715b859ee97cb073ede70b5fc33edf,20771bb0537b05ad20b2a60b77e60e7095732beae2e9d505088ce98fa837fce9,case0:bad[non_square(s)];case1:bad[non_square(s)];case2:info[v=0]&ok;case3:ok;case4:bad[non_square(s)];case5:bad[non_square(s)];case6:info[v=0]&ok;case7:ok
+f58cd4d9830bad322699035e8246007d4be27e19b6f53621317b4f309b3daa9d,78ec2b3dc0948de560148bbc7c6dc9633ad5df70a5a5750cbed721804f082a3b,6c4c580b76c7594043569f9dae16dc2801c16a1fbe12860881b75f8ef929bce5,94231355e7385c5f25ca436aa64191471aea4393d6e86ab7a35fe2afacaefd0d,dff2a1951ada6db574df834048149da3397a75b829abf58c7e69db1b41ac0989,a52b66d3c907035548028bf804711bf422aba95f1a666fc86f4648e05f29caae,93b3a7f48938a6bfbca9606251e923d7fe3e95e041ed79f77e48a07006d63f4a,6bdcecaa18c7a3a0da35bc9559be6eb8e515bc6c291795485ca01d4f5350ff22,200d5e6ae525924a8b207cbfb7eb625cc6858a47d6540a73819624e3be53f2a6,5ad4992c36f8fcaab7fd7407fb8ee40bdd5456a0e599903790b9b71ea0d63181,case0:ok;case1:ok;case2:info[v=0]&ok;case3:ok;case4:ok;case5:ok;case6:info[v=0]&ok;case7:ok
+fd7d912a40f182a3588800d69ebfb5048766da206fd7ebc8d2436c81cbef6421,8d37c862054debe731694536ff46b273ec122b35a9bf1445ac3c4ff9f262c952,,,,,,,,,case0:bad[valid_x(-x-u)];case1:bad[valid_x(-x-u)];case2:info[v=0]&bad[non_square(s)];case3:bad[non_square(s)];case4:bad[valid_x(-x-u)];case5:bad[valid_x(-x-u)];case6:info[v=0]&bad[non_square(s)];case7:bad[non_square(s)]
