{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
module Bcc.Api.Tx (
Tx(.., Tx),
getTxBody,
getTxWitnesses,
ScriptValidity(..),
SophieSigningKey(..),
toSophieSigningKey,
signColeTransaction,
signSophieTransaction,
makeSignedTransaction,
KeyWitness(..),
makeColeKeyWitness,
SophieWitnessSigningKey(..),
makeSophieKeyWitness,
WitnessNetworkIdOrColeAddress (..),
makeSophieBootstrapWitness,
makeSophieSignature,
getSophieKeyWitnessVerificationKey,
AsType(AsTx, AsColeTx, AsSophieTx,
AsKeyWitness, AsColeWitness, AsSophieWitness),
) where
import Prelude
import Data.Maybe
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
import Data.Functor.Identity (Identity)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.Vector as Vector
import Bcc.Binary (Annotated (..))
import qualified Bcc.Binary as CBOR
import qualified Bcc.Prelude as CBOR (cborError)
import qualified Bcc.Crypto.DSIGN.Class as Crypto
import qualified Bcc.Crypto.Util as Crypto
import qualified Bcc.Crypto.Wallet as Crypto.HD
import qualified Bcc.Chain.Common as Cole
import qualified Bcc.Chain.UTxO as Cole
import qualified Bcc.Crypto.Hashing as Cole
import qualified Bcc.Crypto.ProtocolMagic as Cole
import qualified Bcc.Crypto.Signing as Cole
import Bcc.Ledger.BaseTypes (maybeToStrictMaybe, strictMaybeToMaybe)
import Bcc.Ledger.Crypto (StandardCrypto)
import qualified Bcc.Ledger.Core as Ledger
import qualified Bcc.Ledger.Era as Ledger
import qualified Bcc.Ledger.SafeHash as Ledger
import qualified Bcc.Ledger.Sophie.Constraints as Sophie
import qualified Sophie.Spec.Ledger.TxBody as Ledger (EraIndependentTxBody)
import qualified Sophie.Spec.Ledger.Address.Bootstrap as Sophie
import qualified Bcc.Ledger.Keys as Sophie
import qualified Sophie.Spec.Ledger.Tx as Sophie
import qualified Bcc.Ledger.Aurum as Aurum
import qualified Bcc.Ledger.Aurum.Tx as Aurum
import qualified Bcc.Ledger.Aurum.TxWitness as Aurum
import Bcc.Api.Address
import Bcc.Api.Certificate
import Bcc.Api.Eras
import Bcc.Api.HasTypeProxy
import Bcc.Api.Key
import Bcc.Api.KeysCole
import Bcc.Api.KeysSophie
import Bcc.Api.NetworkId
import Bcc.Api.SerialiseCBOR
import Bcc.Api.SerialiseTextEnvelope
import Bcc.Api.TxBody
data Tx era where
ColeTx
:: Cole.ATxAux ByteString
-> Tx ColeEra
SophieTx
:: SophieBasedEra era
-> Ledger.Tx (SophieLedgerEra era)
-> Tx era
instance Eq (Tx era) where
== :: Tx era -> Tx era -> Bool
(==) (ColeTx ATxAux ByteString
txA)
(ColeTx ATxAux ByteString
txB) = ATxAux ByteString
txA ATxAux ByteString -> ATxAux ByteString -> Bool
forall a. Eq a => a -> a -> Bool
== ATxAux ByteString
txB
(==) (SophieTx SophieBasedEra era
era Tx (SophieLedgerEra era)
txA)
(SophieTx SophieBasedEra era
_ Tx (SophieLedgerEra era)
txB) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> Tx (SophieLedgerEra era)
Tx (SophieEra StandardCrypto)
txA Tx (SophieEra StandardCrypto)
-> Tx (SophieEra StandardCrypto) -> Bool
forall a. Eq a => a -> a -> Bool
== Tx (SophieLedgerEra era)
Tx (SophieEra StandardCrypto)
txB
SophieBasedEra era
SophieBasedEraEvie -> Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Evie StandardCrypto)
txA Tx (SophieMAEra 'Evie StandardCrypto)
-> Tx (SophieMAEra 'Evie StandardCrypto) -> Bool
forall a. Eq a => a -> a -> Bool
== Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Evie StandardCrypto)
txB
SophieBasedEra era
SophieBasedEraJen -> Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Jen StandardCrypto)
txA Tx (SophieMAEra 'Jen StandardCrypto)
-> Tx (SophieMAEra 'Jen StandardCrypto) -> Bool
forall a. Eq a => a -> a -> Bool
== Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Jen StandardCrypto)
txB
SophieBasedEra era
SophieBasedEraAurum -> Tx (SophieLedgerEra era)
ValidatedTx (AurumEra StandardCrypto)
txA ValidatedTx (AurumEra StandardCrypto)
-> ValidatedTx (AurumEra StandardCrypto) -> Bool
forall a. Eq a => a -> a -> Bool
== Tx (SophieLedgerEra era)
ValidatedTx (AurumEra StandardCrypto)
txB
(==) ColeTx{} (SophieTx SophieBasedEra era
era Tx (SophieLedgerEra era)
_) = case SophieBasedEra era
era of {}
instance Show (Tx era) where
showsPrec :: Int -> Tx era -> ShowS
showsPrec Int
p (ColeTx ATxAux ByteString
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"ColeTx "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ATxAux ByteString -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 ATxAux ByteString
tx
showsPrec Int
p (SophieTx SophieBasedEra era
SophieBasedEraSophie Tx (SophieLedgerEra era)
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieTx SophieBasedEraSophie "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Tx (SophieEra StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Tx (SophieLedgerEra era)
Tx (SophieEra StandardCrypto)
tx
showsPrec Int
p (SophieTx SophieBasedEra era
SophieBasedEraEvie Tx (SophieLedgerEra era)
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieTx SophieBasedEraEvie "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Tx (SophieMAEra 'Evie StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Evie StandardCrypto)
tx
showsPrec Int
p (SophieTx SophieBasedEra era
SophieBasedEraJen Tx (SophieLedgerEra era)
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieTx SophieBasedEraJen "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Tx (SophieMAEra 'Jen StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Jen StandardCrypto)
tx
showsPrec Int
p (SophieTx SophieBasedEra era
SophieBasedEraAurum Tx (SophieLedgerEra era)
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieTx SophieBasedEraAurum "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ValidatedTx (AurumEra StandardCrypto) -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 Tx (SophieLedgerEra era)
ValidatedTx (AurumEra StandardCrypto)
tx
instance HasTypeProxy era => HasTypeProxy (Tx era) where
data AsType (Tx era) = AsTx (AsType era)
proxyToAsType :: Proxy (Tx era) -> AsType (Tx era)
proxyToAsType Proxy (Tx era)
_ = AsType era -> AsType (Tx era)
forall era. AsType era -> AsType (Tx era)
AsTx (Proxy era -> AsType era
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType (Proxy era
forall k (t :: k). Proxy t
Proxy :: Proxy era))
pattern AsColeTx :: AsType (Tx ColeEra)
pattern $bAsColeTx :: AsType (Tx ColeEra)
$mAsColeTx :: forall r. AsType (Tx ColeEra) -> (Void# -> r) -> (Void# -> r) -> r
AsColeTx = AsTx AsColeEra
{-# COMPLETE AsColeTx #-}
pattern AsSophieTx :: AsType (Tx SophieEra)
pattern $bAsSophieTx :: AsType (Tx SophieEra)
$mAsSophieTx :: forall r.
AsType (Tx SophieEra) -> (Void# -> r) -> (Void# -> r) -> r
AsSophieTx = AsTx AsSophieEra
{-# COMPLETE AsSophieTx #-}
instance IsBccEra era => SerialiseAsCBOR (Tx era) where
serialiseToCBOR :: Tx era -> ByteString
serialiseToCBOR (ColeTx ATxAux ByteString
tx) = ATxAux ByteString -> ByteString
forall t. Decoded t => t -> ByteString
CBOR.recoverBytes ATxAux ByteString
tx
serialiseToCBOR (SophieTx SophieBasedEra era
era Tx (SophieLedgerEra era)
tx) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> Tx (SophieEra StandardCrypto) -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
serialiseSophieBasedTx Tx (SophieLedgerEra era)
Tx (SophieEra StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraEvie -> Tx (SophieMAEra 'Evie StandardCrypto) -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
serialiseSophieBasedTx Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Evie StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraJen -> Tx (SophieMAEra 'Jen StandardCrypto) -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
serialiseSophieBasedTx Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Jen StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraAurum -> ValidatedTx (AurumEra StandardCrypto) -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
serialiseSophieBasedTx Tx (SophieLedgerEra era)
ValidatedTx (AurumEra StandardCrypto)
tx
deserialiseFromCBOR :: AsType (Tx era) -> ByteString -> Either DecoderError (Tx era)
deserialiseFromCBOR AsType (Tx era)
_ ByteString
bs =
case BccEra era
forall era. IsBccEra era => BccEra era
bccEra :: BccEra era of
BccEra era
ColeEra ->
ATxAux ByteString -> Tx ColeEra
ColeTx (ATxAux ByteString -> Tx ColeEra)
-> Either DecoderError (ATxAux ByteString)
-> Either DecoderError (Tx ColeEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Text
-> (forall s. Decoder s (ATxAux ByteSpan))
-> LByteString
-> Either DecoderError (ATxAux ByteString)
forall (f :: * -> *).
Functor f =>
Text
-> (forall s. Decoder s (f ByteSpan))
-> LByteString
-> Either DecoderError (f ByteString)
CBOR.decodeFullAnnotatedBytes
Text
"Cole Tx" forall s. Decoder s (ATxAux ByteSpan)
forall a s. FromCBOR a => Decoder s a
fromCBOR (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
BccEra era
SophieEra -> (Tx (SophieEra StandardCrypto) -> Tx SophieEra)
-> ByteString -> Either DecoderError (Tx SophieEra)
forall tx tx'.
FromCBOR (Annotator tx) =>
(tx -> tx') -> ByteString -> Either DecoderError tx'
deserialiseSophieBasedTx
(SophieBasedEra SophieEra
-> Tx (SophieLedgerEra SophieEra) -> Tx SophieEra
forall era.
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
SophieTx SophieBasedEra SophieEra
SophieBasedEraSophie) ByteString
bs
BccEra era
EvieEra -> (Tx (SophieMAEra 'Evie StandardCrypto) -> Tx EvieEra)
-> ByteString -> Either DecoderError (Tx EvieEra)
forall tx tx'.
FromCBOR (Annotator tx) =>
(tx -> tx') -> ByteString -> Either DecoderError tx'
deserialiseSophieBasedTx
(SophieBasedEra EvieEra
-> Tx (SophieLedgerEra EvieEra) -> Tx EvieEra
forall era.
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
SophieTx SophieBasedEra EvieEra
SophieBasedEraEvie) ByteString
bs
BccEra era
JenEra -> (Tx (SophieMAEra 'Jen StandardCrypto) -> Tx JenEra)
-> ByteString -> Either DecoderError (Tx JenEra)
forall tx tx'.
FromCBOR (Annotator tx) =>
(tx -> tx') -> ByteString -> Either DecoderError tx'
deserialiseSophieBasedTx
(SophieBasedEra JenEra -> Tx (SophieLedgerEra JenEra) -> Tx JenEra
forall era.
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
SophieTx SophieBasedEra JenEra
SophieBasedEraJen) ByteString
bs
BccEra era
AurumEra -> (ValidatedTx (AurumEra StandardCrypto) -> Tx AurumEra)
-> ByteString -> Either DecoderError (Tx AurumEra)
forall tx tx'.
FromCBOR (Annotator tx) =>
(tx -> tx') -> ByteString -> Either DecoderError tx'
deserialiseSophieBasedTx
(SophieBasedEra AurumEra
-> Tx (SophieLedgerEra AurumEra) -> Tx AurumEra
forall era.
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
SophieTx SophieBasedEra AurumEra
SophieBasedEraAurum) ByteString
bs
serialiseSophieBasedTx :: ToCBOR tx => tx -> ByteString
serialiseSophieBasedTx :: tx -> ByteString
serialiseSophieBasedTx = tx -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
CBOR.serialize'
deserialiseSophieBasedTx :: FromCBOR (CBOR.Annotator tx)
=> (tx -> tx')
-> ByteString
-> Either CBOR.DecoderError tx'
deserialiseSophieBasedTx :: (tx -> tx') -> ByteString -> Either DecoderError tx'
deserialiseSophieBasedTx tx -> tx'
mkTx ByteString
bs =
tx -> tx'
mkTx (tx -> tx') -> Either DecoderError tx -> Either DecoderError tx'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> (forall s. Decoder s (Annotator tx))
-> LByteString
-> Either DecoderError tx
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator Text
"Sophie Tx" forall s. Decoder s (Annotator tx)
forall a s. FromCBOR a => Decoder s a
fromCBOR (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
instance IsBccEra era => HasTextEnvelope (Tx era) where
textEnvelopeType :: AsType (Tx era) -> TextEnvelopeType
textEnvelopeType AsType (Tx era)
_ =
case BccEra era
forall era. IsBccEra era => BccEra era
bccEra :: BccEra era of
BccEra era
ColeEra -> TextEnvelopeType
"TxSignedCole"
BccEra era
SophieEra -> TextEnvelopeType
"TxSignedSophie"
BccEra era
EvieEra -> TextEnvelopeType
"Tx EvieEra"
BccEra era
JenEra -> TextEnvelopeType
"Tx JenEra"
BccEra era
AurumEra -> TextEnvelopeType
"Tx AurumEra"
data KeyWitness era where
ColeKeyWitness
:: Cole.TxInWitness
-> KeyWitness ColeEra
SophieBootstrapWitness
:: SophieBasedEra era
-> Sophie.BootstrapWitness StandardCrypto
-> KeyWitness era
SophieKeyWitness
:: SophieBasedEra era
-> Sophie.WitVKey Sophie.Witness StandardCrypto
-> KeyWitness era
instance Eq (KeyWitness era) where
== :: KeyWitness era -> KeyWitness era -> Bool
(==) (ColeKeyWitness TxInWitness
wA)
(ColeKeyWitness TxInWitness
wB) = TxInWitness
wA TxInWitness -> TxInWitness -> Bool
forall a. Eq a => a -> a -> Bool
== TxInWitness
wB
(==) (SophieBootstrapWitness SophieBasedEra era
era BootstrapWitness StandardCrypto
wA)
(SophieBootstrapWitness SophieBasedEra era
_ BootstrapWitness StandardCrypto
wB) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> BootstrapWitness StandardCrypto
wA BootstrapWitness StandardCrypto
-> BootstrapWitness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== BootstrapWitness StandardCrypto
wB
SophieBasedEra era
SophieBasedEraEvie -> BootstrapWitness StandardCrypto
wA BootstrapWitness StandardCrypto
-> BootstrapWitness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== BootstrapWitness StandardCrypto
wB
SophieBasedEra era
SophieBasedEraJen -> BootstrapWitness StandardCrypto
wA BootstrapWitness StandardCrypto
-> BootstrapWitness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== BootstrapWitness StandardCrypto
wB
SophieBasedEra era
SophieBasedEraAurum -> BootstrapWitness StandardCrypto
wA BootstrapWitness StandardCrypto
-> BootstrapWitness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== BootstrapWitness StandardCrypto
wB
(==) (SophieKeyWitness SophieBasedEra era
era WitVKey 'Witness StandardCrypto
wA)
(SophieKeyWitness SophieBasedEra era
_ WitVKey 'Witness StandardCrypto
wB) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> WitVKey 'Witness StandardCrypto
wA WitVKey 'Witness StandardCrypto
-> WitVKey 'Witness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== WitVKey 'Witness StandardCrypto
wB
SophieBasedEra era
SophieBasedEraEvie -> WitVKey 'Witness StandardCrypto
wA WitVKey 'Witness StandardCrypto
-> WitVKey 'Witness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== WitVKey 'Witness StandardCrypto
wB
SophieBasedEra era
SophieBasedEraJen -> WitVKey 'Witness StandardCrypto
wA WitVKey 'Witness StandardCrypto
-> WitVKey 'Witness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== WitVKey 'Witness StandardCrypto
wB
SophieBasedEra era
SophieBasedEraAurum -> WitVKey 'Witness StandardCrypto
wA WitVKey 'Witness StandardCrypto
-> WitVKey 'Witness StandardCrypto -> Bool
forall a. Eq a => a -> a -> Bool
== WitVKey 'Witness StandardCrypto
wB
(==) KeyWitness era
_ KeyWitness era
_ = Bool
False
instance Show (KeyWitness era) where
showsPrec :: Int -> KeyWitness era -> ShowS
showsPrec Int
p (ColeKeyWitness TxInWitness
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"ColeKeyWitness "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> TxInWitness -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 TxInWitness
tx
showsPrec Int
p (SophieBootstrapWitness SophieBasedEra era
SophieBasedEraSophie BootstrapWitness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieBootstrapWitness SophieBasedEraSophie "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> BootstrapWitness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 BootstrapWitness StandardCrypto
tx
showsPrec Int
p (SophieBootstrapWitness SophieBasedEra era
SophieBasedEraEvie BootstrapWitness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieBootstrapWitness SophieBasedEraEvie "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> BootstrapWitness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 BootstrapWitness StandardCrypto
tx
showsPrec Int
p (SophieBootstrapWitness SophieBasedEra era
SophieBasedEraJen BootstrapWitness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieBootstrapWitness SophieBasedEraJen "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> BootstrapWitness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 BootstrapWitness StandardCrypto
tx
showsPrec Int
p (SophieBootstrapWitness SophieBasedEra era
SophieBasedEraAurum BootstrapWitness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieBootstrapWitness SophieBasedEraAurum "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> BootstrapWitness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 BootstrapWitness StandardCrypto
tx
showsPrec Int
p (SophieKeyWitness SophieBasedEra era
SophieBasedEraSophie WitVKey 'Witness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieKeyWitness SophieBasedEraSophie "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> WitVKey 'Witness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 WitVKey 'Witness StandardCrypto
tx
showsPrec Int
p (SophieKeyWitness SophieBasedEra era
SophieBasedEraEvie WitVKey 'Witness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieKeyWitness SophieBasedEraEvie "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> WitVKey 'Witness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 WitVKey 'Witness StandardCrypto
tx
showsPrec Int
p (SophieKeyWitness SophieBasedEra era
SophieBasedEraJen WitVKey 'Witness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieKeyWitness SophieBasedEraJen "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> WitVKey 'Witness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 WitVKey 'Witness StandardCrypto
tx
showsPrec Int
p (SophieKeyWitness SophieBasedEra era
SophieBasedEraAurum WitVKey 'Witness StandardCrypto
tx) =
Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"SophieKeyWitness SophieBasedEraAurum "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> WitVKey 'Witness StandardCrypto -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 WitVKey 'Witness StandardCrypto
tx
instance HasTypeProxy era => HasTypeProxy (KeyWitness era) where
data AsType (KeyWitness era) = AsKeyWitness (AsType era)
proxyToAsType :: Proxy (KeyWitness era) -> AsType (KeyWitness era)
proxyToAsType Proxy (KeyWitness era)
_ = AsType era -> AsType (KeyWitness era)
forall era. AsType era -> AsType (KeyWitness era)
AsKeyWitness (Proxy era -> AsType era
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType (Proxy era
forall k (t :: k). Proxy t
Proxy :: Proxy era))
pattern AsColeWitness :: AsType (KeyWitness ColeEra)
pattern $bAsColeWitness :: AsType (KeyWitness ColeEra)
$mAsColeWitness :: forall r.
AsType (KeyWitness ColeEra) -> (Void# -> r) -> (Void# -> r) -> r
AsColeWitness = AsKeyWitness AsColeEra
{-# COMPLETE AsColeWitness #-}
pattern AsSophieWitness :: AsType (KeyWitness SophieEra)
pattern $bAsSophieWitness :: AsType (KeyWitness SophieEra)
$mAsSophieWitness :: forall r.
AsType (KeyWitness SophieEra) -> (Void# -> r) -> (Void# -> r) -> r
AsSophieWitness = AsKeyWitness AsSophieEra
{-# COMPLETE AsSophieWitness #-}
instance IsBccEra era => SerialiseAsCBOR (KeyWitness era) where
serialiseToCBOR :: KeyWitness era -> ByteString
serialiseToCBOR (ColeKeyWitness TxInWitness
wit) = TxInWitness -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
CBOR.serialize' TxInWitness
wit
serialiseToCBOR (SophieKeyWitness SophieBasedEra era
_era WitVKey 'Witness StandardCrypto
wit) =
Encoding -> ByteString
CBOR.serializeEncoding' (Encoding -> ByteString) -> Encoding -> ByteString
forall a b. (a -> b) -> a -> b
$
WitVKey 'Witness StandardCrypto -> Encoding
forall w. ToCBOR w => w -> Encoding
encodeSophieBasedKeyWitness WitVKey 'Witness StandardCrypto
wit
serialiseToCBOR (SophieBootstrapWitness SophieBasedEra era
_era BootstrapWitness StandardCrypto
wit) =
Encoding -> ByteString
CBOR.serializeEncoding' (Encoding -> ByteString) -> Encoding -> ByteString
forall a b. (a -> b) -> a -> b
$
BootstrapWitness StandardCrypto -> Encoding
forall w. ToCBOR w => w -> Encoding
encodeSophieBasedBootstrapWitness BootstrapWitness StandardCrypto
wit
deserialiseFromCBOR :: AsType (KeyWitness era)
-> ByteString -> Either DecoderError (KeyWitness era)
deserialiseFromCBOR AsType (KeyWitness era)
_ ByteString
bs =
case BccEra era
forall era. IsBccEra era => BccEra era
bccEra :: BccEra era of
BccEra era
ColeEra ->
TxInWitness -> KeyWitness ColeEra
ColeKeyWitness (TxInWitness -> KeyWitness ColeEra)
-> Either DecoderError TxInWitness
-> Either DecoderError (KeyWitness ColeEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either DecoderError TxInWitness
forall a. FromCBOR a => ByteString -> Either DecoderError a
CBOR.decodeFull' ByteString
bs
BccEra era
SophieEra -> SophieBasedEra SophieEra
-> ByteString -> Either DecoderError (KeyWitness SophieEra)
forall era.
SophieBasedEra era
-> ByteString -> Either DecoderError (KeyWitness era)
decodeSophieBasedWitness SophieBasedEra SophieEra
SophieBasedEraSophie ByteString
bs
BccEra era
EvieEra -> SophieBasedEra EvieEra
-> ByteString -> Either DecoderError (KeyWitness EvieEra)
forall era.
SophieBasedEra era
-> ByteString -> Either DecoderError (KeyWitness era)
decodeSophieBasedWitness SophieBasedEra EvieEra
SophieBasedEraEvie ByteString
bs
BccEra era
JenEra -> SophieBasedEra JenEra
-> ByteString -> Either DecoderError (KeyWitness JenEra)
forall era.
SophieBasedEra era
-> ByteString -> Either DecoderError (KeyWitness era)
decodeSophieBasedWitness SophieBasedEra JenEra
SophieBasedEraJen ByteString
bs
BccEra era
AurumEra -> SophieBasedEra AurumEra
-> ByteString -> Either DecoderError (KeyWitness AurumEra)
forall era.
SophieBasedEra era
-> ByteString -> Either DecoderError (KeyWitness era)
decodeSophieBasedWitness SophieBasedEra AurumEra
SophieBasedEraAurum ByteString
bs
encodeSophieBasedKeyWitness :: ToCBOR w => w -> CBOR.Encoding
encodeSophieBasedKeyWitness :: w -> Encoding
encodeSophieBasedKeyWitness w
wit =
Word -> Encoding
CBOR.encodeListLen Word
2 Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
0 Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> w -> Encoding
forall w. ToCBOR w => w -> Encoding
toCBOR w
wit
encodeSophieBasedBootstrapWitness :: ToCBOR w => w -> CBOR.Encoding
encodeSophieBasedBootstrapWitness :: w -> Encoding
encodeSophieBasedBootstrapWitness w
wit =
Word -> Encoding
CBOR.encodeListLen Word
2 Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
1 Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> w -> Encoding
forall w. ToCBOR w => w -> Encoding
toCBOR w
wit
decodeSophieBasedWitness :: forall era.
SophieBasedEra era
-> ByteString
-> Either CBOR.DecoderError (KeyWitness era)
decodeSophieBasedWitness :: SophieBasedEra era
-> ByteString -> Either DecoderError (KeyWitness era)
decodeSophieBasedWitness SophieBasedEra era
era =
Text
-> (forall s. Decoder s (Annotator (KeyWitness era)))
-> LByteString
-> Either DecoderError (KeyWitness era)
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator Text
"Sophie Witness" forall s. Decoder s (Annotator (KeyWitness era))
decode (LByteString -> Either DecoderError (KeyWitness era))
-> (ByteString -> LByteString)
-> ByteString
-> Either DecoderError (KeyWitness era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> LByteString
LBS.fromStrict
where
decode :: CBOR.Decoder s (CBOR.Annotator (KeyWitness era))
decode :: Decoder s (Annotator (KeyWitness era))
decode = do
Int -> Decoder s ()
forall s. Int -> Decoder s ()
CBOR.decodeListLenOf Int
2
Word
t <- Decoder s Word
forall s. Decoder s Word
CBOR.decodeWord
case Word
t of
Word
0 -> (Annotator (WitVKey 'Witness StandardCrypto)
-> Annotator (KeyWitness era))
-> Decoder s (Annotator (WitVKey 'Witness StandardCrypto))
-> Decoder s (Annotator (KeyWitness era))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((WitVKey 'Witness StandardCrypto -> KeyWitness era)
-> Annotator (WitVKey 'Witness StandardCrypto)
-> Annotator (KeyWitness era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
SophieKeyWitness SophieBasedEra era
era)) Decoder s (Annotator (WitVKey 'Witness StandardCrypto))
forall a s. FromCBOR a => Decoder s a
fromCBOR
Word
1 -> (Annotator (BootstrapWitness StandardCrypto)
-> Annotator (KeyWitness era))
-> Decoder s (Annotator (BootstrapWitness StandardCrypto))
-> Decoder s (Annotator (KeyWitness era))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((BootstrapWitness StandardCrypto -> KeyWitness era)
-> Annotator (BootstrapWitness StandardCrypto)
-> Annotator (KeyWitness era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
SophieBootstrapWitness SophieBasedEra era
era)) Decoder s (Annotator (BootstrapWitness StandardCrypto))
forall a s. FromCBOR a => Decoder s a
fromCBOR
Word
_ -> DecoderError -> Decoder s (Annotator (KeyWitness era))
forall e s a. Buildable e => e -> Decoder s a
CBOR.cborError (DecoderError -> Decoder s (Annotator (KeyWitness era)))
-> DecoderError -> Decoder s (Annotator (KeyWitness era))
forall a b. (a -> b) -> a -> b
$ Text -> Word8 -> DecoderError
CBOR.DecoderErrorUnknownTag
Text
"Sophie Witness" (Word -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
t)
instance IsBccEra era => HasTextEnvelope (KeyWitness era) where
textEnvelopeType :: AsType (KeyWitness era) -> TextEnvelopeType
textEnvelopeType AsType (KeyWitness era)
_ =
case BccEra era
forall era. IsBccEra era => BccEra era
bccEra :: BccEra era of
BccEra era
ColeEra -> TextEnvelopeType
"TxWitnessCole"
BccEra era
SophieEra -> TextEnvelopeType
"TxWitnessSophie"
BccEra era
EvieEra -> TextEnvelopeType
"TxWitness EvieEra"
BccEra era
JenEra -> TextEnvelopeType
"TxWitness JenEra"
BccEra era
AurumEra -> TextEnvelopeType
"TxWitness AurumEra"
pattern Tx :: TxBody era -> [KeyWitness era] -> Tx era
pattern $bTx :: TxBody era -> [KeyWitness era] -> Tx era
$mTx :: forall r era.
Tx era
-> (TxBody era -> [KeyWitness era] -> r) -> (Void# -> r) -> r
Tx txbody ws <- (getTxBodyAndWitnesses -> (txbody, ws))
where
Tx TxBody era
txbody [KeyWitness era]
ws = [KeyWitness era] -> TxBody era -> Tx era
forall era. [KeyWitness era] -> TxBody era -> Tx era
makeSignedTransaction [KeyWitness era]
ws TxBody era
txbody
{-# COMPLETE Tx #-}
getTxBodyAndWitnesses :: Tx era -> (TxBody era, [KeyWitness era])
getTxBodyAndWitnesses :: Tx era -> (TxBody era, [KeyWitness era])
getTxBodyAndWitnesses Tx era
tx = (Tx era -> TxBody era
forall era. Tx era -> TxBody era
getTxBody Tx era
tx, Tx era -> [KeyWitness era]
forall era. Tx era -> [KeyWitness era]
getTxWitnesses Tx era
tx)
getTxBody :: forall era. Tx era -> TxBody era
getTxBody :: Tx era -> TxBody era
getTxBody (ColeTx Cole.ATxAux { aTaTx :: forall a. ATxAux a -> Annotated Tx a
Cole.aTaTx = Annotated Tx ByteString
txbody }) =
Annotated Tx ByteString -> TxBody ColeEra
ColeTxBody Annotated Tx ByteString
txbody
getTxBody (SophieTx SophieBasedEra era
era Tx (SophieLedgerEra era)
tx) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> Tx (SophieEra StandardCrypto) -> TxBody era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
SophieBased ledgerera) =>
Tx ledgerera -> TxBody era
getSophieTxBody Tx (SophieLedgerEra era)
Tx (SophieEra StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraEvie -> Tx (SophieMAEra 'Evie StandardCrypto) -> TxBody era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
SophieBased ledgerera) =>
Tx ledgerera -> TxBody era
getSophieTxBody Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Evie StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraJen -> Tx (SophieMAEra 'Jen StandardCrypto) -> TxBody era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
SophieBased ledgerera) =>
Tx ledgerera -> TxBody era
getSophieTxBody Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Jen StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraAurum -> ScriptDataSupportedInEra era
-> TxScriptValiditySupportedInEra era
-> ValidatedTx (AurumEra StandardCrypto)
-> TxBody era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera) =>
ScriptDataSupportedInEra era
-> TxScriptValiditySupportedInEra era
-> ValidatedTx ledgerera
-> TxBody era
getAurumTxBody ScriptDataSupportedInEra era
ScriptDataSupportedInEra AurumEra
ScriptDataInAurumEra TxScriptValiditySupportedInEra era
TxScriptValiditySupportedInEra AurumEra
TxScriptValiditySupportedInAurumEra Tx (SophieLedgerEra era)
ValidatedTx (AurumEra StandardCrypto)
tx
where
getSophieTxBody :: forall ledgerera.
SophieLedgerEra era ~ ledgerera
=> Ledger.Witnesses ledgerera ~ Sophie.WitnessSetHKD Identity ledgerera
=> Sophie.SophieBased ledgerera
=> Sophie.Tx ledgerera
-> TxBody era
getSophieTxBody :: Tx ledgerera -> TxBody era
getSophieTxBody Sophie.Tx {
body :: forall era.
Tx era
-> (Era era, ToCBOR (AuxiliaryData era), ToCBOR (TxBody era),
ToCBOR (Witnesses era)) =>
TxBody era
Sophie.body = TxBody ledgerera
txbody,
auxiliaryData :: forall era.
Tx era
-> (Era era, ToCBOR (AuxiliaryData era), ToCBOR (TxBody era),
ToCBOR (Witnesses era)) =>
StrictMaybe (AuxiliaryData era)
Sophie.auxiliaryData = StrictMaybe (AuxiliaryData ledgerera)
txAuxiliaryData,
wits :: forall era.
Tx era
-> (Era era, ToCBOR (AuxiliaryData era), ToCBOR (TxBody era),
ToCBOR (Witnesses era)) =>
Witnesses era
Sophie.wits = Sophie.WitnessSet
_addrWits
msigWits
_bootWits
} =
SophieBasedEra era
-> TxBody (SophieLedgerEra era)
-> [Script (SophieLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (AuxiliaryData (SophieLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
SophieBasedEra era
-> TxBody (SophieLedgerEra era)
-> [Script (SophieLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (AuxiliaryData (SophieLedgerEra era))
-> TxScriptValidity era
-> TxBody era
SophieTxBody SophieBasedEra era
era TxBody ledgerera
TxBody (SophieLedgerEra era)
txbody
(Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
-> [Script ledgerera]
forall k a. Map k a -> [a]
Map.elems Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
msigWits)
TxBodyScriptData era
forall era. TxBodyScriptData era
TxBodyNoScriptData
(StrictMaybe (AuxiliaryData ledgerera)
-> Maybe (AuxiliaryData ledgerera)
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe (AuxiliaryData ledgerera)
txAuxiliaryData)
TxScriptValidity era
forall era. TxScriptValidity era
TxScriptValidityNone
getAurumTxBody :: forall ledgerera.
SophieLedgerEra era ~ ledgerera
=> ScriptDataSupportedInEra era
-> TxScriptValiditySupportedInEra era
-> Aurum.ValidatedTx ledgerera
-> TxBody era
getAurumTxBody :: ScriptDataSupportedInEra era
-> TxScriptValiditySupportedInEra era
-> ValidatedTx ledgerera
-> TxBody era
getAurumTxBody ScriptDataSupportedInEra era
scriptDataInEra TxScriptValiditySupportedInEra era
txScriptValidityInEra
Aurum.ValidatedTx {
body :: forall era. ValidatedTx era -> TxBody era
Aurum.body = TxBody ledgerera
txbody,
wits :: forall era. ValidatedTx era -> TxWitness era
Aurum.wits = Aurum.TxWitness'
Set (WitVKey 'Witness (Crypto ledgerera))
_addrWits
Set (BootstrapWitness (Crypto ledgerera))
_bootWits
Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
txscripts
TxDats ledgerera
txdats
Redeemers ledgerera
redeemers,
auxiliaryData :: forall era. ValidatedTx era -> StrictMaybe (AuxiliaryData era)
Aurum.auxiliaryData = StrictMaybe (AuxiliaryData ledgerera)
auxiliaryData,
isValid :: forall era. ValidatedTx era -> IsValid
Aurum.isValid = IsValid
isValid
} =
SophieBasedEra era
-> TxBody (SophieLedgerEra era)
-> [Script (SophieLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (AuxiliaryData (SophieLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
SophieBasedEra era
-> TxBody (SophieLedgerEra era)
-> [Script (SophieLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (AuxiliaryData (SophieLedgerEra era))
-> TxScriptValidity era
-> TxBody era
SophieTxBody SophieBasedEra era
era TxBody ledgerera
TxBody (SophieLedgerEra era)
txbody
(Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
-> [Script ledgerera]
forall k a. Map k a -> [a]
Map.elems Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
txscripts)
(ScriptDataSupportedInEra era
-> TxDats (SophieLedgerEra era)
-> Redeemers (SophieLedgerEra era)
-> TxBodyScriptData era
forall era.
ScriptDataSupportedInEra era
-> TxDats (SophieLedgerEra era)
-> Redeemers (SophieLedgerEra era)
-> TxBodyScriptData era
TxBodyScriptData ScriptDataSupportedInEra era
scriptDataInEra TxDats ledgerera
TxDats (SophieLedgerEra era)
txdats Redeemers ledgerera
Redeemers (SophieLedgerEra era)
redeemers)
(StrictMaybe (AuxiliaryData ledgerera)
-> Maybe (AuxiliaryData ledgerera)
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe (AuxiliaryData ledgerera)
auxiliaryData)
(TxScriptValiditySupportedInEra era
-> ScriptValidity -> TxScriptValidity era
forall era.
TxScriptValiditySupportedInEra era
-> ScriptValidity -> TxScriptValidity era
TxScriptValidity TxScriptValiditySupportedInEra era
txScriptValidityInEra (IsValid -> ScriptValidity
isValidToScriptValidity IsValid
isValid))
getTxWitnesses :: forall era. Tx era -> [KeyWitness era]
getTxWitnesses :: Tx era -> [KeyWitness era]
getTxWitnesses (ColeTx Cole.ATxAux { aTaWitness :: forall a. ATxAux a -> Annotated TxWitness a
Cole.aTaWitness = Annotated TxWitness ByteString
witnesses }) =
(TxInWitness -> KeyWitness ColeEra)
-> [TxInWitness] -> [KeyWitness ColeEra]
forall a b. (a -> b) -> [a] -> [b]
map TxInWitness -> KeyWitness ColeEra
ColeKeyWitness
([TxInWitness] -> [KeyWitness ColeEra])
-> (Annotated TxWitness ByteString -> [TxInWitness])
-> Annotated TxWitness ByteString
-> [KeyWitness ColeEra]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxWitness -> [TxInWitness]
forall a. Vector a -> [a]
Vector.toList
(TxWitness -> [TxInWitness])
-> (Annotated TxWitness ByteString -> TxWitness)
-> Annotated TxWitness ByteString
-> [TxInWitness]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Annotated TxWitness ByteString -> TxWitness
forall b a. Annotated b a -> b
unAnnotated
(Annotated TxWitness ByteString -> [KeyWitness ColeEra])
-> Annotated TxWitness ByteString -> [KeyWitness ColeEra]
forall a b. (a -> b) -> a -> b
$ Annotated TxWitness ByteString
witnesses
getTxWitnesses (SophieTx SophieBasedEra era
era Tx (SophieLedgerEra era)
tx) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> Tx (SophieEra StandardCrypto) -> [KeyWitness era]
forall ledgerera.
(Crypto ledgerera ~ StandardCrypto,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
ToCBOR (Witnesses ledgerera), SophieBased ledgerera) =>
Tx ledgerera -> [KeyWitness era]
getSophieTxWitnesses Tx (SophieLedgerEra era)
Tx (SophieEra StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraEvie -> Tx (SophieMAEra 'Evie StandardCrypto) -> [KeyWitness era]
forall ledgerera.
(Crypto ledgerera ~ StandardCrypto,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
ToCBOR (Witnesses ledgerera), SophieBased ledgerera) =>
Tx ledgerera -> [KeyWitness era]
getSophieTxWitnesses Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Evie StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraJen -> Tx (SophieMAEra 'Jen StandardCrypto) -> [KeyWitness era]
forall ledgerera.
(Crypto ledgerera ~ StandardCrypto,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
ToCBOR (Witnesses ledgerera), SophieBased ledgerera) =>
Tx ledgerera -> [KeyWitness era]
getSophieTxWitnesses Tx (SophieLedgerEra era)
Tx (SophieMAEra 'Jen StandardCrypto)
tx
SophieBasedEra era
SophieBasedEraAurum -> ValidatedTx (AurumEra StandardCrypto) -> [KeyWitness era]
forall ledgerera.
(Crypto ledgerera ~ StandardCrypto) =>
ValidatedTx ledgerera -> [KeyWitness era]
getAurumTxWitnesses Tx (SophieLedgerEra era)
ValidatedTx (AurumEra StandardCrypto)
tx
where
getSophieTxWitnesses :: forall ledgerera.
Ledger.Crypto ledgerera ~ StandardCrypto
=> Ledger.Witnesses ledgerera ~ Sophie.WitnessSetHKD Identity ledgerera
=> ToCBOR (Ledger.Witnesses ledgerera)
=> Sophie.SophieBased ledgerera
=> Sophie.Tx ledgerera
-> [KeyWitness era]
getSophieTxWitnesses :: Tx ledgerera -> [KeyWitness era]
getSophieTxWitnesses Sophie.Tx {
wits :: forall era.
Tx era
-> (Era era, ToCBOR (AuxiliaryData era), ToCBOR (TxBody era),
ToCBOR (Witnesses era)) =>
Witnesses era
Sophie.wits =
Sophie.WitnessSet
addrWits
_msigWits
bootWits
} =
(BootstrapWitness StandardCrypto -> KeyWitness era)
-> [BootstrapWitness StandardCrypto] -> [KeyWitness era]
forall a b. (a -> b) -> [a] -> [b]
map (SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
SophieBootstrapWitness SophieBasedEra era
era) (Set (BootstrapWitness StandardCrypto)
-> [BootstrapWitness StandardCrypto]
forall a. Set a -> [a]
Set.elems Set (BootstrapWitness StandardCrypto)
Set (BootstrapWitness (Crypto ledgerera))
bootWits)
[KeyWitness era] -> [KeyWitness era] -> [KeyWitness era]
forall a. [a] -> [a] -> [a]
++ (WitVKey 'Witness StandardCrypto -> KeyWitness era)
-> [WitVKey 'Witness StandardCrypto] -> [KeyWitness era]
forall a b. (a -> b) -> [a] -> [b]
map (SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
SophieKeyWitness SophieBasedEra era
era) (Set (WitVKey 'Witness StandardCrypto)
-> [WitVKey 'Witness StandardCrypto]
forall a. Set a -> [a]
Set.elems Set (WitVKey 'Witness StandardCrypto)
Set (WitVKey 'Witness (Crypto ledgerera))
addrWits)
getAurumTxWitnesses :: forall ledgerera.
Ledger.Crypto ledgerera ~ StandardCrypto
=> Aurum.ValidatedTx ledgerera
-> [KeyWitness era]
getAurumTxWitnesses :: ValidatedTx ledgerera -> [KeyWitness era]
getAurumTxWitnesses Aurum.ValidatedTx {
wits :: forall era. ValidatedTx era -> TxWitness era
Aurum.wits =
Aurum.TxWitness'
Set (WitVKey 'Witness (Crypto ledgerera))
addrWits
Set (BootstrapWitness (Crypto ledgerera))
bootWits
Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
_txscripts
TxDats ledgerera
_txdats
Redeemers ledgerera
_txrdmrs
} =
(BootstrapWitness StandardCrypto -> KeyWitness era)
-> [BootstrapWitness StandardCrypto] -> [KeyWitness era]
forall a b. (a -> b) -> [a] -> [b]
map (SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
SophieBootstrapWitness SophieBasedEra era
era) (Set (BootstrapWitness StandardCrypto)
-> [BootstrapWitness StandardCrypto]
forall a. Set a -> [a]
Set.elems Set (BootstrapWitness StandardCrypto)
Set (BootstrapWitness (Crypto ledgerera))
bootWits)
[KeyWitness era] -> [KeyWitness era] -> [KeyWitness era]
forall a. [a] -> [a] -> [a]
++ (WitVKey 'Witness StandardCrypto -> KeyWitness era)
-> [WitVKey 'Witness StandardCrypto] -> [KeyWitness era]
forall a b. (a -> b) -> [a] -> [b]
map (SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
SophieKeyWitness SophieBasedEra era
era) (Set (WitVKey 'Witness StandardCrypto)
-> [WitVKey 'Witness StandardCrypto]
forall a. Set a -> [a]
Set.elems Set (WitVKey 'Witness StandardCrypto)
Set (WitVKey 'Witness (Crypto ledgerera))
addrWits)
makeSignedTransaction :: forall era.
[KeyWitness era]
-> TxBody era
-> Tx era
makeSignedTransaction :: [KeyWitness era] -> TxBody era -> Tx era
makeSignedTransaction [KeyWitness era]
witnesses (ColeTxBody Annotated Tx ByteString
txbody) =
ATxAux ByteString -> Tx ColeEra
ColeTx
(ATxAux ByteString -> Tx ColeEra)
-> (TxAux -> ATxAux ByteString) -> TxAux -> Tx ColeEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxAux -> ATxAux ByteString
Cole.annotateTxAux
(TxAux -> Tx ColeEra) -> TxAux -> Tx ColeEra
forall a b. (a -> b) -> a -> b
$ Tx -> TxWitness -> TxAux
Cole.mkTxAux
(Annotated Tx ByteString -> Tx
forall b a. Annotated b a -> b
unAnnotated Annotated Tx ByteString
txbody)
([TxInWitness] -> TxWitness
forall a. [a] -> Vector a
Vector.fromList [ TxInWitness
w | ColeKeyWitness TxInWitness
w <- [KeyWitness era]
witnesses ])
makeSignedTransaction [KeyWitness era]
witnesses (SophieTxBody SophieBasedEra era
era TxBody (SophieLedgerEra era)
txbody
[Script (SophieLedgerEra era)]
txscripts
TxBodyScriptData era
txscriptdata
Maybe (AuxiliaryData (SophieLedgerEra era))
txmetadata
TxScriptValidity era
scriptValidity
) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> TxBody (SophieEra StandardCrypto) -> Tx era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Crypto ledgerera ~ StandardCrypto,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
Tx ledgerera ~ Tx ledgerera, ToCBOR (Witnesses ledgerera),
SophieBased ledgerera, ValidateScript ledgerera) =>
TxBody ledgerera -> Tx era
makeSophieSignedTransaction TxBody (SophieEra StandardCrypto)
TxBody (SophieLedgerEra era)
txbody
SophieBasedEra era
SophieBasedEraEvie -> TxBody (SophieMAEra 'Evie StandardCrypto) -> Tx era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Crypto ledgerera ~ StandardCrypto,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
Tx ledgerera ~ Tx ledgerera, ToCBOR (Witnesses ledgerera),
SophieBased ledgerera, ValidateScript ledgerera) =>
TxBody ledgerera -> Tx era
makeSophieSignedTransaction TxBody (SophieMAEra 'Evie StandardCrypto)
TxBody (SophieLedgerEra era)
txbody
SophieBasedEra era
SophieBasedEraJen -> TxBody (SophieMAEra 'Jen StandardCrypto) -> Tx era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Crypto ledgerera ~ StandardCrypto,
Witnesses ledgerera ~ WitnessSetHKD Identity ledgerera,
Tx ledgerera ~ Tx ledgerera, ToCBOR (Witnesses ledgerera),
SophieBased ledgerera, ValidateScript ledgerera) =>
TxBody ledgerera -> Tx era
makeSophieSignedTransaction TxBody (SophieMAEra 'Jen StandardCrypto)
TxBody (SophieLedgerEra era)
txbody
SophieBasedEra era
SophieBasedEraAurum -> TxBody (AurumEra StandardCrypto) -> Tx era
forall ledgerera.
(SophieLedgerEra era ~ ledgerera,
Crypto ledgerera ~ StandardCrypto,
Tx ledgerera ~ ValidatedTx ledgerera,
Script ledgerera ~ Script ledgerera, SophieBased ledgerera,
ValidateScript ledgerera) =>
TxBody ledgerera -> Tx era
makeAurumSignedTransaction TxBody (AurumEra StandardCrypto)
TxBody (SophieLedgerEra era)
txbody
where
makeSophieSignedTransaction
:: forall ledgerera.
SophieLedgerEra era ~ ledgerera
=> Ledger.Crypto ledgerera ~ StandardCrypto
=> Ledger.Witnesses ledgerera ~ Sophie.WitnessSetHKD Identity ledgerera
=> Ledger.Tx ledgerera ~ Sophie.Tx ledgerera
=> ToCBOR (Ledger.Witnesses ledgerera)
=> Sophie.SophieBased ledgerera
=> Sophie.ValidateScript ledgerera
=> Ledger.TxBody ledgerera
-> Tx era
makeSophieSignedTransaction :: TxBody ledgerera -> Tx era
makeSophieSignedTransaction TxBody ledgerera
txbody' =
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
forall era.
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
SophieTx SophieBasedEra era
era (Tx (SophieLedgerEra era) -> Tx era)
-> Tx (SophieLedgerEra era) -> Tx era
forall a b. (a -> b) -> a -> b
$
TxBody ledgerera
-> Witnesses ledgerera
-> StrictMaybe (AuxiliaryData ledgerera)
-> Tx ledgerera
forall era.
(Era era, ToCBOR (AuxiliaryData era), ToCBOR (TxBody era),
ToCBOR (Witnesses era)) =>
TxBody era
-> Witnesses era -> StrictMaybe (AuxiliaryData era) -> Tx era
Sophie.Tx
TxBody ledgerera
txbody'
(Set (WitVKey 'Witness (Crypto ledgerera))
-> Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
-> Set (BootstrapWitness (Crypto ledgerera))
-> WitnessSet ledgerera
forall era.
(Era era, AnnotatedData (Script era)) =>
Set (WitVKey 'Witness (Crypto era))
-> Map (ScriptHash (Crypto era)) (Script era)
-> Set (BootstrapWitness (Crypto era))
-> WitnessSet era
Sophie.WitnessSet
([WitVKey 'Witness StandardCrypto]
-> Set (WitVKey 'Witness StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList [ WitVKey 'Witness StandardCrypto
w | SophieKeyWitness SophieBasedEra era
_ WitVKey 'Witness StandardCrypto
w <- [KeyWitness era]
witnesses ])
([(ScriptHash StandardCrypto, Script ledgerera)]
-> Map (ScriptHash StandardCrypto) (Script ledgerera)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [ (Script ledgerera -> ScriptHash (Crypto ledgerera)
forall era.
ValidateScript era =>
Script era -> ScriptHash (Crypto era)
Ledger.hashScript @ledgerera Script ledgerera
sw, Script ledgerera
sw)
| Script ledgerera
sw <- [Script ledgerera]
[Script (SophieLedgerEra era)]
txscripts ])
([BootstrapWitness StandardCrypto]
-> Set (BootstrapWitness StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList [ BootstrapWitness StandardCrypto
w | SophieBootstrapWitness SophieBasedEra era
_ BootstrapWitness StandardCrypto
w <- [KeyWitness era]
witnesses ]))
(Maybe (AuxiliaryData ledgerera)
-> StrictMaybe (AuxiliaryData ledgerera)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (AuxiliaryData ledgerera)
Maybe (AuxiliaryData (SophieLedgerEra era))
txmetadata)
makeAurumSignedTransaction
:: forall ledgerera.
SophieLedgerEra era ~ ledgerera
=> Ledger.Crypto ledgerera ~ StandardCrypto
=> Ledger.Tx ledgerera ~ Aurum.ValidatedTx ledgerera
=> Ledger.Script ledgerera ~ Aurum.Script ledgerera
=> Sophie.SophieBased ledgerera
=> Sophie.ValidateScript ledgerera
=> Ledger.TxBody ledgerera
-> Tx era
makeAurumSignedTransaction :: TxBody ledgerera -> Tx era
makeAurumSignedTransaction TxBody ledgerera
txbody' =
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
forall era.
SophieBasedEra era -> Tx (SophieLedgerEra era) -> Tx era
SophieTx SophieBasedEra era
era (Tx (SophieLedgerEra era) -> Tx era)
-> Tx (SophieLedgerEra era) -> Tx era
forall a b. (a -> b) -> a -> b
$
TxBody ledgerera
-> TxWitness ledgerera
-> IsValid
-> StrictMaybe (AuxiliaryData ledgerera)
-> ValidatedTx ledgerera
forall era.
TxBody era
-> TxWitness era
-> IsValid
-> StrictMaybe (AuxiliaryData era)
-> ValidatedTx era
Aurum.ValidatedTx
TxBody ledgerera
txbody'
(Set (WitVKey 'Witness (Crypto ledgerera))
-> Set (BootstrapWitness (Crypto ledgerera))
-> Map (ScriptHash (Crypto ledgerera)) (Script ledgerera)
-> TxDats ledgerera
-> Redeemers ledgerera
-> TxWitness ledgerera
forall era.
(Era era, Script era ~ Script era) =>
Set (WitVKey 'Witness (Crypto era))
-> Set (BootstrapWitness (Crypto era))
-> Map (ScriptHash (Crypto era)) (Script era)
-> TxDats era
-> Redeemers era
-> TxWitness era
Aurum.TxWitness
([WitVKey 'Witness StandardCrypto]
-> Set (WitVKey 'Witness StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList [ WitVKey 'Witness StandardCrypto
w | SophieKeyWitness SophieBasedEra era
_ WitVKey 'Witness StandardCrypto
w <- [KeyWitness era]
witnesses ])
([BootstrapWitness StandardCrypto]
-> Set (BootstrapWitness StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList [ BootstrapWitness StandardCrypto
w | SophieBootstrapWitness SophieBasedEra era
_ BootstrapWitness StandardCrypto
w <- [KeyWitness era]
witnesses ])
([(ScriptHash StandardCrypto, Script ledgerera)]
-> Map (ScriptHash StandardCrypto) (Script ledgerera)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [ (Script ledgerera -> ScriptHash (Crypto ledgerera)
forall era.
ValidateScript era =>
Script era -> ScriptHash (Crypto era)
Ledger.hashScript @ledgerera Script ledgerera
Script ledgerera
sw, Script ledgerera
sw)
| Script ledgerera
sw <- [Script (SophieLedgerEra era)]
[Script ledgerera]
txscripts ])
TxDats ledgerera
datums
Redeemers ledgerera
redeemers)
(TxScriptValidity era -> IsValid
forall era. TxScriptValidity era -> IsValid
txScriptValidityToIsValid TxScriptValidity era
scriptValidity)
(Maybe (AuxiliaryData ledgerera)
-> StrictMaybe (AuxiliaryData ledgerera)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (AuxiliaryData ledgerera)
Maybe (AuxiliaryData (SophieLedgerEra era))
txmetadata)
where
(TxDats ledgerera
datums, Redeemers ledgerera
redeemers) =
case TxBodyScriptData era
txscriptdata of
TxBodyScriptData ScriptDataSupportedInEra era
_ TxDats (SophieLedgerEra era)
ds Redeemers (SophieLedgerEra era)
rs -> (TxDats ledgerera
TxDats (SophieLedgerEra era)
ds, Redeemers ledgerera
Redeemers (SophieLedgerEra era)
rs)
TxBodyScriptData era
TxBodyNoScriptData -> (TxDats ledgerera
forall a. Monoid a => a
mempty, Map RdmrPtr (Data ledgerera, ExUnits) -> Redeemers ledgerera
forall era.
Era era =>
Map RdmrPtr (Data era, ExUnits) -> Redeemers era
Aurum.Redeemers Map RdmrPtr (Data ledgerera, ExUnits)
forall a. Monoid a => a
mempty)
makeColeKeyWitness :: forall key.
IsColeKey key
=> NetworkId
-> TxBody ColeEra
-> SigningKey key
-> KeyWitness ColeEra
makeColeKeyWitness :: NetworkId -> TxBody ColeEra -> SigningKey key -> KeyWitness ColeEra
makeColeKeyWitness NetworkId
_ (SophieTxBody SophieBasedEra ColeEra
era TxBody (SophieLedgerEra ColeEra)
_ [Script (SophieLedgerEra ColeEra)]
_ TxBodyScriptData ColeEra
_ Maybe (AuxiliaryData (SophieLedgerEra ColeEra))
_ TxScriptValidity ColeEra
_) = case SophieBasedEra ColeEra
era of {}
makeColeKeyWitness NetworkId
nw (ColeTxBody Annotated Tx ByteString
txbody) =
let txhash :: Cole.Hash Cole.Tx
txhash :: Hash Tx
txhash = Annotated Tx ByteString
-> Hash (BaseType (Annotated Tx ByteString))
forall t. Decoded t => t -> Hash (BaseType t)
Cole.hashDecoded Annotated Tx ByteString
txbody
pm :: Cole.ProtocolMagicId
pm :: ProtocolMagicId
pm = NetworkId -> ProtocolMagicId
toColeProtocolMagicId NetworkId
nw
in case ColeKeyFormat key
forall key. IsColeKey key => ColeKeyFormat key
coleKeyFormat :: ColeKeyFormat key of
ColeKeyFormat key
ColeLegacyKeyFormat ->
\(ColeSigningKeyLegacy sk) -> SigningKey -> ProtocolMagicId -> Hash Tx -> KeyWitness ColeEra
witness SigningKey
sk ProtocolMagicId
pm Hash Tx
txhash
ColeKeyFormat key
ColeModernKeyFormat ->
\(ColeSigningKey sk) -> SigningKey -> ProtocolMagicId -> Hash Tx -> KeyWitness ColeEra
witness SigningKey
sk ProtocolMagicId
pm Hash Tx
txhash
where
witness :: Cole.SigningKey
-> Cole.ProtocolMagicId
-> Cole.Hash Cole.Tx
-> KeyWitness ColeEra
witness :: SigningKey -> ProtocolMagicId -> Hash Tx -> KeyWitness ColeEra
witness SigningKey
sk ProtocolMagicId
pm Hash Tx
txHash =
TxInWitness -> KeyWitness ColeEra
ColeKeyWitness (TxInWitness -> KeyWitness ColeEra)
-> TxInWitness -> KeyWitness ColeEra
forall a b. (a -> b) -> a -> b
$
VerificationKey -> TxSig -> TxInWitness
Cole.VKWitness
(SigningKey -> VerificationKey
Cole.toVerification SigningKey
sk)
(ProtocolMagicId -> SignTag -> SigningKey -> TxSigData -> TxSig
forall a.
ToCBOR a =>
ProtocolMagicId -> SignTag -> SigningKey -> a -> Signature a
Cole.sign ProtocolMagicId
pm SignTag
Cole.SignTx SigningKey
sk (Hash Tx -> TxSigData
Cole.TxSigData Hash Tx
txHash))
data WitnessNetworkIdOrColeAddress
= WitnessNetworkId !NetworkId
| WitnessColeAddress !(Address ColeAddr)
makeSophieBootstrapWitness :: forall era.
IsSophieBasedEra era
=> WitnessNetworkIdOrColeAddress
-> TxBody era
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBootstrapWitness :: WitnessNetworkIdOrColeAddress
-> TxBody era -> SigningKey ColeKey -> KeyWitness era
makeSophieBootstrapWitness WitnessNetworkIdOrColeAddress
_ ColeTxBody{} SigningKey ColeKey
_ =
case SophieBasedEra era
forall era. IsSophieBasedEra era => SophieBasedEra era
sophieBasedEra :: SophieBasedEra era of {}
makeSophieBootstrapWitness WitnessNetworkIdOrColeAddress
nwOrAddr (SophieTxBody SophieBasedEra era
era TxBody (SophieLedgerEra era)
txbody [Script (SophieLedgerEra era)]
_ TxBodyScriptData era
_ Maybe (AuxiliaryData (SophieLedgerEra era))
_ TxScriptValidity era
_) SigningKey ColeKey
sk =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie ->
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
forall era.
HashAnnotated
(TxBody (SophieLedgerEra era))
EraIndependentTxBody
StandardCrypto =>
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBasedBootstrapWitness SophieBasedEra era
era WitnessNetworkIdOrColeAddress
nwOrAddr TxBody (SophieLedgerEra era)
txbody SigningKey ColeKey
sk
SophieBasedEra era
SophieBasedEraEvie ->
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
forall era.
HashAnnotated
(TxBody (SophieLedgerEra era))
EraIndependentTxBody
StandardCrypto =>
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBasedBootstrapWitness SophieBasedEra era
era WitnessNetworkIdOrColeAddress
nwOrAddr TxBody (SophieLedgerEra era)
txbody SigningKey ColeKey
sk
SophieBasedEra era
SophieBasedEraJen ->
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
forall era.
HashAnnotated
(TxBody (SophieLedgerEra era))
EraIndependentTxBody
StandardCrypto =>
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBasedBootstrapWitness SophieBasedEra era
era WitnessNetworkIdOrColeAddress
nwOrAddr TxBody (SophieLedgerEra era)
txbody SigningKey ColeKey
sk
SophieBasedEra era
SophieBasedEraAurum ->
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
forall era.
HashAnnotated
(TxBody (SophieLedgerEra era))
EraIndependentTxBody
StandardCrypto =>
SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBasedBootstrapWitness SophieBasedEra era
era WitnessNetworkIdOrColeAddress
nwOrAddr TxBody (SophieLedgerEra era)
txbody SigningKey ColeKey
sk
makeSophieBasedBootstrapWitness :: forall era.
(Ledger.HashAnnotated
(Ledger.TxBody (SophieLedgerEra era))
Ledger.EraIndependentTxBody
StandardCrypto)
=> SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> Ledger.TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBasedBootstrapWitness :: SophieBasedEra era
-> WitnessNetworkIdOrColeAddress
-> TxBody (SophieLedgerEra era)
-> SigningKey ColeKey
-> KeyWitness era
makeSophieBasedBootstrapWitness SophieBasedEra era
era WitnessNetworkIdOrColeAddress
nwOrAddr TxBody (SophieLedgerEra era)
txbody (ColeSigningKey sk) =
SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
SophieBootstrapWitness SophieBasedEra era
era (BootstrapWitness StandardCrypto -> KeyWitness era)
-> BootstrapWitness StandardCrypto -> KeyWitness era
forall a b. (a -> b) -> a -> b
$
BootstrapWitness :: forall crypto.
Crypto crypto =>
VKey 'Witness crypto
-> SignedDSIGN crypto (Hash crypto EraIndependentTxBody)
-> ChainCode
-> ByteString
-> BootstrapWitness crypto
Sophie.BootstrapWitness {
bwKey :: VKey 'Witness StandardCrypto
Sophie.bwKey = VKey 'Witness StandardCrypto
vk,
bwSig :: SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
Sophie.bwSig = SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
signature,
bwChainCode :: ChainCode
Sophie.bwChainCode = ChainCode
chainCode,
bwAttributes :: ByteString
Sophie.bwAttributes = ByteString
attributes
}
where
(VKey 'Witness StandardCrypto
vk, ChainCode
chainCode) = VerificationKey -> (VKey 'Witness StandardCrypto, ChainCode)
forall crypto.
(DSIGN crypto ~ Ed25519DSIGN) =>
VerificationKey -> (VKey 'Witness crypto, ChainCode)
Sophie.unpackColeVKey (SigningKey -> VerificationKey
Cole.toVerification SigningKey
sk)
signature :: Sophie.SignedDSIGN StandardCrypto
(Sophie.Hash StandardCrypto Ledger.EraIndependentTxBody)
signature :: SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
signature = Hash Blake2b_256 EraIndependentTxBody
-> SophieSigningKey
-> SignedDSIGN
StandardCrypto (Hash Blake2b_256 EraIndependentTxBody)
forall tosign.
SignableRepresentation tosign =>
tosign -> SophieSigningKey -> SignedDSIGN StandardCrypto tosign
makeSophieSignature
Hash StandardCrypto EraIndependentTxBody
Hash Blake2b_256 EraIndependentTxBody
txhash
(XPrv -> SophieSigningKey
SophieExtendedSigningKey (SigningKey -> XPrv
Cole.unSigningKey SigningKey
sk))
txhash :: Sophie.Hash StandardCrypto Ledger.EraIndependentTxBody
txhash :: Hash StandardCrypto EraIndependentTxBody
txhash = SafeHash StandardCrypto EraIndependentTxBody
-> Hash StandardCrypto EraIndependentTxBody
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
Ledger.extractHash (TxBody (SophieLedgerEra era)
-> SafeHash StandardCrypto EraIndependentTxBody
forall c i x.
(HasAlgorithm c, HashAnnotated x i c) =>
x -> SafeHash c i
Ledger.hashAnnotated TxBody (SophieLedgerEra era)
txbody)
attributes :: ByteString
attributes =
Attributes AddrAttributes -> ByteString
forall tx. ToCBOR tx => tx -> ByteString
CBOR.serialize' (Attributes AddrAttributes -> ByteString)
-> Attributes AddrAttributes -> ByteString
forall a b. (a -> b) -> a -> b
$
AddrAttributes -> Attributes AddrAttributes
forall h. h -> Attributes h
Cole.mkAttributes AddrAttributes :: Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
Cole.AddrAttributes {
aaVKDerivationPath :: Maybe HDAddressPayload
Cole.aaVKDerivationPath = Maybe HDAddressPayload
derivationPath,
aaNetworkMagic :: NetworkMagic
Cole.aaNetworkMagic = NetworkMagic
networkMagic
}
eitherNwOrAddr :: Either NetworkId (Address ColeAddr)
eitherNwOrAddr :: Either NetworkId (Address ColeAddr)
eitherNwOrAddr =
case WitnessNetworkIdOrColeAddress
nwOrAddr of
WitnessNetworkId NetworkId
nw -> NetworkId -> Either NetworkId (Address ColeAddr)
forall a b. a -> Either a b
Left NetworkId
nw
WitnessColeAddress Address ColeAddr
addr -> Address ColeAddr -> Either NetworkId (Address ColeAddr)
forall a b. b -> Either a b
Right Address ColeAddr
addr
unColeAddr :: Address ColeAddr -> Cole.Address
unColeAddr :: Address ColeAddr -> Address
unColeAddr (ColeAddress Address
addr) = Address
addr
unAddrAttrs :: Address ColeAddr -> Cole.AddrAttributes
unAddrAttrs :: Address ColeAddr -> AddrAttributes
unAddrAttrs = Attributes AddrAttributes -> AddrAttributes
forall h. Attributes h -> h
Cole.attrData (Attributes AddrAttributes -> AddrAttributes)
-> (Address ColeAddr -> Attributes AddrAttributes)
-> Address ColeAddr
-> AddrAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address -> Attributes AddrAttributes
Cole.addrAttributes (Address -> Attributes AddrAttributes)
-> (Address ColeAddr -> Address)
-> Address ColeAddr
-> Attributes AddrAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address ColeAddr -> Address
unColeAddr
derivationPath :: Maybe Cole.HDAddressPayload
derivationPath :: Maybe HDAddressPayload
derivationPath =
(NetworkId -> Maybe HDAddressPayload)
-> (Address ColeAddr -> Maybe HDAddressPayload)
-> Either NetworkId (Address ColeAddr)
-> Maybe HDAddressPayload
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
(Maybe HDAddressPayload -> NetworkId -> Maybe HDAddressPayload
forall a b. a -> b -> a
const Maybe HDAddressPayload
forall a. Maybe a
Nothing)
(AddrAttributes -> Maybe HDAddressPayload
Cole.aaVKDerivationPath (AddrAttributes -> Maybe HDAddressPayload)
-> (Address ColeAddr -> AddrAttributes)
-> Address ColeAddr
-> Maybe HDAddressPayload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address ColeAddr -> AddrAttributes
unAddrAttrs)
Either NetworkId (Address ColeAddr)
eitherNwOrAddr
networkMagic :: Cole.NetworkMagic
networkMagic :: NetworkMagic
networkMagic =
(NetworkId -> NetworkMagic)
-> (Address ColeAddr -> NetworkMagic)
-> Either NetworkId (Address ColeAddr)
-> NetworkMagic
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
NetworkId -> NetworkMagic
toColeNetworkMagic
(AddrAttributes -> NetworkMagic
Cole.aaNetworkMagic (AddrAttributes -> NetworkMagic)
-> (Address ColeAddr -> AddrAttributes)
-> Address ColeAddr
-> NetworkMagic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address ColeAddr -> AddrAttributes
unAddrAttrs)
Either NetworkId (Address ColeAddr)
eitherNwOrAddr
data SophieWitnessSigningKey =
WitnessPaymentKey (SigningKey PaymentKey)
| WitnessPaymentExtendedKey (SigningKey PaymentExtendedKey)
| WitnessStakeKey (SigningKey StakeKey)
| WitnessStakeExtendedKey (SigningKey StakeExtendedKey)
| WitnessStakePoolKey (SigningKey StakePoolKey)
| WitnessGenesisKey (SigningKey GenesisKey)
| WitnessGenesisExtendedKey (SigningKey GenesisExtendedKey)
| WitnessGenesisDelegateKey (SigningKey GenesisDelegateKey)
| WitnessGenesisDelegateExtendedKey
(SigningKey GenesisDelegateExtendedKey)
| WitnessGenesisUTxOKey (SigningKey GenesisUTxOKey)
| WitnessVestedKey (SigningKey VestedKey)
| WitnessVestedExtendedKey (SigningKey VestedExtendedKey)
| WitnessVestedDelegateKey (SigningKey VestedDelegateKey)
| WitnessVestedDelegateExtendedKey
(SigningKey VestedDelegateExtendedKey)
| WitnessVestedUTxOKey (SigningKey VestedUTxOKey)
makeSophieKeyWitness :: forall era
. IsSophieBasedEra era
=> TxBody era
-> SophieWitnessSigningKey
-> KeyWitness era
makeSophieKeyWitness :: TxBody era -> SophieWitnessSigningKey -> KeyWitness era
makeSophieKeyWitness (SophieTxBody SophieBasedEra era
era TxBody (SophieLedgerEra era)
txbody [Script (SophieLedgerEra era)]
_ TxBodyScriptData era
_ Maybe (AuxiliaryData (SophieLedgerEra era))
_ TxScriptValidity era
_) =
case SophieBasedEra era
era of
SophieBasedEra era
SophieBasedEraSophie -> (SophieBased (SophieLedgerEra era),
Crypto (SophieLedgerEra era) ~ StandardCrypto) =>
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
makeSophieBasedKeyWitness TxBody (SophieLedgerEra era)
txbody
SophieBasedEra era
SophieBasedEraEvie -> (SophieBased (SophieLedgerEra era),
Crypto (SophieLedgerEra era) ~ StandardCrypto) =>
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
makeSophieBasedKeyWitness TxBody (SophieLedgerEra era)
txbody
SophieBasedEra era
SophieBasedEraJen -> (SophieBased (SophieLedgerEra era),
Crypto (SophieLedgerEra era) ~ StandardCrypto) =>
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
makeSophieBasedKeyWitness TxBody (SophieLedgerEra era)
txbody
SophieBasedEra era
SophieBasedEraAurum -> (SophieBased (SophieLedgerEra era),
Crypto (SophieLedgerEra era) ~ StandardCrypto) =>
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
makeSophieBasedKeyWitness TxBody (SophieLedgerEra era)
txbody
where
makeSophieBasedKeyWitness :: Sophie.SophieBased (SophieLedgerEra era)
=> Ledger.Crypto (SophieLedgerEra era)
~ StandardCrypto
=> Ledger.TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey
-> KeyWitness era
makeSophieBasedKeyWitness :: TxBody (SophieLedgerEra era)
-> SophieWitnessSigningKey -> KeyWitness era
makeSophieBasedKeyWitness TxBody (SophieLedgerEra era)
txbody' =
let txhash :: Sophie.Hash StandardCrypto Ledger.EraIndependentTxBody
txhash :: Hash StandardCrypto EraIndependentTxBody
txhash = SafeHash StandardCrypto EraIndependentTxBody
-> Hash StandardCrypto EraIndependentTxBody
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
Ledger.extractHash (TxBody (SophieLedgerEra era)
-> SafeHash StandardCrypto EraIndependentTxBody
forall c i x.
(HasAlgorithm c, HashAnnotated x i c) =>
x -> SafeHash c i
Ledger.hashAnnotated TxBody (SophieLedgerEra era)
txbody')
in \SophieWitnessSigningKey
wsk ->
let sk :: SophieSigningKey
sk = SophieWitnessSigningKey -> SophieSigningKey
toSophieSigningKey SophieWitnessSigningKey
wsk
vk :: VKey 'Witness StandardCrypto
vk = SophieSigningKey -> VKey 'Witness StandardCrypto
getSophieKeyWitnessVerificationKey SophieSigningKey
sk
signature :: SignedDSIGN StandardCrypto (Hash Blake2b_256 EraIndependentTxBody)
signature = Hash Blake2b_256 EraIndependentTxBody
-> SophieSigningKey
-> SignedDSIGN
StandardCrypto (Hash Blake2b_256 EraIndependentTxBody)
forall tosign.
SignableRepresentation tosign =>
tosign -> SophieSigningKey -> SignedDSIGN StandardCrypto tosign
makeSophieSignature Hash StandardCrypto EraIndependentTxBody
Hash Blake2b_256 EraIndependentTxBody
txhash SophieSigningKey
sk
in SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
forall era.
SophieBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
SophieKeyWitness SophieBasedEra era
era (WitVKey 'Witness StandardCrypto -> KeyWitness era)
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
forall a b. (a -> b) -> a -> b
$
VKey 'Witness StandardCrypto
-> SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
-> WitVKey 'Witness StandardCrypto
forall (kr :: KeyRole) crypto.
(Typeable kr, Crypto crypto) =>
VKey kr crypto
-> SignedDSIGN crypto (Hash crypto EraIndependentTxBody)
-> WitVKey kr crypto
Sophie.WitVKey VKey 'Witness StandardCrypto
vk SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
SignedDSIGN StandardCrypto (Hash Blake2b_256 EraIndependentTxBody)
signature
makeSophieKeyWitness ColeTxBody{} =
case SophieBasedEra era
forall era. IsSophieBasedEra era => SophieBasedEra era
sophieBasedEra :: SophieBasedEra era of {}
data SophieSigningKey =
SophieNormalSigningKey (Sophie.SignKeyDSIGN StandardCrypto)
| SophieExtendedSigningKey Crypto.HD.XPrv
toSophieSigningKey :: SophieWitnessSigningKey -> SophieSigningKey
toSophieSigningKey :: SophieWitnessSigningKey -> SophieSigningKey
toSophieSigningKey SophieWitnessSigningKey
key = case SophieWitnessSigningKey
key of
WitnessPaymentKey (PaymentSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessStakeKey (StakeSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessStakePoolKey (StakePoolSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessGenesisKey (GenesisSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessGenesisUTxOKey (GenesisUTxOSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessGenesisDelegateKey (GenesisDelegateSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessVestedKey (VestedSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessVestedUTxOKey (VestedUTxOSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessVestedDelegateKey (VestedDelegateSigningKey sk) -> SignKeyDSIGN StandardCrypto -> SophieSigningKey
SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessPaymentExtendedKey (PaymentExtendedSigningKey sk) ->
XPrv -> SophieSigningKey
SophieExtendedSigningKey XPrv
sk
WitnessStakeExtendedKey (StakeExtendedSigningKey sk) ->
XPrv -> SophieSigningKey
SophieExtendedSigningKey XPrv
sk
WitnessGenesisExtendedKey (GenesisExtendedSigningKey sk) ->
XPrv -> SophieSigningKey
SophieExtendedSigningKey XPrv
sk
WitnessGenesisDelegateExtendedKey (GenesisDelegateExtendedSigningKey sk) ->
XPrv -> SophieSigningKey
SophieExtendedSigningKey XPrv
sk
WitnessVestedExtendedKey (VestedExtendedSigningKey sk) ->
XPrv -> SophieSigningKey
SophieExtendedSigningKey XPrv
sk
WitnessVestedDelegateExtendedKey (VestedDelegateExtendedSigningKey sk) ->
XPrv -> SophieSigningKey
SophieExtendedSigningKey XPrv
sk
getSophieKeyWitnessVerificationKey
:: SophieSigningKey
-> Sophie.VKey Sophie.Witness StandardCrypto
getSophieKeyWitnessVerificationKey :: SophieSigningKey -> VKey 'Witness StandardCrypto
getSophieKeyWitnessVerificationKey (SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk) =
(VKey 'Payment StandardCrypto -> VKey 'Witness StandardCrypto
forall (a :: KeyRole -> * -> *) (r :: KeyRole) crypto
(r' :: KeyRole).
HasKeyRole a =>
a r crypto -> a r' crypto
Sophie.coerceKeyRole :: Sophie.VKey Sophie.Payment StandardCrypto
-> Sophie.VKey Sophie.Witness StandardCrypto)
(VKey 'Payment StandardCrypto -> VKey 'Witness StandardCrypto)
-> (SignKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto)
-> SignKeyDSIGN Ed25519DSIGN
-> VKey 'Witness StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(PaymentVerificationKey vk) -> VKey 'Payment StandardCrypto
vk)
(VerificationKey PaymentKey -> VKey 'Payment StandardCrypto)
-> (SignKeyDSIGN Ed25519DSIGN -> VerificationKey PaymentKey)
-> SignKeyDSIGN Ed25519DSIGN
-> VKey 'Payment StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SigningKey PaymentKey -> VerificationKey PaymentKey
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey
(SigningKey PaymentKey -> VerificationKey PaymentKey)
-> (SignKeyDSIGN Ed25519DSIGN -> SigningKey PaymentKey)
-> SignKeyDSIGN Ed25519DSIGN
-> VerificationKey PaymentKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SignKeyDSIGN StandardCrypto -> SigningKey PaymentKey
SignKeyDSIGN Ed25519DSIGN -> SigningKey PaymentKey
PaymentSigningKey
(SignKeyDSIGN Ed25519DSIGN -> VKey 'Witness StandardCrypto)
-> SignKeyDSIGN Ed25519DSIGN -> VKey 'Witness StandardCrypto
forall a b. (a -> b) -> a -> b
$ SignKeyDSIGN StandardCrypto
SignKeyDSIGN Ed25519DSIGN
sk
getSophieKeyWitnessVerificationKey (SophieExtendedSigningKey XPrv
sk) =
(VKey 'Payment StandardCrypto -> VKey 'Witness StandardCrypto
forall (a :: KeyRole -> * -> *) (r :: KeyRole) crypto
(r' :: KeyRole).
HasKeyRole a =>
a r crypto -> a r' crypto
Sophie.coerceKeyRole :: Sophie.VKey Sophie.Payment StandardCrypto
-> Sophie.VKey Sophie.Witness StandardCrypto)
(VKey 'Payment StandardCrypto -> VKey 'Witness StandardCrypto)
-> (XPrv -> VKey 'Payment StandardCrypto)
-> XPrv
-> VKey 'Witness StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(PaymentVerificationKey vk) -> VKey 'Payment StandardCrypto
vk)
(VerificationKey PaymentKey -> VKey 'Payment StandardCrypto)
-> (XPrv -> VerificationKey PaymentKey)
-> XPrv
-> VKey 'Payment StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VerificationKey PaymentExtendedKey -> VerificationKey PaymentKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey PaymentExtendedKey
-> VerificationKey PaymentKey)
(VerificationKey PaymentExtendedKey -> VerificationKey PaymentKey)
-> (XPrv -> VerificationKey PaymentExtendedKey)
-> XPrv
-> VerificationKey PaymentKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SigningKey PaymentExtendedKey -> VerificationKey PaymentExtendedKey
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey
(SigningKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey)
-> (XPrv -> SigningKey PaymentExtendedKey)
-> XPrv
-> VerificationKey PaymentExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey PaymentExtendedKey
PaymentExtendedSigningKey
(XPrv -> VKey 'Witness StandardCrypto)
-> XPrv -> VKey 'Witness StandardCrypto
forall a b. (a -> b) -> a -> b
$ XPrv
sk
makeSophieSignature
:: Crypto.SignableRepresentation tosign
=> tosign
-> SophieSigningKey
-> Sophie.SignedDSIGN StandardCrypto tosign
makeSophieSignature :: tosign -> SophieSigningKey -> SignedDSIGN StandardCrypto tosign
makeSophieSignature tosign
tosign (SophieNormalSigningKey SignKeyDSIGN StandardCrypto
sk) =
ContextDSIGN Ed25519DSIGN
-> tosign
-> SignKeyDSIGN Ed25519DSIGN
-> SignedDSIGN Ed25519DSIGN tosign
forall v a.
(DSIGNAlgorithm v, Signable v a) =>
ContextDSIGN v -> a -> SignKeyDSIGN v -> SignedDSIGN v a
Crypto.signedDSIGN () tosign
tosign SignKeyDSIGN StandardCrypto
SignKeyDSIGN Ed25519DSIGN
sk
makeSophieSignature tosign
tosign (SophieExtendedSigningKey XPrv
sk) =
XSignature -> SignedDSIGN StandardCrypto tosign
forall b. XSignature -> SignedDSIGN StandardCrypto b
fromXSignature (XSignature -> SignedDSIGN StandardCrypto tosign)
-> XSignature -> SignedDSIGN StandardCrypto tosign
forall a b. (a -> b) -> a -> b
$
ByteString -> XPrv -> ByteString -> XSignature
forall passPhrase msg.
(ByteArrayAccess passPhrase, ByteArrayAccess msg) =>
passPhrase -> XPrv -> msg -> XSignature
Crypto.HD.sign
ByteString
BS.empty
XPrv
sk
(tosign -> ByteString
forall a. SignableRepresentation a => a -> ByteString
Crypto.getSignableRepresentation tosign
tosign)
where
fromXSignature :: Crypto.HD.XSignature
-> Sophie.SignedDSIGN StandardCrypto b
fromXSignature :: XSignature -> SignedDSIGN StandardCrypto b
fromXSignature =
SigDSIGN Ed25519DSIGN -> SignedDSIGN Ed25519DSIGN b
forall v a. SigDSIGN v -> SignedDSIGN v a
Crypto.SignedDSIGN
(SigDSIGN Ed25519DSIGN -> SignedDSIGN Ed25519DSIGN b)
-> (XSignature -> SigDSIGN Ed25519DSIGN)
-> XSignature
-> SignedDSIGN Ed25519DSIGN b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SigDSIGN Ed25519DSIGN
-> Maybe (SigDSIGN Ed25519DSIGN) -> SigDSIGN Ed25519DSIGN
forall a. a -> Maybe a -> a
fromMaybe SigDSIGN Ed25519DSIGN
forall a. a
impossible
(Maybe (SigDSIGN Ed25519DSIGN) -> SigDSIGN Ed25519DSIGN)
-> (XSignature -> Maybe (SigDSIGN Ed25519DSIGN))
-> XSignature
-> SigDSIGN Ed25519DSIGN
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (SigDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SigDSIGN v)
Crypto.rawDeserialiseSigDSIGN
(ByteString -> Maybe (SigDSIGN Ed25519DSIGN))
-> (XSignature -> ByteString)
-> XSignature
-> Maybe (SigDSIGN Ed25519DSIGN)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XSignature -> ByteString
Crypto.HD.unXSignature
impossible :: a
impossible =
String -> a
forall a. HasCallStack => String -> a
error String
"makeSophieKeyWitnessSignature: cole and sophie signature sizes do not match"
signColeTransaction :: NetworkId
-> TxBody ColeEra
-> [SigningKey ColeKey]
-> Tx ColeEra
signColeTransaction :: NetworkId -> TxBody ColeEra -> [SigningKey ColeKey] -> Tx ColeEra
signColeTransaction NetworkId
nw TxBody ColeEra
txbody [SigningKey ColeKey]
sks =
[KeyWitness ColeEra] -> TxBody ColeEra -> Tx ColeEra
forall era. [KeyWitness era] -> TxBody era -> Tx era
makeSignedTransaction [KeyWitness ColeEra]
witnesses TxBody ColeEra
txbody
where
witnesses :: [KeyWitness ColeEra]
witnesses = (SigningKey ColeKey -> KeyWitness ColeEra)
-> [SigningKey ColeKey] -> [KeyWitness ColeEra]
forall a b. (a -> b) -> [a] -> [b]
map (NetworkId
-> TxBody ColeEra -> SigningKey ColeKey -> KeyWitness ColeEra
forall key.
IsColeKey key =>
NetworkId -> TxBody ColeEra -> SigningKey key -> KeyWitness ColeEra
makeColeKeyWitness NetworkId
nw TxBody ColeEra
txbody) [SigningKey ColeKey]
sks
signSophieTransaction :: IsSophieBasedEra era
=> TxBody era
-> [SophieWitnessSigningKey]
-> Tx era
signSophieTransaction :: TxBody era -> [SophieWitnessSigningKey] -> Tx era
signSophieTransaction TxBody era
txbody [SophieWitnessSigningKey]
sks =
[KeyWitness era] -> TxBody era -> Tx era
forall era. [KeyWitness era] -> TxBody era -> Tx era
makeSignedTransaction [KeyWitness era]
witnesses TxBody era
txbody
where
witnesses :: [KeyWitness era]
witnesses = (SophieWitnessSigningKey -> KeyWitness era)
-> [SophieWitnessSigningKey] -> [KeyWitness era]
forall a b. (a -> b) -> [a] -> [b]
map (TxBody era -> SophieWitnessSigningKey -> KeyWitness era
forall era.
IsSophieBasedEra era =>
TxBody era -> SophieWitnessSigningKey -> KeyWitness era
makeSophieKeyWitness TxBody era
txbody) [SophieWitnessSigningKey]
sks