{-# LANGUAGE TypeApplications #-}
module Test.Crypto.Vector.StringConstants (
invalidEcdsaSigLengthError,
invalidSchnorrVerKeyLengthError,
invalidEcdsaVerKeyLengthError,
invalidSchnorrSigLengthError,
cannotDecodeVerificationKeyError,
unexpectedDecodingError,
)
where
import Cardano.Crypto.SECP256K1.Constants (
SECP256K1_ECDSA_PUBKEY_BYTES,
SECP256K1_ECDSA_SIGNATURE_BYTES,
SECP256K1_SCHNORR_PUBKEY_BYTES,
SECP256K1_SCHNORR_SIGNATURE_BYTES,
)
import Data.Data (Proxy (Proxy))
import GHC.TypeLits (natVal)
invalidEcdsaVerKeyLengthError :: Integer -> String
invalidEcdsaVerKeyLengthError :: Integer -> String
invalidEcdsaVerKeyLengthError =
String -> Integer -> Integer -> String
wrongLengthError String
"PinnedSizedBytes 33" (Integer -> Integer -> String) -> Integer -> Integer -> String
forall a b. (a -> b) -> a -> b
$ Proxy SECP256K1_ECDSA_PUBKEY_BYTES -> Integer
forall (n :: Natural) (proxy :: Natural -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy SECP256K1_ECDSA_PUBKEY_BYTES -> Integer)
-> Proxy SECP256K1_ECDSA_PUBKEY_BYTES -> Integer
forall a b. (a -> b) -> a -> b
$ forall (t :: Natural). Proxy t
forall {k} (t :: k). Proxy t
Proxy @SECP256K1_ECDSA_PUBKEY_BYTES
invalidSchnorrVerKeyLengthError :: Integer -> String
invalidSchnorrVerKeyLengthError :: Integer -> String
invalidSchnorrVerKeyLengthError =
String -> Integer -> Integer -> String
wrongLengthError String
"VerKeyDSIGN SchnorrSecp256k1DSIGN" (Integer -> Integer -> String) -> Integer -> Integer -> String
forall a b. (a -> b) -> a -> b
$
Proxy SECP256K1_SCHNORR_PUBKEY_BYTES -> Integer
forall (n :: Natural) (proxy :: Natural -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy SECP256K1_SCHNORR_PUBKEY_BYTES -> Integer)
-> Proxy SECP256K1_SCHNORR_PUBKEY_BYTES -> Integer
forall a b. (a -> b) -> a -> b
$
forall (t :: Natural). Proxy t
forall {k} (t :: k). Proxy t
Proxy @SECP256K1_SCHNORR_PUBKEY_BYTES
invalidEcdsaSigLengthError :: Integer -> String
invalidEcdsaSigLengthError :: Integer -> String
invalidEcdsaSigLengthError =
String -> Integer -> Integer -> String
wrongLengthError String
"PinnedSizedBytes 64" (Integer -> Integer -> String) -> Integer -> Integer -> String
forall a b. (a -> b) -> a -> b
$ Proxy SECP256K1_ECDSA_SIGNATURE_BYTES -> Integer
forall (n :: Natural) (proxy :: Natural -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy SECP256K1_ECDSA_SIGNATURE_BYTES -> Integer)
-> Proxy SECP256K1_ECDSA_SIGNATURE_BYTES -> Integer
forall a b. (a -> b) -> a -> b
$ forall (t :: Natural). Proxy t
forall {k} (t :: k). Proxy t
Proxy @SECP256K1_ECDSA_SIGNATURE_BYTES
invalidSchnorrSigLengthError :: Integer -> String
invalidSchnorrSigLengthError :: Integer -> String
invalidSchnorrSigLengthError =
String -> Integer -> Integer -> String
wrongLengthError (String
"PinnedSizedBytes " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
schnorrSigSize) Integer
schnorrSigSize
where
schnorrSigSize :: Integer
schnorrSigSize = Proxy SECP256K1_ECDSA_SIGNATURE_BYTES -> Integer
forall (n :: Natural) (proxy :: Natural -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy SECP256K1_ECDSA_SIGNATURE_BYTES -> Integer)
-> Proxy SECP256K1_ECDSA_SIGNATURE_BYTES -> Integer
forall a b. (a -> b) -> a -> b
$ forall (t :: Natural). Proxy t
forall {k} (t :: k). Proxy t
Proxy @SECP256K1_SCHNORR_SIGNATURE_BYTES
wrongLengthError :: String -> Integer -> Integer -> String
wrongLengthError :: String -> Integer -> Integer -> String
wrongLengthError String
typeName Integer
expectedLength Integer
actualLength =
String
typeName
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
": wrong length, expected "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
expectedLength
String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" bytes but got "
String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
actualLength
cannotDecodeVerificationKeyError :: String
cannotDecodeVerificationKeyError :: String
cannotDecodeVerificationKeyError = String
"VerKeyDSIGN SchnorrSecp256k1DSIGN: deserialisation failed"
unexpectedDecodingError :: String
unexpectedDecodingError :: String
unexpectedDecodingError = String
"Test failed. Unexpected decoding error encountered."