{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
module Cardano.Api.Typed (
Byron,
Shelley,
HasTypeProxy(..),
AsType(..),
Key,
VerificationKey(..),
SigningKey(..),
getVerificationKey,
verificationKeyHash,
castVerificationKey,
castSigningKey,
generateSigningKey,
deterministicSigningKey,
deterministicSigningKeySeedSize,
Crypto.Seed,
Crypto.mkSeedFromBytes,
Crypto.readSeedFromSystemEntropy,
Hash(..),
castHash,
Address(..),
NetworkId(..),
makeByronAddress,
ByronKey,
makeShelleyAddress,
PaymentCredential(..),
StakeAddressReference(..),
PaymentKey,
PaymentExtendedKey,
StakeAddress(..),
StakeCredential(..),
makeStakeAddress,
StakeKey,
StakeExtendedKey,
TxBody(..),
TxId(..),
getTxId,
TxIn(..),
TxOut(..),
TxIx(..),
TTL,
TxFee,
Lovelace(..),
makeByronTransaction,
makeShelleyTransaction,
SlotNo(..),
TxExtraContent(..),
txExtraContentEmpty,
Certificate(..),
Tx(..),
getTxBody,
getTxWitnesses,
ShelleySigningKey,
toShelleySigningKey,
signByronTransaction,
signShelleyTransaction,
makeSignedTransaction,
Witness(..),
makeByronKeyWitness,
ShelleyWitnessSigningKey(..),
makeShelleyKeyWitness,
WitnessNetworkIdOrByronAddress (..),
makeShelleyBootstrapWitness,
makeShelleyScriptWitness,
makeShelleySignature,
getShelleyKeyWitnessVerificationKey,
transactionFee,
estimateTransactionFee,
TxMetadata (TxMetadata, TxMetadataShelley),
TxMetadataValue(..),
toShelleyMetaData,
fromShelleyMetaData,
makeTransactionMetadata,
makeStakeAddressRegistrationCertificate,
makeStakeAddressDeregistrationCertificate,
makeStakeAddressDelegationCertificate,
makeStakePoolRegistrationCertificate,
makeStakePoolRetirementCertificate,
StakePoolParameters(..),
StakePoolRelay(..),
StakePoolMetadataReference(..),
StakePoolMetadata(..),
validateAndHashStakePoolMetadata,
StakePoolMetadataValidationError(..),
Script(..),
parseScript,
parseScriptAny,
parseScriptAll,
parseScriptAtLeast,
parseScriptSig,
scriptHash,
MultiSigScript(..),
makeMultiSigScript,
SerialiseAsCBOR,
ToCBOR,
FromCBOR,
serialiseToCBOR,
deserialiseFromCBOR,
ToJSON,
FromJSON,
serialiseToJSON,
deserialiseFromJSON,
SerialiseAsBech32,
serialiseToBech32,
deserialiseFromBech32,
deserialiseAnyOfFromBech32,
Bech32DecodeError(..),
SerialiseAddress,
serialiseAddress,
deserialiseAddress,
SerialiseAsRawBytes,
serialiseToRawBytes,
deserialiseFromRawBytes,
serialiseToRawBytesHex,
deserialiseFromRawBytesHex,
HasTextEnvelope(..),
TextEnvelope,
TextEnvelopeType,
TextEnvelopeDescr,
TextEnvelopeError,
serialiseToTextEnvelope,
deserialiseFromTextEnvelope,
readFileTextEnvelope,
writeFileTextEnvelope,
readTextEnvelopeFromFile,
readTextEnvelopeOfTypeFromFile,
FromSomeType(..),
deserialiseFromTextEnvelopeAnyOf,
readFileTextEnvelopeAnyOf,
Error(..),
throwErrorAsException,
FileError(..),
connectToLocalNode,
LocalNodeConnectInfo(..),
ByronMode,
ShelleyMode,
CardanoMode,
NodeConsensusMode(..),
LocalNodeClientProtocols(..),
nullLocalNodeClientProtocols,
withNodeProtocolClient,
ChainSyncClient(..),
LocalTxSubmissionClient(..),
submitTxToNodeLocal,
LocalStateQueryClient(..),
queryNodeLocalState,
StakePoolKey,
PoolId,
KesKey,
VrfKey,
OperationalCertificate(..),
OperationalCertificateIssueCounter(..),
Shelley.KESPeriod(..),
OperationalCertIssueError(..),
issueOperationalCertificate,
GenesisKey,
GenesisExtendedKey,
GenesisDelegateKey,
GenesisDelegateExtendedKey,
GenesisUTxOKey,
genesisUTxOPseudoTxIn,
makeMIRCertificate,
makeGenesisKeyDelegationCertificate,
UpdateProposal(..),
ProtocolParametersUpdate(..),
EpochNo(..),
NetworkMagic(..),
makeShelleyUpdateProposal,
toShelleyPParamsUpdate,
toByronNetworkMagic,
toByronProtocolMagicId,
toByronRequiresNetworkMagic,
toByronLovelace,
toByronTxIn,
toByronTxId,
toByronTxOut,
toShelleyNetwork,
toShelleyPoolParams,
toNetworkMagic,
Shelley.Addr(..),
Shelley.Coin(..),
EpochSize(..),
Shelley.GenDelegPair(..),
Shelley.KeyRole (..),
Shelley.KeyHash(..),
Shelley.PParams'(..),
Shelley.PParamsUpdate,
Shelley.VerKeyVRF,
StandardShelley,
Shelley.emptyPParams,
Shelley.truncateUnitInterval,
emptyGenesisStaking,
secondsToNominalDiffTime
) where
import Prelude
import Cardano.Prelude (decodeEitherBase16)
import Data.Aeson.Encode.Pretty (encodePretty')
import Data.Bifunctor (first)
import Data.Kind (Constraint, Type)
import qualified Data.List as List
import qualified Data.List.NonEmpty as NonEmpty
import Data.Maybe
import Data.Proxy (Proxy (..))
import Data.Scientific (toBoundedInteger)
import Data.String (IsString (fromString))
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Data.Void (Void)
import Data.Word
import Numeric.Natural
import Data.IP (IPv4, IPv6)
import Network.Socket (PortNumber)
import qualified Network.URI as URI
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Base58 as Base58
import qualified Data.ByteString.Char8 as BSC
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Short as SBS
import qualified Data.Map.Lazy as Map.Lazy
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import qualified Data.Sequence.Strict as Seq
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Vector (Vector)
import qualified Data.Vector as Vector
import qualified Codec.Binary.Bech32 as Bech32
import Control.Applicative
import Control.Monad
import Control.Concurrent.STM
import Control.Exception (Exception (..), IOException, throwIO)
import Control.Monad.Trans.Except (ExceptT (..))
import Control.Monad.Trans.Except.Extra
import Control.Tracer (nullTracer)
import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), object, (.:), (.=))
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Types as Aeson
import Cardano.Binary (Annotated (..), FromCBOR (fromCBOR), ToCBOR (toCBOR), reAnnotate,
recoverBytes)
import qualified Cardano.Binary as CBOR
import qualified Cardano.Prelude as CBOR (cborError)
import qualified Shelley.Spec.Ledger.Serialization as CBOR (CBORGroup (..), decodeNullMaybe,
encodeNullMaybe)
import Cardano.Slotting.Slot (EpochNo (..), EpochSize (..), SlotNo (..))
import Ouroboros.Network.Block (Point, Tip)
import Ouroboros.Network.Magic (NetworkMagic (..))
import Ouroboros.Network.Mux (MuxMode (InitiatorMode), MuxPeer (..),
RunMiniProtocol (InitiatorProtocolOnly))
import Ouroboros.Network.NodeToClient (NetworkConnectTracers (..),
NodeToClientProtocols (..), NodeToClientVersionData (..), chainSyncPeerNull,
connectTo, foldMapVersions, localSnocket, localStateQueryPeerNull,
localTxSubmissionPeerNull, versionedNodeToClientProtocols, withIOManager)
import Ouroboros.Network.Util.ShowProxy (ShowProxy)
import Ouroboros.Consensus.Block (BlockProtocol)
import Ouroboros.Consensus.Cardano (ProtocolClient, protocolClientInfo)
import Ouroboros.Consensus.Ledger.Query (Query, ShowQuery)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx)
import Ouroboros.Consensus.Network.NodeToClient (Codecs' (..), clientCodecs)
import Ouroboros.Consensus.Node.NetworkProtocolVersion (BlockNodeToClientVersion,
SupportedNetworkProtocolVersion, supportedNodeToClientVersions)
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolClientInfo (..))
import Ouroboros.Consensus.Node.Run (SerialiseNodeToClientConstraints)
import Ouroboros.Consensus.Shelley.Node (emptyGenesisStaking)
import Ouroboros.Consensus.Util.Time (secondsToNominalDiffTime)
import Ouroboros.Consensus.Cardano.Block (CardanoBlock)
import Ouroboros.Consensus.Cardano.ByronHFC (ByronBlockHFC)
import Ouroboros.Consensus.Cardano.ShelleyHFC (ShelleyBlockHFC)
import qualified Cardano.Crypto.DSIGN.Class as Crypto
import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.KES.Class as Crypto
import qualified Cardano.Crypto.Libsodium as Crypto
import qualified Cardano.Crypto.Seed as Crypto
import qualified Cardano.Crypto.Util as Crypto
import qualified Cardano.Crypto.VRF.Class as Crypto
import qualified Cardano.Crypto.Wallet as Crypto.HD
import qualified Cardano.Crypto.Hashing as Byron
import qualified Cardano.Crypto.ProtocolMagic as Byron
import qualified Cardano.Crypto.Signing as Byron
import qualified Cardano.Chain.Common as Byron
import qualified Cardano.Chain.Genesis as Byron
import qualified Cardano.Chain.Slotting as Byron
import qualified Cardano.Chain.UTxO as Byron
import Ouroboros.Consensus.Shelley.Eras (StandardShelley)
import Ouroboros.Consensus.Shelley.Protocol.Crypto (StandardCrypto)
import qualified Cardano.Ledger.Core as Shelley (Script)
import qualified Cardano.Ledger.Crypto as Shelley (DSIGN, KES, VRF)
import qualified Shelley.Spec.Ledger.Address as Shelley
import qualified Shelley.Spec.Ledger.Address.Bootstrap as Shelley
import Shelley.Spec.Ledger.BaseTypes (maybeToStrictMaybe, strictMaybeToMaybe)
import qualified Shelley.Spec.Ledger.BaseTypes as Shelley
import qualified Shelley.Spec.Ledger.Coin as Shelley
import qualified Shelley.Spec.Ledger.Credential as Shelley
import qualified Shelley.Spec.Ledger.Genesis as Shelley
import qualified Shelley.Spec.Ledger.Keys as Shelley
import qualified Shelley.Spec.Ledger.LedgerState as Shelley
import qualified Shelley.Spec.Ledger.MetaData as Shelley
import qualified Shelley.Spec.Ledger.OCert as Shelley
import qualified Shelley.Spec.Ledger.PParams as Shelley
import qualified Shelley.Spec.Ledger.Scripts as Shelley
import qualified Shelley.Spec.Ledger.Tx as Shelley
import qualified Shelley.Spec.Ledger.TxBody as Shelley
import qualified Shelley.Spec.Ledger.UTxO as Shelley
import Shelley.Spec.Ledger.TxBody (MIRPot (..))
import Cardano.Api.Protocol.Byron (mkNodeClientProtocolByron)
import Cardano.Api.Protocol.Cardano (mkNodeClientProtocolCardano)
import Cardano.Api.Protocol.Shelley (mkNodeClientProtocolShelley)
import qualified Cardano.Api.Shelley.Serialisation.Legacy as Legacy
import qualified Cardano.Api.TextView as TextView
import Ouroboros.Network.Protocol.ChainSync.Client as ChainSync
import Ouroboros.Network.Protocol.LocalStateQuery.Client as StateQuery
import Ouroboros.Network.Protocol.LocalStateQuery.Type (AcquireFailure)
import Ouroboros.Network.Protocol.LocalTxSubmission.Client as TxSubmission
data Byron
data Shelley
class HasTypeProxy t where
data AsType t
proxyToAsType :: Proxy t -> AsType t
class (Eq (VerificationKey keyrole),
Show (VerificationKey keyrole),
SerialiseAsRawBytes (Hash keyrole),
HasTextEnvelope (VerificationKey keyrole),
HasTextEnvelope (SigningKey keyrole))
=> Key keyrole where
data VerificationKey keyrole :: Type
data SigningKey keyrole :: Type
getVerificationKey :: SigningKey keyrole -> VerificationKey keyrole
deterministicSigningKey :: AsType keyrole -> Crypto.Seed -> SigningKey keyrole
deterministicSigningKeySeedSize :: AsType keyrole -> Word
verificationKeyHash :: VerificationKey keyrole -> Hash keyrole
generateSigningKey :: Key keyrole => AsType keyrole -> IO (SigningKey keyrole)
generateSigningKey :: AsType keyrole -> IO (SigningKey keyrole)
generateSigningKey AsType keyrole
keytype = do
Seed
seed <- Word -> IO Seed
Crypto.readSeedFromSystemEntropy Word
seedSize
SigningKey keyrole -> IO (SigningKey keyrole)
forall (m :: * -> *) a. Monad m => a -> m a
return (SigningKey keyrole -> IO (SigningKey keyrole))
-> SigningKey keyrole -> IO (SigningKey keyrole)
forall a b. (a -> b) -> a -> b
$! AsType keyrole -> Seed -> SigningKey keyrole
forall keyrole.
Key keyrole =>
AsType keyrole -> Seed -> SigningKey keyrole
deterministicSigningKey AsType keyrole
keytype Seed
seed
where
seedSize :: Word
seedSize = AsType keyrole -> Word
forall keyrole. Key keyrole => AsType keyrole -> Word
deterministicSigningKeySeedSize AsType keyrole
keytype
class CastVerificationKeyRole keyroleA keyroleB where
castVerificationKey :: VerificationKey keyroleA -> VerificationKey keyroleB
class CastSigningKeyRole keyroleA keyroleB where
castSigningKey :: SigningKey keyroleA -> SigningKey keyroleB
data family Hash keyrole :: Type
class CastHash keyroleA keyroleB where
castHash :: Hash keyroleA -> Hash keyroleB
data Address era where
ByronAddress
:: Byron.Address
-> Address era
ShelleyAddress
:: Shelley.Network
-> Shelley.PaymentCredential StandardShelley
-> Shelley.StakeReference StandardShelley
-> Address Shelley
deriving instance Eq (Address Byron)
deriving instance Ord (Address Byron)
deriving instance Show (Address Byron)
deriving instance Eq (Address Shelley)
deriving instance Ord (Address Shelley)
deriving instance Show (Address Shelley)
data StakeAddress where
StakeAddress
:: Shelley.Network
-> Shelley.StakeCredential StandardShelley
-> StakeAddress
deriving (StakeAddress -> StakeAddress -> Bool
(StakeAddress -> StakeAddress -> Bool)
-> (StakeAddress -> StakeAddress -> Bool) -> Eq StakeAddress
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakeAddress -> StakeAddress -> Bool
$c/= :: StakeAddress -> StakeAddress -> Bool
== :: StakeAddress -> StakeAddress -> Bool
$c== :: StakeAddress -> StakeAddress -> Bool
Eq, Eq StakeAddress
Eq StakeAddress
-> (StakeAddress -> StakeAddress -> Ordering)
-> (StakeAddress -> StakeAddress -> Bool)
-> (StakeAddress -> StakeAddress -> Bool)
-> (StakeAddress -> StakeAddress -> Bool)
-> (StakeAddress -> StakeAddress -> Bool)
-> (StakeAddress -> StakeAddress -> StakeAddress)
-> (StakeAddress -> StakeAddress -> StakeAddress)
-> Ord StakeAddress
StakeAddress -> StakeAddress -> Bool
StakeAddress -> StakeAddress -> Ordering
StakeAddress -> StakeAddress -> StakeAddress
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: StakeAddress -> StakeAddress -> StakeAddress
$cmin :: StakeAddress -> StakeAddress -> StakeAddress
max :: StakeAddress -> StakeAddress -> StakeAddress
$cmax :: StakeAddress -> StakeAddress -> StakeAddress
>= :: StakeAddress -> StakeAddress -> Bool
$c>= :: StakeAddress -> StakeAddress -> Bool
> :: StakeAddress -> StakeAddress -> Bool
$c> :: StakeAddress -> StakeAddress -> Bool
<= :: StakeAddress -> StakeAddress -> Bool
$c<= :: StakeAddress -> StakeAddress -> Bool
< :: StakeAddress -> StakeAddress -> Bool
$c< :: StakeAddress -> StakeAddress -> Bool
compare :: StakeAddress -> StakeAddress -> Ordering
$ccompare :: StakeAddress -> StakeAddress -> Ordering
$cp1Ord :: Eq StakeAddress
Ord, Int -> StakeAddress -> ShowS
[StakeAddress] -> ShowS
StakeAddress -> String
(Int -> StakeAddress -> ShowS)
-> (StakeAddress -> String)
-> ([StakeAddress] -> ShowS)
-> Show StakeAddress
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakeAddress] -> ShowS
$cshowList :: [StakeAddress] -> ShowS
show :: StakeAddress -> String
$cshow :: StakeAddress -> String
showsPrec :: Int -> StakeAddress -> ShowS
$cshowsPrec :: Int -> StakeAddress -> ShowS
Show)
data NetworkId
= Mainnet
| Testnet !NetworkMagic
deriving (NetworkId -> NetworkId -> Bool
(NetworkId -> NetworkId -> Bool)
-> (NetworkId -> NetworkId -> Bool) -> Eq NetworkId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkId -> NetworkId -> Bool
$c/= :: NetworkId -> NetworkId -> Bool
== :: NetworkId -> NetworkId -> Bool
$c== :: NetworkId -> NetworkId -> Bool
Eq, Int -> NetworkId -> ShowS
[NetworkId] -> ShowS
NetworkId -> String
(Int -> NetworkId -> ShowS)
-> (NetworkId -> String)
-> ([NetworkId] -> ShowS)
-> Show NetworkId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkId] -> ShowS
$cshowList :: [NetworkId] -> ShowS
show :: NetworkId -> String
$cshow :: NetworkId -> String
showsPrec :: Int -> NetworkId -> ShowS
$cshowsPrec :: Int -> NetworkId -> ShowS
Show)
data PaymentCredential
= PaymentCredentialByKey (Hash PaymentKey)
| PaymentCredentialByScript (Hash Script)
deriving (PaymentCredential -> PaymentCredential -> Bool
(PaymentCredential -> PaymentCredential -> Bool)
-> (PaymentCredential -> PaymentCredential -> Bool)
-> Eq PaymentCredential
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentCredential -> PaymentCredential -> Bool
$c/= :: PaymentCredential -> PaymentCredential -> Bool
== :: PaymentCredential -> PaymentCredential -> Bool
$c== :: PaymentCredential -> PaymentCredential -> Bool
Eq, Int -> PaymentCredential -> ShowS
[PaymentCredential] -> ShowS
PaymentCredential -> String
(Int -> PaymentCredential -> ShowS)
-> (PaymentCredential -> String)
-> ([PaymentCredential] -> ShowS)
-> Show PaymentCredential
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentCredential] -> ShowS
$cshowList :: [PaymentCredential] -> ShowS
show :: PaymentCredential -> String
$cshow :: PaymentCredential -> String
showsPrec :: Int -> PaymentCredential -> ShowS
$cshowsPrec :: Int -> PaymentCredential -> ShowS
Show)
data StakeCredential
= StakeCredentialByKey (Hash StakeKey)
| StakeCredentialByScript (Hash Script)
deriving (StakeCredential -> StakeCredential -> Bool
(StakeCredential -> StakeCredential -> Bool)
-> (StakeCredential -> StakeCredential -> Bool)
-> Eq StakeCredential
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakeCredential -> StakeCredential -> Bool
$c/= :: StakeCredential -> StakeCredential -> Bool
== :: StakeCredential -> StakeCredential -> Bool
$c== :: StakeCredential -> StakeCredential -> Bool
Eq, Int -> StakeCredential -> ShowS
[StakeCredential] -> ShowS
StakeCredential -> String
(Int -> StakeCredential -> ShowS)
-> (StakeCredential -> String)
-> ([StakeCredential] -> ShowS)
-> Show StakeCredential
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakeCredential] -> ShowS
$cshowList :: [StakeCredential] -> ShowS
show :: StakeCredential -> String
$cshow :: StakeCredential -> String
showsPrec :: Int -> StakeCredential -> ShowS
$cshowsPrec :: Int -> StakeCredential -> ShowS
Show)
data StakeAddressReference
= StakeAddressByValue StakeCredential
| StakeAddressByPointer StakeAddressPointer
| NoStakeAddress
deriving (StakeAddressReference -> StakeAddressReference -> Bool
(StakeAddressReference -> StakeAddressReference -> Bool)
-> (StakeAddressReference -> StakeAddressReference -> Bool)
-> Eq StakeAddressReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakeAddressReference -> StakeAddressReference -> Bool
$c/= :: StakeAddressReference -> StakeAddressReference -> Bool
== :: StakeAddressReference -> StakeAddressReference -> Bool
$c== :: StakeAddressReference -> StakeAddressReference -> Bool
Eq, Int -> StakeAddressReference -> ShowS
[StakeAddressReference] -> ShowS
StakeAddressReference -> String
(Int -> StakeAddressReference -> ShowS)
-> (StakeAddressReference -> String)
-> ([StakeAddressReference] -> ShowS)
-> Show StakeAddressReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakeAddressReference] -> ShowS
$cshowList :: [StakeAddressReference] -> ShowS
show :: StakeAddressReference -> String
$cshow :: StakeAddressReference -> String
showsPrec :: Int -> StakeAddressReference -> ShowS
$cshowsPrec :: Int -> StakeAddressReference -> ShowS
Show)
type StakeAddressPointer = Shelley.Ptr
instance HasTypeProxy (Address Byron) where
data AsType (Address Byron) = AsByronAddress
proxyToAsType :: Proxy (Address Byron) -> AsType (Address Byron)
proxyToAsType Proxy (Address Byron)
_ = AsType (Address Byron)
AsByronAddress
instance HasTypeProxy (Address Shelley) where
data AsType (Address Shelley) = AsShelleyAddress
proxyToAsType :: Proxy (Address Shelley) -> AsType (Address Shelley)
proxyToAsType Proxy (Address Shelley)
_ = AsType (Address Shelley)
AsShelleyAddress
instance HasTypeProxy StakeAddress where
data AsType StakeAddress = AsStakeAddress
proxyToAsType :: Proxy StakeAddress -> AsType StakeAddress
proxyToAsType Proxy StakeAddress
_ = AsType StakeAddress
AsStakeAddress
instance SerialiseAsRawBytes (Address Byron) where
serialiseToRawBytes :: Address Byron -> ByteString
serialiseToRawBytes (ByronAddress Address
addr) = Address -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' Address
addr
deserialiseFromRawBytes :: AsType (Address Byron) -> ByteString -> Maybe (Address Byron)
deserialiseFromRawBytes AsType (Address Byron)
AsByronAddress ByteString
bs =
case ByteString -> Either DecoderError Address
forall a. FromCBOR a => ByteString -> Either DecoderError a
CBOR.decodeFull' ByteString
bs of
Left DecoderError
_ -> Maybe (Address Byron)
forall a. Maybe a
Nothing
Right Address
addr -> Address Byron -> Maybe (Address Byron)
forall a. a -> Maybe a
Just (Address -> Address Byron
forall era. Address -> Address era
ByronAddress Address
addr)
instance SerialiseAsRawBytes (Address Shelley) where
serialiseToRawBytes :: Address Shelley -> ByteString
serialiseToRawBytes (ByronAddress Address
addr) =
Addr Any -> ByteString
forall era. Addr era -> ByteString
Shelley.serialiseAddr
(Addr Any -> ByteString)
-> (Address -> Addr Any) -> Address -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BootstrapAddress Any -> Addr Any
forall era. BootstrapAddress era -> Addr era
Shelley.AddrBootstrap
(BootstrapAddress Any -> Addr Any)
-> (Address -> BootstrapAddress Any) -> Address -> Addr Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address -> BootstrapAddress Any
forall era. Address -> BootstrapAddress era
Shelley.BootstrapAddress
(Address -> ByteString) -> Address -> ByteString
forall a b. (a -> b) -> a -> b
$ Address
addr
serialiseToRawBytes (ShelleyAddress Network
nw PaymentCredential StandardShelley
pc StakeReference StandardShelley
scr) =
Addr StandardShelley -> ByteString
forall era. Addr era -> ByteString
Shelley.serialiseAddr (Network
-> PaymentCredential StandardShelley
-> StakeReference StandardShelley
-> Addr StandardShelley
forall era.
Network -> PaymentCredential era -> StakeReference era -> Addr era
Shelley.Addr Network
nw PaymentCredential StandardShelley
pc StakeReference StandardShelley
scr)
deserialiseFromRawBytes :: AsType (Address Shelley) -> ByteString -> Maybe (Address Shelley)
deserialiseFromRawBytes AsType (Address Shelley)
AsShelleyAddress ByteString
bs =
case ByteString -> Maybe (Addr StandardShelley)
forall era. Era era => ByteString -> Maybe (Addr era)
Shelley.deserialiseAddr ByteString
bs of
Maybe (Addr StandardShelley)
Nothing -> Maybe (Address Shelley)
forall a. Maybe a
Nothing
Just (Shelley.Addr Network
nw PaymentCredential StandardShelley
pc StakeReference StandardShelley
scr) ->
Address Shelley -> Maybe (Address Shelley)
forall a. a -> Maybe a
Just (Network
-> PaymentCredential StandardShelley
-> StakeReference StandardShelley
-> Address Shelley
ShelleyAddress Network
nw PaymentCredential StandardShelley
pc StakeReference StandardShelley
scr)
Just (Shelley.AddrBootstrap (Shelley.BootstrapAddress Address
addr)) ->
Address Shelley -> Maybe (Address Shelley)
forall a. a -> Maybe a
Just (Address -> Address Shelley
forall era. Address -> Address era
ByronAddress Address
addr)
instance SerialiseAsRawBytes StakeAddress where
serialiseToRawBytes :: StakeAddress -> ByteString
serialiseToRawBytes (StakeAddress Network
nw StakeCredential StandardShelley
sc) =
RewardAcnt StandardShelley -> ByteString
forall era. RewardAcnt era -> ByteString
Shelley.serialiseRewardAcnt (Network
-> StakeCredential StandardShelley -> RewardAcnt StandardShelley
forall era. Network -> Credential 'Staking era -> RewardAcnt era
Shelley.RewardAcnt Network
nw StakeCredential StandardShelley
sc)
deserialiseFromRawBytes :: AsType StakeAddress -> ByteString -> Maybe StakeAddress
deserialiseFromRawBytes AsType StakeAddress
AsStakeAddress ByteString
bs =
case ByteString -> Maybe (RewardAcnt StandardShelley)
forall era. Era era => ByteString -> Maybe (RewardAcnt era)
Shelley.deserialiseRewardAcnt ByteString
bs of
Maybe (RewardAcnt StandardShelley)
Nothing -> Maybe StakeAddress
forall a. Maybe a
Nothing
Just (Shelley.RewardAcnt Network
nw StakeCredential StandardShelley
sc) -> StakeAddress -> Maybe StakeAddress
forall a. a -> Maybe a
Just (Network -> StakeCredential StandardShelley -> StakeAddress
StakeAddress Network
nw StakeCredential StandardShelley
sc)
instance SerialiseAsBech32 (Address Shelley) where
bech32PrefixFor :: Address Shelley -> Text
bech32PrefixFor (ShelleyAddress Network
Shelley.Mainnet PaymentCredential StandardShelley
_ StakeReference StandardShelley
_) = Text
"addr"
bech32PrefixFor (ShelleyAddress Network
Shelley.Testnet PaymentCredential StandardShelley
_ StakeReference StandardShelley
_) = Text
"addr_test"
bech32PrefixFor (ByronAddress Address
_) = Text
"addr"
bech32PrefixesPermitted :: AsType (Address Shelley) -> [Text]
bech32PrefixesPermitted AsType (Address Shelley)
AsShelleyAddress = [Text
"addr", Text
"addr_test"]
instance SerialiseAsBech32 StakeAddress where
bech32PrefixFor :: StakeAddress -> Text
bech32PrefixFor (StakeAddress Network
Shelley.Mainnet StakeCredential StandardShelley
_) = Text
"stake"
bech32PrefixFor (StakeAddress Network
Shelley.Testnet StakeCredential StandardShelley
_) = Text
"stake_test"
bech32PrefixesPermitted :: AsType StakeAddress -> [Text]
bech32PrefixesPermitted AsType StakeAddress
AsStakeAddress = [Text
"stake", Text
"stake_test"]
instance SerialiseAddress (Address Byron) where
serialiseAddress :: Address Byron -> Text
serialiseAddress addr :: Address Byron
addr@ByronAddress{} =
ByteString -> Text
Text.decodeLatin1
(ByteString -> Text)
-> (Address Byron -> ByteString) -> Address Byron -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Alphabet -> ByteString -> ByteString
Base58.encodeBase58 Alphabet
Base58.bitcoinAlphabet
(ByteString -> ByteString)
-> (Address Byron -> ByteString) -> Address Byron -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address Byron -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytes
(Address Byron -> Text) -> Address Byron -> Text
forall a b. (a -> b) -> a -> b
$ Address Byron
addr
deserialiseAddress :: AsType (Address Byron) -> Text -> Maybe (Address Byron)
deserialiseAddress AsType (Address Byron)
AsByronAddress Text
txt = do
ByteString
bs <- Alphabet -> ByteString -> Maybe ByteString
Base58.decodeBase58 Alphabet
Base58.bitcoinAlphabet (Text -> ByteString
Text.encodeUtf8 Text
txt)
AsType (Address Byron) -> ByteString -> Maybe (Address Byron)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytes AsType (Address Byron)
AsByronAddress ByteString
bs
instance SerialiseAddress (Address Shelley) where
serialiseAddress :: Address Shelley -> Text
serialiseAddress (ByronAddress Address
addr) =
Address Byron -> Text
forall addr. SerialiseAddress addr => addr -> Text
serialiseAddress (Address -> Address Byron
forall era. Address -> Address era
ByronAddress Address
addr :: Address Byron)
serialiseAddress addr :: Address Shelley
addr@ShelleyAddress{} =
Address Shelley -> Text
forall a. SerialiseAsBech32 a => a -> Text
serialiseToBech32 Address Shelley
addr
deserialiseAddress :: AsType (Address Shelley) -> Text -> Maybe (Address Shelley)
deserialiseAddress AsType (Address Shelley)
AsShelleyAddress Text
t =
Maybe (Address Shelley)
deserialiseAsShelleyAddress
Maybe (Address Shelley)
-> Maybe (Address Shelley) -> Maybe (Address Shelley)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (Address Shelley)
deserialiseAsByronAddress
where
deserialiseAsShelleyAddress :: Maybe (Address Shelley)
deserialiseAsShelleyAddress =
(Bech32DecodeError -> Maybe (Address Shelley))
-> (Address Shelley -> Maybe (Address Shelley))
-> Either Bech32DecodeError (Address Shelley)
-> Maybe (Address Shelley)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (Address Shelley)
-> Bech32DecodeError -> Maybe (Address Shelley)
forall a b. a -> b -> a
const Maybe (Address Shelley)
forall a. Maybe a
Nothing) Address Shelley -> Maybe (Address Shelley)
forall a. a -> Maybe a
Just (Either Bech32DecodeError (Address Shelley)
-> Maybe (Address Shelley))
-> Either Bech32DecodeError (Address Shelley)
-> Maybe (Address Shelley)
forall a b. (a -> b) -> a -> b
$
AsType (Address Shelley)
-> Text -> Either Bech32DecodeError (Address Shelley)
forall a.
SerialiseAsBech32 a =>
AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 AsType (Address Shelley)
AsShelleyAddress Text
t
deserialiseAsByronAddress :: Maybe (Address Shelley)
deserialiseAsByronAddress =
Address Byron -> Address Shelley
castByronToShelleyAddress (Address Byron -> Address Shelley)
-> Maybe (Address Byron) -> Maybe (Address Shelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
AsType (Address Byron) -> Text -> Maybe (Address Byron)
forall addr.
SerialiseAddress addr =>
AsType addr -> Text -> Maybe addr
deserialiseAddress AsType (Address Byron)
AsByronAddress Text
t
castByronToShelleyAddress :: Address Byron -> Address Shelley
castByronToShelleyAddress :: Address Byron -> Address Shelley
castByronToShelleyAddress (ByronAddress Address
addr) = Address -> Address Shelley
forall era. Address -> Address era
ByronAddress Address
addr
instance SerialiseAddress StakeAddress where
serialiseAddress :: StakeAddress -> Text
serialiseAddress addr :: StakeAddress
addr@StakeAddress{} =
StakeAddress -> Text
forall a. SerialiseAsBech32 a => a -> Text
serialiseToBech32 StakeAddress
addr
deserialiseAddress :: AsType StakeAddress -> Text -> Maybe StakeAddress
deserialiseAddress AsType StakeAddress
AsStakeAddress Text
t =
(Bech32DecodeError -> Maybe StakeAddress)
-> (StakeAddress -> Maybe StakeAddress)
-> Either Bech32DecodeError StakeAddress
-> Maybe StakeAddress
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe StakeAddress -> Bech32DecodeError -> Maybe StakeAddress
forall a b. a -> b -> a
const Maybe StakeAddress
forall a. Maybe a
Nothing) StakeAddress -> Maybe StakeAddress
forall a. a -> Maybe a
Just (Either Bech32DecodeError StakeAddress -> Maybe StakeAddress)
-> Either Bech32DecodeError StakeAddress -> Maybe StakeAddress
forall a b. (a -> b) -> a -> b
$
AsType StakeAddress
-> Text -> Either Bech32DecodeError StakeAddress
forall a.
SerialiseAsBech32 a =>
AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 AsType StakeAddress
AsStakeAddress Text
t
makeByronAddress :: NetworkId
-> VerificationKey ByronKey
-> Address era
makeByronAddress :: NetworkId -> VerificationKey ByronKey -> Address era
makeByronAddress NetworkId
nw (ByronVerificationKey vk) =
Address -> Address era
forall era. Address -> Address era
ByronAddress (Address -> Address era) -> Address -> Address era
forall a b. (a -> b) -> a -> b
$
NetworkMagic -> VerificationKey -> Address
Byron.makeVerKeyAddress
(NetworkId -> NetworkMagic
toByronNetworkMagic NetworkId
nw)
VerificationKey
vk
makeShelleyAddress :: NetworkId
-> PaymentCredential
-> StakeAddressReference
-> Address Shelley
makeShelleyAddress :: NetworkId
-> PaymentCredential -> StakeAddressReference -> Address Shelley
makeShelleyAddress NetworkId
nw PaymentCredential
pc StakeAddressReference
scr =
Network
-> PaymentCredential StandardShelley
-> StakeReference StandardShelley
-> Address Shelley
ShelleyAddress
(NetworkId -> Network
toShelleyNetwork NetworkId
nw)
(PaymentCredential -> PaymentCredential StandardShelley
toShelleyPaymentCredential PaymentCredential
pc)
(StakeAddressReference -> StakeReference StandardShelley
toShelleyStakeReference StakeAddressReference
scr)
makeStakeAddress :: NetworkId
-> StakeCredential
-> StakeAddress
makeStakeAddress :: NetworkId -> StakeCredential -> StakeAddress
makeStakeAddress NetworkId
nw StakeCredential
sc =
Network -> StakeCredential StandardShelley -> StakeAddress
StakeAddress
(NetworkId -> Network
toShelleyNetwork NetworkId
nw)
(StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential StakeCredential
sc)
toByronProtocolMagicId :: NetworkId -> Byron.ProtocolMagicId
toByronProtocolMagicId :: NetworkId -> ProtocolMagicId
toByronProtocolMagicId NetworkId
Mainnet = ProtocolMagicId
Byron.mainnetProtocolMagicId
toByronProtocolMagicId (Testnet (NetworkMagic Word32
pm)) = Word32 -> ProtocolMagicId
Byron.ProtocolMagicId Word32
pm
toByronNetworkMagic :: NetworkId -> Byron.NetworkMagic
toByronNetworkMagic :: NetworkId -> NetworkMagic
toByronNetworkMagic NetworkId
Mainnet = NetworkMagic
Byron.NetworkMainOrStage
toByronNetworkMagic (Testnet (NetworkMagic Word32
nm)) = Word32 -> NetworkMagic
Byron.NetworkTestnet Word32
nm
toByronRequiresNetworkMagic :: NetworkId -> Byron.RequiresNetworkMagic
toByronRequiresNetworkMagic :: NetworkId -> RequiresNetworkMagic
toByronRequiresNetworkMagic NetworkId
Mainnet = RequiresNetworkMagic
Byron.RequiresNoMagic
toByronRequiresNetworkMagic Testnet{} = RequiresNetworkMagic
Byron.RequiresMagic
toShelleyNetwork :: NetworkId -> Shelley.Network
toShelleyNetwork :: NetworkId -> Network
toShelleyNetwork NetworkId
Mainnet = Network
Shelley.Mainnet
toShelleyNetwork (Testnet NetworkMagic
_) = Network
Shelley.Testnet
toNetworkMagic :: NetworkId -> NetworkMagic
toNetworkMagic :: NetworkId -> NetworkMagic
toNetworkMagic NetworkId
Mainnet = Word32 -> NetworkMagic
NetworkMagic (ProtocolMagicId -> Word32
Byron.unProtocolMagicId ProtocolMagicId
Byron.mainnetProtocolMagicId)
toNetworkMagic (Testnet NetworkMagic
nm) = NetworkMagic
nm
toShelleyAddr :: Address era -> Shelley.Addr StandardShelley
toShelleyAddr :: Address era -> Addr StandardShelley
toShelleyAddr (ByronAddress Address
addr) = BootstrapAddress StandardShelley -> Addr StandardShelley
forall era. BootstrapAddress era -> Addr era
Shelley.AddrBootstrap
(Address -> BootstrapAddress StandardShelley
forall era. Address -> BootstrapAddress era
Shelley.BootstrapAddress Address
addr)
toShelleyAddr (ShelleyAddress Network
nw PaymentCredential StandardShelley
pc StakeReference StandardShelley
scr) = Network
-> PaymentCredential StandardShelley
-> StakeReference StandardShelley
-> Addr StandardShelley
forall era.
Network -> PaymentCredential era -> StakeReference era -> Addr era
Shelley.Addr Network
nw PaymentCredential StandardShelley
pc StakeReference StandardShelley
scr
toShelleyStakeAddr :: StakeAddress -> Shelley.RewardAcnt StandardShelley
toShelleyStakeAddr :: StakeAddress -> RewardAcnt StandardShelley
toShelleyStakeAddr (StakeAddress Network
nw StakeCredential StandardShelley
sc) =
RewardAcnt :: forall era. Network -> Credential 'Staking era -> RewardAcnt era
Shelley.RewardAcnt {
getRwdNetwork :: Network
Shelley.getRwdNetwork = Network
nw,
getRwdCred :: StakeCredential StandardShelley
Shelley.getRwdCred = StakeCredential StandardShelley
sc
}
toShelleyPaymentCredential :: PaymentCredential
-> Shelley.PaymentCredential StandardShelley
toShelleyPaymentCredential :: PaymentCredential -> PaymentCredential StandardShelley
toShelleyPaymentCredential (PaymentCredentialByKey (PaymentKeyHash kh)) =
KeyHash 'Payment (Crypto StandardShelley)
-> PaymentCredential StandardShelley
forall (kr :: KeyRole) era.
KeyHash kr (Crypto era) -> Credential kr era
Shelley.KeyHashObj KeyHash 'Payment StandardCrypto
KeyHash 'Payment (Crypto StandardShelley)
kh
toShelleyPaymentCredential (PaymentCredentialByScript (ScriptHash sh)) =
ScriptHash StandardShelley -> PaymentCredential StandardShelley
forall (kr :: KeyRole) era. ScriptHash era -> Credential kr era
Shelley.ScriptHashObj ScriptHash StandardShelley
sh
toShelleyStakeCredential :: StakeCredential
-> Shelley.StakeCredential StandardShelley
toShelleyStakeCredential :: StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential (StakeCredentialByKey (StakeKeyHash kh)) =
KeyHash 'Staking (Crypto StandardShelley)
-> StakeCredential StandardShelley
forall (kr :: KeyRole) era.
KeyHash kr (Crypto era) -> Credential kr era
Shelley.KeyHashObj KeyHash 'Staking StandardCrypto
KeyHash 'Staking (Crypto StandardShelley)
kh
toShelleyStakeCredential (StakeCredentialByScript (ScriptHash kh)) =
ScriptHash StandardShelley -> StakeCredential StandardShelley
forall (kr :: KeyRole) era. ScriptHash era -> Credential kr era
Shelley.ScriptHashObj ScriptHash StandardShelley
kh
toShelleyStakeReference :: StakeAddressReference
-> Shelley.StakeReference StandardShelley
toShelleyStakeReference :: StakeAddressReference -> StakeReference StandardShelley
toShelleyStakeReference (StakeAddressByValue StakeCredential
stakecred) =
StakeCredential StandardShelley -> StakeReference StandardShelley
forall era. StakeCredential era -> StakeReference era
Shelley.StakeRefBase (StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential StakeCredential
stakecred)
toShelleyStakeReference (StakeAddressByPointer StakeAddressPointer
ptr) =
StakeAddressPointer -> StakeReference StandardShelley
forall era. StakeAddressPointer -> StakeReference era
Shelley.StakeRefPtr StakeAddressPointer
ptr
toShelleyStakeReference StakeAddressReference
NoStakeAddress =
StakeReference StandardShelley
forall era. StakeReference era
Shelley.StakeRefNull
newtype TxId = TxId (Shelley.Hash StandardCrypto ())
deriving stock (TxId -> TxId -> Bool
(TxId -> TxId -> Bool) -> (TxId -> TxId -> Bool) -> Eq TxId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxId -> TxId -> Bool
$c/= :: TxId -> TxId -> Bool
== :: TxId -> TxId -> Bool
$c== :: TxId -> TxId -> Bool
Eq, Eq TxId
Eq TxId
-> (TxId -> TxId -> Ordering)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> TxId)
-> (TxId -> TxId -> TxId)
-> Ord TxId
TxId -> TxId -> Bool
TxId -> TxId -> Ordering
TxId -> TxId -> TxId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TxId -> TxId -> TxId
$cmin :: TxId -> TxId -> TxId
max :: TxId -> TxId -> TxId
$cmax :: TxId -> TxId -> TxId
>= :: TxId -> TxId -> Bool
$c>= :: TxId -> TxId -> Bool
> :: TxId -> TxId -> Bool
$c> :: TxId -> TxId -> Bool
<= :: TxId -> TxId -> Bool
$c<= :: TxId -> TxId -> Bool
< :: TxId -> TxId -> Bool
$c< :: TxId -> TxId -> Bool
compare :: TxId -> TxId -> Ordering
$ccompare :: TxId -> TxId -> Ordering
$cp1Ord :: Eq TxId
Ord, Int -> TxId -> ShowS
[TxId] -> ShowS
TxId -> String
(Int -> TxId -> ShowS)
-> (TxId -> String) -> ([TxId] -> ShowS) -> Show TxId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxId] -> ShowS
$cshowList :: [TxId] -> ShowS
show :: TxId -> String
$cshow :: TxId -> String
showsPrec :: Int -> TxId -> ShowS
$cshowsPrec :: Int -> TxId -> ShowS
Show)
deriving newtype (String -> TxId
(String -> TxId) -> IsString TxId
forall a. (String -> a) -> IsString a
fromString :: String -> TxId
$cfromString :: String -> TxId
IsString)
instance HasTypeProxy TxId where
data AsType TxId = AsTxId
proxyToAsType :: Proxy TxId -> AsType TxId
proxyToAsType Proxy TxId
_ = AsType TxId
AsTxId
instance SerialiseAsRawBytes TxId where
serialiseToRawBytes :: TxId -> ByteString
serialiseToRawBytes (TxId Hash StandardCrypto ()
h) = Hash Blake2b_256 () -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 ()
Hash StandardCrypto ()
h
deserialiseFromRawBytes :: AsType TxId -> ByteString -> Maybe TxId
deserialiseFromRawBytes AsType TxId
AsTxId ByteString
bs = Hash Blake2b_256 () -> TxId
Hash StandardCrypto () -> TxId
TxId (Hash Blake2b_256 () -> TxId)
-> Maybe (Hash Blake2b_256 ()) -> Maybe TxId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_256 ())
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
toByronTxId :: TxId -> Byron.TxId
toByronTxId :: TxId -> TxId
toByronTxId (TxId Hash StandardCrypto ()
h) =
ByteString -> TxId
forall a. ByteString -> Hash a
Byron.unsafeHashFromBytes (Hash Blake2b_256 () -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 ()
Hash StandardCrypto ()
h)
toShelleyTxId :: TxId -> Shelley.TxId StandardShelley
toShelleyTxId :: TxId -> TxId StandardShelley
toShelleyTxId (TxId Hash StandardCrypto ()
h) =
Hash (Crypto StandardShelley) EraIndependentTxBody
-> TxId StandardShelley
forall era. Hash (Crypto era) EraIndependentTxBody -> TxId era
Shelley.TxId (Hash Blake2b_256 () -> Hash Blake2b_256 EraIndependentTxBody
forall h a b. Hash h a -> Hash h b
Crypto.castHash Hash Blake2b_256 ()
Hash StandardCrypto ()
h)
getTxId :: TxBody era -> TxId
getTxId :: TxBody era -> TxId
getTxId (ByronTxBody Annotated Tx ByteString
tx) =
Hash Blake2b_256 () -> TxId
Hash StandardCrypto () -> TxId
TxId
(Hash Blake2b_256 () -> TxId)
-> (Annotated Tx ByteString -> Hash Blake2b_256 ())
-> Annotated Tx ByteString
-> TxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShortByteString -> Hash Blake2b_256 ()
forall h a. ShortByteString -> Hash h a
Crypto.UnsafeHash
(ShortByteString -> Hash Blake2b_256 ())
-> (Annotated Tx ByteString -> ShortByteString)
-> Annotated Tx ByteString
-> Hash Blake2b_256 ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ShortByteString
SBS.toShort
(ByteString -> ShortByteString)
-> (Annotated Tx ByteString -> ByteString)
-> Annotated Tx ByteString
-> ShortByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Annotated Tx ByteString -> ByteString
forall t. Decoded t => t -> ByteString
recoverBytes
(Annotated Tx ByteString -> TxId)
-> Annotated Tx ByteString -> TxId
forall a b. (a -> b) -> a -> b
$ Annotated Tx ByteString
tx
getTxId (ShelleyTxBody TxBody StandardShelley
tx Maybe MetaData
_) =
Hash Blake2b_256 () -> TxId
Hash StandardCrypto () -> TxId
TxId
(Hash Blake2b_256 () -> TxId)
-> (TxBody StandardShelley -> Hash Blake2b_256 ())
-> TxBody StandardShelley
-> TxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_256 EraIndependentTxBody -> Hash Blake2b_256 ()
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_256 EraIndependentTxBody -> Hash Blake2b_256 ())
-> (TxBody StandardShelley
-> Hash Blake2b_256 EraIndependentTxBody)
-> TxBody StandardShelley
-> Hash Blake2b_256 ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(Shelley.TxId Hash (Crypto StandardShelley) EraIndependentTxBody
txhash) -> Hash Blake2b_256 EraIndependentTxBody
Hash (Crypto StandardShelley) EraIndependentTxBody
txhash)
(TxId StandardShelley -> Hash Blake2b_256 EraIndependentTxBody)
-> (TxBody StandardShelley -> TxId StandardShelley)
-> TxBody StandardShelley
-> Hash Blake2b_256 EraIndependentTxBody
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxBodyConstraints StandardShelley =>
TxBody StandardShelley -> TxId StandardShelley
forall era. TxBodyConstraints era => TxBody era -> TxId era
Shelley.txid @StandardShelley
(TxBody StandardShelley -> TxId) -> TxBody StandardShelley -> TxId
forall a b. (a -> b) -> a -> b
$ TxBody StandardShelley
tx
data TxIn = TxIn TxId TxIx
deriving instance Eq TxIn
deriving instance Show TxIn
newtype TxIx = TxIx Word
deriving stock (TxIx -> TxIx -> Bool
(TxIx -> TxIx -> Bool) -> (TxIx -> TxIx -> Bool) -> Eq TxIx
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxIx -> TxIx -> Bool
$c/= :: TxIx -> TxIx -> Bool
== :: TxIx -> TxIx -> Bool
$c== :: TxIx -> TxIx -> Bool
Eq, Eq TxIx
Eq TxIx
-> (TxIx -> TxIx -> Ordering)
-> (TxIx -> TxIx -> Bool)
-> (TxIx -> TxIx -> Bool)
-> (TxIx -> TxIx -> Bool)
-> (TxIx -> TxIx -> Bool)
-> (TxIx -> TxIx -> TxIx)
-> (TxIx -> TxIx -> TxIx)
-> Ord TxIx
TxIx -> TxIx -> Bool
TxIx -> TxIx -> Ordering
TxIx -> TxIx -> TxIx
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TxIx -> TxIx -> TxIx
$cmin :: TxIx -> TxIx -> TxIx
max :: TxIx -> TxIx -> TxIx
$cmax :: TxIx -> TxIx -> TxIx
>= :: TxIx -> TxIx -> Bool
$c>= :: TxIx -> TxIx -> Bool
> :: TxIx -> TxIx -> Bool
$c> :: TxIx -> TxIx -> Bool
<= :: TxIx -> TxIx -> Bool
$c<= :: TxIx -> TxIx -> Bool
< :: TxIx -> TxIx -> Bool
$c< :: TxIx -> TxIx -> Bool
compare :: TxIx -> TxIx -> Ordering
$ccompare :: TxIx -> TxIx -> Ordering
$cp1Ord :: Eq TxIx
Ord, Int -> TxIx -> ShowS
[TxIx] -> ShowS
TxIx -> String
(Int -> TxIx -> ShowS)
-> (TxIx -> String) -> ([TxIx] -> ShowS) -> Show TxIx
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxIx] -> ShowS
$cshowList :: [TxIx] -> ShowS
show :: TxIx -> String
$cshow :: TxIx -> String
showsPrec :: Int -> TxIx -> ShowS
$cshowsPrec :: Int -> TxIx -> ShowS
Show)
deriving newtype (Int -> TxIx
TxIx -> Int
TxIx -> [TxIx]
TxIx -> TxIx
TxIx -> TxIx -> [TxIx]
TxIx -> TxIx -> TxIx -> [TxIx]
(TxIx -> TxIx)
-> (TxIx -> TxIx)
-> (Int -> TxIx)
-> (TxIx -> Int)
-> (TxIx -> [TxIx])
-> (TxIx -> TxIx -> [TxIx])
-> (TxIx -> TxIx -> [TxIx])
-> (TxIx -> TxIx -> TxIx -> [TxIx])
-> Enum TxIx
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: TxIx -> TxIx -> TxIx -> [TxIx]
$cenumFromThenTo :: TxIx -> TxIx -> TxIx -> [TxIx]
enumFromTo :: TxIx -> TxIx -> [TxIx]
$cenumFromTo :: TxIx -> TxIx -> [TxIx]
enumFromThen :: TxIx -> TxIx -> [TxIx]
$cenumFromThen :: TxIx -> TxIx -> [TxIx]
enumFrom :: TxIx -> [TxIx]
$cenumFrom :: TxIx -> [TxIx]
fromEnum :: TxIx -> Int
$cfromEnum :: TxIx -> Int
toEnum :: Int -> TxIx
$ctoEnum :: Int -> TxIx
pred :: TxIx -> TxIx
$cpred :: TxIx -> TxIx
succ :: TxIx -> TxIx
$csucc :: TxIx -> TxIx
Enum)
data TxOut era = TxOut (Address era) Lovelace
deriving instance Eq (TxOut Byron)
deriving instance Eq (TxOut Shelley)
deriving instance Show (TxOut Byron)
deriving instance Show (TxOut Shelley)
newtype Lovelace = Lovelace Integer
deriving (Lovelace -> Lovelace -> Bool
(Lovelace -> Lovelace -> Bool)
-> (Lovelace -> Lovelace -> Bool) -> Eq Lovelace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Lovelace -> Lovelace -> Bool
$c/= :: Lovelace -> Lovelace -> Bool
== :: Lovelace -> Lovelace -> Bool
$c== :: Lovelace -> Lovelace -> Bool
Eq, Eq Lovelace
Eq Lovelace
-> (Lovelace -> Lovelace -> Ordering)
-> (Lovelace -> Lovelace -> Bool)
-> (Lovelace -> Lovelace -> Bool)
-> (Lovelace -> Lovelace -> Bool)
-> (Lovelace -> Lovelace -> Bool)
-> (Lovelace -> Lovelace -> Lovelace)
-> (Lovelace -> Lovelace -> Lovelace)
-> Ord Lovelace
Lovelace -> Lovelace -> Bool
Lovelace -> Lovelace -> Ordering
Lovelace -> Lovelace -> Lovelace
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Lovelace -> Lovelace -> Lovelace
$cmin :: Lovelace -> Lovelace -> Lovelace
max :: Lovelace -> Lovelace -> Lovelace
$cmax :: Lovelace -> Lovelace -> Lovelace
>= :: Lovelace -> Lovelace -> Bool
$c>= :: Lovelace -> Lovelace -> Bool
> :: Lovelace -> Lovelace -> Bool
$c> :: Lovelace -> Lovelace -> Bool
<= :: Lovelace -> Lovelace -> Bool
$c<= :: Lovelace -> Lovelace -> Bool
< :: Lovelace -> Lovelace -> Bool
$c< :: Lovelace -> Lovelace -> Bool
compare :: Lovelace -> Lovelace -> Ordering
$ccompare :: Lovelace -> Lovelace -> Ordering
$cp1Ord :: Eq Lovelace
Ord, Int -> Lovelace
Lovelace -> Int
Lovelace -> [Lovelace]
Lovelace -> Lovelace
Lovelace -> Lovelace -> [Lovelace]
Lovelace -> Lovelace -> Lovelace -> [Lovelace]
(Lovelace -> Lovelace)
-> (Lovelace -> Lovelace)
-> (Int -> Lovelace)
-> (Lovelace -> Int)
-> (Lovelace -> [Lovelace])
-> (Lovelace -> Lovelace -> [Lovelace])
-> (Lovelace -> Lovelace -> [Lovelace])
-> (Lovelace -> Lovelace -> Lovelace -> [Lovelace])
-> Enum Lovelace
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Lovelace -> Lovelace -> Lovelace -> [Lovelace]
$cenumFromThenTo :: Lovelace -> Lovelace -> Lovelace -> [Lovelace]
enumFromTo :: Lovelace -> Lovelace -> [Lovelace]
$cenumFromTo :: Lovelace -> Lovelace -> [Lovelace]
enumFromThen :: Lovelace -> Lovelace -> [Lovelace]
$cenumFromThen :: Lovelace -> Lovelace -> [Lovelace]
enumFrom :: Lovelace -> [Lovelace]
$cenumFrom :: Lovelace -> [Lovelace]
fromEnum :: Lovelace -> Int
$cfromEnum :: Lovelace -> Int
toEnum :: Int -> Lovelace
$ctoEnum :: Int -> Lovelace
pred :: Lovelace -> Lovelace
$cpred :: Lovelace -> Lovelace
succ :: Lovelace -> Lovelace
$csucc :: Lovelace -> Lovelace
Enum, Int -> Lovelace -> ShowS
[Lovelace] -> ShowS
Lovelace -> String
(Int -> Lovelace -> ShowS)
-> (Lovelace -> String) -> ([Lovelace] -> ShowS) -> Show Lovelace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lovelace] -> ShowS
$cshowList :: [Lovelace] -> ShowS
show :: Lovelace -> String
$cshow :: Lovelace -> String
showsPrec :: Int -> Lovelace -> ShowS
$cshowsPrec :: Int -> Lovelace -> ShowS
Show)
toByronTxIn :: TxIn -> Byron.TxIn
toByronTxIn :: TxIn -> TxIn
toByronTxIn (TxIn TxId
txid (TxIx Word
txix)) =
TxId -> Word32 -> TxIn
Byron.TxInUtxo (TxId -> TxId
toByronTxId TxId
txid) (Word -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
txix)
toByronTxOut :: TxOut Byron -> Maybe Byron.TxOut
toByronTxOut :: TxOut Byron -> Maybe TxOut
toByronTxOut (TxOut (ByronAddress Address
addr) Lovelace
value) =
Address -> Lovelace -> TxOut
Byron.TxOut Address
addr (Lovelace -> TxOut) -> Maybe Lovelace -> Maybe TxOut
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> Maybe Lovelace
toByronLovelace Lovelace
value
toByronLovelace :: Lovelace -> Maybe Byron.Lovelace
toByronLovelace :: Lovelace -> Maybe Lovelace
toByronLovelace (Lovelace Integer
x) =
case Integer -> Either LovelaceError Lovelace
Byron.integerToLovelace Integer
x of
Left LovelaceError
_ -> Maybe Lovelace
forall a. Maybe a
Nothing
Right Lovelace
x' -> Lovelace -> Maybe Lovelace
forall a. a -> Maybe a
Just Lovelace
x'
toShelleyTxIn :: TxIn -> Shelley.TxIn StandardShelley
toShelleyTxIn :: TxIn -> TxIn StandardShelley
toShelleyTxIn (TxIn TxId
txid (TxIx Word
txix)) =
TxId StandardShelley -> Natural -> TxIn StandardShelley
forall era. Era era => TxId era -> Natural -> TxIn era
Shelley.TxIn (TxId -> TxId StandardShelley
toShelleyTxId TxId
txid) (Word -> Natural
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
txix)
toShelleyTxOut :: TxOut era -> Shelley.TxOut StandardShelley
toShelleyTxOut :: TxOut era -> TxOut StandardShelley
toShelleyTxOut (TxOut Address era
addr Lovelace
value) =
Addr StandardShelley
-> Value StandardShelley -> TxOut StandardShelley
forall era. ShelleyBased era => Addr era -> Value era -> TxOut era
Shelley.TxOut (Address era -> Addr StandardShelley
forall era. Address era -> Addr StandardShelley
toShelleyAddr Address era
addr) (Lovelace -> Coin
toShelleyLovelace Lovelace
value)
toShelleyLovelace :: Lovelace -> Shelley.Coin
toShelleyLovelace :: Lovelace -> Coin
toShelleyLovelace (Lovelace Integer
l) = Integer -> Coin
Shelley.Coin Integer
l
data TxBody era where
ByronTxBody
:: Annotated Byron.Tx ByteString
-> TxBody Byron
ShelleyTxBody
:: Shelley.TxBody StandardShelley
-> Maybe Shelley.MetaData
-> TxBody Shelley
deriving instance Eq (TxBody Byron)
deriving instance Show (TxBody Byron)
deriving instance Eq (TxBody Shelley)
deriving instance Show (TxBody Shelley)
instance HasTypeProxy (TxBody Byron) where
data AsType (TxBody Byron) = AsByronTxBody
proxyToAsType :: Proxy (TxBody Byron) -> AsType (TxBody Byron)
proxyToAsType Proxy (TxBody Byron)
_ = AsType (TxBody Byron)
AsByronTxBody
instance HasTypeProxy (TxBody Shelley) where
data AsType (TxBody Shelley) = AsShelleyTxBody
proxyToAsType :: Proxy (TxBody Shelley) -> AsType (TxBody Shelley)
proxyToAsType Proxy (TxBody Shelley)
_ = AsType (TxBody Shelley)
AsShelleyTxBody
instance SerialiseAsCBOR (TxBody Byron) where
serialiseToCBOR :: TxBody Byron -> ByteString
serialiseToCBOR (ByronTxBody Annotated Tx ByteString
txbody) =
Annotated Tx ByteString -> ByteString
forall t. Decoded t => t -> ByteString
recoverBytes Annotated Tx ByteString
txbody
deserialiseFromCBOR :: AsType (TxBody Byron)
-> ByteString -> Either DecoderError (TxBody Byron)
deserialiseFromCBOR AsType (TxBody Byron)
AsByronTxBody ByteString
bs = do
Annotated Tx ByteString -> TxBody Byron
ByronTxBody (Annotated Tx ByteString -> TxBody Byron)
-> Either DecoderError (Annotated Tx ByteString)
-> Either DecoderError (TxBody Byron)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Text
-> (forall s. Decoder s (Annotated Tx ByteSpan))
-> LByteString
-> Either DecoderError (Annotated Tx ByteString)
forall (f :: * -> *).
Functor f =>
Text
-> (forall s. Decoder s (f ByteSpan))
-> LByteString
-> Either DecoderError (f ByteString)
CBOR.decodeFullAnnotatedBytes
Text
"Byron TxBody"
forall s. Decoder s (Annotated Tx ByteSpan)
forall a s. FromCBOR a => Decoder s (Annotated a ByteSpan)
CBOR.fromCBORAnnotated
(ByteString -> LByteString
LBS.fromStrict ByteString
bs)
instance SerialiseAsCBOR (TxBody Shelley) where
serialiseToCBOR :: TxBody Shelley -> ByteString
serialiseToCBOR (ShelleyTxBody TxBody StandardShelley
txbody Maybe MetaData
txmetadata) =
Encoding -> ByteString
CBOR.serializeEncoding' (Encoding -> ByteString) -> Encoding -> ByteString
forall a b. (a -> b) -> a -> b
$
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> TxBody StandardShelley -> Encoding
forall a. ToCBOR a => a -> Encoding
CBOR.toCBOR TxBody StandardShelley
txbody
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (MetaData -> Encoding) -> Maybe MetaData -> Encoding
forall a. (a -> Encoding) -> Maybe a -> Encoding
CBOR.encodeNullMaybe MetaData -> Encoding
forall a. ToCBOR a => a -> Encoding
CBOR.toCBOR Maybe MetaData
txmetadata
deserialiseFromCBOR :: AsType (TxBody Shelley)
-> ByteString -> Either DecoderError (TxBody Shelley)
deserialiseFromCBOR AsType (TxBody Shelley)
AsShelleyTxBody ByteString
bs =
Text
-> (forall s. Decoder s (Annotator (TxBody Shelley)))
-> LByteString
-> Either DecoderError (TxBody Shelley)
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator
Text
"Shelley TxBody"
forall s. Decoder s (Annotator (TxBody Shelley))
decodeAnnotatedPair
(ByteString -> LByteString
LBS.fromStrict ByteString
bs)
where
decodeAnnotatedPair :: CBOR.Decoder s (CBOR.Annotator (TxBody Shelley))
decodeAnnotatedPair :: Decoder s (Annotator (TxBody Shelley))
decodeAnnotatedPair = do
Int -> Decoder s ()
forall s. Int -> Decoder s ()
CBOR.decodeListLenOf Int
2
Annotator (TxBody StandardShelley)
txbody <- Decoder s (Annotator (TxBody StandardShelley))
forall a s. FromCBOR a => Decoder s a
fromCBOR
Maybe (Annotator MetaData)
txmetadata <- Decoder s (Annotator MetaData)
-> Decoder s (Maybe (Annotator MetaData))
forall s a. Decoder s a -> Decoder s (Maybe a)
CBOR.decodeNullMaybe Decoder s (Annotator MetaData)
forall a s. FromCBOR a => Decoder s a
fromCBOR
Annotator (TxBody Shelley)
-> Decoder s (Annotator (TxBody Shelley))
forall (m :: * -> *) a. Monad m => a -> m a
return (Annotator (TxBody Shelley)
-> Decoder s (Annotator (TxBody Shelley)))
-> Annotator (TxBody Shelley)
-> Decoder s (Annotator (TxBody Shelley))
forall a b. (a -> b) -> a -> b
$ (FullByteString -> TxBody Shelley) -> Annotator (TxBody Shelley)
forall a. (FullByteString -> a) -> Annotator a
CBOR.Annotator ((FullByteString -> TxBody Shelley) -> Annotator (TxBody Shelley))
-> (FullByteString -> TxBody Shelley) -> Annotator (TxBody Shelley)
forall a b. (a -> b) -> a -> b
$ \FullByteString
fbs ->
TxBody StandardShelley -> Maybe MetaData -> TxBody Shelley
ShelleyTxBody
((Annotator (TxBody StandardShelley)
-> FullByteString -> TxBody StandardShelley)
-> FullByteString
-> Annotator (TxBody StandardShelley)
-> TxBody StandardShelley
forall a b c. (a -> b -> c) -> b -> a -> c
flip Annotator (TxBody StandardShelley)
-> FullByteString -> TxBody StandardShelley
forall a. Annotator a -> FullByteString -> a
CBOR.runAnnotator FullByteString
fbs Annotator (TxBody StandardShelley)
txbody)
((Annotator MetaData -> FullByteString -> MetaData)
-> FullByteString -> Annotator MetaData -> MetaData
forall a b c. (a -> b -> c) -> b -> a -> c
flip Annotator MetaData -> FullByteString -> MetaData
forall a. Annotator a -> FullByteString -> a
CBOR.runAnnotator FullByteString
fbs (Annotator MetaData -> MetaData)
-> Maybe (Annotator MetaData) -> Maybe MetaData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Annotator MetaData)
txmetadata)
instance HasTextEnvelope (TxBody Byron) where
textEnvelopeType :: AsType (TxBody Byron) -> TextEnvelopeType
textEnvelopeType AsType (TxBody Byron)
_ = TextEnvelopeType
"TxUnsignedByron"
instance HasTextEnvelope (TxBody Shelley) where
textEnvelopeType :: AsType (TxBody Shelley) -> TextEnvelopeType
textEnvelopeType AsType (TxBody Shelley)
_ = TextEnvelopeType
"TxUnsignedShelley"
data ByronTxBodyConversionError =
ByronTxBodyEmptyTxIns
| ByronTxBodyEmptyTxOuts
| ByronTxBodyLovelaceOverflow (TxOut Byron)
deriving Int -> ByronTxBodyConversionError -> ShowS
[ByronTxBodyConversionError] -> ShowS
ByronTxBodyConversionError -> String
(Int -> ByronTxBodyConversionError -> ShowS)
-> (ByronTxBodyConversionError -> String)
-> ([ByronTxBodyConversionError] -> ShowS)
-> Show ByronTxBodyConversionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ByronTxBodyConversionError] -> ShowS
$cshowList :: [ByronTxBodyConversionError] -> ShowS
show :: ByronTxBodyConversionError -> String
$cshow :: ByronTxBodyConversionError -> String
showsPrec :: Int -> ByronTxBodyConversionError -> ShowS
$cshowsPrec :: Int -> ByronTxBodyConversionError -> ShowS
Show
makeByronTransaction :: [TxIn]
-> [TxOut Byron]
-> Either ByronTxBodyConversionError
(TxBody Byron)
makeByronTransaction :: [TxIn]
-> [TxOut Byron]
-> Either ByronTxBodyConversionError (TxBody Byron)
makeByronTransaction [TxIn]
ins [TxOut Byron]
outs = do
NonEmpty TxIn
ins' <- [TxIn] -> Maybe (NonEmpty TxIn)
forall a. [a] -> Maybe (NonEmpty a)
NonEmpty.nonEmpty [TxIn]
ins Maybe (NonEmpty TxIn)
-> ByronTxBodyConversionError
-> Either ByronTxBodyConversionError (NonEmpty TxIn)
forall a e. Maybe a -> e -> Either e a
?! ByronTxBodyConversionError
ByronTxBodyEmptyTxIns
let ins'' :: NonEmpty TxIn
ins'' = (TxIn -> TxIn) -> NonEmpty TxIn -> NonEmpty TxIn
forall a b. (a -> b) -> NonEmpty a -> NonEmpty b
NonEmpty.map TxIn -> TxIn
toByronTxIn NonEmpty TxIn
ins'
NonEmpty (TxOut Byron)
outs' <- [TxOut Byron] -> Maybe (NonEmpty (TxOut Byron))
forall a. [a] -> Maybe (NonEmpty a)
NonEmpty.nonEmpty [TxOut Byron]
outs Maybe (NonEmpty (TxOut Byron))
-> ByronTxBodyConversionError
-> Either ByronTxBodyConversionError (NonEmpty (TxOut Byron))
forall a e. Maybe a -> e -> Either e a
?! ByronTxBodyConversionError
ByronTxBodyEmptyTxOuts
NonEmpty TxOut
outs'' <- (TxOut Byron -> Either ByronTxBodyConversionError TxOut)
-> NonEmpty (TxOut Byron)
-> Either ByronTxBodyConversionError (NonEmpty TxOut)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
(\TxOut Byron
out -> TxOut Byron -> Maybe TxOut
toByronTxOut TxOut Byron
out Maybe TxOut
-> ByronTxBodyConversionError
-> Either ByronTxBodyConversionError TxOut
forall a e. Maybe a -> e -> Either e a
?! TxOut Byron -> ByronTxBodyConversionError
ByronTxBodyLovelaceOverflow TxOut Byron
out)
NonEmpty (TxOut Byron)
outs'
TxBody Byron -> Either ByronTxBodyConversionError (TxBody Byron)
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody Byron -> Either ByronTxBodyConversionError (TxBody Byron))
-> TxBody Byron -> Either ByronTxBodyConversionError (TxBody Byron)
forall a b. (a -> b) -> a -> b
$
Annotated Tx ByteString -> TxBody Byron
ByronTxBody (Annotated Tx ByteString -> TxBody Byron)
-> Annotated Tx ByteString -> TxBody Byron
forall a b. (a -> b) -> a -> b
$
Annotated Tx () -> Annotated Tx ByteString
forall a b. ToCBOR a => Annotated a b -> Annotated a ByteString
reAnnotate (Annotated Tx () -> Annotated Tx ByteString)
-> Annotated Tx () -> Annotated Tx ByteString
forall a b. (a -> b) -> a -> b
$
Tx -> () -> Annotated Tx ()
forall b a. b -> a -> Annotated b a
Annotated
(NonEmpty TxIn -> NonEmpty TxOut -> TxAttributes -> Tx
Byron.UnsafeTx NonEmpty TxIn
ins'' NonEmpty TxOut
outs'' (() -> TxAttributes
forall h. h -> Attributes h
Byron.mkAttributes ()))
()
data =
{
TxExtraContent -> Maybe TxMetadata
txMetadata :: Maybe TxMetadata,
TxExtraContent -> [(StakeAddress, Lovelace)]
txWithdrawals :: [(StakeAddress, Lovelace)],
TxExtraContent -> [Certificate]
txCertificates :: [Certificate],
TxExtraContent -> Maybe UpdateProposal
txUpdateProposal :: Maybe UpdateProposal
}
txExtraContentEmpty :: TxExtraContent
=
TxExtraContent :: Maybe TxMetadata
-> [(StakeAddress, Lovelace)]
-> [Certificate]
-> Maybe UpdateProposal
-> TxExtraContent
TxExtraContent {
txMetadata :: Maybe TxMetadata
txMetadata = Maybe TxMetadata
forall a. Maybe a
Nothing,
txWithdrawals :: [(StakeAddress, Lovelace)]
txWithdrawals = [],
txCertificates :: [Certificate]
txCertificates = [],
txUpdateProposal :: Maybe UpdateProposal
txUpdateProposal = Maybe UpdateProposal
forall a. Maybe a
Nothing
}
type TxFee = Lovelace
type TTL = SlotNo
makeShelleyTransaction :: TxExtraContent
-> TTL
-> TxFee
-> [TxIn]
-> [TxOut anyera]
-> TxBody Shelley
makeShelleyTransaction :: TxExtraContent
-> TTL -> Lovelace -> [TxIn] -> [TxOut anyera] -> TxBody Shelley
makeShelleyTransaction TxExtraContent {
Maybe TxMetadata
txMetadata :: Maybe TxMetadata
txMetadata :: TxExtraContent -> Maybe TxMetadata
txMetadata,
[(StakeAddress, Lovelace)]
txWithdrawals :: [(StakeAddress, Lovelace)]
txWithdrawals :: TxExtraContent -> [(StakeAddress, Lovelace)]
txWithdrawals,
[Certificate]
txCertificates :: [Certificate]
txCertificates :: TxExtraContent -> [Certificate]
txCertificates,
Maybe UpdateProposal
txUpdateProposal :: Maybe UpdateProposal
txUpdateProposal :: TxExtraContent -> Maybe UpdateProposal
txUpdateProposal
} TTL
ttl Lovelace
fee [TxIn]
ins [TxOut anyera]
outs =
TxBody StandardShelley -> Maybe MetaData -> TxBody Shelley
ShelleyTxBody
(Set (TxIn StandardShelley)
-> StrictSeq (TxOut StandardShelley)
-> StrictSeq (DCert StandardShelley)
-> Wdrl StandardShelley
-> Coin
-> TTL
-> StrictMaybe (Update StandardShelley)
-> StrictMaybe (MetaDataHash StandardShelley)
-> TxBody StandardShelley
forall era.
ShelleyBased era =>
Set (TxIn era)
-> StrictSeq (TxOut era)
-> StrictSeq (DCert era)
-> Wdrl era
-> Coin
-> TTL
-> StrictMaybe (Update era)
-> StrictMaybe (MetaDataHash era)
-> TxBody era
Shelley.TxBody
([TxIn StandardShelley] -> Set (TxIn StandardShelley)
forall a. Ord a => [a] -> Set a
Set.fromList ((TxIn -> TxIn StandardShelley) -> [TxIn] -> [TxIn StandardShelley]
forall a b. (a -> b) -> [a] -> [b]
map TxIn -> TxIn StandardShelley
toShelleyTxIn [TxIn]
ins))
([TxOut StandardShelley] -> StrictSeq (TxOut StandardShelley)
forall a. [a] -> StrictSeq a
Seq.fromList ((TxOut anyera -> TxOut StandardShelley)
-> [TxOut anyera] -> [TxOut StandardShelley]
forall a b. (a -> b) -> [a] -> [b]
map TxOut anyera -> TxOut StandardShelley
forall era. TxOut era -> TxOut StandardShelley
toShelleyTxOut [TxOut anyera]
outs))
([DCert StandardShelley] -> StrictSeq (DCert StandardShelley)
forall a. [a] -> StrictSeq a
Seq.fromList [ DCert StandardShelley
cert | Certificate DCert StandardShelley
cert <- [Certificate]
txCertificates ])
([(StakeAddress, Lovelace)] -> Wdrl StandardShelley
toShelleyWdrl [(StakeAddress, Lovelace)]
txWithdrawals)
(Lovelace -> Coin
toShelleyLovelace Lovelace
fee)
TTL
ttl
(UpdateProposal -> Update StandardShelley
toShelleyUpdate (UpdateProposal -> Update StandardShelley)
-> StrictMaybe UpdateProposal
-> StrictMaybe (Update StandardShelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe UpdateProposal -> StrictMaybe UpdateProposal
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe UpdateProposal
txUpdateProposal)
(TxMetadata -> MetaDataHash StandardShelley
forall era. Era era => TxMetadata -> MetaDataHash era
toShelleyMetadataHash (TxMetadata -> MetaDataHash StandardShelley)
-> StrictMaybe TxMetadata
-> StrictMaybe (MetaDataHash StandardShelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe TxMetadata -> StrictMaybe TxMetadata
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe TxMetadata
txMetadata))
(TxMetadata -> MetaData
toShelleyMetadata (TxMetadata -> MetaData) -> Maybe TxMetadata -> Maybe MetaData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe TxMetadata
txMetadata)
where
toShelleyUpdate :: UpdateProposal -> Update StandardShelley
toShelleyUpdate (UpdateProposal Update StandardShelley
p) = Update StandardShelley
p
toShelleyMetadata :: TxMetadata -> MetaData
toShelleyMetadata (TxMetadataShelley MetaData
m) = MetaData
m
toShelleyMetadataHash :: TxMetadata -> MetaDataHash era
toShelleyMetadataHash (TxMetadataShelley MetaData
m) = MetaData -> MetaDataHash era
forall era. Era era => MetaData -> MetaDataHash era
Shelley.hashMetaData MetaData
m
toShelleyWdrl :: [(StakeAddress, Lovelace)] -> Shelley.Wdrl StandardShelley
toShelleyWdrl :: [(StakeAddress, Lovelace)] -> Wdrl StandardShelley
toShelleyWdrl [(StakeAddress, Lovelace)]
wdrls =
Map (RewardAcnt StandardShelley) Coin -> Wdrl StandardShelley
forall era. Map (RewardAcnt era) Coin -> Wdrl era
Shelley.Wdrl (Map (RewardAcnt StandardShelley) Coin -> Wdrl StandardShelley)
-> Map (RewardAcnt StandardShelley) Coin -> Wdrl StandardShelley
forall a b. (a -> b) -> a -> b
$
[(RewardAcnt StandardShelley, Coin)]
-> Map (RewardAcnt StandardShelley) Coin
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (StakeAddress -> RewardAcnt StandardShelley
toShelleyStakeAddr StakeAddress
stakeAddr, Lovelace -> Coin
toShelleyLovelace Lovelace
value)
| (StakeAddress
stakeAddr, Lovelace
value) <- [(StakeAddress, Lovelace)]
wdrls ]
data Tx era where
ByronTx
:: Byron.ATxAux ByteString
-> Tx Byron
ShelleyTx
:: Shelley.Tx StandardShelley
-> Tx Shelley
deriving instance Eq (Tx Byron)
deriving instance Show (Tx Byron)
deriving instance Eq (Tx Shelley)
deriving instance Show (Tx Shelley)
instance HasTypeProxy (Tx Byron) where
data AsType (Tx Byron) = AsByronTx
proxyToAsType :: Proxy (Tx Byron) -> AsType (Tx Byron)
proxyToAsType Proxy (Tx Byron)
_ = AsType (Tx Byron)
AsByronTx
instance HasTypeProxy (Tx Shelley) where
data AsType (Tx Shelley) = AsShelleyTx
proxyToAsType :: Proxy (Tx Shelley) -> AsType (Tx Shelley)
proxyToAsType Proxy (Tx Shelley)
_ = AsType (Tx Shelley)
AsShelleyTx
instance SerialiseAsCBOR (Tx Byron) where
serialiseToCBOR :: Tx Byron -> ByteString
serialiseToCBOR (ByronTx ATxAux ByteString
tx) = ATxAux ByteString -> ByteString
forall t. Decoded t => t -> ByteString
CBOR.recoverBytes ATxAux ByteString
tx
deserialiseFromCBOR :: AsType (Tx Byron) -> ByteString -> Either DecoderError (Tx Byron)
deserialiseFromCBOR AsType (Tx Byron)
AsByronTx ByteString
bs =
ATxAux ByteString -> Tx Byron
ByronTx (ATxAux ByteString -> Tx Byron)
-> Either DecoderError (ATxAux ByteString)
-> Either DecoderError (Tx Byron)
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
"Byron Tx" forall s. Decoder s (ATxAux ByteSpan)
forall a s. FromCBOR a => Decoder s a
fromCBOR (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
instance SerialiseAsCBOR (Tx Shelley) where
serialiseToCBOR :: Tx Shelley -> ByteString
serialiseToCBOR (ShelleyTx Tx StandardShelley
tx) =
Tx StandardShelley -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' Tx StandardShelley
tx
deserialiseFromCBOR :: AsType (Tx Shelley)
-> ByteString -> Either DecoderError (Tx Shelley)
deserialiseFromCBOR AsType (Tx Shelley)
AsShelleyTx ByteString
bs =
Tx StandardShelley -> Tx Shelley
ShelleyTx (Tx StandardShelley -> Tx Shelley)
-> Either DecoderError (Tx StandardShelley)
-> Either DecoderError (Tx Shelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Text
-> (forall s. Decoder s (Annotator (Tx StandardShelley)))
-> LByteString
-> Either DecoderError (Tx StandardShelley)
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator Text
"Shelley Tx" forall s. Decoder s (Annotator (Tx StandardShelley))
forall a s. FromCBOR a => Decoder s a
fromCBOR (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
instance HasTextEnvelope (Tx Byron) where
textEnvelopeType :: AsType (Tx Byron) -> TextEnvelopeType
textEnvelopeType AsType (Tx Byron)
_ = TextEnvelopeType
"TxSignedByron"
instance HasTextEnvelope (Tx Shelley) where
textEnvelopeType :: AsType (Tx Shelley) -> TextEnvelopeType
textEnvelopeType AsType (Tx Shelley)
_ = TextEnvelopeType
"TxSignedShelley"
data Witness era where
ByronKeyWitness
:: Byron.TxInWitness
-> Witness Byron
ShelleyBootstrapWitness
:: Shelley.BootstrapWitness StandardShelley
-> Witness Shelley
ShelleyKeyWitness
:: Shelley.WitVKey Shelley.Witness StandardShelley
-> Witness Shelley
ShelleyScriptWitness
:: Shelley.Script StandardShelley
-> Witness Shelley
deriving instance Eq (Witness Byron)
deriving instance Show (Witness Byron)
deriving instance Eq (Witness Shelley)
deriving instance Show (Witness Shelley)
instance HasTypeProxy (Witness Byron) where
data AsType (Witness Byron) = AsByronWitness
proxyToAsType :: Proxy (Witness Byron) -> AsType (Witness Byron)
proxyToAsType Proxy (Witness Byron)
_ = AsType (Witness Byron)
AsByronWitness
instance HasTypeProxy (Witness Shelley) where
data AsType (Witness Shelley) = AsShelleyWitness
proxyToAsType :: Proxy (Witness Shelley) -> AsType (Witness Shelley)
proxyToAsType Proxy (Witness Shelley)
_ = AsType (Witness Shelley)
AsShelleyWitness
instance SerialiseAsCBOR (Witness Byron) where
serialiseToCBOR :: Witness Byron -> ByteString
serialiseToCBOR (ByronKeyWitness TxInWitness
wit) = TxInWitness -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' TxInWitness
wit
deserialiseFromCBOR :: AsType (Witness Byron)
-> ByteString -> Either DecoderError (Witness Byron)
deserialiseFromCBOR AsType (Witness Byron)
AsByronWitness ByteString
bs =
TxInWitness -> Witness Byron
ByronKeyWitness (TxInWitness -> Witness Byron)
-> Either DecoderError TxInWitness
-> Either DecoderError (Witness Byron)
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
instance SerialiseAsCBOR (Witness Shelley) where
serialiseToCBOR :: Witness Shelley -> ByteString
serialiseToCBOR = Encoding -> ByteString
CBOR.serializeEncoding' (Encoding -> ByteString)
-> (Witness Shelley -> Encoding) -> Witness Shelley -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Witness Shelley -> Encoding
encodeShelleyWitness
where
encodeShelleyWitness :: Witness Shelley -> CBOR.Encoding
encodeShelleyWitness :: Witness Shelley -> Encoding
encodeShelleyWitness (ShelleyKeyWitness WitVKey 'Witness StandardShelley
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
<> WitVKey 'Witness StandardShelley -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR WitVKey 'Witness StandardShelley
wit
encodeShelleyWitness (ShelleyBootstrapWitness BootstrapWitness StandardShelley
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
<> BootstrapWitness StandardShelley -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR BootstrapWitness StandardShelley
wit
encodeShelleyWitness (ShelleyScriptWitness Script StandardShelley
wit) =
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> WrappedMultiSig StandardShelley -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (MultiSig StandardShelley -> WrappedMultiSig StandardShelley
forall era. MultiSig era -> WrappedMultiSig era
Legacy.WrappedMultiSig MultiSig StandardShelley
Script StandardShelley
wit)
deserialiseFromCBOR :: AsType (Witness Shelley)
-> ByteString -> Either DecoderError (Witness Shelley)
deserialiseFromCBOR AsType (Witness Shelley)
AsShelleyWitness ByteString
bs =
Text
-> (forall s. Decoder s (Annotator (Witness Shelley)))
-> LByteString
-> Either DecoderError (Witness Shelley)
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator Text
"Shelley Witness"
forall s. Decoder s (Annotator (Witness Shelley))
decodeShelleyWitness (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
where
decodeShelleyWitness :: CBOR.Decoder s (CBOR.Annotator (Witness Shelley))
decodeShelleyWitness :: Decoder s (Annotator (Witness Shelley))
decodeShelleyWitness = 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 StandardShelley)
-> Annotator (Witness Shelley))
-> Decoder s (Annotator (WitVKey 'Witness StandardShelley))
-> Decoder s (Annotator (Witness Shelley))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((WitVKey 'Witness StandardShelley -> Witness Shelley)
-> Annotator (WitVKey 'Witness StandardShelley)
-> Annotator (Witness Shelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap WitVKey 'Witness StandardShelley -> Witness Shelley
ShelleyKeyWitness) Decoder s (Annotator (WitVKey 'Witness StandardShelley))
forall a s. FromCBOR a => Decoder s a
fromCBOR
Word
1 -> (Annotator (BootstrapWitness StandardShelley)
-> Annotator (Witness Shelley))
-> Decoder s (Annotator (BootstrapWitness StandardShelley))
-> Decoder s (Annotator (Witness Shelley))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((BootstrapWitness StandardShelley -> Witness Shelley)
-> Annotator (BootstrapWitness StandardShelley)
-> Annotator (Witness Shelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BootstrapWitness StandardShelley -> Witness Shelley
ShelleyBootstrapWitness) Decoder s (Annotator (BootstrapWitness StandardShelley))
forall a s. FromCBOR a => Decoder s a
fromCBOR
Word
2 -> (Annotator (WrappedMultiSig StandardShelley)
-> Annotator (Witness Shelley))
-> Decoder s (Annotator (WrappedMultiSig StandardShelley))
-> Decoder s (Annotator (Witness Shelley))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((WrappedMultiSig StandardShelley -> Witness Shelley)
-> Annotator (WrappedMultiSig StandardShelley)
-> Annotator (Witness Shelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (MultiSig StandardShelley -> Witness Shelley
Script StandardShelley -> Witness Shelley
ShelleyScriptWitness (MultiSig StandardShelley -> Witness Shelley)
-> (WrappedMultiSig StandardShelley -> MultiSig StandardShelley)
-> WrappedMultiSig StandardShelley
-> Witness Shelley
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedMultiSig StandardShelley -> MultiSig StandardShelley
forall era. WrappedMultiSig era -> MultiSig era
Legacy.unWrappedMultiSig)) Decoder s (Annotator (WrappedMultiSig StandardShelley))
forall a s. FromCBOR a => Decoder s a
fromCBOR
Word
_ -> DecoderError -> Decoder s (Annotator (Witness Shelley))
forall e s a. Buildable e => e -> Decoder s a
CBOR.cborError (DecoderError -> Decoder s (Annotator (Witness Shelley)))
-> DecoderError -> Decoder s (Annotator (Witness Shelley))
forall a b. (a -> b) -> a -> b
$ Text -> Word8 -> DecoderError
CBOR.DecoderErrorUnknownTag
Text
"Shelley Witness" (Word -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
t)
instance HasTextEnvelope (Witness Byron) where
textEnvelopeType :: AsType (Witness Byron) -> TextEnvelopeType
textEnvelopeType AsType (Witness Byron)
_ = TextEnvelopeType
"TxWitnessByron"
instance HasTextEnvelope (Witness Shelley) where
textEnvelopeType :: AsType (Witness Shelley) -> TextEnvelopeType
textEnvelopeType AsType (Witness Shelley)
_ = TextEnvelopeType
"TxWitnessShelley"
getTxBody :: Tx era -> TxBody era
getTxBody :: Tx era -> TxBody era
getTxBody (ByronTx Byron.ATxAux { aTaTx :: forall a. ATxAux a -> Annotated Tx a
Byron.aTaTx = Annotated Tx ByteString
txbody }) =
Annotated Tx ByteString -> TxBody Byron
ByronTxBody Annotated Tx ByteString
txbody
getTxBody (ShelleyTx Shelley.Tx {
_body :: forall era. Tx era -> TxBodyConstraints era => TxBody era
Shelley._body = TxBody StandardShelley
txbody,
_metadata :: forall era. Tx era -> TxBodyConstraints era => StrictMaybe MetaData
Shelley._metadata = StrictMaybe MetaData
txmetadata
}) =
TxBody StandardShelley -> Maybe MetaData -> TxBody Shelley
ShelleyTxBody TxBody StandardShelley
TxBody StandardShelley
txbody (StrictMaybe MetaData -> Maybe MetaData
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe MetaData
txmetadata)
getTxWitnesses :: Tx era -> [Witness era]
getTxWitnesses :: Tx era -> [Witness era]
getTxWitnesses (ByronTx Byron.ATxAux { aTaWitness :: forall a. ATxAux a -> Annotated TxWitness a
Byron.aTaWitness = Annotated TxWitness ByteString
witnesses }) =
(TxInWitness -> Witness Byron) -> [TxInWitness] -> [Witness Byron]
forall a b. (a -> b) -> [a] -> [b]
map TxInWitness -> Witness Byron
ByronKeyWitness
([TxInWitness] -> [Witness Byron])
-> (Annotated TxWitness ByteString -> [TxInWitness])
-> Annotated TxWitness ByteString
-> [Witness Byron]
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 -> [Witness Byron])
-> Annotated TxWitness ByteString -> [Witness Byron]
forall a b. (a -> b) -> a -> b
$ Annotated TxWitness ByteString
witnesses
getTxWitnesses (ShelleyTx Shelley.Tx {
_witnessSet :: forall era. Tx era -> TxBodyConstraints era => WitnessSet era
Shelley._witnessSet =
Shelley.WitnessSet
Set (WitVKey 'Witness StandardShelley)
addrWits
Map (ScriptHash StandardShelley) (Script StandardShelley)
msigWits
Set (BootstrapWitness StandardShelley)
bootWits
}) =
(BootstrapWitness StandardShelley -> Witness Shelley)
-> [BootstrapWitness StandardShelley] -> [Witness Shelley]
forall a b. (a -> b) -> [a] -> [b]
map BootstrapWitness StandardShelley -> Witness Shelley
ShelleyBootstrapWitness (Set (BootstrapWitness StandardShelley)
-> [BootstrapWitness StandardShelley]
forall a. Set a -> [a]
Set.elems Set (BootstrapWitness StandardShelley)
bootWits)
[Witness Shelley] -> [Witness Shelley] -> [Witness Shelley]
forall a. [a] -> [a] -> [a]
++ (WitVKey 'Witness StandardShelley -> Witness Shelley)
-> [WitVKey 'Witness StandardShelley] -> [Witness Shelley]
forall a b. (a -> b) -> [a] -> [b]
map WitVKey 'Witness StandardShelley -> Witness Shelley
ShelleyKeyWitness (Set (WitVKey 'Witness StandardShelley)
-> [WitVKey 'Witness StandardShelley]
forall a. Set a -> [a]
Set.elems Set (WitVKey 'Witness StandardShelley)
addrWits)
[Witness Shelley] -> [Witness Shelley] -> [Witness Shelley]
forall a. [a] -> [a] -> [a]
++ (MultiSig StandardShelley -> Witness Shelley)
-> [MultiSig StandardShelley] -> [Witness Shelley]
forall a b. (a -> b) -> [a] -> [b]
map MultiSig StandardShelley -> Witness Shelley
Script StandardShelley -> Witness Shelley
ShelleyScriptWitness (Map (ScriptHash StandardShelley) (MultiSig StandardShelley)
-> [MultiSig StandardShelley]
forall k a. Map k a -> [a]
Map.elems Map (ScriptHash StandardShelley) (MultiSig StandardShelley)
Map (ScriptHash StandardShelley) (Script StandardShelley)
msigWits)
makeSignedTransaction :: [Witness era]
-> TxBody era
-> Tx era
makeSignedTransaction :: [Witness era] -> TxBody era -> Tx era
makeSignedTransaction [Witness era]
witnesses (ByronTxBody Annotated Tx ByteString
txbody) =
ATxAux ByteString -> Tx Byron
ByronTx
(ATxAux ByteString -> Tx Byron)
-> (TxAux -> ATxAux ByteString) -> TxAux -> Tx Byron
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxAux -> ATxAux ByteString
Byron.annotateTxAux
(TxAux -> Tx Byron) -> TxAux -> Tx Byron
forall a b. (a -> b) -> a -> b
$ Tx -> TxWitness -> TxAux
Byron.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 ((Witness Byron -> TxInWitness) -> [Witness Byron] -> [TxInWitness]
forall a b. (a -> b) -> [a] -> [b]
map Witness Byron -> TxInWitness
selectByronWitness [Witness era]
[Witness Byron]
witnesses))
where
selectByronWitness :: Witness Byron -> Byron.TxInWitness
selectByronWitness :: Witness Byron -> TxInWitness
selectByronWitness (ByronKeyWitness TxInWitness
w) = TxInWitness
w
makeSignedTransaction [Witness era]
witnesses (ShelleyTxBody TxBody StandardShelley
txbody Maybe MetaData
txmetadata) =
Tx StandardShelley -> Tx Shelley
ShelleyTx (Tx StandardShelley -> Tx Shelley)
-> Tx StandardShelley -> Tx Shelley
forall a b. (a -> b) -> a -> b
$
TxBody StandardShelley
-> WitnessSet StandardShelley
-> StrictMaybe MetaData
-> Tx StandardShelley
forall era.
TxBodyConstraints era =>
TxBody era -> WitnessSet era -> StrictMaybe MetaData -> Tx era
Shelley.Tx
TxBody StandardShelley
TxBody StandardShelley
txbody
(Set (WitVKey 'Witness StandardShelley)
-> Map (ScriptHash StandardShelley) (Script StandardShelley)
-> Set (BootstrapWitness StandardShelley)
-> WitnessSet StandardShelley
forall era.
(Era era, AnnotatedData (Script era)) =>
Set (WitVKey 'Witness era)
-> Map (ScriptHash era) (Script era)
-> Set (BootstrapWitness era)
-> WitnessSet era
Shelley.WitnessSet
([WitVKey 'Witness StandardShelley]
-> Set (WitVKey 'Witness StandardShelley)
forall a. Ord a => [a] -> Set a
Set.fromList [ WitVKey 'Witness StandardShelley
w | ShelleyKeyWitness WitVKey 'Witness StandardShelley
w <- [Witness era]
witnesses ])
([(ScriptHash StandardShelley, MultiSig StandardShelley)]
-> Map (ScriptHash StandardShelley) (MultiSig StandardShelley)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [ (MultiSig StandardShelley -> ScriptHash StandardShelley
forall era. Era era => MultiSig era -> ScriptHash era
Shelley.hashMultiSigScript MultiSig StandardShelley
Script StandardShelley
sw, MultiSig StandardShelley
Script StandardShelley
sw)
| ShelleyScriptWitness Script StandardShelley
sw <- [Witness era]
witnesses ])
([BootstrapWitness StandardShelley]
-> Set (BootstrapWitness StandardShelley)
forall a. Ord a => [a] -> Set a
Set.fromList [ BootstrapWitness StandardShelley
w | ShelleyBootstrapWitness BootstrapWitness StandardShelley
w <- [Witness era]
witnesses ]))
(Maybe MetaData -> StrictMaybe MetaData
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe MetaData
txmetadata)
makeByronKeyWitness :: NetworkId
-> TxBody Byron
-> SigningKey ByronKey
-> Witness Byron
makeByronKeyWitness :: NetworkId -> TxBody Byron -> SigningKey ByronKey -> Witness Byron
makeByronKeyWitness NetworkId
nw (ByronTxBody Annotated Tx ByteString
txbody) =
let txhash :: Byron.Hash Byron.Tx
txhash :: TxId
txhash = Annotated Tx ByteString
-> Hash (BaseType (Annotated Tx ByteString))
forall t. Decoded t => t -> Hash (BaseType t)
Byron.hashDecoded Annotated Tx ByteString
txbody
pm :: Byron.ProtocolMagicId
pm :: ProtocolMagicId
pm = NetworkId -> ProtocolMagicId
toByronProtocolMagicId NetworkId
nw
in \(ByronSigningKey sk) ->
TxInWitness -> Witness Byron
ByronKeyWitness (TxInWitness -> Witness Byron) -> TxInWitness -> Witness Byron
forall a b. (a -> b) -> a -> b
$
VerificationKey -> TxSig -> TxInWitness
Byron.VKWitness
(SigningKey -> VerificationKey
Byron.toVerification SigningKey
sk)
(ProtocolMagicId -> SignTag -> SigningKey -> TxSigData -> TxSig
forall a.
ToCBOR a =>
ProtocolMagicId -> SignTag -> SigningKey -> a -> Signature a
Byron.sign ProtocolMagicId
pm SignTag
Byron.SignTx SigningKey
sk (TxId -> TxSigData
Byron.TxSigData TxId
txhash))
data WitnessNetworkIdOrByronAddress
= WitnessNetworkId !NetworkId
| WitnessByronAddress !(Address Byron)
makeShelleyBootstrapWitness :: WitnessNetworkIdOrByronAddress
-> TxBody Shelley
-> SigningKey ByronKey
-> Witness Shelley
makeShelleyBootstrapWitness :: WitnessNetworkIdOrByronAddress
-> TxBody Shelley -> SigningKey ByronKey -> Witness Shelley
makeShelleyBootstrapWitness WitnessNetworkIdOrByronAddress
nwOrAddr (ShelleyTxBody TxBody StandardShelley
txbody Maybe MetaData
_) (ByronSigningKey sk) =
BootstrapWitness StandardShelley -> Witness Shelley
ShelleyBootstrapWitness (BootstrapWitness StandardShelley -> Witness Shelley)
-> BootstrapWitness StandardShelley -> Witness Shelley
forall a b. (a -> b) -> a -> b
$
BootstrapWitness :: forall era.
Era era =>
VKey 'Witness (Crypto era)
-> SignedDSIGN
(Crypto era) (Hash (Crypto era) EraIndependentTxBody)
-> ChainCode
-> ByteString
-> BootstrapWitness era
Shelley.BootstrapWitness {
bwKey :: VKey 'Witness (Crypto StandardShelley)
Shelley.bwKey = VKey 'Witness StandardCrypto
VKey 'Witness (Crypto StandardShelley)
vk,
bwSig :: SignedDSIGN
(Crypto StandardShelley)
(Hash (Crypto StandardShelley) EraIndependentTxBody)
Shelley.bwSig = SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
SignedDSIGN
(Crypto StandardShelley)
(Hash (Crypto StandardShelley) EraIndependentTxBody)
signature,
bwChainCode :: ChainCode
Shelley.bwChainCode = ChainCode
chainCode,
bwAttributes :: ByteString
Shelley.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)
Shelley.unpackByronVKey (SigningKey -> VerificationKey
Byron.toVerification SigningKey
sk)
signature :: Shelley.SignedDSIGN StandardCrypto
(Shelley.Hash StandardCrypto Shelley.EraIndependentTxBody)
signature :: SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
signature = Hash Blake2b_256 EraIndependentTxBody
-> ShelleySigningKey
-> SignedDSIGN
StandardCrypto (Hash Blake2b_256 EraIndependentTxBody)
forall tosign.
SignableRepresentation tosign =>
tosign -> ShelleySigningKey -> SignedDSIGN StandardCrypto tosign
makeShelleySignature
Hash Blake2b_256 EraIndependentTxBody
Hash StandardCrypto EraIndependentTxBody
txhash
(XPrv -> ShelleySigningKey
ShelleyExtendedSigningKey (SigningKey -> XPrv
Byron.unSigningKey SigningKey
sk))
txhash :: Shelley.Hash StandardCrypto Shelley.EraIndependentTxBody
txhash :: Hash StandardCrypto EraIndependentTxBody
txhash = TxBody StandardShelley
-> Hash (Crypto StandardShelley) EraIndependentTxBody
forall era.
Era era =>
TxBody era -> Hash (Crypto era) EraIndependentTxBody
Shelley.eraIndTxBodyHash TxBody StandardShelley
txbody
attributes :: ByteString
attributes =
Attributes AddrAttributes -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' (Attributes AddrAttributes -> ByteString)
-> Attributes AddrAttributes -> ByteString
forall a b. (a -> b) -> a -> b
$
AddrAttributes -> Attributes AddrAttributes
forall h. h -> Attributes h
Byron.mkAttributes AddrAttributes :: Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
Byron.AddrAttributes {
aaVKDerivationPath :: Maybe HDAddressPayload
Byron.aaVKDerivationPath = Maybe HDAddressPayload
derivationPath,
aaNetworkMagic :: NetworkMagic
Byron.aaNetworkMagic = NetworkMagic
networkMagic
}
eitherNwOrAddr :: Either NetworkId (Address Byron)
eitherNwOrAddr :: Either NetworkId (Address Byron)
eitherNwOrAddr =
case WitnessNetworkIdOrByronAddress
nwOrAddr of
WitnessNetworkId NetworkId
nw -> NetworkId -> Either NetworkId (Address Byron)
forall a b. a -> Either a b
Left NetworkId
nw
WitnessByronAddress Address Byron
addr -> Address Byron -> Either NetworkId (Address Byron)
forall a b. b -> Either a b
Right Address Byron
addr
unByronAddr :: Address Byron -> Byron.Address
unByronAddr :: Address Byron -> Address
unByronAddr (ByronAddress Address
addr) = Address
addr
unAddrAttrs :: Address Byron -> Byron.AddrAttributes
unAddrAttrs :: Address Byron -> AddrAttributes
unAddrAttrs = Attributes AddrAttributes -> AddrAttributes
forall h. Attributes h -> h
Byron.attrData (Attributes AddrAttributes -> AddrAttributes)
-> (Address Byron -> Attributes AddrAttributes)
-> Address Byron
-> AddrAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address -> Attributes AddrAttributes
Byron.addrAttributes (Address -> Attributes AddrAttributes)
-> (Address Byron -> Address)
-> Address Byron
-> Attributes AddrAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address Byron -> Address
unByronAddr
derivationPath :: Maybe Byron.HDAddressPayload
derivationPath :: Maybe HDAddressPayload
derivationPath =
(NetworkId -> Maybe HDAddressPayload)
-> (Address Byron -> Maybe HDAddressPayload)
-> Either NetworkId (Address Byron)
-> 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
Byron.aaVKDerivationPath (AddrAttributes -> Maybe HDAddressPayload)
-> (Address Byron -> AddrAttributes)
-> Address Byron
-> Maybe HDAddressPayload
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address Byron -> AddrAttributes
unAddrAttrs)
Either NetworkId (Address Byron)
eitherNwOrAddr
networkMagic :: Byron.NetworkMagic
networkMagic :: NetworkMagic
networkMagic =
(NetworkId -> NetworkMagic)
-> (Address Byron -> NetworkMagic)
-> Either NetworkId (Address Byron)
-> NetworkMagic
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
NetworkId -> NetworkMagic
toByronNetworkMagic
(AddrAttributes -> NetworkMagic
Byron.aaNetworkMagic (AddrAttributes -> NetworkMagic)
-> (Address Byron -> AddrAttributes)
-> Address Byron
-> NetworkMagic
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address Byron -> AddrAttributes
unAddrAttrs)
Either NetworkId (Address Byron)
eitherNwOrAddr
data ShelleyWitnessSigningKey =
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)
makeShelleyKeyWitness :: TxBody Shelley
-> ShelleyWitnessSigningKey
-> Witness Shelley
makeShelleyKeyWitness :: TxBody Shelley -> ShelleyWitnessSigningKey -> Witness Shelley
makeShelleyKeyWitness (ShelleyTxBody TxBody StandardShelley
txbody Maybe MetaData
_) =
let txhash :: Shelley.Hash StandardCrypto (Shelley.TxBody StandardShelley)
txhash :: Hash StandardCrypto (TxBody StandardShelley)
txhash = (TxBody StandardShelley -> ByteString)
-> TxBody StandardShelley
-> Hash Blake2b_256 (TxBody StandardShelley)
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith TxBody StandardShelley -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' TxBody StandardShelley
txbody
in \ShelleyWitnessSigningKey
wsk ->
let sk :: ShelleySigningKey
sk = ShelleyWitnessSigningKey -> ShelleySigningKey
toShelleySigningKey ShelleyWitnessSigningKey
wsk
vk :: VKey 'Witness StandardCrypto
vk = ShelleySigningKey -> VKey 'Witness StandardCrypto
getShelleyKeyWitnessVerificationKey ShelleySigningKey
sk
signature :: SignedDSIGN
StandardCrypto (Hash Blake2b_256 (TxBody StandardShelley))
signature = Hash Blake2b_256 (TxBody StandardShelley)
-> ShelleySigningKey
-> SignedDSIGN
StandardCrypto (Hash Blake2b_256 (TxBody StandardShelley))
forall tosign.
SignableRepresentation tosign =>
tosign -> ShelleySigningKey -> SignedDSIGN StandardCrypto tosign
makeShelleySignature Hash Blake2b_256 (TxBody StandardShelley)
Hash StandardCrypto (TxBody StandardShelley)
txhash ShelleySigningKey
sk
in WitVKey 'Witness StandardShelley -> Witness Shelley
ShelleyKeyWitness (WitVKey 'Witness StandardShelley -> Witness Shelley)
-> WitVKey 'Witness StandardShelley -> Witness Shelley
forall a b. (a -> b) -> a -> b
$
VKey 'Witness (Crypto StandardShelley)
-> SignedDSIGN
(Crypto StandardShelley)
(Hash (Crypto StandardShelley) (TxBody StandardShelley))
-> WitVKey 'Witness StandardShelley
forall (kr :: KeyRole) era.
(Typeable kr, Era era) =>
VKey kr (Crypto era)
-> SignedDSIGN (Crypto era) (Hash (Crypto era) (TxBody era))
-> WitVKey kr era
Shelley.WitVKey VKey 'Witness StandardCrypto
VKey 'Witness (Crypto StandardShelley)
vk SignedDSIGN
StandardCrypto (Hash Blake2b_256 (TxBody StandardShelley))
SignedDSIGN
(Crypto StandardShelley)
(Hash (Crypto StandardShelley) (TxBody StandardShelley))
signature
data ShelleySigningKey =
ShelleyNormalSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
| ShelleyExtendedSigningKey Crypto.HD.XPrv
toShelleySigningKey :: ShelleyWitnessSigningKey -> ShelleySigningKey
toShelleySigningKey :: ShelleyWitnessSigningKey -> ShelleySigningKey
toShelleySigningKey ShelleyWitnessSigningKey
key = case ShelleyWitnessSigningKey
key of
WitnessPaymentKey (PaymentSigningKey sk) -> SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessStakeKey (StakeSigningKey sk) -> SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessStakePoolKey (StakePoolSigningKey sk) -> SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessGenesisKey (GenesisSigningKey sk) -> SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessGenesisUTxOKey (GenesisUTxOSigningKey sk) -> SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessGenesisDelegateKey (GenesisDelegateSigningKey sk) ->
SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
sk
WitnessPaymentExtendedKey (PaymentExtendedSigningKey sk) ->
XPrv -> ShelleySigningKey
ShelleyExtendedSigningKey XPrv
sk
WitnessStakeExtendedKey (StakeExtendedSigningKey sk) ->
XPrv -> ShelleySigningKey
ShelleyExtendedSigningKey XPrv
sk
WitnessGenesisExtendedKey (GenesisExtendedSigningKey sk) ->
XPrv -> ShelleySigningKey
ShelleyExtendedSigningKey XPrv
sk
WitnessGenesisDelegateExtendedKey (GenesisDelegateExtendedSigningKey sk) ->
XPrv -> ShelleySigningKey
ShelleyExtendedSigningKey XPrv
sk
getShelleyKeyWitnessVerificationKey
:: ShelleySigningKey
-> Shelley.VKey Shelley.Witness StandardCrypto
getShelleyKeyWitnessVerificationKey :: ShelleySigningKey -> VKey 'Witness StandardCrypto
getShelleyKeyWitnessVerificationKey (ShelleyNormalSigningKey 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
Shelley.coerceKeyRole :: Shelley.VKey Shelley.Payment StandardCrypto
-> Shelley.VKey Shelley.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 Ed25519DSIGN -> SigningKey PaymentKey
SignKeyDSIGN StandardCrypto -> SigningKey PaymentKey
PaymentSigningKey
(SignKeyDSIGN Ed25519DSIGN -> VKey 'Witness StandardCrypto)
-> SignKeyDSIGN Ed25519DSIGN -> VKey 'Witness StandardCrypto
forall a b. (a -> b) -> a -> b
$ SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
getShelleyKeyWitnessVerificationKey (ShelleyExtendedSigningKey XPrv
sk) =
(VKey 'Payment StandardCrypto -> VKey 'Witness StandardCrypto
forall (a :: KeyRole -> * -> *) (r :: KeyRole) crypto
(r' :: KeyRole).
HasKeyRole a =>
a r crypto -> a r' crypto
Shelley.coerceKeyRole :: Shelley.VKey Shelley.Payment StandardCrypto
-> Shelley.VKey Shelley.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
makeShelleySignature
:: Crypto.SignableRepresentation tosign
=> tosign
-> ShelleySigningKey
-> Shelley.SignedDSIGN StandardCrypto tosign
makeShelleySignature :: tosign -> ShelleySigningKey -> SignedDSIGN StandardCrypto tosign
makeShelleySignature tosign
tosign (ShelleyNormalSigningKey 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 Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
makeShelleySignature tosign
tosign (ShelleyExtendedSigningKey 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
-> Shelley.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
"makeShelleyKeyWitnessSignature: byron and shelley signature sizes do not match"
signByronTransaction :: NetworkId
-> TxBody Byron
-> [SigningKey ByronKey]
-> Tx Byron
signByronTransaction :: NetworkId -> TxBody Byron -> [SigningKey ByronKey] -> Tx Byron
signByronTransaction NetworkId
nw TxBody Byron
txbody [SigningKey ByronKey]
sks =
[Witness Byron] -> TxBody Byron -> Tx Byron
forall era. [Witness era] -> TxBody era -> Tx era
makeSignedTransaction [Witness Byron]
witnesses TxBody Byron
txbody
where
witnesses :: [Witness Byron]
witnesses = (SigningKey ByronKey -> Witness Byron)
-> [SigningKey ByronKey] -> [Witness Byron]
forall a b. (a -> b) -> [a] -> [b]
map (NetworkId -> TxBody Byron -> SigningKey ByronKey -> Witness Byron
makeByronKeyWitness NetworkId
nw TxBody Byron
txbody) [SigningKey ByronKey]
sks
signShelleyTransaction :: TxBody Shelley
-> [ShelleyWitnessSigningKey]
-> Tx Shelley
signShelleyTransaction :: TxBody Shelley -> [ShelleyWitnessSigningKey] -> Tx Shelley
signShelleyTransaction TxBody Shelley
txbody [ShelleyWitnessSigningKey]
sks =
[Witness Shelley] -> TxBody Shelley -> Tx Shelley
forall era. [Witness era] -> TxBody era -> Tx era
makeSignedTransaction [Witness Shelley]
witnesses TxBody Shelley
txbody
where
witnesses :: [Witness Shelley]
witnesses = (ShelleyWitnessSigningKey -> Witness Shelley)
-> [ShelleyWitnessSigningKey] -> [Witness Shelley]
forall a b. (a -> b) -> [a] -> [b]
map (TxBody Shelley -> ShelleyWitnessSigningKey -> Witness Shelley
makeShelleyKeyWitness TxBody Shelley
txbody) [ShelleyWitnessSigningKey]
sks
transactionFee :: Natural
-> Natural
-> Tx Shelley
-> Lovelace
transactionFee :: Natural -> Natural -> Tx Shelley -> Lovelace
transactionFee Natural
txFeeFixed Natural
txFeePerByte (ShelleyTx Tx StandardShelley
tx) =
Integer -> Lovelace
Lovelace (Integer
a Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
x Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
b)
where
a :: Integer
a = Natural -> Integer
forall a. Integral a => a -> Integer
toInteger Natural
txFeePerByte
x :: Integer
x = Tx StandardShelley -> Integer
forall era. Tx era -> Integer
Shelley.txsize Tx StandardShelley
tx
b :: Integer
b = Natural -> Integer
forall a. Integral a => a -> Integer
toInteger Natural
txFeeFixed
estimateTransactionFee :: NetworkId
-> Natural
-> Natural
-> Tx Shelley
-> Int
-> Int
-> Int
-> Int
-> Lovelace
estimateTransactionFee :: NetworkId
-> Natural
-> Natural
-> Tx Shelley
-> Int
-> Int
-> Int
-> Int
-> Lovelace
estimateTransactionFee NetworkId
nw Natural
txFeeFixed Natural
txFeePerByte (ShelleyTx Tx StandardShelley
tx) =
let Lovelace Integer
baseFee = Natural -> Natural -> Tx Shelley -> Lovelace
transactionFee Natural
txFeeFixed Natural
txFeePerByte (Tx StandardShelley -> Tx Shelley
ShelleyTx Tx StandardShelley
tx)
in \Int
nInputs Int
nOutputs Int
nShelleyKeyWitnesses Int
nByronKeyWitnesses ->
let extraBytes :: Int
extraBytes :: Int
extraBytes = Int
nInputs Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
sizeInput
Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
nOutputs Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
sizeOutput
Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
nByronKeyWitnesses Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
sizeByronKeyWitnesses
Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
nShelleyKeyWitnesses Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
sizeShelleyKeyWitnesses
in Integer -> Lovelace
Lovelace (Integer
baseFee Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Natural -> Integer
forall a. Integral a => a -> Integer
toInteger Natural
txFeePerByte Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
extraBytes)
where
sizeInput :: Int
sizeInput = Int
smallArray Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
uint Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
hashObj
sizeOutput :: Int
sizeOutput = Int
smallArray Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
uint Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
address
sizeByronKeyWitnesses :: Int
sizeByronKeyWitnesses = Int
smallArray Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
keyObj Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
sigObj Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
ccodeObj Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
attrsObj
sizeShelleyKeyWitnesses :: Int
sizeShelleyKeyWitnesses = Int
smallArray Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
keyObj Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
sigObj
smallArray :: Int
smallArray = Int
1
uint :: Int
uint = Int
5
hashObj :: Int
hashObj = Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
hashLen
hashLen :: Int
hashLen = Int
32
keyObj :: Int
keyObj = Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
keyLen
keyLen :: Int
keyLen = Int
32
sigObj :: Int
sigObj = Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
sigLen
sigLen :: Int
sigLen = Int
64
ccodeObj :: Int
ccodeObj = Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
ccodeLen
ccodeLen :: Int
ccodeLen = Int
32
address :: Int
address = Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
addrHeader Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
addrHashLen
addrHeader :: Int
addrHeader = Int
1
addrHashLen :: Int
addrHashLen = Int
28
attrsObj :: Int
attrsObj = Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ByteString -> Int
BS.length ByteString
attributes
attributes :: ByteString
attributes = Attributes AddrAttributes -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' (Attributes AddrAttributes -> ByteString)
-> Attributes AddrAttributes -> ByteString
forall a b. (a -> b) -> a -> b
$
AddrAttributes -> Attributes AddrAttributes
forall h. h -> Attributes h
Byron.mkAttributes AddrAttributes :: Maybe HDAddressPayload -> NetworkMagic -> AddrAttributes
Byron.AddrAttributes {
aaVKDerivationPath :: Maybe HDAddressPayload
Byron.aaVKDerivationPath = Maybe HDAddressPayload
forall a. Maybe a
Nothing,
aaNetworkMagic :: NetworkMagic
Byron.aaNetworkMagic = NetworkId -> NetworkMagic
toByronNetworkMagic NetworkId
nw
}
newtype Script = Script (Shelley.Script StandardShelley)
deriving stock (Script -> Script -> Bool
(Script -> Script -> Bool)
-> (Script -> Script -> Bool) -> Eq Script
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Script -> Script -> Bool
$c/= :: Script -> Script -> Bool
== :: Script -> Script -> Bool
$c== :: Script -> Script -> Bool
Eq, Eq Script
Eq Script
-> (Script -> Script -> Ordering)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Bool)
-> (Script -> Script -> Script)
-> (Script -> Script -> Script)
-> Ord Script
Script -> Script -> Bool
Script -> Script -> Ordering
Script -> Script -> Script
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Script -> Script -> Script
$cmin :: Script -> Script -> Script
max :: Script -> Script -> Script
$cmax :: Script -> Script -> Script
>= :: Script -> Script -> Bool
$c>= :: Script -> Script -> Bool
> :: Script -> Script -> Bool
$c> :: Script -> Script -> Bool
<= :: Script -> Script -> Bool
$c<= :: Script -> Script -> Bool
< :: Script -> Script -> Bool
$c< :: Script -> Script -> Bool
compare :: Script -> Script -> Ordering
$ccompare :: Script -> Script -> Ordering
$cp1Ord :: Eq Script
Ord, Int -> Script -> ShowS
[Script] -> ShowS
Script -> String
(Int -> Script -> ShowS)
-> (Script -> String) -> ([Script] -> ShowS) -> Show Script
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Script] -> ShowS
$cshowList :: [Script] -> ShowS
show :: Script -> String
$cshow :: Script -> String
showsPrec :: Int -> Script -> ShowS
$cshowsPrec :: Int -> Script -> ShowS
Show)
deriving newtype (Typeable Script
Typeable Script
-> (Script -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy Script -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Script] -> Size)
-> ToCBOR Script
Script -> Encoding
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Script] -> Size
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy Script -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Script] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Script] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy Script -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy Script -> Size
toCBOR :: Script -> Encoding
$ctoCBOR :: Script -> Encoding
$cp1ToCBOR :: Typeable Script
ToCBOR)
newtype instance Hash Script = ScriptHash (Shelley.ScriptHash StandardShelley)
deriving (Hash Script -> Hash Script -> Bool
(Hash Script -> Hash Script -> Bool)
-> (Hash Script -> Hash Script -> Bool) -> Eq (Hash Script)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash Script -> Hash Script -> Bool
$c/= :: Hash Script -> Hash Script -> Bool
== :: Hash Script -> Hash Script -> Bool
$c== :: Hash Script -> Hash Script -> Bool
Eq, Eq (Hash Script)
Eq (Hash Script)
-> (Hash Script -> Hash Script -> Ordering)
-> (Hash Script -> Hash Script -> Bool)
-> (Hash Script -> Hash Script -> Bool)
-> (Hash Script -> Hash Script -> Bool)
-> (Hash Script -> Hash Script -> Bool)
-> (Hash Script -> Hash Script -> Hash Script)
-> (Hash Script -> Hash Script -> Hash Script)
-> Ord (Hash Script)
Hash Script -> Hash Script -> Bool
Hash Script -> Hash Script -> Ordering
Hash Script -> Hash Script -> Hash Script
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash Script -> Hash Script -> Hash Script
$cmin :: Hash Script -> Hash Script -> Hash Script
max :: Hash Script -> Hash Script -> Hash Script
$cmax :: Hash Script -> Hash Script -> Hash Script
>= :: Hash Script -> Hash Script -> Bool
$c>= :: Hash Script -> Hash Script -> Bool
> :: Hash Script -> Hash Script -> Bool
$c> :: Hash Script -> Hash Script -> Bool
<= :: Hash Script -> Hash Script -> Bool
$c<= :: Hash Script -> Hash Script -> Bool
< :: Hash Script -> Hash Script -> Bool
$c< :: Hash Script -> Hash Script -> Bool
compare :: Hash Script -> Hash Script -> Ordering
$ccompare :: Hash Script -> Hash Script -> Ordering
$cp1Ord :: Eq (Hash Script)
Ord, Int -> Hash Script -> ShowS
[Hash Script] -> ShowS
Hash Script -> String
(Int -> Hash Script -> ShowS)
-> (Hash Script -> String)
-> ([Hash Script] -> ShowS)
-> Show (Hash Script)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash Script] -> ShowS
$cshowList :: [Hash Script] -> ShowS
show :: Hash Script -> String
$cshow :: Hash Script -> String
showsPrec :: Int -> Hash Script -> ShowS
$cshowsPrec :: Int -> Hash Script -> ShowS
Show)
data MultiSigScript = RequireSignature (Hash PaymentKey)
| RequireAllOf [MultiSigScript]
| RequireAnyOf [MultiSigScript]
| RequireMOf Int [MultiSigScript]
deriving (MultiSigScript -> MultiSigScript -> Bool
(MultiSigScript -> MultiSigScript -> Bool)
-> (MultiSigScript -> MultiSigScript -> Bool) -> Eq MultiSigScript
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MultiSigScript -> MultiSigScript -> Bool
$c/= :: MultiSigScript -> MultiSigScript -> Bool
== :: MultiSigScript -> MultiSigScript -> Bool
$c== :: MultiSigScript -> MultiSigScript -> Bool
Eq, Int -> MultiSigScript -> ShowS
[MultiSigScript] -> ShowS
MultiSigScript -> String
(Int -> MultiSigScript -> ShowS)
-> (MultiSigScript -> String)
-> ([MultiSigScript] -> ShowS)
-> Show MultiSigScript
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MultiSigScript] -> ShowS
$cshowList :: [MultiSigScript] -> ShowS
show :: MultiSigScript -> String
$cshow :: MultiSigScript -> String
showsPrec :: Int -> MultiSigScript -> ShowS
$cshowsPrec :: Int -> MultiSigScript -> ShowS
Show)
instance ToJSON MultiSigScript where
toJSON :: MultiSigScript -> Value
toJSON (RequireSignature Hash PaymentKey
pKeyHash) =
[Pair] -> Value
object [ Text
"keyHash" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String (ByteString -> Text
Text.decodeUtf8 (ByteString -> Text)
-> (Hash PaymentKey -> ByteString) -> Hash PaymentKey -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash PaymentKey -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex (Hash PaymentKey -> Text) -> Hash PaymentKey -> Text
forall a b. (a -> b) -> a -> b
$ Hash PaymentKey
pKeyHash)
, Text
"type" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"sig"
]
toJSON (RequireAnyOf [MultiSigScript]
reqScripts) =
[Pair] -> Value
object [ Text
"type" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"any", Text
"scripts" Text -> [Value] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= (MultiSigScript -> Value) -> [MultiSigScript] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map MultiSigScript -> Value
forall a. ToJSON a => a -> Value
toJSON [MultiSigScript]
reqScripts ]
toJSON (RequireAllOf [MultiSigScript]
reqScripts) =
[Pair] -> Value
object [ Text
"type" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"all", Text
"scripts" Text -> [Value] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= (MultiSigScript -> Value) -> [MultiSigScript] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map MultiSigScript -> Value
forall a. ToJSON a => a -> Value
toJSON [MultiSigScript]
reqScripts ]
toJSON (RequireMOf Int
reqNum [MultiSigScript]
reqScripts) =
[Pair] -> Value
object [ Text
"type" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Text -> Value
String Text
"atLeast"
, Text
"required" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Int
reqNum
, Text
"scripts" Text -> [Value] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= (MultiSigScript -> Value) -> [MultiSigScript] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map MultiSigScript -> Value
forall a. ToJSON a => a -> Value
toJSON [MultiSigScript]
reqScripts
]
instance FromJSON MultiSigScript where
parseJSON :: Value -> Parser MultiSigScript
parseJSON = Value -> Parser MultiSigScript
parseScript
parseScript :: Value -> Aeson.Parser MultiSigScript
parseScript :: Value -> Parser MultiSigScript
parseScript Value
v = Value -> Parser MultiSigScript
parseScriptSig Value
v
Parser MultiSigScript
-> Parser MultiSigScript -> Parser MultiSigScript
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Value -> Parser MultiSigScript
parseScriptAny Value
v
Parser MultiSigScript
-> Parser MultiSigScript -> Parser MultiSigScript
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Value -> Parser MultiSigScript
parseScriptAll Value
v
Parser MultiSigScript
-> Parser MultiSigScript -> Parser MultiSigScript
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Value -> Parser MultiSigScript
parseScriptAtLeast Value
v
parseScriptAny :: Value -> Aeson.Parser MultiSigScript
parseScriptAny :: Value -> Parser MultiSigScript
parseScriptAny = String
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"any" ((Object -> Parser MultiSigScript)
-> Value -> Parser MultiSigScript)
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
Text
t <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type"
case Text
t :: Text of
Text
"any" -> do Vector Value
s <- Object
obj Object -> Text -> Parser (Vector Value)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"scripts"
[MultiSigScript] -> MultiSigScript
RequireAnyOf ([MultiSigScript] -> MultiSigScript)
-> Parser [MultiSigScript] -> Parser MultiSigScript
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector Value -> Parser [MultiSigScript]
gatherMultiSigScripts Vector Value
s
Text
_ -> String -> Parser MultiSigScript
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"\"any\" multi-signature script value not found"
parseScriptAll :: Value -> Aeson.Parser MultiSigScript
parseScriptAll :: Value -> Parser MultiSigScript
parseScriptAll = String
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"all" ((Object -> Parser MultiSigScript)
-> Value -> Parser MultiSigScript)
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
Text
t <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type"
case Text
t :: Text of
Text
"all" -> do Vector Value
s <- Object
obj Object -> Text -> Parser (Vector Value)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"scripts"
[MultiSigScript] -> MultiSigScript
RequireAllOf ([MultiSigScript] -> MultiSigScript)
-> Parser [MultiSigScript] -> Parser MultiSigScript
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector Value -> Parser [MultiSigScript]
gatherMultiSigScripts Vector Value
s
Text
_ -> String -> Parser MultiSigScript
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"\"all\" multi-signature script value not found"
parseScriptAtLeast :: Value -> Aeson.Parser MultiSigScript
parseScriptAtLeast :: Value -> Parser MultiSigScript
parseScriptAtLeast = String
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"atLeast" ((Object -> Parser MultiSigScript)
-> Value -> Parser MultiSigScript)
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
Text
v <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type"
case Text
v :: Text of
Text
"atLeast" -> do
Value
r <- Object
obj Object -> Text -> Parser Value
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"required"
Vector Value
s <- Object
obj Object -> Text -> Parser (Vector Value)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"scripts"
case Value
r of
Number Scientific
sci ->
case Scientific -> Maybe Int
forall i. (Integral i, Bounded i) => Scientific -> Maybe i
toBoundedInteger Scientific
sci of
Just Int
reqInt ->
do [MultiSigScript]
msigscripts <- Vector Value -> Parser [MultiSigScript]
gatherMultiSigScripts Vector Value
s
let numScripts :: Int
numScripts = [MultiSigScript] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [MultiSigScript]
msigscripts
Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when
(Int
reqInt Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
numScripts)
(String -> Parser ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"Required number of script signatures exceeds the number of scripts."
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" Required number: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
reqInt
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" Number of scripts: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
numScripts)
MultiSigScript -> Parser MultiSigScript
forall (m :: * -> *) a. Monad m => a -> m a
return (MultiSigScript -> Parser MultiSigScript)
-> MultiSigScript -> Parser MultiSigScript
forall a b. (a -> b) -> a -> b
$ Int -> [MultiSigScript] -> MultiSigScript
RequireMOf Int
reqInt [MultiSigScript]
msigscripts
Maybe Int
Nothing -> String -> Parser MultiSigScript
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser MultiSigScript)
-> String -> Parser MultiSigScript
forall a b. (a -> b) -> a -> b
$ String
"Error in multi-signature \"required\" key: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Scientific -> String
forall a. Show a => a -> String
show Scientific
sci String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" is not a valid Int"
Value
_ -> String -> Parser MultiSigScript
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"\"required\" value should be an integer"
Text
_ -> String -> Parser MultiSigScript
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"\"atLeast\" multi-signature script value not found"
parseScriptSig :: Value -> Aeson.Parser MultiSigScript
parseScriptSig :: Value -> Parser MultiSigScript
parseScriptSig = String
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"sig" ((Object -> Parser MultiSigScript)
-> Value -> Parser MultiSigScript)
-> (Object -> Parser MultiSigScript)
-> Value
-> Parser MultiSigScript
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
Text
v <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type"
case Text
v :: Text of
Text
"sig" -> do Text
k <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"keyHash"
Hash PaymentKey -> MultiSigScript
RequireSignature (Hash PaymentKey -> MultiSigScript)
-> Parser (Hash PaymentKey) -> Parser MultiSigScript
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Parser (Hash PaymentKey)
convertToHash Text
k
Text
_ -> String -> Parser MultiSigScript
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"\"sig\" multi-signature script value not found"
convertToHash :: Text -> Aeson.Parser (Hash PaymentKey)
convertToHash :: Text -> Parser (Hash PaymentKey)
convertToHash Text
txt = case AsType (Hash PaymentKey) -> ByteString -> Maybe (Hash PaymentKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType PaymentKey -> AsType (Hash PaymentKey)
forall a. AsType a -> AsType (Hash a)
AsHash AsType PaymentKey
AsPaymentKey) (ByteString -> Maybe (Hash PaymentKey))
-> ByteString -> Maybe (Hash PaymentKey)
forall a b. (a -> b) -> a -> b
$ Text -> ByteString
Text.encodeUtf8 Text
txt of
Just Hash PaymentKey
payKeyHash -> Hash PaymentKey -> Parser (Hash PaymentKey)
forall (m :: * -> *) a. Monad m => a -> m a
return Hash PaymentKey
payKeyHash
Maybe (Hash PaymentKey)
Nothing -> String -> Parser (Hash PaymentKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (Hash PaymentKey))
-> String -> Parser (Hash PaymentKey)
forall a b. (a -> b) -> a -> b
$ String
"Error deserialising payment key hash: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
Text.unpack Text
txt
gatherMultiSigScripts :: Vector Value -> Aeson.Parser [MultiSigScript]
gatherMultiSigScripts :: Vector Value -> Parser [MultiSigScript]
gatherMultiSigScripts Vector Value
vs = [Parser MultiSigScript] -> Parser [MultiSigScript]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([Parser MultiSigScript] -> Parser [MultiSigScript])
-> (Vector (Parser MultiSigScript) -> [Parser MultiSigScript])
-> Vector (Parser MultiSigScript)
-> Parser [MultiSigScript]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector (Parser MultiSigScript) -> [Parser MultiSigScript]
forall a. Vector a -> [a]
Vector.toList (Vector (Parser MultiSigScript) -> Parser [MultiSigScript])
-> Vector (Parser MultiSigScript) -> Parser [MultiSigScript]
forall a b. (a -> b) -> a -> b
$ (Value -> Parser MultiSigScript)
-> Vector Value -> Vector (Parser MultiSigScript)
forall a b. (a -> b) -> Vector a -> Vector b
Vector.map Value -> Parser MultiSigScript
parseScript Vector Value
vs
instance HasTypeProxy Script where
data AsType Script = AsScript
proxyToAsType :: Proxy Script -> AsType Script
proxyToAsType Proxy Script
_ = AsType Script
AsScript
instance SerialiseAsRawBytes (Hash Script) where
serialiseToRawBytes :: Hash Script -> ByteString
serialiseToRawBytes (ScriptHash (Shelley.ScriptHash h)) =
Hash Blake2b_224 (MultiSig StandardShelley) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (MultiSig StandardShelley)
Hash (ADDRHASH (Crypto StandardShelley)) (Script StandardShelley)
h
deserialiseFromRawBytes :: AsType (Hash Script) -> ByteString -> Maybe (Hash Script)
deserialiseFromRawBytes (AsHash AsScript) ByteString
bs =
ScriptHash StandardShelley -> Hash Script
ScriptHash (ScriptHash StandardShelley -> Hash Script)
-> (Hash Blake2b_224 (MultiSig StandardShelley)
-> ScriptHash StandardShelley)
-> Hash Blake2b_224 (MultiSig StandardShelley)
-> Hash Script
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (MultiSig StandardShelley)
-> ScriptHash StandardShelley
forall era.
Hash (ADDRHASH (Crypto era)) (Script era) -> ScriptHash era
Shelley.ScriptHash (Hash Blake2b_224 (MultiSig StandardShelley) -> Hash Script)
-> Maybe (Hash Blake2b_224 (MultiSig StandardShelley))
-> Maybe (Hash Script)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (MultiSig StandardShelley))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance SerialiseAsCBOR Script where
serialiseToCBOR :: Script -> ByteString
serialiseToCBOR (Script Script StandardShelley
s) =
WrappedMultiSig StandardShelley -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' (MultiSig StandardShelley -> WrappedMultiSig StandardShelley
forall era. MultiSig era -> WrappedMultiSig era
Legacy.WrappedMultiSig MultiSig StandardShelley
Script StandardShelley
s)
deserialiseFromCBOR :: AsType Script -> ByteString -> Either DecoderError Script
deserialiseFromCBOR AsType Script
AsScript ByteString
bs =
MultiSig StandardShelley -> Script
Script StandardShelley -> Script
Script (MultiSig StandardShelley -> Script)
-> (WrappedMultiSig StandardShelley -> MultiSig StandardShelley)
-> WrappedMultiSig StandardShelley
-> Script
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WrappedMultiSig StandardShelley -> MultiSig StandardShelley
forall era. WrappedMultiSig era -> MultiSig era
Legacy.unWrappedMultiSig (WrappedMultiSig StandardShelley -> Script)
-> Either DecoderError (WrappedMultiSig StandardShelley)
-> Either DecoderError Script
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Text
-> (forall s.
Decoder s (Annotator (WrappedMultiSig StandardShelley)))
-> LByteString
-> Either DecoderError (WrappedMultiSig StandardShelley)
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator Text
"Script" forall s. Decoder s (Annotator (WrappedMultiSig StandardShelley))
forall a s. FromCBOR a => Decoder s a
fromCBOR (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
instance HasTextEnvelope Script where
textEnvelopeType :: AsType Script -> TextEnvelopeType
textEnvelopeType AsType Script
_ = TextEnvelopeType
"Script"
textEnvelopeDefaultDescr :: Script -> TextEnvelopeDescr
textEnvelopeDefaultDescr (Script Script StandardShelley
_) = TextEnvelopeDescr
"Multi-signature script"
scriptHash :: Script -> Hash Script
scriptHash :: Script -> Hash Script
scriptHash (Script Script StandardShelley
s) = ScriptHash StandardShelley -> Hash Script
ScriptHash (MultiSig StandardShelley -> ScriptHash StandardShelley
forall era. Era era => MultiSig era -> ScriptHash era
Shelley.hashMultiSigScript MultiSig StandardShelley
Script StandardShelley
s)
makeMultiSigScript :: MultiSigScript -> Script
makeMultiSigScript :: MultiSigScript -> Script
makeMultiSigScript = MultiSig StandardShelley -> Script
Script StandardShelley -> Script
Script (MultiSig StandardShelley -> Script)
-> (MultiSigScript -> MultiSig StandardShelley)
-> MultiSigScript
-> Script
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MultiSigScript -> MultiSig StandardShelley
go
where
go :: MultiSigScript -> Shelley.MultiSig StandardShelley
go :: MultiSigScript -> MultiSig StandardShelley
go (RequireSignature (PaymentKeyHash kh))
= KeyHash 'Witness (Crypto StandardShelley)
-> MultiSig StandardShelley
forall era.
Era era =>
KeyHash 'Witness (Crypto era) -> MultiSig era
Shelley.RequireSignature (KeyHash 'Payment StandardCrypto -> KeyHash 'Witness StandardCrypto
forall (a :: KeyRole -> * -> *) (r :: KeyRole) crypto
(r' :: KeyRole).
HasKeyRole a =>
a r crypto -> a r' crypto
Shelley.coerceKeyRole KeyHash 'Payment StandardCrypto
kh)
go (RequireAllOf [MultiSigScript]
s) = [MultiSig StandardShelley] -> MultiSig StandardShelley
forall era. Era era => [MultiSig era] -> MultiSig era
Shelley.RequireAllOf ((MultiSigScript -> MultiSig StandardShelley)
-> [MultiSigScript] -> [MultiSig StandardShelley]
forall a b. (a -> b) -> [a] -> [b]
map MultiSigScript -> MultiSig StandardShelley
go [MultiSigScript]
s)
go (RequireAnyOf [MultiSigScript]
s) = [MultiSig StandardShelley] -> MultiSig StandardShelley
forall era. Era era => [MultiSig era] -> MultiSig era
Shelley.RequireAnyOf ((MultiSigScript -> MultiSig StandardShelley)
-> [MultiSigScript] -> [MultiSig StandardShelley]
forall a b. (a -> b) -> [a] -> [b]
map MultiSigScript -> MultiSig StandardShelley
go [MultiSigScript]
s)
go (RequireMOf Int
m [MultiSigScript]
s) = Int -> [MultiSig StandardShelley] -> MultiSig StandardShelley
forall era. Era era => Int -> [MultiSig era] -> MultiSig era
Shelley.RequireMOf Int
m ((MultiSigScript -> MultiSig StandardShelley)
-> [MultiSigScript] -> [MultiSig StandardShelley]
forall a b. (a -> b) -> [a] -> [b]
map MultiSigScript -> MultiSig StandardShelley
go [MultiSigScript]
s)
makeShelleyScriptWitness :: Script -> Witness Shelley
makeShelleyScriptWitness :: Script -> Witness Shelley
makeShelleyScriptWitness (Script Script StandardShelley
s) = Script StandardShelley -> Witness Shelley
ShelleyScriptWitness Script StandardShelley
s
newtype Certificate = Certificate (Shelley.DCert StandardShelley)
deriving stock (Certificate -> Certificate -> Bool
(Certificate -> Certificate -> Bool)
-> (Certificate -> Certificate -> Bool) -> Eq Certificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Certificate -> Certificate -> Bool
$c/= :: Certificate -> Certificate -> Bool
== :: Certificate -> Certificate -> Bool
$c== :: Certificate -> Certificate -> Bool
Eq, Int -> Certificate -> ShowS
[Certificate] -> ShowS
Certificate -> String
(Int -> Certificate -> ShowS)
-> (Certificate -> String)
-> ([Certificate] -> ShowS)
-> Show Certificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Certificate] -> ShowS
$cshowList :: [Certificate] -> ShowS
show :: Certificate -> String
$cshow :: Certificate -> String
showsPrec :: Int -> Certificate -> ShowS
$cshowsPrec :: Int -> Certificate -> ShowS
Show)
deriving newtype (Typeable Certificate
Typeable Certificate
-> (Certificate -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy Certificate -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Certificate] -> Size)
-> ToCBOR Certificate
Certificate -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Certificate] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy Certificate -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Certificate] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [Certificate] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy Certificate -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy Certificate -> Size
toCBOR :: Certificate -> Encoding
$ctoCBOR :: Certificate -> Encoding
$cp1ToCBOR :: Typeable Certificate
ToCBOR, Typeable Certificate
Decoder s Certificate
Typeable Certificate
-> (forall s. Decoder s Certificate)
-> (Proxy Certificate -> Text)
-> FromCBOR Certificate
Proxy Certificate -> Text
forall s. Decoder s Certificate
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy Certificate -> Text
$clabel :: Proxy Certificate -> Text
fromCBOR :: Decoder s Certificate
$cfromCBOR :: forall s. Decoder s Certificate
$cp1FromCBOR :: Typeable Certificate
FromCBOR)
deriving anyclass HasTypeProxy Certificate
Certificate -> ByteString
HasTypeProxy Certificate
-> (Certificate -> ByteString)
-> (AsType Certificate
-> ByteString -> Either DecoderError Certificate)
-> SerialiseAsCBOR Certificate
AsType Certificate -> ByteString -> Either DecoderError Certificate
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType Certificate -> ByteString -> Either DecoderError Certificate
$cdeserialiseFromCBOR :: AsType Certificate -> ByteString -> Either DecoderError Certificate
serialiseToCBOR :: Certificate -> ByteString
$cserialiseToCBOR :: Certificate -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy Certificate
SerialiseAsCBOR
instance HasTypeProxy Certificate where
data AsType Certificate = AsCertificate
proxyToAsType :: Proxy Certificate -> AsType Certificate
proxyToAsType Proxy Certificate
_ = AsType Certificate
AsCertificate
instance HasTextEnvelope Certificate where
textEnvelopeType :: AsType Certificate -> TextEnvelopeType
textEnvelopeType AsType Certificate
_ = TextEnvelopeType
"CertificateShelley"
textEnvelopeDefaultDescr :: Certificate -> TextEnvelopeDescr
textEnvelopeDefaultDescr (Certificate DCert StandardShelley
cert) = case DCert StandardShelley
cert of
Shelley.DCertDeleg Shelley.RegKey {} -> TextEnvelopeDescr
"Stake address registration"
Shelley.DCertDeleg Shelley.DeRegKey {} -> TextEnvelopeDescr
"Stake address de-registration"
Shelley.DCertDeleg Shelley.Delegate {} -> TextEnvelopeDescr
"Stake address delegation"
Shelley.DCertPool Shelley.RegPool {} -> TextEnvelopeDescr
"Pool registration"
Shelley.DCertPool Shelley.RetirePool {} -> TextEnvelopeDescr
"Pool retirement"
Shelley.DCertGenesis{} -> TextEnvelopeDescr
"Genesis key delegation"
Shelley.DCertMir{} -> TextEnvelopeDescr
"MIR"
makeStakeAddressRegistrationCertificate
:: StakeCredential
-> Certificate
makeStakeAddressRegistrationCertificate :: StakeCredential -> Certificate
makeStakeAddressRegistrationCertificate StakeCredential
stakecred =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (DelegCert StandardShelley -> DCert StandardShelley)
-> DelegCert StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DelegCert StandardShelley -> DCert StandardShelley
forall era. DelegCert era -> DCert era
Shelley.DCertDeleg
(DelegCert StandardShelley -> Certificate)
-> DelegCert StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ StakeCredential StandardShelley -> DelegCert StandardShelley
forall era. StakeCredential era -> DelegCert era
Shelley.RegKey
(StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential StakeCredential
stakecred)
makeStakeAddressDeregistrationCertificate
:: StakeCredential
-> Certificate
makeStakeAddressDeregistrationCertificate :: StakeCredential -> Certificate
makeStakeAddressDeregistrationCertificate StakeCredential
stakecred =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (DelegCert StandardShelley -> DCert StandardShelley)
-> DelegCert StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DelegCert StandardShelley -> DCert StandardShelley
forall era. DelegCert era -> DCert era
Shelley.DCertDeleg
(DelegCert StandardShelley -> Certificate)
-> DelegCert StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ StakeCredential StandardShelley -> DelegCert StandardShelley
forall era. StakeCredential era -> DelegCert era
Shelley.DeRegKey
(StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential StakeCredential
stakecred)
makeStakeAddressDelegationCertificate
:: StakeCredential
-> PoolId
-> Certificate
makeStakeAddressDelegationCertificate :: StakeCredential -> PoolId -> Certificate
makeStakeAddressDelegationCertificate StakeCredential
stakecred (StakePoolKeyHash poolid) =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (Delegation StandardShelley -> DCert StandardShelley)
-> Delegation StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DelegCert StandardShelley -> DCert StandardShelley
forall era. DelegCert era -> DCert era
Shelley.DCertDeleg
(DelegCert StandardShelley -> DCert StandardShelley)
-> (Delegation StandardShelley -> DelegCert StandardShelley)
-> Delegation StandardShelley
-> DCert StandardShelley
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Delegation StandardShelley -> DelegCert StandardShelley
forall era. Delegation era -> DelegCert era
Shelley.Delegate
(Delegation StandardShelley -> Certificate)
-> Delegation StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ StakeCredential StandardShelley
-> KeyHash 'StakePool (Crypto StandardShelley)
-> Delegation StandardShelley
forall era.
StakeCredential era
-> KeyHash 'StakePool (Crypto era) -> Delegation era
Shelley.Delegation
(StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential StakeCredential
stakecred)
KeyHash 'StakePool StandardCrypto
KeyHash 'StakePool (Crypto StandardShelley)
poolid
makeGenesisKeyDelegationCertificate
:: Hash GenesisKey
-> Hash GenesisDelegateKey
-> Hash VrfKey
-> Certificate
makeGenesisKeyDelegationCertificate :: Hash GenesisKey
-> Hash GenesisDelegateKey -> Hash VrfKey -> Certificate
makeGenesisKeyDelegationCertificate (GenesisKeyHash genesiskh)
(GenesisDelegateKeyHash delegatekh)
(VrfKeyHash vrfkh) =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (GenesisDelegCert StandardShelley -> DCert StandardShelley)
-> GenesisDelegCert StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenesisDelegCert StandardShelley -> DCert StandardShelley
forall era. GenesisDelegCert era -> DCert era
Shelley.DCertGenesis
(GenesisDelegCert StandardShelley -> Certificate)
-> GenesisDelegCert StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ KeyHash 'Genesis (Crypto StandardShelley)
-> KeyHash 'GenesisDelegate (Crypto StandardShelley)
-> Hash
(Crypto StandardShelley) (VerKeyVRF (Crypto StandardShelley))
-> GenesisDelegCert StandardShelley
forall era.
KeyHash 'Genesis (Crypto era)
-> KeyHash 'GenesisDelegate (Crypto era)
-> Hash (Crypto era) (VerKeyVRF (Crypto era))
-> GenesisDelegCert era
Shelley.GenesisDelegCert
KeyHash 'Genesis StandardCrypto
KeyHash 'Genesis (Crypto StandardShelley)
genesiskh
KeyHash 'GenesisDelegate StandardCrypto
KeyHash 'GenesisDelegate (Crypto StandardShelley)
delegatekh
Hash StandardCrypto (VerKeyVRF StandardCrypto)
Hash (Crypto StandardShelley) (VerKeyVRF (Crypto StandardShelley))
vrfkh
makeMIRCertificate
:: MIRPot
-> [(StakeCredential, Lovelace)]
-> Certificate
makeMIRCertificate :: MIRPot -> [(StakeCredential, Lovelace)] -> Certificate
makeMIRCertificate MIRPot
mirpot [(StakeCredential, Lovelace)]
amounts =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (MIRCert StandardShelley -> DCert StandardShelley)
-> MIRCert StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MIRCert StandardShelley -> DCert StandardShelley
forall era. MIRCert era -> DCert era
Shelley.DCertMir
(MIRCert StandardShelley -> Certificate)
-> MIRCert StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ MIRPot
-> Map (StakeCredential StandardShelley) Coin
-> MIRCert StandardShelley
forall era.
MIRPot -> Map (Credential 'Staking era) Coin -> MIRCert era
Shelley.MIRCert
MIRPot
mirpot
((Coin -> Coin -> Coin)
-> [(StakeCredential StandardShelley, Coin)]
-> Map (StakeCredential StandardShelley) Coin
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith Coin -> Coin -> Coin
forall a. Semigroup a => a -> a -> a
(<>)
[ (StakeCredential -> StakeCredential StandardShelley
toShelleyStakeCredential StakeCredential
sc, Lovelace -> Coin
toShelleyLovelace Lovelace
v)
| (StakeCredential
sc, Lovelace
v) <- [(StakeCredential, Lovelace)]
amounts ])
makeStakePoolRegistrationCertificate
:: StakePoolParameters
-> Certificate
makeStakePoolRegistrationCertificate :: StakePoolParameters -> Certificate
makeStakePoolRegistrationCertificate StakePoolParameters
poolparams =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (PoolCert StandardShelley -> DCert StandardShelley)
-> PoolCert StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PoolCert StandardShelley -> DCert StandardShelley
forall era. PoolCert era -> DCert era
Shelley.DCertPool
(PoolCert StandardShelley -> Certificate)
-> PoolCert StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ PoolParams StandardShelley -> PoolCert StandardShelley
forall era. PoolParams era -> PoolCert era
Shelley.RegPool
(StakePoolParameters -> PoolParams StandardShelley
toShelleyPoolParams StakePoolParameters
poolparams)
makeStakePoolRetirementCertificate
:: PoolId
-> EpochNo
-> Certificate
makeStakePoolRetirementCertificate :: PoolId -> EpochNo -> Certificate
makeStakePoolRetirementCertificate (StakePoolKeyHash poolid) EpochNo
epochno =
DCert StandardShelley -> Certificate
Certificate
(DCert StandardShelley -> Certificate)
-> (PoolCert StandardShelley -> DCert StandardShelley)
-> PoolCert StandardShelley
-> Certificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PoolCert StandardShelley -> DCert StandardShelley
forall era. PoolCert era -> DCert era
Shelley.DCertPool
(PoolCert StandardShelley -> Certificate)
-> PoolCert StandardShelley -> Certificate
forall a b. (a -> b) -> a -> b
$ KeyHash 'StakePool (Crypto StandardShelley)
-> EpochNo -> PoolCert StandardShelley
forall era.
KeyHash 'StakePool (Crypto era) -> EpochNo -> PoolCert era
Shelley.RetirePool
KeyHash 'StakePool StandardCrypto
KeyHash 'StakePool (Crypto StandardShelley)
poolid
EpochNo
epochno
type PoolId = Hash StakePoolKey
data StakePoolParameters =
StakePoolParameters {
StakePoolParameters -> PoolId
stakePoolId :: PoolId,
StakePoolParameters -> Hash VrfKey
stakePoolVRF :: Hash VrfKey,
StakePoolParameters -> Lovelace
stakePoolCost :: Lovelace,
StakePoolParameters -> Rational
stakePoolMargin :: Rational,
StakePoolParameters -> StakeAddress
stakePoolRewardAccount :: StakeAddress,
StakePoolParameters -> Lovelace
stakePoolPledge :: Lovelace,
StakePoolParameters -> [Hash StakeKey]
stakePoolOwners :: [Hash StakeKey],
StakePoolParameters -> [StakePoolRelay]
stakePoolRelays :: [StakePoolRelay],
StakePoolParameters -> Maybe StakePoolMetadataReference
stakePoolMetadata :: Maybe StakePoolMetadataReference
}
deriving (StakePoolParameters -> StakePoolParameters -> Bool
(StakePoolParameters -> StakePoolParameters -> Bool)
-> (StakePoolParameters -> StakePoolParameters -> Bool)
-> Eq StakePoolParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakePoolParameters -> StakePoolParameters -> Bool
$c/= :: StakePoolParameters -> StakePoolParameters -> Bool
== :: StakePoolParameters -> StakePoolParameters -> Bool
$c== :: StakePoolParameters -> StakePoolParameters -> Bool
Eq, Int -> StakePoolParameters -> ShowS
[StakePoolParameters] -> ShowS
StakePoolParameters -> String
(Int -> StakePoolParameters -> ShowS)
-> (StakePoolParameters -> String)
-> ([StakePoolParameters] -> ShowS)
-> Show StakePoolParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakePoolParameters] -> ShowS
$cshowList :: [StakePoolParameters] -> ShowS
show :: StakePoolParameters -> String
$cshow :: StakePoolParameters -> String
showsPrec :: Int -> StakePoolParameters -> ShowS
$cshowsPrec :: Int -> StakePoolParameters -> ShowS
Show)
data StakePoolRelay =
StakePoolRelayIp
(Maybe IPv4) (Maybe IPv6) (Maybe PortNumber)
| StakePoolRelayDnsARecord
ByteString (Maybe PortNumber)
| StakePoolRelayDnsSrvRecord
ByteString
deriving (StakePoolRelay -> StakePoolRelay -> Bool
(StakePoolRelay -> StakePoolRelay -> Bool)
-> (StakePoolRelay -> StakePoolRelay -> Bool) -> Eq StakePoolRelay
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakePoolRelay -> StakePoolRelay -> Bool
$c/= :: StakePoolRelay -> StakePoolRelay -> Bool
== :: StakePoolRelay -> StakePoolRelay -> Bool
$c== :: StakePoolRelay -> StakePoolRelay -> Bool
Eq, Int -> StakePoolRelay -> ShowS
[StakePoolRelay] -> ShowS
StakePoolRelay -> String
(Int -> StakePoolRelay -> ShowS)
-> (StakePoolRelay -> String)
-> ([StakePoolRelay] -> ShowS)
-> Show StakePoolRelay
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakePoolRelay] -> ShowS
$cshowList :: [StakePoolRelay] -> ShowS
show :: StakePoolRelay -> String
$cshow :: StakePoolRelay -> String
showsPrec :: Int -> StakePoolRelay -> ShowS
$cshowsPrec :: Int -> StakePoolRelay -> ShowS
Show)
data StakePoolMetadataReference =
StakePoolMetadataReference {
StakePoolMetadataReference -> URI
stakePoolMetadataURL :: URI.URI,
StakePoolMetadataReference -> Hash StakePoolMetadata
stakePoolMetadataHash :: Hash StakePoolMetadata
}
deriving (StakePoolMetadataReference -> StakePoolMetadataReference -> Bool
(StakePoolMetadataReference -> StakePoolMetadataReference -> Bool)
-> (StakePoolMetadataReference
-> StakePoolMetadataReference -> Bool)
-> Eq StakePoolMetadataReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakePoolMetadataReference -> StakePoolMetadataReference -> Bool
$c/= :: StakePoolMetadataReference -> StakePoolMetadataReference -> Bool
== :: StakePoolMetadataReference -> StakePoolMetadataReference -> Bool
$c== :: StakePoolMetadataReference -> StakePoolMetadataReference -> Bool
Eq, Int -> StakePoolMetadataReference -> ShowS
[StakePoolMetadataReference] -> ShowS
StakePoolMetadataReference -> String
(Int -> StakePoolMetadataReference -> ShowS)
-> (StakePoolMetadataReference -> String)
-> ([StakePoolMetadataReference] -> ShowS)
-> Show StakePoolMetadataReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakePoolMetadataReference] -> ShowS
$cshowList :: [StakePoolMetadataReference] -> ShowS
show :: StakePoolMetadataReference -> String
$cshow :: StakePoolMetadataReference -> String
showsPrec :: Int -> StakePoolMetadataReference -> ShowS
$cshowsPrec :: Int -> StakePoolMetadataReference -> ShowS
Show)
toShelleyPoolParams :: StakePoolParameters -> Shelley.PoolParams StandardShelley
toShelleyPoolParams :: StakePoolParameters -> PoolParams StandardShelley
toShelleyPoolParams StakePoolParameters {
stakePoolId :: StakePoolParameters -> PoolId
stakePoolId = StakePoolKeyHash poolkh
, stakePoolVRF :: StakePoolParameters -> Hash VrfKey
stakePoolVRF = VrfKeyHash vrfkh
, Lovelace
stakePoolCost :: Lovelace
stakePoolCost :: StakePoolParameters -> Lovelace
stakePoolCost
, Rational
stakePoolMargin :: Rational
stakePoolMargin :: StakePoolParameters -> Rational
stakePoolMargin
, StakeAddress
stakePoolRewardAccount :: StakeAddress
stakePoolRewardAccount :: StakePoolParameters -> StakeAddress
stakePoolRewardAccount
, Lovelace
stakePoolPledge :: Lovelace
stakePoolPledge :: StakePoolParameters -> Lovelace
stakePoolPledge
, [Hash StakeKey]
stakePoolOwners :: [Hash StakeKey]
stakePoolOwners :: StakePoolParameters -> [Hash StakeKey]
stakePoolOwners
, [StakePoolRelay]
stakePoolRelays :: [StakePoolRelay]
stakePoolRelays :: StakePoolParameters -> [StakePoolRelay]
stakePoolRelays
, Maybe StakePoolMetadataReference
stakePoolMetadata :: Maybe StakePoolMetadataReference
stakePoolMetadata :: StakePoolParameters -> Maybe StakePoolMetadataReference
stakePoolMetadata
} =
PoolParams :: forall era.
KeyHash 'StakePool (Crypto era)
-> Hash (Crypto era) (VerKeyVRF (Crypto era))
-> Coin
-> Coin
-> UnitInterval
-> RewardAcnt era
-> Set (KeyHash 'Staking (Crypto era))
-> StrictSeq StakePoolRelay
-> StrictMaybe PoolMetaData
-> PoolParams era
Shelley.PoolParams {
_poolId :: KeyHash 'StakePool (Crypto StandardShelley)
Shelley._poolId = KeyHash 'StakePool StandardCrypto
KeyHash 'StakePool (Crypto StandardShelley)
poolkh
, _poolVrf :: Hash (Crypto StandardShelley) (VerKeyVRF (Crypto StandardShelley))
Shelley._poolVrf = Hash StandardCrypto (VerKeyVRF StandardCrypto)
Hash (Crypto StandardShelley) (VerKeyVRF (Crypto StandardShelley))
vrfkh
, _poolPledge :: Coin
Shelley._poolPledge = Lovelace -> Coin
toShelleyLovelace Lovelace
stakePoolPledge
, _poolCost :: Coin
Shelley._poolCost = Lovelace -> Coin
toShelleyLovelace Lovelace
stakePoolCost
, _poolMargin :: UnitInterval
Shelley._poolMargin = Ratio Word64 -> UnitInterval
Shelley.truncateUnitInterval
(Rational -> Ratio Word64
forall a. Fractional a => Rational -> a
fromRational Rational
stakePoolMargin)
, _poolRAcnt :: RewardAcnt StandardShelley
Shelley._poolRAcnt = StakeAddress -> RewardAcnt StandardShelley
toShelleyStakeAddr StakeAddress
stakePoolRewardAccount
, _poolOwners :: Set (KeyHash 'Staking (Crypto StandardShelley))
Shelley._poolOwners = [KeyHash 'Staking StandardCrypto]
-> Set (KeyHash 'Staking StandardCrypto)
forall a. Ord a => [a] -> Set a
Set.fromList
[ KeyHash 'Staking StandardCrypto
kh | StakeKeyHash kh <- [Hash StakeKey]
stakePoolOwners ]
, _poolRelays :: StrictSeq StakePoolRelay
Shelley._poolRelays = [StakePoolRelay] -> StrictSeq StakePoolRelay
forall a. [a] -> StrictSeq a
Seq.fromList
((StakePoolRelay -> StakePoolRelay)
-> [StakePoolRelay] -> [StakePoolRelay]
forall a b. (a -> b) -> [a] -> [b]
map StakePoolRelay -> StakePoolRelay
toShelleyStakePoolRelay [StakePoolRelay]
stakePoolRelays)
, _poolMD :: StrictMaybe PoolMetaData
Shelley._poolMD = StakePoolMetadataReference -> PoolMetaData
toShelleyPoolMetaData (StakePoolMetadataReference -> PoolMetaData)
-> StrictMaybe StakePoolMetadataReference
-> StrictMaybe PoolMetaData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe StakePoolMetadataReference
-> StrictMaybe StakePoolMetadataReference
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe StakePoolMetadataReference
stakePoolMetadata
}
where
toShelleyStakePoolRelay :: StakePoolRelay -> Shelley.StakePoolRelay
toShelleyStakePoolRelay :: StakePoolRelay -> StakePoolRelay
toShelleyStakePoolRelay (StakePoolRelayIp Maybe IPv4
mipv4 Maybe IPv6
mipv6 Maybe PortNumber
mport) =
StrictMaybe Port
-> StrictMaybe IPv4 -> StrictMaybe IPv6 -> StakePoolRelay
Shelley.SingleHostAddr
(PortNumber -> Port
forall a b. (Integral a, Num b) => a -> b
fromIntegral (PortNumber -> Port) -> StrictMaybe PortNumber -> StrictMaybe Port
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe PortNumber -> StrictMaybe PortNumber
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe PortNumber
mport)
(Maybe IPv4 -> StrictMaybe IPv4
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe IPv4
mipv4)
(Maybe IPv6 -> StrictMaybe IPv6
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe IPv6
mipv6)
toShelleyStakePoolRelay (StakePoolRelayDnsARecord ByteString
dnsname Maybe PortNumber
mport) =
StrictMaybe Port -> DnsName -> StakePoolRelay
Shelley.SingleHostName
(PortNumber -> Port
forall a b. (Integral a, Num b) => a -> b
fromIntegral (PortNumber -> Port) -> StrictMaybe PortNumber -> StrictMaybe Port
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe PortNumber -> StrictMaybe PortNumber
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe PortNumber
mport)
(ByteString -> DnsName
toShelleyDnsName ByteString
dnsname)
toShelleyStakePoolRelay (StakePoolRelayDnsSrvRecord ByteString
dnsname) =
DnsName -> StakePoolRelay
Shelley.MultiHostName
(ByteString -> DnsName
toShelleyDnsName ByteString
dnsname)
toShelleyPoolMetaData :: StakePoolMetadataReference -> Shelley.PoolMetaData
toShelleyPoolMetaData :: StakePoolMetadataReference -> PoolMetaData
toShelleyPoolMetaData StakePoolMetadataReference {
URI
stakePoolMetadataURL :: URI
stakePoolMetadataURL :: StakePoolMetadataReference -> URI
stakePoolMetadataURL
, stakePoolMetadataHash :: StakePoolMetadataReference -> Hash StakePoolMetadata
stakePoolMetadataHash = StakePoolMetadataHash mdh
} =
PoolMetaData :: Url -> ByteString -> PoolMetaData
Shelley.PoolMetaData {
_poolMDUrl :: Url
Shelley._poolMDUrl = URI -> Url
toShelleyUrl URI
stakePoolMetadataURL
, _poolMDHash :: ByteString
Shelley._poolMDHash = Hash Blake2b_256 ByteString -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 ByteString
Hash StandardCrypto ByteString
mdh
}
toShelleyDnsName :: ByteString -> Shelley.DnsName
toShelleyDnsName :: ByteString -> DnsName
toShelleyDnsName = DnsName -> Maybe DnsName -> DnsName
forall a. a -> Maybe a -> a
fromMaybe (String -> DnsName
forall a. HasCallStack => String -> a
error String
"toShelleyDnsName: invalid dns name. TODO: proper validation")
(Maybe DnsName -> DnsName)
-> (ByteString -> Maybe DnsName) -> ByteString -> DnsName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe DnsName
Shelley.textToDns
(Text -> Maybe DnsName)
-> (ByteString -> Text) -> ByteString -> Maybe DnsName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
Text.decodeLatin1
toShelleyUrl :: URI.URI -> Shelley.Url
toShelleyUrl :: URI -> Url
toShelleyUrl URI
uri = Url -> Maybe Url -> Url
forall a. a -> Maybe a -> a
fromMaybe (String -> Url
forall a. HasCallStack => String -> a
error String
"toShelleyUrl: invalid url. TODO: proper validation")
(Maybe Url -> Url) -> (String -> Maybe Url) -> String -> Url
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Url
Shelley.textToUrl
(Text -> Maybe Url) -> (String -> Text) -> String -> Maybe Url
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack
(String -> Url) -> String -> Url
forall a b. (a -> b) -> a -> b
$ ShowS -> URI -> ShowS
URI.uriToString ShowS
forall a. a -> a
id URI
uri String
""
data StakePoolMetadata =
StakePoolMetadata {
StakePoolMetadata -> Text
stakePoolName :: !Text
, StakePoolMetadata -> Text
stakePoolDescription :: !Text
, StakePoolMetadata -> Text
stakePoolTicker :: !Text
, StakePoolMetadata -> Text
stakePoolHomepage :: !Text
}
deriving (StakePoolMetadata -> StakePoolMetadata -> Bool
(StakePoolMetadata -> StakePoolMetadata -> Bool)
-> (StakePoolMetadata -> StakePoolMetadata -> Bool)
-> Eq StakePoolMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StakePoolMetadata -> StakePoolMetadata -> Bool
$c/= :: StakePoolMetadata -> StakePoolMetadata -> Bool
== :: StakePoolMetadata -> StakePoolMetadata -> Bool
$c== :: StakePoolMetadata -> StakePoolMetadata -> Bool
Eq, Int -> StakePoolMetadata -> ShowS
[StakePoolMetadata] -> ShowS
StakePoolMetadata -> String
(Int -> StakePoolMetadata -> ShowS)
-> (StakePoolMetadata -> String)
-> ([StakePoolMetadata] -> ShowS)
-> Show StakePoolMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakePoolMetadata] -> ShowS
$cshowList :: [StakePoolMetadata] -> ShowS
show :: StakePoolMetadata -> String
$cshow :: StakePoolMetadata -> String
showsPrec :: Int -> StakePoolMetadata -> ShowS
$cshowsPrec :: Int -> StakePoolMetadata -> ShowS
Show)
newtype instance Hash StakePoolMetadata =
StakePoolMetadataHash (Shelley.Hash StandardCrypto ByteString)
deriving (Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool
(Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool)
-> (Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool)
-> Eq (Hash StakePoolMetadata)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool
$c/= :: Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool
== :: Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool
$c== :: Hash StakePoolMetadata -> Hash StakePoolMetadata -> Bool
Eq, Int -> Hash StakePoolMetadata -> ShowS
[Hash StakePoolMetadata] -> ShowS
Hash StakePoolMetadata -> String
(Int -> Hash StakePoolMetadata -> ShowS)
-> (Hash StakePoolMetadata -> String)
-> ([Hash StakePoolMetadata] -> ShowS)
-> Show (Hash StakePoolMetadata)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash StakePoolMetadata] -> ShowS
$cshowList :: [Hash StakePoolMetadata] -> ShowS
show :: Hash StakePoolMetadata -> String
$cshow :: Hash StakePoolMetadata -> String
showsPrec :: Int -> Hash StakePoolMetadata -> ShowS
$cshowsPrec :: Int -> Hash StakePoolMetadata -> ShowS
Show)
instance HasTypeProxy StakePoolMetadata where
data AsType StakePoolMetadata = AsStakePoolMetadata
proxyToAsType :: Proxy StakePoolMetadata -> AsType StakePoolMetadata
proxyToAsType Proxy StakePoolMetadata
_ = AsType StakePoolMetadata
AsStakePoolMetadata
instance SerialiseAsRawBytes (Hash StakePoolMetadata) where
serialiseToRawBytes :: Hash StakePoolMetadata -> ByteString
serialiseToRawBytes (StakePoolMetadataHash h) = Hash Blake2b_256 ByteString -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 ByteString
Hash StandardCrypto ByteString
h
deserialiseFromRawBytes :: AsType (Hash StakePoolMetadata)
-> ByteString -> Maybe (Hash StakePoolMetadata)
deserialiseFromRawBytes (AsHash AsStakePoolMetadata) ByteString
bs =
Hash Blake2b_256 ByteString -> Hash StakePoolMetadata
Hash StandardCrypto ByteString -> Hash StakePoolMetadata
StakePoolMetadataHash (Hash Blake2b_256 ByteString -> Hash StakePoolMetadata)
-> Maybe (Hash Blake2b_256 ByteString)
-> Maybe (Hash StakePoolMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_256 ByteString)
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance FromJSON StakePoolMetadata where
parseJSON :: Value -> Parser StakePoolMetadata
parseJSON =
String
-> (Object -> Parser StakePoolMetadata)
-> Value
-> Parser StakePoolMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"StakePoolMetadata" ((Object -> Parser StakePoolMetadata)
-> Value -> Parser StakePoolMetadata)
-> (Object -> Parser StakePoolMetadata)
-> Value
-> Parser StakePoolMetadata
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
Text -> Text -> Text -> Text -> StakePoolMetadata
StakePoolMetadata
(Text -> Text -> Text -> Text -> StakePoolMetadata)
-> Parser Text
-> Parser (Text -> Text -> Text -> StakePoolMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object -> Parser Text
parseName Object
obj
Parser (Text -> Text -> Text -> StakePoolMetadata)
-> Parser Text -> Parser (Text -> Text -> StakePoolMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object -> Parser Text
parseDescription Object
obj
Parser (Text -> Text -> StakePoolMetadata)
-> Parser Text -> Parser (Text -> StakePoolMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object -> Parser Text
parseTicker Object
obj
Parser (Text -> StakePoolMetadata)
-> Parser Text -> Parser StakePoolMetadata
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"homepage"
where
parseName :: Aeson.Object -> Aeson.Parser Text
parseName :: Object -> Parser Text
parseName Object
obj = do
Text
name <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"name"
if Text -> Int
Text.length Text
name Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
50
then Text -> Parser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
name
else String -> Parser Text
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Text) -> String -> Parser Text
forall a b. (a -> b) -> a -> b
$ String
"\"name\" must have at most 50 characters, but it has "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Text -> Int
Text.length Text
name)
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" characters."
parseDescription :: Aeson.Object -> Aeson.Parser Text
parseDescription :: Object -> Parser Text
parseDescription Object
obj = do
Text
description <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"description"
if Text -> Int
Text.length Text
description Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
255
then Text -> Parser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
description
else String -> Parser Text
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Text) -> String -> Parser Text
forall a b. (a -> b) -> a -> b
$
String
"\"description\" must have at most 255 characters, but it has "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Text -> Int
Text.length Text
description)
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" characters."
parseTicker :: Aeson.Object -> Aeson.Parser Text
parseTicker :: Object -> Parser Text
parseTicker Object
obj = do
Text
ticker <- Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"ticker"
let tickerLen :: Int
tickerLen = Text -> Int
Text.length Text
ticker
if Int
tickerLen Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
3 Bool -> Bool -> Bool
&& Int
tickerLen Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
5
then Text -> Parser Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
ticker
else String -> Parser Text
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Text) -> String -> Parser Text
forall a b. (a -> b) -> a -> b
$
String
"\"ticker\" must have at least 3 and at most 5 "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"characters, but it has "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Text -> Int
Text.length Text
ticker)
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" characters."
data StakePoolMetadataValidationError
= StakePoolMetadataJsonDecodeError !String
| StakePoolMetadataInvalidLengthError
!Int
!Int
deriving Int -> StakePoolMetadataValidationError -> ShowS
[StakePoolMetadataValidationError] -> ShowS
StakePoolMetadataValidationError -> String
(Int -> StakePoolMetadataValidationError -> ShowS)
-> (StakePoolMetadataValidationError -> String)
-> ([StakePoolMetadataValidationError] -> ShowS)
-> Show StakePoolMetadataValidationError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StakePoolMetadataValidationError] -> ShowS
$cshowList :: [StakePoolMetadataValidationError] -> ShowS
show :: StakePoolMetadataValidationError -> String
$cshow :: StakePoolMetadataValidationError -> String
showsPrec :: Int -> StakePoolMetadataValidationError -> ShowS
$cshowsPrec :: Int -> StakePoolMetadataValidationError -> ShowS
Show
instance Error StakePoolMetadataValidationError where
displayError :: StakePoolMetadataValidationError -> String
displayError (StakePoolMetadataJsonDecodeError String
errStr) = String
errStr
displayError (StakePoolMetadataInvalidLengthError Int
maxLen Int
actualLen) =
String
"Stake pool metadata must consist of at most "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
maxLen
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" bytes, but it consists of "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
actualLen
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" bytes."
validateAndHashStakePoolMetadata
:: ByteString
-> Either StakePoolMetadataValidationError
(StakePoolMetadata, Hash StakePoolMetadata)
validateAndHashStakePoolMetadata :: ByteString
-> Either
StakePoolMetadataValidationError
(StakePoolMetadata, Hash StakePoolMetadata)
validateAndHashStakePoolMetadata ByteString
bs
| ByteString -> Int
BS.length ByteString
bs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
512 = do
StakePoolMetadata
md <- (String -> StakePoolMetadataValidationError)
-> Either String StakePoolMetadata
-> Either StakePoolMetadataValidationError StakePoolMetadata
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first String -> StakePoolMetadataValidationError
StakePoolMetadataJsonDecodeError
(ByteString -> Either String StakePoolMetadata
forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecodeStrict' ByteString
bs)
let mdh :: Hash StakePoolMetadata
mdh = Hash StandardCrypto ByteString -> Hash StakePoolMetadata
StakePoolMetadataHash ((ByteString -> ByteString)
-> ByteString -> Hash Blake2b_256 ByteString
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith ByteString -> ByteString
forall a. a -> a
id ByteString
bs)
(StakePoolMetadata, Hash StakePoolMetadata)
-> Either
StakePoolMetadataValidationError
(StakePoolMetadata, Hash StakePoolMetadata)
forall (m :: * -> *) a. Monad m => a -> m a
return (StakePoolMetadata
md, Hash StakePoolMetadata
mdh)
| Bool
otherwise = StakePoolMetadataValidationError
-> Either
StakePoolMetadataValidationError
(StakePoolMetadata, Hash StakePoolMetadata)
forall a b. a -> Either a b
Left (StakePoolMetadataValidationError
-> Either
StakePoolMetadataValidationError
(StakePoolMetadata, Hash StakePoolMetadata))
-> StakePoolMetadataValidationError
-> Either
StakePoolMetadataValidationError
(StakePoolMetadata, Hash StakePoolMetadata)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> StakePoolMetadataValidationError
StakePoolMetadataInvalidLengthError Int
512 (ByteString -> Int
BS.length ByteString
bs)
newtype TxMetadata = TxMetadataShelley Shelley.MetaData
deriving stock (TxMetadata -> TxMetadata -> Bool
(TxMetadata -> TxMetadata -> Bool)
-> (TxMetadata -> TxMetadata -> Bool) -> Eq TxMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxMetadata -> TxMetadata -> Bool
$c/= :: TxMetadata -> TxMetadata -> Bool
== :: TxMetadata -> TxMetadata -> Bool
$c== :: TxMetadata -> TxMetadata -> Bool
Eq, Int -> TxMetadata -> ShowS
[TxMetadata] -> ShowS
TxMetadata -> String
(Int -> TxMetadata -> ShowS)
-> (TxMetadata -> String)
-> ([TxMetadata] -> ShowS)
-> Show TxMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxMetadata] -> ShowS
$cshowList :: [TxMetadata] -> ShowS
show :: TxMetadata -> String
$cshow :: TxMetadata -> String
showsPrec :: Int -> TxMetadata -> ShowS
$cshowsPrec :: Int -> TxMetadata -> ShowS
Show)
{-# COMPLETE TxMetadata #-}
pattern TxMetadata :: Map Word64 TxMetadataValue -> TxMetadata
pattern $bTxMetadata :: Map Word64 TxMetadataValue -> TxMetadata
$mTxMetadata :: forall r.
TxMetadata
-> (Map Word64 TxMetadataValue -> r) -> (Void# -> r) -> r
TxMetadata m <- TxMetadataShelley (fromShelleyMetaData -> m) where
TxMetadata = MetaData -> TxMetadata
TxMetadataShelley (MetaData -> TxMetadata)
-> (Map Word64 TxMetadataValue -> MetaData)
-> Map Word64 TxMetadataValue
-> TxMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map Word64 TxMetadataValue -> MetaData
toShelleyMetaData
data TxMetadataValue = TxMetaNumber Integer
| TxMetaBytes ByteString
| TxMetaText Text
| TxMetaList [TxMetadataValue]
| TxMetaMap [(TxMetadataValue, TxMetadataValue)]
deriving stock (TxMetadataValue -> TxMetadataValue -> Bool
(TxMetadataValue -> TxMetadataValue -> Bool)
-> (TxMetadataValue -> TxMetadataValue -> Bool)
-> Eq TxMetadataValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TxMetadataValue -> TxMetadataValue -> Bool
$c/= :: TxMetadataValue -> TxMetadataValue -> Bool
== :: TxMetadataValue -> TxMetadataValue -> Bool
$c== :: TxMetadataValue -> TxMetadataValue -> Bool
Eq, Eq TxMetadataValue
Eq TxMetadataValue
-> (TxMetadataValue -> TxMetadataValue -> Ordering)
-> (TxMetadataValue -> TxMetadataValue -> Bool)
-> (TxMetadataValue -> TxMetadataValue -> Bool)
-> (TxMetadataValue -> TxMetadataValue -> Bool)
-> (TxMetadataValue -> TxMetadataValue -> Bool)
-> (TxMetadataValue -> TxMetadataValue -> TxMetadataValue)
-> (TxMetadataValue -> TxMetadataValue -> TxMetadataValue)
-> Ord TxMetadataValue
TxMetadataValue -> TxMetadataValue -> Bool
TxMetadataValue -> TxMetadataValue -> Ordering
TxMetadataValue -> TxMetadataValue -> TxMetadataValue
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: TxMetadataValue -> TxMetadataValue -> TxMetadataValue
$cmin :: TxMetadataValue -> TxMetadataValue -> TxMetadataValue
max :: TxMetadataValue -> TxMetadataValue -> TxMetadataValue
$cmax :: TxMetadataValue -> TxMetadataValue -> TxMetadataValue
>= :: TxMetadataValue -> TxMetadataValue -> Bool
$c>= :: TxMetadataValue -> TxMetadataValue -> Bool
> :: TxMetadataValue -> TxMetadataValue -> Bool
$c> :: TxMetadataValue -> TxMetadataValue -> Bool
<= :: TxMetadataValue -> TxMetadataValue -> Bool
$c<= :: TxMetadataValue -> TxMetadataValue -> Bool
< :: TxMetadataValue -> TxMetadataValue -> Bool
$c< :: TxMetadataValue -> TxMetadataValue -> Bool
compare :: TxMetadataValue -> TxMetadataValue -> Ordering
$ccompare :: TxMetadataValue -> TxMetadataValue -> Ordering
$cp1Ord :: Eq TxMetadataValue
Ord, Int -> TxMetadataValue -> ShowS
[TxMetadataValue] -> ShowS
TxMetadataValue -> String
(Int -> TxMetadataValue -> ShowS)
-> (TxMetadataValue -> String)
-> ([TxMetadataValue] -> ShowS)
-> Show TxMetadataValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxMetadataValue] -> ShowS
$cshowList :: [TxMetadataValue] -> ShowS
show :: TxMetadataValue -> String
$cshow :: TxMetadataValue -> String
showsPrec :: Int -> TxMetadataValue -> ShowS
$cshowsPrec :: Int -> TxMetadataValue -> ShowS
Show)
instance Semigroup TxMetadata where
TxMetadataShelley (Shelley.MetaData Map Word64 MetaDatum
m1)
<> :: TxMetadata -> TxMetadata -> TxMetadata
<> TxMetadataShelley (Shelley.MetaData Map Word64 MetaDatum
m2) =
MetaData -> TxMetadata
TxMetadataShelley (Map Word64 MetaDatum -> MetaData
Shelley.MetaData (Map Word64 MetaDatum
m1 Map Word64 MetaDatum
-> Map Word64 MetaDatum -> Map Word64 MetaDatum
forall a. Semigroup a => a -> a -> a
<> Map Word64 MetaDatum
m2))
instance Monoid TxMetadata where
mempty :: TxMetadata
mempty = MetaData -> TxMetadata
TxMetadataShelley (Map Word64 MetaDatum -> MetaData
Shelley.MetaData Map Word64 MetaDatum
forall a. Monoid a => a
mempty)
instance HasTypeProxy TxMetadata where
data AsType TxMetadata = AsTxMetadata
proxyToAsType :: Proxy TxMetadata -> AsType TxMetadata
proxyToAsType Proxy TxMetadata
_ = AsType TxMetadata
AsTxMetadata
instance SerialiseAsCBOR TxMetadata where
serialiseToCBOR :: TxMetadata -> ByteString
serialiseToCBOR (TxMetadataShelley MetaData
tx) =
MetaData -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize' MetaData
tx
deserialiseFromCBOR :: AsType TxMetadata -> ByteString -> Either DecoderError TxMetadata
deserialiseFromCBOR AsType TxMetadata
AsTxMetadata ByteString
bs =
MetaData -> TxMetadata
TxMetadataShelley (MetaData -> TxMetadata)
-> Either DecoderError MetaData -> Either DecoderError TxMetadata
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Text
-> (forall s. Decoder s (Annotator MetaData))
-> LByteString
-> Either DecoderError MetaData
forall a.
Text
-> (forall s. Decoder s (Annotator a))
-> LByteString
-> Either DecoderError a
CBOR.decodeAnnotator Text
"TxMetadata" forall s. Decoder s (Annotator MetaData)
forall a s. FromCBOR a => Decoder s a
fromCBOR (ByteString -> LByteString
LBS.fromStrict ByteString
bs)
makeTransactionMetadata :: Map Word64 TxMetadataValue -> TxMetadata
makeTransactionMetadata :: Map Word64 TxMetadataValue -> TxMetadata
makeTransactionMetadata = Map Word64 TxMetadataValue -> TxMetadata
TxMetadata
toShelleyMetaData :: Map Word64 TxMetadataValue -> Shelley.MetaData
toShelleyMetaData :: Map Word64 TxMetadataValue -> MetaData
toShelleyMetaData =
Map Word64 MetaDatum -> MetaData
Shelley.MetaData
(Map Word64 MetaDatum -> MetaData)
-> (Map Word64 TxMetadataValue -> Map Word64 MetaDatum)
-> Map Word64 TxMetadataValue
-> MetaData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TxMetadataValue -> MetaDatum)
-> Map Word64 TxMetadataValue -> Map Word64 MetaDatum
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map TxMetadataValue -> MetaDatum
toShelleyMetaDatum
where
toShelleyMetaDatum :: TxMetadataValue -> Shelley.MetaDatum
toShelleyMetaDatum :: TxMetadataValue -> MetaDatum
toShelleyMetaDatum (TxMetaNumber Integer
x) = Integer -> MetaDatum
Shelley.I Integer
x
toShelleyMetaDatum (TxMetaBytes ByteString
x) = ByteString -> MetaDatum
Shelley.B ByteString
x
toShelleyMetaDatum (TxMetaText Text
x) = Text -> MetaDatum
Shelley.S Text
x
toShelleyMetaDatum (TxMetaList [TxMetadataValue]
xs) = [MetaDatum] -> MetaDatum
Shelley.List
[ TxMetadataValue -> MetaDatum
toShelleyMetaDatum TxMetadataValue
x | TxMetadataValue
x <- [TxMetadataValue]
xs ]
toShelleyMetaDatum (TxMetaMap [(TxMetadataValue, TxMetadataValue)]
xs) = [(MetaDatum, MetaDatum)] -> MetaDatum
Shelley.Map
[ (TxMetadataValue -> MetaDatum
toShelleyMetaDatum TxMetadataValue
k,
TxMetadataValue -> MetaDatum
toShelleyMetaDatum TxMetadataValue
v)
| (TxMetadataValue
k,TxMetadataValue
v) <- [(TxMetadataValue, TxMetadataValue)]
xs ]
fromShelleyMetaData :: Shelley.MetaData -> Map Word64 TxMetadataValue
fromShelleyMetaData :: MetaData -> Map Word64 TxMetadataValue
fromShelleyMetaData (Shelley.MetaData Map Word64 MetaDatum
mdMap) =
(MetaDatum -> TxMetadataValue)
-> Map Word64 MetaDatum -> Map Word64 TxMetadataValue
forall a b k. (a -> b) -> Map k a -> Map k b
Map.Lazy.map MetaDatum -> TxMetadataValue
fromShelleyMetaDatum Map Word64 MetaDatum
mdMap
where
fromShelleyMetaDatum :: Shelley.MetaDatum -> TxMetadataValue
fromShelleyMetaDatum :: MetaDatum -> TxMetadataValue
fromShelleyMetaDatum (Shelley.I Integer
x) = Integer -> TxMetadataValue
TxMetaNumber Integer
x
fromShelleyMetaDatum (Shelley.B ByteString
x) = ByteString -> TxMetadataValue
TxMetaBytes ByteString
x
fromShelleyMetaDatum (Shelley.S Text
x) = Text -> TxMetadataValue
TxMetaText Text
x
fromShelleyMetaDatum (Shelley.List [MetaDatum]
xs) = [TxMetadataValue] -> TxMetadataValue
TxMetaList
[ MetaDatum -> TxMetadataValue
fromShelleyMetaDatum MetaDatum
x | MetaDatum
x <- [MetaDatum]
xs ]
fromShelleyMetaDatum (Shelley.Map [(MetaDatum, MetaDatum)]
xs) = [(TxMetadataValue, TxMetadataValue)] -> TxMetadataValue
TxMetaMap
[ (MetaDatum -> TxMetadataValue
fromShelleyMetaDatum MetaDatum
k,
MetaDatum -> TxMetadataValue
fromShelleyMetaDatum MetaDatum
v)
| (MetaDatum
k,MetaDatum
v) <- [(MetaDatum, MetaDatum)]
xs ]
newtype UpdateProposal = UpdateProposal (Shelley.Update StandardShelley)
deriving stock (UpdateProposal -> UpdateProposal -> Bool
(UpdateProposal -> UpdateProposal -> Bool)
-> (UpdateProposal -> UpdateProposal -> Bool) -> Eq UpdateProposal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProposal -> UpdateProposal -> Bool
$c/= :: UpdateProposal -> UpdateProposal -> Bool
== :: UpdateProposal -> UpdateProposal -> Bool
$c== :: UpdateProposal -> UpdateProposal -> Bool
Eq, Int -> UpdateProposal -> ShowS
[UpdateProposal] -> ShowS
UpdateProposal -> String
(Int -> UpdateProposal -> ShowS)
-> (UpdateProposal -> String)
-> ([UpdateProposal] -> ShowS)
-> Show UpdateProposal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProposal] -> ShowS
$cshowList :: [UpdateProposal] -> ShowS
show :: UpdateProposal -> String
$cshow :: UpdateProposal -> String
showsPrec :: Int -> UpdateProposal -> ShowS
$cshowsPrec :: Int -> UpdateProposal -> ShowS
Show)
deriving newtype (Typeable UpdateProposal
Typeable UpdateProposal
-> (UpdateProposal -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy UpdateProposal -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [UpdateProposal] -> Size)
-> ToCBOR UpdateProposal
UpdateProposal -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [UpdateProposal] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy UpdateProposal -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [UpdateProposal] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [UpdateProposal] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy UpdateProposal -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy UpdateProposal -> Size
toCBOR :: UpdateProposal -> Encoding
$ctoCBOR :: UpdateProposal -> Encoding
$cp1ToCBOR :: Typeable UpdateProposal
ToCBOR, Typeable UpdateProposal
Decoder s UpdateProposal
Typeable UpdateProposal
-> (forall s. Decoder s UpdateProposal)
-> (Proxy UpdateProposal -> Text)
-> FromCBOR UpdateProposal
Proxy UpdateProposal -> Text
forall s. Decoder s UpdateProposal
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy UpdateProposal -> Text
$clabel :: Proxy UpdateProposal -> Text
fromCBOR :: Decoder s UpdateProposal
$cfromCBOR :: forall s. Decoder s UpdateProposal
$cp1FromCBOR :: Typeable UpdateProposal
FromCBOR)
deriving anyclass HasTypeProxy UpdateProposal
UpdateProposal -> ByteString
HasTypeProxy UpdateProposal
-> (UpdateProposal -> ByteString)
-> (AsType UpdateProposal
-> ByteString -> Either DecoderError UpdateProposal)
-> SerialiseAsCBOR UpdateProposal
AsType UpdateProposal
-> ByteString -> Either DecoderError UpdateProposal
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType UpdateProposal
-> ByteString -> Either DecoderError UpdateProposal
$cdeserialiseFromCBOR :: AsType UpdateProposal
-> ByteString -> Either DecoderError UpdateProposal
serialiseToCBOR :: UpdateProposal -> ByteString
$cserialiseToCBOR :: UpdateProposal -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy UpdateProposal
SerialiseAsCBOR
instance HasTypeProxy UpdateProposal where
data AsType UpdateProposal = AsUpdateProposal
proxyToAsType :: Proxy UpdateProposal -> AsType UpdateProposal
proxyToAsType Proxy UpdateProposal
_ = AsType UpdateProposal
AsUpdateProposal
instance HasTextEnvelope UpdateProposal where
textEnvelopeType :: AsType UpdateProposal -> TextEnvelopeType
textEnvelopeType AsType UpdateProposal
_ = TextEnvelopeType
"UpdateProposalShelley"
data ProtocolParametersUpdate =
ProtocolParametersUpdate {
ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: Maybe (Natural, Natural),
ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization :: Maybe Rational,
:: Maybe (Maybe ByteString),
:: Maybe Natural,
ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural,
ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural,
ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural,
ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte :: Maybe Natural,
ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinUTxOValue :: Maybe Lovelace,
ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakeAddressDeposit :: Maybe Lovelace,
ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakePoolDeposit :: Maybe Lovelace,
ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinPoolCost :: Maybe Lovelace,
ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo,
ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum :: Maybe Natural,
ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational,
ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational,
ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational
}
deriving (ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
(ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool)
-> (ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool)
-> Eq ProtocolParametersUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
$c/= :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
== :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
$c== :: ProtocolParametersUpdate -> ProtocolParametersUpdate -> Bool
Eq, Int -> ProtocolParametersUpdate -> ShowS
[ProtocolParametersUpdate] -> ShowS
ProtocolParametersUpdate -> String
(Int -> ProtocolParametersUpdate -> ShowS)
-> (ProtocolParametersUpdate -> String)
-> ([ProtocolParametersUpdate] -> ShowS)
-> Show ProtocolParametersUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtocolParametersUpdate] -> ShowS
$cshowList :: [ProtocolParametersUpdate] -> ShowS
show :: ProtocolParametersUpdate -> String
$cshow :: ProtocolParametersUpdate -> String
showsPrec :: Int -> ProtocolParametersUpdate -> ShowS
$cshowsPrec :: Int -> ProtocolParametersUpdate -> ShowS
Show)
instance Semigroup ProtocolParametersUpdate where
ProtocolParametersUpdate
ppu1 <> :: ProtocolParametersUpdate
-> ProtocolParametersUpdate -> ProtocolParametersUpdate
<> ProtocolParametersUpdate
ppu2 =
ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe ByteString)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> ProtocolParametersUpdate
ProtocolParametersUpdate {
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion = (ProtocolParametersUpdate -> Maybe (Natural, Natural))
-> Maybe (Natural, Natural)
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion
, protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization
, protocolUpdateExtraPraosEntropy :: Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy = (ProtocolParametersUpdate -> Maybe (Maybe ByteString))
-> Maybe (Maybe ByteString)
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy
, protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize
, protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize
, protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize
, protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed
, protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte
, protocolUpdateMinUTxOValue :: Maybe Lovelace
protocolUpdateMinUTxOValue = (ProtocolParametersUpdate -> Maybe Lovelace) -> Maybe Lovelace
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinUTxOValue
, protocolUpdateStakeAddressDeposit :: Maybe Lovelace
protocolUpdateStakeAddressDeposit = (ProtocolParametersUpdate -> Maybe Lovelace) -> Maybe Lovelace
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakeAddressDeposit
, protocolUpdateStakePoolDeposit :: Maybe Lovelace
protocolUpdateStakePoolDeposit = (ProtocolParametersUpdate -> Maybe Lovelace) -> Maybe Lovelace
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakePoolDeposit
, protocolUpdateMinPoolCost :: Maybe Lovelace
protocolUpdateMinPoolCost = (ProtocolParametersUpdate -> Maybe Lovelace) -> Maybe Lovelace
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinPoolCost
, protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch = (ProtocolParametersUpdate -> Maybe EpochNo) -> Maybe EpochNo
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
, protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum = (ProtocolParametersUpdate -> Maybe Natural) -> Maybe Natural
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum
, protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence
, protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion
, protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut = (ProtocolParametersUpdate -> Maybe Rational) -> Maybe Rational
forall a. (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut
}
where
merge :: (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge :: (ProtocolParametersUpdate -> Maybe a) -> Maybe a
merge ProtocolParametersUpdate -> Maybe a
f = ProtocolParametersUpdate -> Maybe a
f ProtocolParametersUpdate
ppu2 Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` ProtocolParametersUpdate -> Maybe a
f ProtocolParametersUpdate
ppu1
instance Monoid ProtocolParametersUpdate where
mempty :: ProtocolParametersUpdate
mempty =
ProtocolParametersUpdate :: Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe ByteString)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> ProtocolParametersUpdate
ProtocolParametersUpdate {
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion = Maybe (Natural, Natural)
forall a. Maybe a
Nothing
, protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization = Maybe Rational
forall a. Maybe a
Nothing
, protocolUpdateExtraPraosEntropy :: Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy = Maybe (Maybe ByteString)
forall a. Maybe a
Nothing
, protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize = Maybe Natural
forall a. Maybe a
Nothing
, protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize = Maybe Natural
forall a. Maybe a
Nothing
, protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize = Maybe Natural
forall a. Maybe a
Nothing
, protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed = Maybe Natural
forall a. Maybe a
Nothing
, protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte = Maybe Natural
forall a. Maybe a
Nothing
, protocolUpdateMinUTxOValue :: Maybe Lovelace
protocolUpdateMinUTxOValue = Maybe Lovelace
forall a. Maybe a
Nothing
, protocolUpdateStakeAddressDeposit :: Maybe Lovelace
protocolUpdateStakeAddressDeposit = Maybe Lovelace
forall a. Maybe a
Nothing
, protocolUpdateStakePoolDeposit :: Maybe Lovelace
protocolUpdateStakePoolDeposit = Maybe Lovelace
forall a. Maybe a
Nothing
, protocolUpdateMinPoolCost :: Maybe Lovelace
protocolUpdateMinPoolCost = Maybe Lovelace
forall a. Maybe a
Nothing
, protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch = Maybe EpochNo
forall a. Maybe a
Nothing
, protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum = Maybe Natural
forall a. Maybe a
Nothing
, protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence = Maybe Rational
forall a. Maybe a
Nothing
, protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion = Maybe Rational
forall a. Maybe a
Nothing
, protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut = Maybe Rational
forall a. Maybe a
Nothing
}
makeShelleyUpdateProposal :: ProtocolParametersUpdate
-> [Hash GenesisKey]
-> EpochNo
-> UpdateProposal
makeShelleyUpdateProposal :: ProtocolParametersUpdate
-> [Hash GenesisKey] -> EpochNo -> UpdateProposal
makeShelleyUpdateProposal ProtocolParametersUpdate
params [Hash GenesisKey]
genesisKeyHashes EpochNo
epochno =
let ppup :: PParamsUpdate StandardShelley
ppup = ProtocolParametersUpdate -> PParamsUpdate StandardShelley
toShelleyPParamsUpdate ProtocolParametersUpdate
params in
Update StandardShelley -> UpdateProposal
UpdateProposal (Update StandardShelley -> UpdateProposal)
-> Update StandardShelley -> UpdateProposal
forall a b. (a -> b) -> a -> b
$
ProposedPPUpdates StandardShelley
-> EpochNo -> Update StandardShelley
forall era. ProposedPPUpdates era -> EpochNo -> Update era
Shelley.Update
(Map
(KeyHash 'Genesis (Crypto StandardShelley))
(PParamsUpdate StandardShelley)
-> ProposedPPUpdates StandardShelley
forall era.
Map (KeyHash 'Genesis (Crypto era)) (PParamsUpdate era)
-> ProposedPPUpdates era
Shelley.ProposedPPUpdates
([(KeyHash 'Genesis StandardCrypto, PParamsUpdate StandardShelley)]
-> Map
(KeyHash 'Genesis StandardCrypto) (PParamsUpdate StandardShelley)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (KeyHash 'Genesis StandardCrypto
kh, PParamsUpdate StandardShelley
ppup) | GenesisKeyHash kh <- [Hash GenesisKey]
genesisKeyHashes ]))
EpochNo
epochno
toShelleyPParamsUpdate :: ProtocolParametersUpdate
-> Shelley.PParamsUpdate StandardShelley
toShelleyPParamsUpdate :: ProtocolParametersUpdate -> PParamsUpdate StandardShelley
toShelleyPParamsUpdate
ProtocolParametersUpdate {
Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion
, Maybe Rational
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization
, Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy :: Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy :: ProtocolParametersUpdate -> Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy
, Maybe Natural
protocolUpdateMaxBlockHeaderSize :: Maybe Natural
protocolUpdateMaxBlockHeaderSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockHeaderSize
, Maybe Natural
protocolUpdateMaxBlockBodySize :: Maybe Natural
protocolUpdateMaxBlockBodySize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxBlockBodySize
, Maybe Natural
protocolUpdateMaxTxSize :: Maybe Natural
protocolUpdateMaxTxSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxTxSize
, Maybe Natural
protocolUpdateTxFeeFixed :: Maybe Natural
protocolUpdateTxFeeFixed :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeeFixed
, Maybe Natural
protocolUpdateTxFeePerByte :: Maybe Natural
protocolUpdateTxFeePerByte :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateTxFeePerByte
, Maybe Lovelace
protocolUpdateMinUTxOValue :: Maybe Lovelace
protocolUpdateMinUTxOValue :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinUTxOValue
, Maybe Lovelace
protocolUpdateStakeAddressDeposit :: Maybe Lovelace
protocolUpdateStakeAddressDeposit :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakeAddressDeposit
, Maybe Lovelace
protocolUpdateStakePoolDeposit :: Maybe Lovelace
protocolUpdateStakePoolDeposit :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakePoolDeposit
, Maybe Lovelace
protocolUpdateMinPoolCost :: Maybe Lovelace
protocolUpdateMinPoolCost :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinPoolCost
, Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch :: ProtocolParametersUpdate -> Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
, Maybe Natural
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum
, Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence
, Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion
, Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut
} =
PParams :: forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f Rational
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> PParams' f era
Shelley.PParams {
_minfeeA :: HKD StrictMaybe Natural
Shelley._minfeeA = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateTxFeePerByte
, _minfeeB :: HKD StrictMaybe Natural
Shelley._minfeeB = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateTxFeeFixed
, _maxBBSize :: HKD StrictMaybe Natural
Shelley._maxBBSize = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxBlockBodySize
, _maxTxSize :: HKD StrictMaybe Natural
Shelley._maxTxSize = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxTxSize
, _maxBHSize :: HKD StrictMaybe Natural
Shelley._maxBHSize = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateMaxBlockHeaderSize
, _keyDeposit :: HKD StrictMaybe Coin
Shelley._keyDeposit = Lovelace -> Coin
toShelleyLovelace (Lovelace -> Coin) -> StrictMaybe Lovelace -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Lovelace -> StrictMaybe Lovelace
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Lovelace
protocolUpdateStakeAddressDeposit
, _poolDeposit :: HKD StrictMaybe Coin
Shelley._poolDeposit = Lovelace -> Coin
toShelleyLovelace (Lovelace -> Coin) -> StrictMaybe Lovelace -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Lovelace -> StrictMaybe Lovelace
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Lovelace
protocolUpdateStakePoolDeposit
, _eMax :: HKD StrictMaybe EpochNo
Shelley._eMax = Maybe EpochNo -> StrictMaybe EpochNo
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe EpochNo
protocolUpdatePoolRetireMaxEpoch
, _nOpt :: HKD StrictMaybe Natural
Shelley._nOpt = Maybe Natural -> StrictMaybe Natural
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Natural
protocolUpdateStakePoolTargetNum
, _a0 :: HKD StrictMaybe Rational
Shelley._a0 = Maybe Rational -> StrictMaybe Rational
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Rational
protocolUpdatePoolPledgeInfluence
, _rho :: HKD StrictMaybe UnitInterval
Shelley._rho = Ratio Word64 -> UnitInterval
Shelley.truncateUnitInterval (Ratio Word64 -> UnitInterval)
-> (Rational -> Ratio Word64) -> Rational -> UnitInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Ratio Word64
forall a. Fractional a => Rational -> a
fromRational (Rational -> UnitInterval)
-> StrictMaybe Rational -> StrictMaybe UnitInterval
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Rational -> StrictMaybe Rational
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Rational
protocolUpdateMonetaryExpansion
, _tau :: HKD StrictMaybe UnitInterval
Shelley._tau = Ratio Word64 -> UnitInterval
Shelley.truncateUnitInterval (Ratio Word64 -> UnitInterval)
-> (Rational -> Ratio Word64) -> Rational -> UnitInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Ratio Word64
forall a. Fractional a => Rational -> a
fromRational (Rational -> UnitInterval)
-> StrictMaybe Rational -> StrictMaybe UnitInterval
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Rational -> StrictMaybe Rational
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Rational
protocolUpdateTreasuryCut
, _d :: HKD StrictMaybe UnitInterval
Shelley._d = Ratio Word64 -> UnitInterval
Shelley.truncateUnitInterval (Ratio Word64 -> UnitInterval)
-> (Rational -> Ratio Word64) -> Rational -> UnitInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Ratio Word64
forall a. Fractional a => Rational -> a
fromRational (Rational -> UnitInterval)
-> StrictMaybe Rational -> StrictMaybe UnitInterval
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Rational -> StrictMaybe Rational
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Rational
protocolUpdateDecentralization
, _extraEntropy :: HKD StrictMaybe Nonce
Shelley._extraEntropy = Maybe ByteString -> Nonce
mkNonce (Maybe ByteString -> Nonce)
-> StrictMaybe (Maybe ByteString) -> StrictMaybe Nonce
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe (Maybe ByteString) -> StrictMaybe (Maybe ByteString)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (Maybe ByteString)
protocolUpdateExtraPraosEntropy
, _protocolVersion :: HKD StrictMaybe ProtVer
Shelley._protocolVersion = (Natural -> Natural -> ProtVer) -> (Natural, Natural) -> ProtVer
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Natural -> Natural -> ProtVer
Shelley.ProtVer ((Natural, Natural) -> ProtVer)
-> StrictMaybe (Natural, Natural) -> StrictMaybe ProtVer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe (Natural, Natural) -> StrictMaybe (Natural, Natural)
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe (Natural, Natural)
protocolUpdateProtocolVersion
, _minUTxOValue :: HKD StrictMaybe Coin
Shelley._minUTxOValue = Lovelace -> Coin
toShelleyLovelace (Lovelace -> Coin) -> StrictMaybe Lovelace -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Lovelace -> StrictMaybe Lovelace
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Lovelace
protocolUpdateMinUTxOValue
, _minPoolCost :: HKD StrictMaybe Coin
Shelley._minPoolCost = Lovelace -> Coin
toShelleyLovelace (Lovelace -> Coin) -> StrictMaybe Lovelace -> StrictMaybe Coin
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Maybe Lovelace -> StrictMaybe Lovelace
forall a. Maybe a -> StrictMaybe a
maybeToStrictMaybe Maybe Lovelace
protocolUpdateMinPoolCost
}
where
mkNonce :: Maybe ByteString -> Nonce
mkNonce Maybe ByteString
Nothing = Nonce
Shelley.NeutralNonce
mkNonce (Just ByteString
bs) = Hash Blake2b_256 Nonce -> Nonce
Shelley.Nonce
(Hash Blake2b_256 Nonce -> Nonce)
-> (ByteString -> Hash Blake2b_256 Nonce) -> ByteString -> Nonce
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_256 ByteString -> Hash Blake2b_256 Nonce
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_256 ByteString -> Hash Blake2b_256 Nonce)
-> (ByteString -> Hash Blake2b_256 ByteString)
-> ByteString
-> Hash Blake2b_256 Nonce
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> ByteString)
-> ByteString -> Hash Blake2b_256 ByteString
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith ByteString -> ByteString
forall a. a -> a
id
(ByteString -> Nonce) -> ByteString -> Nonce
forall a b. (a -> b) -> a -> b
$ ByteString
bs
data OperationalCertificate =
OperationalCertificate
!(Shelley.OCert StandardCrypto)
!(VerificationKey StakePoolKey)
deriving (OperationalCertificate -> OperationalCertificate -> Bool
(OperationalCertificate -> OperationalCertificate -> Bool)
-> (OperationalCertificate -> OperationalCertificate -> Bool)
-> Eq OperationalCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OperationalCertificate -> OperationalCertificate -> Bool
$c/= :: OperationalCertificate -> OperationalCertificate -> Bool
== :: OperationalCertificate -> OperationalCertificate -> Bool
$c== :: OperationalCertificate -> OperationalCertificate -> Bool
Eq, Int -> OperationalCertificate -> ShowS
[OperationalCertificate] -> ShowS
OperationalCertificate -> String
(Int -> OperationalCertificate -> ShowS)
-> (OperationalCertificate -> String)
-> ([OperationalCertificate] -> ShowS)
-> Show OperationalCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OperationalCertificate] -> ShowS
$cshowList :: [OperationalCertificate] -> ShowS
show :: OperationalCertificate -> String
$cshow :: OperationalCertificate -> String
showsPrec :: Int -> OperationalCertificate -> ShowS
$cshowsPrec :: Int -> OperationalCertificate -> ShowS
Show)
deriving anyclass HasTypeProxy OperationalCertificate
OperationalCertificate -> ByteString
HasTypeProxy OperationalCertificate
-> (OperationalCertificate -> ByteString)
-> (AsType OperationalCertificate
-> ByteString -> Either DecoderError OperationalCertificate)
-> SerialiseAsCBOR OperationalCertificate
AsType OperationalCertificate
-> ByteString -> Either DecoderError OperationalCertificate
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType OperationalCertificate
-> ByteString -> Either DecoderError OperationalCertificate
$cdeserialiseFromCBOR :: AsType OperationalCertificate
-> ByteString -> Either DecoderError OperationalCertificate
serialiseToCBOR :: OperationalCertificate -> ByteString
$cserialiseToCBOR :: OperationalCertificate -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy OperationalCertificate
SerialiseAsCBOR
data OperationalCertificateIssueCounter =
OperationalCertificateIssueCounter
!Word64
!(VerificationKey StakePoolKey)
deriving (OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool
(OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool)
-> (OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool)
-> Eq OperationalCertificateIssueCounter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool
$c/= :: OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool
== :: OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool
$c== :: OperationalCertificateIssueCounter
-> OperationalCertificateIssueCounter -> Bool
Eq, Int -> OperationalCertificateIssueCounter -> ShowS
[OperationalCertificateIssueCounter] -> ShowS
OperationalCertificateIssueCounter -> String
(Int -> OperationalCertificateIssueCounter -> ShowS)
-> (OperationalCertificateIssueCounter -> String)
-> ([OperationalCertificateIssueCounter] -> ShowS)
-> Show OperationalCertificateIssueCounter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OperationalCertificateIssueCounter] -> ShowS
$cshowList :: [OperationalCertificateIssueCounter] -> ShowS
show :: OperationalCertificateIssueCounter -> String
$cshow :: OperationalCertificateIssueCounter -> String
showsPrec :: Int -> OperationalCertificateIssueCounter -> ShowS
$cshowsPrec :: Int -> OperationalCertificateIssueCounter -> ShowS
Show)
deriving anyclass HasTypeProxy OperationalCertificateIssueCounter
OperationalCertificateIssueCounter -> ByteString
HasTypeProxy OperationalCertificateIssueCounter
-> (OperationalCertificateIssueCounter -> ByteString)
-> (AsType OperationalCertificateIssueCounter
-> ByteString
-> Either DecoderError OperationalCertificateIssueCounter)
-> SerialiseAsCBOR OperationalCertificateIssueCounter
AsType OperationalCertificateIssueCounter
-> ByteString
-> Either DecoderError OperationalCertificateIssueCounter
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType OperationalCertificateIssueCounter
-> ByteString
-> Either DecoderError OperationalCertificateIssueCounter
$cdeserialiseFromCBOR :: AsType OperationalCertificateIssueCounter
-> ByteString
-> Either DecoderError OperationalCertificateIssueCounter
serialiseToCBOR :: OperationalCertificateIssueCounter -> ByteString
$cserialiseToCBOR :: OperationalCertificateIssueCounter -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy OperationalCertificateIssueCounter
SerialiseAsCBOR
instance ToCBOR OperationalCertificate where
toCBOR :: OperationalCertificate -> Encoding
toCBOR (OperationalCertificate OCert StandardCrypto
ocert VerificationKey StakePoolKey
vkey) =
(CBORGroup (OCert StandardCrypto), VerificationKey StakePoolKey)
-> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (OCert StandardCrypto -> CBORGroup (OCert StandardCrypto)
forall a. a -> CBORGroup a
CBOR.CBORGroup OCert StandardCrypto
ocert, VerificationKey StakePoolKey
vkey)
instance FromCBOR OperationalCertificate where
fromCBOR :: Decoder s OperationalCertificate
fromCBOR = do
(CBOR.CBORGroup OCert StandardCrypto
ocert, VerificationKey StakePoolKey
vkey) <- Decoder
s (CBORGroup (OCert StandardCrypto), VerificationKey StakePoolKey)
forall a s. FromCBOR a => Decoder s a
fromCBOR
OperationalCertificate -> Decoder s OperationalCertificate
forall (m :: * -> *) a. Monad m => a -> m a
return (OCert StandardCrypto
-> VerificationKey StakePoolKey -> OperationalCertificate
OperationalCertificate OCert StandardCrypto
ocert VerificationKey StakePoolKey
vkey)
instance ToCBOR OperationalCertificateIssueCounter where
toCBOR :: OperationalCertificateIssueCounter -> Encoding
toCBOR (OperationalCertificateIssueCounter Word64
counter VerificationKey StakePoolKey
vkey) =
(Word64, VerificationKey StakePoolKey) -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (Word64
counter, VerificationKey StakePoolKey
vkey)
instance FromCBOR OperationalCertificateIssueCounter where
fromCBOR :: Decoder s OperationalCertificateIssueCounter
fromCBOR = do
(Word64
counter, VerificationKey StakePoolKey
vkey) <- Decoder s (Word64, VerificationKey StakePoolKey)
forall a s. FromCBOR a => Decoder s a
fromCBOR
OperationalCertificateIssueCounter
-> Decoder s OperationalCertificateIssueCounter
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
-> VerificationKey StakePoolKey
-> OperationalCertificateIssueCounter
OperationalCertificateIssueCounter Word64
counter VerificationKey StakePoolKey
vkey)
instance HasTypeProxy OperationalCertificate where
data AsType OperationalCertificate = AsOperationalCertificate
proxyToAsType :: Proxy OperationalCertificate -> AsType OperationalCertificate
proxyToAsType Proxy OperationalCertificate
_ = AsType OperationalCertificate
AsOperationalCertificate
instance HasTypeProxy OperationalCertificateIssueCounter where
data AsType OperationalCertificateIssueCounter = AsOperationalCertificateIssueCounter
proxyToAsType :: Proxy OperationalCertificateIssueCounter
-> AsType OperationalCertificateIssueCounter
proxyToAsType Proxy OperationalCertificateIssueCounter
_ = AsType OperationalCertificateIssueCounter
AsOperationalCertificateIssueCounter
instance HasTextEnvelope OperationalCertificate where
textEnvelopeType :: AsType OperationalCertificate -> TextEnvelopeType
textEnvelopeType AsType OperationalCertificate
_ = TextEnvelopeType
"NodeOperationalCertificate"
instance HasTextEnvelope OperationalCertificateIssueCounter where
textEnvelopeType :: AsType OperationalCertificateIssueCounter -> TextEnvelopeType
textEnvelopeType AsType OperationalCertificateIssueCounter
_ = TextEnvelopeType
"NodeOperationalCertificateIssueCounter"
data OperationalCertIssueError =
OperationalCertKeyMismatch (VerificationKey StakePoolKey)
(VerificationKey StakePoolKey)
deriving Int -> OperationalCertIssueError -> ShowS
[OperationalCertIssueError] -> ShowS
OperationalCertIssueError -> String
(Int -> OperationalCertIssueError -> ShowS)
-> (OperationalCertIssueError -> String)
-> ([OperationalCertIssueError] -> ShowS)
-> Show OperationalCertIssueError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OperationalCertIssueError] -> ShowS
$cshowList :: [OperationalCertIssueError] -> ShowS
show :: OperationalCertIssueError -> String
$cshow :: OperationalCertIssueError -> String
showsPrec :: Int -> OperationalCertIssueError -> ShowS
$cshowsPrec :: Int -> OperationalCertIssueError -> ShowS
Show
instance Error OperationalCertIssueError where
displayError :: OperationalCertIssueError -> String
displayError (OperationalCertKeyMismatch VerificationKey StakePoolKey
_counterKey VerificationKey StakePoolKey
_signingKey) =
String
"Key mismatch: the signing key does not match the one that goes with the counter"
issueOperationalCertificate :: VerificationKey KesKey
-> Either (SigningKey StakePoolKey)
(SigningKey GenesisDelegateExtendedKey)
-> Shelley.KESPeriod
-> OperationalCertificateIssueCounter
-> Either OperationalCertIssueError
(OperationalCertificate,
OperationalCertificateIssueCounter)
issueOperationalCertificate :: VerificationKey KesKey
-> Either
(SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
-> KESPeriod
-> OperationalCertificateIssueCounter
-> Either
OperationalCertIssueError
(OperationalCertificate, OperationalCertificateIssueCounter)
issueOperationalCertificate (KesVerificationKey kesVKey)
Either
(SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
skey
KESPeriod
kesPeriod
(OperationalCertificateIssueCounter Word64
counter VerificationKey StakePoolKey
poolVKey)
| VerificationKey StakePoolKey
poolVKey VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool
forall a. Eq a => a -> a -> Bool
/= VerificationKey StakePoolKey
poolVKey'
= OperationalCertIssueError
-> Either
OperationalCertIssueError
(OperationalCertificate, OperationalCertificateIssueCounter)
forall a b. a -> Either a b
Left (VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> OperationalCertIssueError
OperationalCertKeyMismatch VerificationKey StakePoolKey
poolVKey VerificationKey StakePoolKey
poolVKey')
| Bool
otherwise
= (OperationalCertificate, OperationalCertificateIssueCounter)
-> Either
OperationalCertIssueError
(OperationalCertificate, OperationalCertificateIssueCounter)
forall a b. b -> Either a b
Right (OCert StandardCrypto
-> VerificationKey StakePoolKey -> OperationalCertificate
OperationalCertificate OCert StandardCrypto
ocert VerificationKey StakePoolKey
poolVKey,
Word64
-> VerificationKey StakePoolKey
-> OperationalCertificateIssueCounter
OperationalCertificateIssueCounter (Word64 -> Word64
forall a. Enum a => a -> a
succ Word64
counter) VerificationKey StakePoolKey
poolVKey)
where
poolVKey' :: VerificationKey StakePoolKey
poolVKey' :: VerificationKey StakePoolKey
poolVKey' = (SigningKey StakePoolKey -> VerificationKey StakePoolKey)
-> (SigningKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey)
-> Either
(SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
-> VerificationKey StakePoolKey
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either SigningKey StakePoolKey -> VerificationKey StakePoolKey
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
convert (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey)
-> (SigningKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey)
-> SigningKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SigningKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey
forall keyrole.
Key keyrole =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey) Either
(SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
skey
where
convert :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
convert :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
convert = (VerificationKey GenesisDelegateKey -> VerificationKey StakePoolKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey GenesisDelegateKey
-> VerificationKey StakePoolKey)
(VerificationKey GenesisDelegateKey
-> VerificationKey StakePoolKey)
-> (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateKey)
-> VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateKey)
ocert :: Shelley.OCert StandardCrypto
ocert :: OCert StandardCrypto
ocert = VerKeyKES StandardCrypto
-> Word64
-> KESPeriod
-> SignedDSIGN StandardCrypto (OCertSignable StandardCrypto)
-> OCert StandardCrypto
forall crypto.
VerKeyKES crypto
-> Word64
-> KESPeriod
-> SignedDSIGN crypto (OCertSignable crypto)
-> OCert crypto
Shelley.OCert VerKeyKES StandardCrypto
kesVKey Word64
counter KESPeriod
kesPeriod SignedDSIGN StandardCrypto (OCertSignable StandardCrypto)
signature
signature :: Shelley.SignedDSIGN
StandardCrypto
(Shelley.OCertSignable StandardCrypto)
signature :: SignedDSIGN StandardCrypto (OCertSignable StandardCrypto)
signature = OCertSignable StandardCrypto
-> ShelleySigningKey
-> SignedDSIGN StandardCrypto (OCertSignable StandardCrypto)
forall tosign.
SignableRepresentation tosign =>
tosign -> ShelleySigningKey -> SignedDSIGN StandardCrypto tosign
makeShelleySignature
(VerKeyKES StandardCrypto
-> Word64 -> KESPeriod -> OCertSignable StandardCrypto
forall crypto.
VerKeyKES crypto -> Word64 -> KESPeriod -> OCertSignable crypto
Shelley.OCertSignable VerKeyKES StandardCrypto
kesVKey Word64
counter KESPeriod
kesPeriod)
ShelleySigningKey
skey'
where
skey' :: ShelleySigningKey
skey' :: ShelleySigningKey
skey' = case Either
(SigningKey StakePoolKey) (SigningKey GenesisDelegateExtendedKey)
skey of
Left (StakePoolSigningKey poolSKey) ->
SignKeyDSIGN StandardCrypto -> ShelleySigningKey
ShelleyNormalSigningKey SignKeyDSIGN StandardCrypto
poolSKey
Right (GenesisDelegateExtendedSigningKey delegSKey) ->
XPrv -> ShelleySigningKey
ShelleyExtendedSigningKey XPrv
delegSKey
data ByronMode
data ShelleyMode
data CardanoMode
data LocalNodeConnectInfo mode block =
LocalNodeConnectInfo {
LocalNodeConnectInfo mode block -> String
localNodeSocketPath :: FilePath,
LocalNodeConnectInfo mode block -> NetworkId
localNodeNetworkId :: NetworkId,
LocalNodeConnectInfo mode block -> NodeConsensusMode mode block
localNodeConsensusMode :: NodeConsensusMode mode block
}
data NodeConsensusMode mode block where
ByronMode
:: Byron.EpochSlots
-> NodeConsensusMode ByronMode ByronBlockHFC
ShelleyMode
:: NodeConsensusMode ShelleyMode (ShelleyBlockHFC StandardShelley)
CardanoMode
:: Byron.EpochSlots
-> NodeConsensusMode CardanoMode (CardanoBlock StandardCrypto)
withNodeProtocolClient
:: NodeConsensusMode mode block
-> ( (SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block)
=> ProtocolClient block (BlockProtocol block) -> a)
-> a
withNodeProtocolClient :: NodeConsensusMode mode block
-> ((SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a)
-> a
withNodeProtocolClient (ByronMode EpochSlots
epochSlots) (SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a
f =
(SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a
ProtocolClient block (BlockProtocol block) -> a
f (EpochSlots -> ProtocolClient ByronBlockHFC ProtocolByron
mkNodeClientProtocolByron EpochSlots
epochSlots)
withNodeProtocolClient NodeConsensusMode mode block
ShelleyMode (SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a
f = (SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a
ProtocolClient block (BlockProtocol block) -> a
f ProtocolClient block (BlockProtocol block)
ProtocolClient (ShelleyBlockHFC StandardShelley) ProtocolShelley
mkNodeClientProtocolShelley
withNodeProtocolClient (CardanoMode EpochSlots
epochSlots) (SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a
f =
(SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a
ProtocolClient block (BlockProtocol block) -> a
f (EpochSlots
-> ProtocolClient (CardanoBlock StandardCrypto) ProtocolCardano
mkNodeClientProtocolCardano EpochSlots
epochSlots)
data LocalNodeClientProtocols block =
LocalNodeClientProtocols {
LocalNodeClientProtocols block
-> Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
localChainSyncClient
:: Maybe (ChainSyncClient
block
(Point block)
(Tip block)
IO ())
, LocalNodeClientProtocols block
-> Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient
:: Maybe (LocalTxSubmissionClient
(GenTx block)
(ApplyTxErr block)
IO ())
, LocalNodeClientProtocols block
-> Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient
:: Maybe (LocalStateQueryClient
block
(Point block)
(Query block)
IO ())
}
nullLocalNodeClientProtocols :: LocalNodeClientProtocols block
nullLocalNodeClientProtocols :: LocalNodeClientProtocols block
nullLocalNodeClientProtocols =
LocalNodeClientProtocols :: forall block.
Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
-> Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
-> Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
-> LocalNodeClientProtocols block
LocalNodeClientProtocols {
localChainSyncClient :: Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
localChainSyncClient = Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
forall a. Maybe a
Nothing,
localTxSubmissionClient :: Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient = Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
forall a. Maybe a
Nothing,
localStateQueryClient :: Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient = Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
forall a. Maybe a
Nothing
}
connectToLocalNode :: forall mode block.
(ShowProxy block, ShowProxy (ApplyTxErr block),
ShowProxy (Query block), ShowProxy (GenTx block),
ShowQuery (Query block))
=> LocalNodeConnectInfo mode block
-> LocalNodeClientProtocols block
-> IO ()
connectToLocalNode :: LocalNodeConnectInfo mode block
-> LocalNodeClientProtocols block -> IO ()
connectToLocalNode LocalNodeConnectInfo {
localNodeSocketPath :: forall mode block. LocalNodeConnectInfo mode block -> String
localNodeSocketPath = String
path,
localNodeNetworkId :: forall mode block. LocalNodeConnectInfo mode block -> NetworkId
localNodeNetworkId = NetworkId
network,
localNodeConsensusMode :: forall mode block.
LocalNodeConnectInfo mode block -> NodeConsensusMode mode block
localNodeConsensusMode = NodeConsensusMode mode block
mode
} LocalNodeClientProtocols block
clientptcls =
(IOManager -> IO ()) -> IO ()
WithIOManager
withIOManager ((IOManager -> IO ()) -> IO ()) -> (IOManager -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \IOManager
iomgr ->
NodeConsensusMode mode block
-> ((SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> IO ())
-> IO ()
forall mode block a.
NodeConsensusMode mode block
-> ((SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> a)
-> a
withNodeProtocolClient NodeConsensusMode mode block
mode (((SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> IO ())
-> IO ())
-> ((SerialiseNodeToClientConstraints block,
SupportedNetworkProtocolVersion block) =>
ProtocolClient block (BlockProtocol block) -> IO ())
-> IO ()
forall a b. (a -> b) -> a -> b
$ \ProtocolClient block (BlockProtocol block)
ptcl ->
LocalSnocket
-> NetworkConnectTracers LocalAddress NodeToClientVersion
-> Versions
NodeToClientVersion
NodeToClientVersionData
(OuroborosApplication
'InitiatorMode LocalAddress LByteString IO () Void)
-> String
-> IO ()
forall a b.
LocalSnocket
-> NetworkConnectTracers LocalAddress NodeToClientVersion
-> Versions
NodeToClientVersion
NodeToClientVersionData
(OuroborosApplication
'InitiatorMode LocalAddress LByteString IO a b)
-> String
-> IO ()
connectTo
(IOManager -> String -> LocalSnocket
localSnocket IOManager
iomgr String
path)
NetworkConnectTracers :: forall addr vNumber.
Tracer IO (WithMuxBearer (ConnectionId addr) MuxTrace)
-> Tracer
IO
(WithMuxBearer
(ConnectionId addr) (TraceSendRecv (Handshake vNumber Term)))
-> NetworkConnectTracers addr vNumber
NetworkConnectTracers {
nctMuxTracer :: Tracer IO (WithMuxBearer (ConnectionId LocalAddress) MuxTrace)
nctMuxTracer = Tracer IO (WithMuxBearer (ConnectionId LocalAddress) MuxTrace)
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer,
nctHandshakeTracer :: Tracer
IO
(WithMuxBearer
(ConnectionId LocalAddress)
(TraceSendRecv (Handshake NodeToClientVersion Term)))
nctHandshakeTracer = Tracer
IO
(WithMuxBearer
(ConnectionId LocalAddress)
(TraceSendRecv (Handshake NodeToClientVersion Term)))
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer
}
(((NodeToClientVersion, BlockNodeToClientVersion block)
-> Versions
NodeToClientVersion
NodeToClientVersionData
(OuroborosApplication
'InitiatorMode LocalAddress LByteString IO () Void))
-> [(NodeToClientVersion, BlockNodeToClientVersion block)]
-> Versions
NodeToClientVersion
NodeToClientVersionData
(OuroborosApplication
'InitiatorMode LocalAddress LByteString IO () Void)
forall vNum (f :: * -> *) x extra r.
(Ord vNum, Foldable f, HasCallStack) =>
(x -> Versions vNum extra r) -> f x -> Versions vNum extra r
foldMapVersions
(\(NodeToClientVersion
version, BlockNodeToClientVersion block
blockVersion) ->
NodeToClientVersion
-> NodeToClientVersionData
-> (ConnectionId LocalAddress
-> STM IO ControlMessage
-> NodeToClientProtocols 'InitiatorMode LByteString IO () Void)
-> Versions
NodeToClientVersion
NodeToClientVersionData
(OuroborosApplication
'InitiatorMode LocalAddress LByteString IO () Void)
forall (m :: * -> *) (appType :: MuxMode) bytes a b.
NodeToClientVersion
-> NodeToClientVersionData
-> (ConnectionId LocalAddress
-> STM m ControlMessage
-> NodeToClientProtocols appType bytes m a b)
-> Versions
NodeToClientVersion
NodeToClientVersionData
(OuroborosApplication appType LocalAddress bytes m a b)
versionedNodeToClientProtocols
NodeToClientVersion
version
NodeToClientVersionData :: NetworkMagic -> NodeToClientVersionData
NodeToClientVersionData {
networkMagic :: NetworkMagic
networkMagic = NetworkId -> NetworkMagic
toNetworkMagic NetworkId
network
}
(\ConnectionId LocalAddress
_conn STM IO ControlMessage
_runOrStop -> SerialiseNodeToClientConstraints block =>
ProtocolClient block (BlockProtocol block)
-> BlockNodeToClientVersion block
-> NodeToClientProtocols 'InitiatorMode LByteString IO () Void
ProtocolClient block (BlockProtocol block)
-> BlockNodeToClientVersion block
-> NodeToClientProtocols 'InitiatorMode LByteString IO () Void
protocols ProtocolClient block (BlockProtocol block)
ptcl BlockNodeToClientVersion block
blockVersion))
(Map NodeToClientVersion (BlockNodeToClientVersion block)
-> [(NodeToClientVersion, BlockNodeToClientVersion block)]
forall k a. Map k a -> [(k, a)]
Map.toList (Proxy block
-> Map NodeToClientVersion (BlockNodeToClientVersion block)
forall blk.
SupportedNetworkProtocolVersion blk =>
Proxy blk -> Map NodeToClientVersion (BlockNodeToClientVersion blk)
supportedNodeToClientVersions Proxy block
proxy)))
String
path
where
proxy :: Proxy block
proxy :: Proxy block
proxy = Proxy block
forall k (t :: k). Proxy t
Proxy
protocols :: SerialiseNodeToClientConstraints block
=> ProtocolClient block (BlockProtocol block)
-> BlockNodeToClientVersion block
-> NodeToClientProtocols InitiatorMode LBS.ByteString IO () Void
protocols :: ProtocolClient block (BlockProtocol block)
-> BlockNodeToClientVersion block
-> NodeToClientProtocols 'InitiatorMode LByteString IO () Void
protocols ProtocolClient block (BlockProtocol block)
ptcl BlockNodeToClientVersion block
clientVersion =
let Codecs {
Codec
(ChainSync block (Point block) (Tip block))
DeserialiseFailure
IO
LByteString
cChainSyncCodec :: forall blk serialisedBlk e (m :: * -> *) bCS bTX bSQ.
Codecs' blk serialisedBlk e m bCS bTX bSQ
-> Codec (ChainSync serialisedBlk (Point blk) (Tip blk)) e m bCS
cChainSyncCodec :: Codec
(ChainSync block (Point block) (Tip block))
DeserialiseFailure
IO
LByteString
cChainSyncCodec
, Codec
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
DeserialiseFailure
IO
LByteString
cTxSubmissionCodec :: forall blk serialisedBlk e (m :: * -> *) bCS bTX bSQ.
Codecs' blk serialisedBlk e m bCS bTX bSQ
-> Codec (LocalTxSubmission (GenTx blk) (ApplyTxErr blk)) e m bTX
cTxSubmissionCodec :: Codec
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
DeserialiseFailure
IO
LByteString
cTxSubmissionCodec
, Codec
(LocalStateQuery block (Point block) (Query block))
DeserialiseFailure
IO
LByteString
cStateQueryCodec :: forall blk serialisedBlk e (m :: * -> *) bCS bTX bSQ.
Codecs' blk serialisedBlk e m bCS bTX bSQ
-> Codec (LocalStateQuery blk (Point blk) (Query blk)) e m bSQ
cStateQueryCodec :: Codec
(LocalStateQuery block (Point block) (Query block))
DeserialiseFailure
IO
LByteString
cStateQueryCodec
} = CodecConfig block
-> BlockNodeToClientVersion block
-> Codecs'
block
block
DeserialiseFailure
IO
LByteString
LByteString
LByteString
forall (m :: * -> *) blk.
(MonadST m, SerialiseNodeToClientConstraints blk,
ShowQuery (Query blk)) =>
CodecConfig blk
-> BlockNodeToClientVersion blk -> ClientCodecs blk m
clientCodecs (ProtocolClientInfo block -> CodecConfig block
forall b. ProtocolClientInfo b -> CodecConfig b
pClientInfoCodecConfig (ProtocolClient block (BlockProtocol block)
-> ProtocolClientInfo block
forall blk p. ProtocolClient blk p -> ProtocolClientInfo blk
protocolClientInfo ProtocolClient block (BlockProtocol block)
ptcl))
BlockNodeToClientVersion block
clientVersion
LocalNodeClientProtocols {
Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
localChainSyncClient :: Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
localChainSyncClient :: forall block.
LocalNodeClientProtocols block
-> Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
localChainSyncClient,
Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient :: Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient :: forall block.
LocalNodeClientProtocols block
-> Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient,
Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient :: Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient :: forall block.
LocalNodeClientProtocols block
-> Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient
} = LocalNodeClientProtocols block
clientptcls
in NodeToClientProtocols :: forall (appType :: MuxMode) bytes (m :: * -> *) a b.
RunMiniProtocol appType bytes m a b
-> RunMiniProtocol appType bytes m a b
-> RunMiniProtocol appType bytes m a b
-> NodeToClientProtocols appType bytes m a b
NodeToClientProtocols {
localChainSyncProtocol :: RunMiniProtocol 'InitiatorMode LByteString IO () Void
localChainSyncProtocol =
MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void
forall bytes (m :: * -> *) a.
MuxPeer bytes m a -> RunMiniProtocol 'InitiatorMode bytes m a Void
InitiatorProtocolOnly (MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void)
-> MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void
forall a b. (a -> b) -> a -> b
$
Tracer
IO (TraceSendRecv (ChainSync block (Point block) (Tip block)))
-> Codec
(ChainSync block (Point block) (Tip block))
DeserialiseFailure
IO
LByteString
-> Peer
(ChainSync block (Point block) (Tip block)) 'AsClient 'StIdle IO ()
-> MuxPeer LByteString IO ()
forall (pr :: PeerRole) ps (st :: ps) failure bytes (m :: * -> *)
a.
(Show failure, forall (st' :: ps). Show (ClientHasAgency st'),
forall (st' :: ps). Show (ServerHasAgency st'), ShowProxy ps) =>
Tracer m (TraceSendRecv ps)
-> Codec ps failure m bytes
-> Peer ps pr st m a
-> MuxPeer bytes m a
MuxPeer
Tracer
IO (TraceSendRecv (ChainSync block (Point block) (Tip block)))
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer
Codec
(ChainSync block (Point block) (Tip block))
DeserialiseFailure
IO
LByteString
cChainSyncCodec
(Peer
(ChainSync block (Point block) (Tip block)) 'AsClient 'StIdle IO ()
-> (ChainSyncClient block (Point block) (Tip block) IO ()
-> Peer
(ChainSync block (Point block) (Tip block))
'AsClient
'StIdle
IO
())
-> Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
-> Peer
(ChainSync block (Point block) (Tip block)) 'AsClient 'StIdle IO ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Peer
(ChainSync block (Point block) (Tip block)) 'AsClient 'StIdle IO ()
forall header point tip (m :: * -> *) a.
MonadTimer m =>
Peer (ChainSync header point tip) 'AsClient 'StIdle m a
chainSyncPeerNull
ChainSyncClient block (Point block) (Tip block) IO ()
-> Peer
(ChainSync block (Point block) (Tip block)) 'AsClient 'StIdle IO ()
forall header point tip (m :: * -> *) a.
Monad m =>
ChainSyncClient header point tip m a
-> Peer (ChainSync header point tip) 'AsClient 'StIdle m a
chainSyncClientPeer
Maybe (ChainSyncClient block (Point block) (Tip block) IO ())
localChainSyncClient)
, localTxSubmissionProtocol :: RunMiniProtocol 'InitiatorMode LByteString IO () Void
localTxSubmissionProtocol =
MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void
forall bytes (m :: * -> *) a.
MuxPeer bytes m a -> RunMiniProtocol 'InitiatorMode bytes m a Void
InitiatorProtocolOnly (MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void)
-> MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void
forall a b. (a -> b) -> a -> b
$
Tracer
IO
(TraceSendRecv
(LocalTxSubmission (GenTx block) (ApplyTxErr block)))
-> Codec
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
DeserialiseFailure
IO
LByteString
-> Peer
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
'AsClient
'StIdle
IO
()
-> MuxPeer LByteString IO ()
forall (pr :: PeerRole) ps (st :: ps) failure bytes (m :: * -> *)
a.
(Show failure, forall (st' :: ps). Show (ClientHasAgency st'),
forall (st' :: ps). Show (ServerHasAgency st'), ShowProxy ps) =>
Tracer m (TraceSendRecv ps)
-> Codec ps failure m bytes
-> Peer ps pr st m a
-> MuxPeer bytes m a
MuxPeer
Tracer
IO
(TraceSendRecv
(LocalTxSubmission (GenTx block) (ApplyTxErr block)))
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer
Codec
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
DeserialiseFailure
IO
LByteString
cTxSubmissionCodec
(Peer
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
'AsClient
'StIdle
IO
()
-> (LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
-> Peer
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
'AsClient
'StIdle
IO
())
-> Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
-> Peer
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
'AsClient
'StIdle
IO
()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Peer
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
'AsClient
'StIdle
IO
()
forall tx reject (m :: * -> *) a.
MonadTimer m =>
Peer (LocalTxSubmission tx reject) 'AsClient 'StIdle m a
localTxSubmissionPeerNull
LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
-> Peer
(LocalTxSubmission (GenTx block) (ApplyTxErr block))
'AsClient
'StIdle
IO
()
forall tx reject (m :: * -> *) a.
Monad m =>
LocalTxSubmissionClient tx reject m a
-> Peer (LocalTxSubmission tx reject) 'AsClient 'StIdle m a
localTxSubmissionClientPeer
Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient)
, localStateQueryProtocol :: RunMiniProtocol 'InitiatorMode LByteString IO () Void
localStateQueryProtocol =
MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void
forall bytes (m :: * -> *) a.
MuxPeer bytes m a -> RunMiniProtocol 'InitiatorMode bytes m a Void
InitiatorProtocolOnly (MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void)
-> MuxPeer LByteString IO ()
-> RunMiniProtocol 'InitiatorMode LByteString IO () Void
forall a b. (a -> b) -> a -> b
$
Tracer
IO
(TraceSendRecv (LocalStateQuery block (Point block) (Query block)))
-> Codec
(LocalStateQuery block (Point block) (Query block))
DeserialiseFailure
IO
LByteString
-> Peer
(LocalStateQuery block (Point block) (Query block))
'AsClient
'StIdle
IO
()
-> MuxPeer LByteString IO ()
forall (pr :: PeerRole) ps (st :: ps) failure bytes (m :: * -> *)
a.
(Show failure, forall (st' :: ps). Show (ClientHasAgency st'),
forall (st' :: ps). Show (ServerHasAgency st'), ShowProxy ps) =>
Tracer m (TraceSendRecv ps)
-> Codec ps failure m bytes
-> Peer ps pr st m a
-> MuxPeer bytes m a
MuxPeer
Tracer
IO
(TraceSendRecv (LocalStateQuery block (Point block) (Query block)))
forall (m :: * -> *) a. Applicative m => Tracer m a
nullTracer
Codec
(LocalStateQuery block (Point block) (Query block))
DeserialiseFailure
IO
LByteString
cStateQueryCodec
(Peer
(LocalStateQuery block (Point block) (Query block))
'AsClient
'StIdle
IO
()
-> (LocalStateQueryClient block (Point block) (Query block) IO ()
-> Peer
(LocalStateQuery block (Point block) (Query block))
'AsClient
'StIdle
IO
())
-> Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
-> Peer
(LocalStateQuery block (Point block) (Query block))
'AsClient
'StIdle
IO
()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Peer
(LocalStateQuery block (Point block) (Query block))
'AsClient
'StIdle
IO
()
forall block point (query :: * -> *) (m :: * -> *) a.
MonadTimer m =>
Peer (LocalStateQuery block point query) 'AsClient 'StIdle m a
localStateQueryPeerNull
LocalStateQueryClient block (Point block) (Query block) IO ()
-> Peer
(LocalStateQuery block (Point block) (Query block))
'AsClient
'StIdle
IO
()
forall block point (query :: * -> *) (m :: * -> *) a.
Monad m =>
LocalStateQueryClient block point query m a
-> Peer (LocalStateQuery block point query) 'AsClient 'StIdle m a
localStateQueryClientPeer
Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient)
}
queryNodeLocalState :: forall mode block result.
(ShowProxy block, ShowProxy (ApplyTxErr block),
ShowProxy (Query block), ShowProxy (GenTx block),
ShowQuery (Query block))
=> LocalNodeConnectInfo mode block
-> (Point block, Query block result)
-> IO (Either AcquireFailure result)
queryNodeLocalState :: LocalNodeConnectInfo mode block
-> (Point block, Query block result)
-> IO (Either AcquireFailure result)
queryNodeLocalState LocalNodeConnectInfo mode block
connctInfo (Point block, Query block result)
pointAndQuery = do
TMVar (Either AcquireFailure result)
resultVar <- IO (TMVar (Either AcquireFailure result))
forall a. IO (TMVar a)
newEmptyTMVarIO
LocalNodeConnectInfo mode block
-> LocalNodeClientProtocols block -> IO ()
forall mode block.
(ShowProxy block, ShowProxy (ApplyTxErr block),
ShowProxy (Query block), ShowProxy (GenTx block),
ShowQuery (Query block)) =>
LocalNodeConnectInfo mode block
-> LocalNodeClientProtocols block -> IO ()
connectToLocalNode
LocalNodeConnectInfo mode block
connctInfo
LocalNodeClientProtocols block
forall block. LocalNodeClientProtocols block
nullLocalNodeClientProtocols {
localStateQueryClient :: Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
localStateQueryClient =
LocalStateQueryClient block (Point block) (Query block) IO ()
-> Maybe
(LocalStateQueryClient block (Point block) (Query block) IO ())
forall a. a -> Maybe a
Just (TMVar (Either AcquireFailure result)
-> (Point block, Query block result)
-> LocalStateQueryClient block (Point block) (Query block) IO ()
localStateQuerySingle TMVar (Either AcquireFailure result)
resultVar (Point block, Query block result)
pointAndQuery)
}
STM (Either AcquireFailure result)
-> IO (Either AcquireFailure result)
forall a. STM a -> IO a
atomically (TMVar (Either AcquireFailure result)
-> STM (Either AcquireFailure result)
forall a. TMVar a -> STM a
takeTMVar TMVar (Either AcquireFailure result)
resultVar)
where
localStateQuerySingle
:: TMVar (Either AcquireFailure result)
-> (Point block, Query block result)
-> LocalStateQueryClient block (Point block) (Query block) IO ()
localStateQuerySingle :: TMVar (Either AcquireFailure result)
-> (Point block, Query block result)
-> LocalStateQueryClient block (Point block) (Query block) IO ()
localStateQuerySingle TMVar (Either AcquireFailure result)
resultVar (Point block
point, Query block result
query) =
IO (ClientStIdle block (Point block) (Query block) IO ())
-> LocalStateQueryClient block (Point block) (Query block) IO ()
forall block point (query :: * -> *) (m :: * -> *) a.
m (ClientStIdle block point query m a)
-> LocalStateQueryClient block point query m a
LocalStateQueryClient (IO (ClientStIdle block (Point block) (Query block) IO ())
-> LocalStateQueryClient block (Point block) (Query block) IO ())
-> IO (ClientStIdle block (Point block) (Query block) IO ())
-> LocalStateQueryClient block (Point block) (Query block) IO ()
forall a b. (a -> b) -> a -> b
$ ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ()))
-> ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ())
forall a b. (a -> b) -> a -> b
$
Point block
-> ClientStAcquiring block (Point block) (Query block) IO ()
-> ClientStIdle block (Point block) (Query block) IO ()
forall point block (query :: * -> *) (m :: * -> *) a.
point
-> ClientStAcquiring block point query m a
-> ClientStIdle block point query m a
SendMsgAcquire Point block
point (ClientStAcquiring block (Point block) (Query block) IO ()
-> ClientStIdle block (Point block) (Query block) IO ())
-> ClientStAcquiring block (Point block) (Query block) IO ()
-> ClientStIdle block (Point block) (Query block) IO ()
forall a b. (a -> b) -> a -> b
$
ClientStAcquiring :: forall block point (query :: * -> *) (m :: * -> *) a.
ClientStAcquired block point query m a
-> (AcquireFailure -> m (ClientStIdle block point query m a))
-> ClientStAcquiring block point query m a
ClientStAcquiring {
recvMsgAcquired :: ClientStAcquired block (Point block) (Query block) IO ()
recvMsgAcquired =
Query block result
-> ClientStQuerying block (Point block) (Query block) IO () result
-> ClientStAcquired block (Point block) (Query block) IO ()
forall (query :: * -> *) result block point (m :: * -> *) a.
query result
-> ClientStQuerying block point query m a result
-> ClientStAcquired block point query m a
SendMsgQuery Query block result
query (ClientStQuerying block (Point block) (Query block) IO () result
-> ClientStAcquired block (Point block) (Query block) IO ())
-> ClientStQuerying block (Point block) (Query block) IO () result
-> ClientStAcquired block (Point block) (Query block) IO ()
forall a b. (a -> b) -> a -> b
$
ClientStQuerying :: forall block point (query :: * -> *) (m :: * -> *) a result.
(result -> m (ClientStAcquired block point query m a))
-> ClientStQuerying block point query m a result
ClientStQuerying {
recvMsgResult :: result
-> IO (ClientStAcquired block (Point block) (Query block) IO ())
recvMsgResult = \result
result -> do
STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TMVar (Either AcquireFailure result)
-> Either AcquireFailure result -> STM ()
forall a. TMVar a -> a -> STM ()
putTMVar TMVar (Either AcquireFailure result)
resultVar (result -> Either AcquireFailure result
forall a b. b -> Either a b
Right result
result)
ClientStAcquired block (Point block) (Query block) IO ()
-> IO (ClientStAcquired block (Point block) (Query block) IO ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ClientStAcquired block (Point block) (Query block) IO ()
-> IO (ClientStAcquired block (Point block) (Query block) IO ()))
-> ClientStAcquired block (Point block) (Query block) IO ()
-> IO (ClientStAcquired block (Point block) (Query block) IO ())
forall a b. (a -> b) -> a -> b
$ IO (ClientStIdle block (Point block) (Query block) IO ())
-> ClientStAcquired block (Point block) (Query block) IO ()
forall (m :: * -> *) block point (query :: * -> *) a.
m (ClientStIdle block point query m a)
-> ClientStAcquired block point query m a
SendMsgRelease (IO (ClientStIdle block (Point block) (Query block) IO ())
-> ClientStAcquired block (Point block) (Query block) IO ())
-> IO (ClientStIdle block (Point block) (Query block) IO ())
-> ClientStAcquired block (Point block) (Query block) IO ()
forall a b. (a -> b) -> a -> b
$
ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ()))
-> ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ())
forall a b. (a -> b) -> a -> b
$ () -> ClientStIdle block (Point block) (Query block) IO ()
forall a block point (query :: * -> *) (m :: * -> *).
a -> ClientStIdle block point query m a
StateQuery.SendMsgDone ()
}
, recvMsgFailure :: AcquireFailure
-> IO (ClientStIdle block (Point block) (Query block) IO ())
recvMsgFailure = \AcquireFailure
failure -> do
STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TMVar (Either AcquireFailure result)
-> Either AcquireFailure result -> STM ()
forall a. TMVar a -> a -> STM ()
putTMVar TMVar (Either AcquireFailure result)
resultVar (AcquireFailure -> Either AcquireFailure result
forall a b. a -> Either a b
Left AcquireFailure
failure)
ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ()))
-> ClientStIdle block (Point block) (Query block) IO ()
-> IO (ClientStIdle block (Point block) (Query block) IO ())
forall a b. (a -> b) -> a -> b
$ () -> ClientStIdle block (Point block) (Query block) IO ()
forall a block point (query :: * -> *) (m :: * -> *).
a -> ClientStIdle block point query m a
StateQuery.SendMsgDone ()
}
submitTxToNodeLocal :: forall mode block.
(ShowProxy block, ShowProxy (ApplyTxErr block),
ShowProxy (Query block), ShowProxy (GenTx block),
ShowQuery (Query block))
=> LocalNodeConnectInfo mode block
-> GenTx block
-> IO (SubmitResult (ApplyTxErr block))
submitTxToNodeLocal :: LocalNodeConnectInfo mode block
-> GenTx block -> IO (SubmitResult (ApplyTxErr block))
submitTxToNodeLocal LocalNodeConnectInfo mode block
connctInfo GenTx block
tx = do
TMVar (SubmitResult (ApplyTxErr block))
resultVar <- IO (TMVar (SubmitResult (ApplyTxErr block)))
forall a. IO (TMVar a)
newEmptyTMVarIO
LocalNodeConnectInfo mode block
-> LocalNodeClientProtocols block -> IO ()
forall mode block.
(ShowProxy block, ShowProxy (ApplyTxErr block),
ShowProxy (Query block), ShowProxy (GenTx block),
ShowQuery (Query block)) =>
LocalNodeConnectInfo mode block
-> LocalNodeClientProtocols block -> IO ()
connectToLocalNode
LocalNodeConnectInfo mode block
connctInfo
LocalNodeClientProtocols block
forall block. LocalNodeClientProtocols block
nullLocalNodeClientProtocols {
localTxSubmissionClient :: Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
localTxSubmissionClient =
LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
-> Maybe
(LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
forall a. a -> Maybe a
Just (TMVar (SubmitResult (ApplyTxErr block))
-> LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
localTxSubmissionClientSingle TMVar (SubmitResult (ApplyTxErr block))
resultVar)
}
STM (SubmitResult (ApplyTxErr block))
-> IO (SubmitResult (ApplyTxErr block))
forall a. STM a -> IO a
atomically (TMVar (SubmitResult (ApplyTxErr block))
-> STM (SubmitResult (ApplyTxErr block))
forall a. TMVar a -> STM a
takeTMVar TMVar (SubmitResult (ApplyTxErr block))
resultVar)
where
localTxSubmissionClientSingle
:: TMVar (SubmitResult (ApplyTxErr block))
-> LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
localTxSubmissionClientSingle :: TMVar (SubmitResult (ApplyTxErr block))
-> LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
localTxSubmissionClientSingle TMVar (SubmitResult (ApplyTxErr block))
resultVar =
IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
-> LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
forall tx reject (m :: * -> *) a.
m (LocalTxClientStIdle tx reject m a)
-> LocalTxSubmissionClient tx reject m a
LocalTxSubmissionClient (IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
-> LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ())
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
-> LocalTxSubmissionClient (GenTx block) (ApplyTxErr block) IO ()
forall a b. (a -> b) -> a -> b
$
LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()))
-> LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
forall a b. (a -> b) -> a -> b
$ GenTx block
-> (SubmitResult (ApplyTxErr block)
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()))
-> LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
forall tx reject (m :: * -> *) a.
tx
-> (SubmitResult reject -> m (LocalTxClientStIdle tx reject m a))
-> LocalTxClientStIdle tx reject m a
SendMsgSubmitTx GenTx block
tx ((SubmitResult (ApplyTxErr block)
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()))
-> LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
-> (SubmitResult (ApplyTxErr block)
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()))
-> LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
forall a b. (a -> b) -> a -> b
$ \SubmitResult (ApplyTxErr block)
result -> do
STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TMVar (SubmitResult (ApplyTxErr block))
-> SubmitResult (ApplyTxErr block) -> STM ()
forall a. TMVar a -> a -> STM ()
putTMVar TMVar (SubmitResult (ApplyTxErr block))
resultVar SubmitResult (ApplyTxErr block)
result
LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
-> IO (LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> LocalTxClientStIdle (GenTx block) (ApplyTxErr block) IO ()
forall a tx reject (m :: * -> *).
a -> LocalTxClientStIdle tx reject m a
TxSubmission.SendMsgDone ())
class HasTypeProxy a => SerialiseAsCBOR a where
serialiseToCBOR :: a -> ByteString
deserialiseFromCBOR :: AsType a -> ByteString -> Either CBOR.DecoderError a
default serialiseToCBOR :: ToCBOR a => a -> ByteString
serialiseToCBOR = a -> ByteString
forall a. ToCBOR a => a -> ByteString
CBOR.serialize'
default deserialiseFromCBOR :: FromCBOR a
=> AsType a
-> ByteString
-> Either CBOR.DecoderError a
deserialiseFromCBOR AsType a
_proxy = ByteString -> Either DecoderError a
forall a. FromCBOR a => ByteString -> Either DecoderError a
CBOR.decodeFull'
newtype JsonDecodeError = JsonDecodeError String
serialiseToJSON :: ToJSON a => a -> ByteString
serialiseToJSON :: a -> ByteString
serialiseToJSON = LByteString -> ByteString
LBS.toStrict (LByteString -> ByteString)
-> (a -> LByteString) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> LByteString
forall a. ToJSON a => a -> LByteString
Aeson.encode
deserialiseFromJSON :: FromJSON a
=> AsType a
-> ByteString
-> Either JsonDecodeError a
deserialiseFromJSON :: AsType a -> ByteString -> Either JsonDecodeError a
deserialiseFromJSON AsType a
_proxy = (String -> Either JsonDecodeError a)
-> (a -> Either JsonDecodeError a)
-> Either String a
-> Either JsonDecodeError a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (JsonDecodeError -> Either JsonDecodeError a
forall a b. a -> Either a b
Left (JsonDecodeError -> Either JsonDecodeError a)
-> (String -> JsonDecodeError)
-> String
-> Either JsonDecodeError a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> JsonDecodeError
JsonDecodeError) a -> Either JsonDecodeError a
forall a b. b -> Either a b
Right
(Either String a -> Either JsonDecodeError a)
-> (ByteString -> Either String a)
-> ByteString
-> Either JsonDecodeError a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either String a
forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecodeStrict'
class HasTypeProxy a => SerialiseAsRawBytes a where
serialiseToRawBytes :: a -> ByteString
deserialiseFromRawBytes :: AsType a -> ByteString -> Maybe a
serialiseToRawBytesHex :: SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex :: a -> ByteString
serialiseToRawBytesHex = ByteString -> ByteString
Base16.encode (ByteString -> ByteString) -> (a -> ByteString) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytes
deserialiseFromRawBytesHex :: SerialiseAsRawBytes a
=> AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex :: AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex AsType a
proxy ByteString
hex = case ByteString -> Either String ByteString
decodeEitherBase16 ByteString
hex of
Right ByteString
raw -> AsType a -> ByteString -> Maybe a
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytes AsType a
proxy ByteString
raw
Left String
_ -> Maybe a
forall a. Maybe a
Nothing
newtype UsingRawBytesHex a = UsingRawBytesHex a
instance SerialiseAsRawBytes a => Show (UsingRawBytesHex a) where
show :: UsingRawBytesHex a -> String
show (UsingRawBytesHex a
x) = ByteString -> String
forall a. Show a => a -> String
show (a -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex a
x)
instance SerialiseAsRawBytes a => IsString (UsingRawBytesHex a) where
fromString :: String -> UsingRawBytesHex a
fromString String
str =
case ByteString -> Either String ByteString
decodeEitherBase16 (String -> ByteString
BSC.pack String
str) of
Right ByteString
raw -> case AsType a -> ByteString -> Maybe a
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytes AsType a
ttoken ByteString
raw of
Just a
x -> a -> UsingRawBytesHex a
forall a. a -> UsingRawBytesHex a
UsingRawBytesHex a
x
Maybe a
Nothing -> String -> UsingRawBytesHex a
forall a. HasCallStack => String -> a
error (String
"fromString: cannot deserialise " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
str)
Left String
msg -> String -> UsingRawBytesHex a
forall a. HasCallStack => String -> a
error (String
"fromString: invalid hex " String -> ShowS
forall a. [a] -> [a] -> [a]
++ ShowS
forall a. Show a => a -> String
show String
str String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
msg)
where
ttoken :: AsType a
ttoken :: AsType a
ttoken = Proxy a -> AsType a
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType Proxy a
forall k (t :: k). Proxy t
Proxy
class (HasTypeProxy a, SerialiseAsRawBytes a) => SerialiseAsBech32 a where
bech32PrefixFor :: a -> Text
bech32PrefixesPermitted :: AsType a -> [Text]
serialiseToBech32 :: SerialiseAsBech32 a => a -> Text
serialiseToBech32 :: a -> Text
serialiseToBech32 a
a =
HumanReadablePart -> DataPart -> Text
Bech32.encodeLenient
HumanReadablePart
humanReadablePart
(ByteString -> DataPart
Bech32.dataPartFromBytes (a -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytes a
a))
where
humanReadablePart :: HumanReadablePart
humanReadablePart =
case Text -> Either HumanReadablePartError HumanReadablePart
Bech32.humanReadablePartFromText (a -> Text
forall a. SerialiseAsBech32 a => a -> Text
bech32PrefixFor a
a) of
Right HumanReadablePart
p -> HumanReadablePart
p
Left HumanReadablePartError
err -> String -> HumanReadablePart
forall a. HasCallStack => String -> a
error (String -> HumanReadablePart) -> String -> HumanReadablePart
forall a b. (a -> b) -> a -> b
$ String
"serialiseToBech32: invalid prefix "
String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show (a -> Text
forall a. SerialiseAsBech32 a => a -> Text
bech32PrefixFor a
a)
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", " String -> ShowS
forall a. [a] -> [a] -> [a]
++ HumanReadablePartError -> String
forall a. Show a => a -> String
show HumanReadablePartError
err
deserialiseFromBech32 :: SerialiseAsBech32 a
=> AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 :: AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 AsType a
asType Text
bech32Str = do
(HumanReadablePart
prefix, DataPart
dataPart) <- Text -> Either DecodingError (HumanReadablePart, DataPart)
Bech32.decodeLenient Text
bech32Str
Either DecodingError (HumanReadablePart, DataPart)
-> (DecodingError -> Bech32DecodeError)
-> Either Bech32DecodeError (HumanReadablePart, DataPart)
forall e a e'. Either e a -> (e -> e') -> Either e' a
?!. DecodingError -> Bech32DecodeError
Bech32DecodingError
let actualPrefix :: Text
actualPrefix = HumanReadablePart -> Text
Bech32.humanReadablePartToText HumanReadablePart
prefix
permittedPrefixes :: [Text]
permittedPrefixes = AsType a -> [Text]
forall a. SerialiseAsBech32 a => AsType a -> [Text]
bech32PrefixesPermitted AsType a
asType
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Text
actualPrefix Text -> [Text] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Text]
permittedPrefixes)
Maybe () -> Bech32DecodeError -> Either Bech32DecodeError ()
forall a e. Maybe a -> e -> Either e a
?! Text -> Set Text -> Bech32DecodeError
Bech32UnexpectedPrefix Text
actualPrefix ([Text] -> Set Text
forall a. Ord a => [a] -> Set a
Set.fromList [Text]
permittedPrefixes)
ByteString
payload <- DataPart -> Maybe ByteString
Bech32.dataPartToBytes DataPart
dataPart
Maybe ByteString
-> Bech32DecodeError -> Either Bech32DecodeError ByteString
forall a e. Maybe a -> e -> Either e a
?! Text -> Bech32DecodeError
Bech32DataPartToBytesError (DataPart -> Text
Bech32.dataPartToText DataPart
dataPart)
a
value <- AsType a -> ByteString -> Maybe a
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytes AsType a
asType ByteString
payload
Maybe a -> Bech32DecodeError -> Either Bech32DecodeError a
forall a e. Maybe a -> e -> Either e a
?! ByteString -> Bech32DecodeError
Bech32DeserialiseFromBytesError ByteString
payload
let expectedPrefix :: Text
expectedPrefix = a -> Text
forall a. SerialiseAsBech32 a => a -> Text
bech32PrefixFor a
value
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Text
actualPrefix Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
expectedPrefix)
Maybe () -> Bech32DecodeError -> Either Bech32DecodeError ()
forall a e. Maybe a -> e -> Either e a
?! Text -> Text -> Bech32DecodeError
Bech32WrongPrefix Text
actualPrefix Text
expectedPrefix
a -> Either Bech32DecodeError a
forall (m :: * -> *) a. Monad m => a -> m a
return a
value
deserialiseAnyOfFromBech32
:: forall b.
[FromSomeType SerialiseAsBech32 b]
-> Text
-> Either Bech32DecodeError b
deserialiseAnyOfFromBech32 :: [FromSomeType SerialiseAsBech32 b]
-> Text -> Either Bech32DecodeError b
deserialiseAnyOfFromBech32 [FromSomeType SerialiseAsBech32 b]
types Text
bech32Str = do
(HumanReadablePart
prefix, DataPart
dataPart) <- Text -> Either DecodingError (HumanReadablePart, DataPart)
Bech32.decodeLenient Text
bech32Str
Either DecodingError (HumanReadablePart, DataPart)
-> (DecodingError -> Bech32DecodeError)
-> Either Bech32DecodeError (HumanReadablePart, DataPart)
forall e a e'. Either e a -> (e -> e') -> Either e' a
?!. DecodingError -> Bech32DecodeError
Bech32DecodingError
let actualPrefix :: Text
actualPrefix = HumanReadablePart -> Text
Bech32.humanReadablePartToText HumanReadablePart
prefix
FromSomeType AsType a
actualType a -> b
fromType <-
Text -> Maybe (FromSomeType SerialiseAsBech32 b)
findForPrefix Text
actualPrefix
Maybe (FromSomeType SerialiseAsBech32 b)
-> Bech32DecodeError
-> Either Bech32DecodeError (FromSomeType SerialiseAsBech32 b)
forall a e. Maybe a -> e -> Either e a
?! Text -> Set Text -> Bech32DecodeError
Bech32UnexpectedPrefix Text
actualPrefix Set Text
permittedPrefixes
ByteString
payload <- DataPart -> Maybe ByteString
Bech32.dataPartToBytes DataPart
dataPart
Maybe ByteString
-> Bech32DecodeError -> Either Bech32DecodeError ByteString
forall a e. Maybe a -> e -> Either e a
?! Text -> Bech32DecodeError
Bech32DataPartToBytesError (DataPart -> Text
Bech32.dataPartToText DataPart
dataPart)
a
value <- AsType a -> ByteString -> Maybe a
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytes AsType a
actualType ByteString
payload
Maybe a -> Bech32DecodeError -> Either Bech32DecodeError a
forall a e. Maybe a -> e -> Either e a
?! ByteString -> Bech32DecodeError
Bech32DeserialiseFromBytesError ByteString
payload
let expectedPrefix :: Text
expectedPrefix = a -> Text
forall a. SerialiseAsBech32 a => a -> Text
bech32PrefixFor a
value
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Text
actualPrefix Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
expectedPrefix)
Maybe () -> Bech32DecodeError -> Either Bech32DecodeError ()
forall a e. Maybe a -> e -> Either e a
?! Text -> Text -> Bech32DecodeError
Bech32WrongPrefix Text
actualPrefix Text
expectedPrefix
b -> Either Bech32DecodeError b
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> b
fromType a
value)
where
findForPrefix
:: Text
-> Maybe (FromSomeType SerialiseAsBech32 b)
findForPrefix :: Text -> Maybe (FromSomeType SerialiseAsBech32 b)
findForPrefix Text
prefix =
(FromSomeType SerialiseAsBech32 b -> Bool)
-> [FromSomeType SerialiseAsBech32 b]
-> Maybe (FromSomeType SerialiseAsBech32 b)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
List.find
(\(FromSomeType AsType a
t a -> b
_) -> Text
prefix Text -> [Text] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` AsType a -> [Text]
forall a. SerialiseAsBech32 a => AsType a -> [Text]
bech32PrefixesPermitted AsType a
t)
[FromSomeType SerialiseAsBech32 b]
types
permittedPrefixes :: Set Text
permittedPrefixes :: Set Text
permittedPrefixes =
[Text] -> Set Text
forall a. Ord a => [a] -> Set a
Set.fromList ([Text] -> Set Text) -> [Text] -> Set Text
forall a b. (a -> b) -> a -> b
$ [[Text]] -> [Text]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ AsType a -> [Text]
forall a. SerialiseAsBech32 a => AsType a -> [Text]
bech32PrefixesPermitted AsType a
ttoken
| FromSomeType AsType a
ttoken a -> b
_f <- [FromSomeType SerialiseAsBech32 b]
types
]
data Bech32DecodeError =
Bech32DecodingError !Bech32.DecodingError
| Bech32UnexpectedPrefix !Text !(Set Text)
| Bech32DataPartToBytesError !Text
| Bech32DeserialiseFromBytesError !ByteString
| Bech32WrongPrefix !Text !Text
deriving (Bech32DecodeError -> Bech32DecodeError -> Bool
(Bech32DecodeError -> Bech32DecodeError -> Bool)
-> (Bech32DecodeError -> Bech32DecodeError -> Bool)
-> Eq Bech32DecodeError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bech32DecodeError -> Bech32DecodeError -> Bool
$c/= :: Bech32DecodeError -> Bech32DecodeError -> Bool
== :: Bech32DecodeError -> Bech32DecodeError -> Bool
$c== :: Bech32DecodeError -> Bech32DecodeError -> Bool
Eq, Int -> Bech32DecodeError -> ShowS
[Bech32DecodeError] -> ShowS
Bech32DecodeError -> String
(Int -> Bech32DecodeError -> ShowS)
-> (Bech32DecodeError -> String)
-> ([Bech32DecodeError] -> ShowS)
-> Show Bech32DecodeError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Bech32DecodeError] -> ShowS
$cshowList :: [Bech32DecodeError] -> ShowS
show :: Bech32DecodeError -> String
$cshow :: Bech32DecodeError -> String
showsPrec :: Int -> Bech32DecodeError -> ShowS
$cshowsPrec :: Int -> Bech32DecodeError -> ShowS
Show)
instance Error Bech32DecodeError where
displayError :: Bech32DecodeError -> String
displayError Bech32DecodeError
err = case Bech32DecodeError
err of
Bech32DecodingError DecodingError
decErr -> DecodingError -> String
forall a. Show a => a -> String
show DecodingError
decErr
Bech32UnexpectedPrefix Text
actual Set Text
permitted ->
String
"Unexpected Bech32 prefix: the actual prefix is " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
actual
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
", but it was expected to be "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
List.intercalate String
" or " ((Text -> String) -> [Text] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Text -> String
forall a. Show a => a -> String
show (Set Text -> [Text]
forall a. Set a -> [a]
Set.toList Set Text
permitted))
Bech32DataPartToBytesError Text
_dataPart ->
String
"There was an error in extracting the bytes from the data part of the \
\Bech32-encoded string."
Bech32DeserialiseFromBytesError ByteString
_bytes ->
String
"There was an error in deserialising the data part of the \
\Bech32-encoded string into a value of the expected type."
Bech32WrongPrefix Text
actual Text
expected ->
String
"Mismatch in the Bech32 prefix: the actual prefix is " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
actual
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
", but the prefix for this payload value should be " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
expected
class HasTypeProxy addr => SerialiseAddress addr where
serialiseAddress :: addr -> Text
deserialiseAddress :: AsType addr -> Text -> Maybe addr
type TextEnvelope = TextView.TextView
type TextEnvelopeType = TextView.TextViewType
type TextEnvelopeDescr = TextView.TextViewDescription
class SerialiseAsCBOR a => HasTextEnvelope a where
textEnvelopeType :: AsType a -> TextEnvelopeType
textEnvelopeDefaultDescr :: a -> TextEnvelopeDescr
textEnvelopeDefaultDescr a
_ = TextEnvelopeDescr
""
type TextEnvelopeError = TextView.TextViewError
data FileError e = FileError FilePath e
| FileIOError FilePath IOException
deriving Int -> FileError e -> ShowS
[FileError e] -> ShowS
FileError e -> String
(Int -> FileError e -> ShowS)
-> (FileError e -> String)
-> ([FileError e] -> ShowS)
-> Show (FileError e)
forall e. Show e => Int -> FileError e -> ShowS
forall e. Show e => [FileError e] -> ShowS
forall e. Show e => FileError e -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileError e] -> ShowS
$cshowList :: forall e. Show e => [FileError e] -> ShowS
show :: FileError e -> String
$cshow :: forall e. Show e => FileError e -> String
showsPrec :: Int -> FileError e -> ShowS
$cshowsPrec :: forall e. Show e => Int -> FileError e -> ShowS
Show
instance Error e => Error (FileError e) where
displayError :: FileError e -> String
displayError (FileIOError String
path IOException
ioe) =
String
path String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ IOException -> String
forall e. Exception e => e -> String
displayException IOException
ioe
displayError (FileError String
path e
e) =
String
path String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ e -> String
forall e. Error e => e -> String
displayError e
e
instance Error TextView.TextViewError where
displayError :: TextViewError -> String
displayError = Text -> String
Text.unpack (Text -> String)
-> (TextViewError -> Text) -> TextViewError -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextViewError -> Text
TextView.renderTextViewError
serialiseToTextEnvelope :: forall a. HasTextEnvelope a
=> Maybe TextEnvelopeDescr -> a -> TextEnvelope
serialiseToTextEnvelope :: Maybe TextEnvelopeDescr -> a -> TextEnvelope
serialiseToTextEnvelope Maybe TextEnvelopeDescr
mbDescr a
a =
TextView :: TextEnvelopeType -> TextEnvelopeDescr -> ByteString -> TextEnvelope
TextView.TextView {
tvType :: TextEnvelopeType
TextView.tvType = AsType a -> TextEnvelopeType
forall a. HasTextEnvelope a => AsType a -> TextEnvelopeType
textEnvelopeType AsType a
ttoken
, tvDescription :: TextEnvelopeDescr
TextView.tvDescription = TextEnvelopeDescr -> Maybe TextEnvelopeDescr -> TextEnvelopeDescr
forall a. a -> Maybe a -> a
fromMaybe (a -> TextEnvelopeDescr
forall a. HasTextEnvelope a => a -> TextEnvelopeDescr
textEnvelopeDefaultDescr a
a) Maybe TextEnvelopeDescr
mbDescr
, tvRawCBOR :: ByteString
TextView.tvRawCBOR = a -> ByteString
forall a. SerialiseAsCBOR a => a -> ByteString
serialiseToCBOR a
a
}
where
ttoken :: AsType a
ttoken :: AsType a
ttoken = Proxy a -> AsType a
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType Proxy a
forall k (t :: k). Proxy t
Proxy
deserialiseFromTextEnvelope :: HasTextEnvelope a
=> AsType a
-> TextEnvelope
-> Either TextEnvelopeError a
deserialiseFromTextEnvelope :: AsType a -> TextEnvelope -> Either TextViewError a
deserialiseFromTextEnvelope AsType a
ttoken TextEnvelope
te = do
TextEnvelopeType -> TextEnvelope -> Either TextViewError ()
TextView.expectTextViewOfType (AsType a -> TextEnvelopeType
forall a. HasTextEnvelope a => AsType a -> TextEnvelopeType
textEnvelopeType AsType a
ttoken) TextEnvelope
te
(DecoderError -> TextViewError)
-> Either DecoderError a -> Either TextViewError a
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first DecoderError -> TextViewError
TextView.TextViewDecodeError (Either DecoderError a -> Either TextViewError a)
-> Either DecoderError a -> Either TextViewError a
forall a b. (a -> b) -> a -> b
$
AsType a -> ByteString -> Either DecoderError a
forall a.
SerialiseAsCBOR a =>
AsType a -> ByteString -> Either DecoderError a
deserialiseFromCBOR AsType a
ttoken (TextEnvelope -> ByteString
TextView.tvRawCBOR TextEnvelope
te)
data FromSomeType (c :: Type -> Constraint) b where
FromSomeType :: c a => AsType a -> (a -> b) -> FromSomeType c b
deserialiseFromTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b]
-> TextEnvelope
-> Either TextEnvelopeError b
deserialiseFromTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b]
-> TextEnvelope -> Either TextViewError b
deserialiseFromTextEnvelopeAnyOf [FromSomeType HasTextEnvelope b]
types TextEnvelope
te =
case (FromSomeType HasTextEnvelope b -> Bool)
-> [FromSomeType HasTextEnvelope b]
-> Maybe (FromSomeType HasTextEnvelope b)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
List.find FromSomeType HasTextEnvelope b -> Bool
matching [FromSomeType HasTextEnvelope b]
types of
Maybe (FromSomeType HasTextEnvelope b)
Nothing ->
TextViewError -> Either TextViewError b
forall a b. a -> Either a b
Left ([TextEnvelopeType] -> TextEnvelopeType -> TextViewError
TextView.TextViewTypeError [TextEnvelopeType]
expectedTypes TextEnvelopeType
actualType)
Just (FromSomeType AsType a
ttoken a -> b
f) ->
(DecoderError -> TextViewError)
-> Either DecoderError b -> Either TextViewError b
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first DecoderError -> TextViewError
TextView.TextViewDecodeError (Either DecoderError b -> Either TextViewError b)
-> Either DecoderError b -> Either TextViewError b
forall a b. (a -> b) -> a -> b
$
a -> b
f (a -> b) -> Either DecoderError a -> Either DecoderError b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType a -> ByteString -> Either DecoderError a
forall a.
SerialiseAsCBOR a =>
AsType a -> ByteString -> Either DecoderError a
deserialiseFromCBOR AsType a
ttoken (TextEnvelope -> ByteString
TextView.tvRawCBOR TextEnvelope
te)
where
actualType :: TextEnvelopeType
actualType = TextEnvelope -> TextEnvelopeType
TextView.tvType TextEnvelope
te
expectedTypes :: [TextEnvelopeType]
expectedTypes = [ AsType a -> TextEnvelopeType
forall a. HasTextEnvelope a => AsType a -> TextEnvelopeType
textEnvelopeType AsType a
ttoken
| FromSomeType AsType a
ttoken a -> b
_f <- [FromSomeType HasTextEnvelope b]
types ]
matching :: FromSomeType HasTextEnvelope b -> Bool
matching (FromSomeType AsType a
ttoken a -> b
_f) = TextEnvelopeType
actualType TextEnvelopeType -> TextEnvelopeType -> Bool
forall a. Eq a => a -> a -> Bool
== AsType a -> TextEnvelopeType
forall a. HasTextEnvelope a => AsType a -> TextEnvelopeType
textEnvelopeType AsType a
ttoken
writeFileTextEnvelope :: HasTextEnvelope a
=> FilePath
-> Maybe TextEnvelopeDescr
-> a
-> IO (Either (FileError ()) ())
writeFileTextEnvelope :: String
-> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ())
writeFileTextEnvelope String
path Maybe TextEnvelopeDescr
mbDescr a
a =
ExceptT (FileError ()) IO () -> IO (Either (FileError ()) ())
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT (FileError ()) IO () -> IO (Either (FileError ()) ()))
-> ExceptT (FileError ()) IO () -> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> b
$ do
(IOException -> FileError ())
-> IO () -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a.
MonadIO m =>
(IOException -> x) -> IO a -> ExceptT x m a
handleIOExceptT (String -> IOException -> FileError ()
forall e. String -> IOException -> FileError e
FileIOError String
path) (IO () -> ExceptT (FileError ()) IO ())
-> IO () -> ExceptT (FileError ()) IO ()
forall a b. (a -> b) -> a -> b
$ String -> ByteString -> IO ()
BS.writeFile String
path ByteString
content
where
content :: ByteString
content = LByteString -> ByteString
LBS.toStrict (LByteString -> ByteString) -> LByteString -> ByteString
forall a b. (a -> b) -> a -> b
$ Config -> TextEnvelope -> LByteString
forall a. ToJSON a => Config -> a -> LByteString
encodePretty' Config
TextView.textViewJSONConfig (Maybe TextEnvelopeDescr -> a -> TextEnvelope
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> TextEnvelope
serialiseToTextEnvelope Maybe TextEnvelopeDescr
mbDescr a
a) LByteString -> LByteString -> LByteString
forall a. Semigroup a => a -> a -> a
<> LByteString
"\n"
readFileTextEnvelope :: HasTextEnvelope a
=> AsType a
-> FilePath
-> IO (Either (FileError TextEnvelopeError) a)
readFileTextEnvelope :: AsType a -> String -> IO (Either (FileError TextViewError) a)
readFileTextEnvelope AsType a
ttoken String
path =
ExceptT (FileError TextViewError) IO a
-> IO (Either (FileError TextViewError) a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT (FileError TextViewError) IO a
-> IO (Either (FileError TextViewError) a))
-> ExceptT (FileError TextViewError) IO a
-> IO (Either (FileError TextViewError) a)
forall a b. (a -> b) -> a -> b
$ do
ByteString
content <- (IOException -> FileError TextViewError)
-> IO ByteString -> ExceptT (FileError TextViewError) IO ByteString
forall (m :: * -> *) x a.
MonadIO m =>
(IOException -> x) -> IO a -> ExceptT x m a
handleIOExceptT (String -> IOException -> FileError TextViewError
forall e. String -> IOException -> FileError e
FileIOError String
path) (IO ByteString -> ExceptT (FileError TextViewError) IO ByteString)
-> IO ByteString -> ExceptT (FileError TextViewError) IO ByteString
forall a b. (a -> b) -> a -> b
$ String -> IO ByteString
BS.readFile String
path
(TextViewError -> FileError TextViewError)
-> ExceptT TextViewError IO a
-> ExceptT (FileError TextViewError) IO a
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT (String -> TextViewError -> FileError TextViewError
forall e. String -> e -> FileError e
FileError String
path) (ExceptT TextViewError IO a
-> ExceptT (FileError TextViewError) IO a)
-> ExceptT TextViewError IO a
-> ExceptT (FileError TextViewError) IO a
forall a b. (a -> b) -> a -> b
$ Either TextViewError a -> ExceptT TextViewError IO a
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either TextViewError a -> ExceptT TextViewError IO a)
-> Either TextViewError a -> ExceptT TextViewError IO a
forall a b. (a -> b) -> a -> b
$ do
TextEnvelope
te <- (String -> TextViewError)
-> Either String TextEnvelope -> Either TextViewError TextEnvelope
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first String -> TextViewError
TextView.TextViewAesonDecodeError (Either String TextEnvelope -> Either TextViewError TextEnvelope)
-> Either String TextEnvelope -> Either TextViewError TextEnvelope
forall a b. (a -> b) -> a -> b
$ ByteString -> Either String TextEnvelope
forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecodeStrict' ByteString
content
AsType a -> TextEnvelope -> Either TextViewError a
forall a.
HasTextEnvelope a =>
AsType a -> TextEnvelope -> Either TextViewError a
deserialiseFromTextEnvelope AsType a
ttoken TextEnvelope
te
readFileTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b]
-> FilePath
-> IO (Either (FileError TextEnvelopeError) b)
readFileTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b]
-> String -> IO (Either (FileError TextViewError) b)
readFileTextEnvelopeAnyOf [FromSomeType HasTextEnvelope b]
types String
path =
ExceptT (FileError TextViewError) IO b
-> IO (Either (FileError TextViewError) b)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT (FileError TextViewError) IO b
-> IO (Either (FileError TextViewError) b))
-> ExceptT (FileError TextViewError) IO b
-> IO (Either (FileError TextViewError) b)
forall a b. (a -> b) -> a -> b
$ do
ByteString
content <- (IOException -> FileError TextViewError)
-> IO ByteString -> ExceptT (FileError TextViewError) IO ByteString
forall (m :: * -> *) x a.
MonadIO m =>
(IOException -> x) -> IO a -> ExceptT x m a
handleIOExceptT (String -> IOException -> FileError TextViewError
forall e. String -> IOException -> FileError e
FileIOError String
path) (IO ByteString -> ExceptT (FileError TextViewError) IO ByteString)
-> IO ByteString -> ExceptT (FileError TextViewError) IO ByteString
forall a b. (a -> b) -> a -> b
$ String -> IO ByteString
BS.readFile String
path
(TextViewError -> FileError TextViewError)
-> ExceptT TextViewError IO b
-> ExceptT (FileError TextViewError) IO b
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT (String -> TextViewError -> FileError TextViewError
forall e. String -> e -> FileError e
FileError String
path) (ExceptT TextViewError IO b
-> ExceptT (FileError TextViewError) IO b)
-> ExceptT TextViewError IO b
-> ExceptT (FileError TextViewError) IO b
forall a b. (a -> b) -> a -> b
$ Either TextViewError b -> ExceptT TextViewError IO b
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either TextViewError b -> ExceptT TextViewError IO b)
-> Either TextViewError b -> ExceptT TextViewError IO b
forall a b. (a -> b) -> a -> b
$ do
TextEnvelope
te <- (String -> TextViewError)
-> Either String TextEnvelope -> Either TextViewError TextEnvelope
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first String -> TextViewError
TextView.TextViewAesonDecodeError (Either String TextEnvelope -> Either TextViewError TextEnvelope)
-> Either String TextEnvelope -> Either TextViewError TextEnvelope
forall a b. (a -> b) -> a -> b
$ ByteString -> Either String TextEnvelope
forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecodeStrict' ByteString
content
[FromSomeType HasTextEnvelope b]
-> TextEnvelope -> Either TextViewError b
forall b.
[FromSomeType HasTextEnvelope b]
-> TextEnvelope -> Either TextViewError b
deserialiseFromTextEnvelopeAnyOf [FromSomeType HasTextEnvelope b]
types TextEnvelope
te
readTextEnvelopeFromFile :: FilePath
-> IO (Either (FileError TextEnvelopeError) TextEnvelope)
readTextEnvelopeFromFile :: String -> IO (Either (FileError TextViewError) TextEnvelope)
readTextEnvelopeFromFile String
path =
ExceptT (FileError TextViewError) IO TextEnvelope
-> IO (Either (FileError TextViewError) TextEnvelope)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT (FileError TextViewError) IO TextEnvelope
-> IO (Either (FileError TextViewError) TextEnvelope))
-> ExceptT (FileError TextViewError) IO TextEnvelope
-> IO (Either (FileError TextViewError) TextEnvelope)
forall a b. (a -> b) -> a -> b
$ do
ByteString
bs <- (IOException -> FileError TextViewError)
-> IO ByteString -> ExceptT (FileError TextViewError) IO ByteString
forall (m :: * -> *) x a.
MonadIO m =>
(IOException -> x) -> IO a -> ExceptT x m a
handleIOExceptT (String -> IOException -> FileError TextViewError
forall e. String -> IOException -> FileError e
FileIOError String
path) (IO ByteString -> ExceptT (FileError TextViewError) IO ByteString)
-> IO ByteString -> ExceptT (FileError TextViewError) IO ByteString
forall a b. (a -> b) -> a -> b
$
String -> IO ByteString
BS.readFile String
path
(String -> FileError TextViewError)
-> ExceptT String IO TextEnvelope
-> ExceptT (FileError TextViewError) IO TextEnvelope
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT (String -> TextViewError -> FileError TextViewError
forall e. String -> e -> FileError e
FileError String
path (TextViewError -> FileError TextViewError)
-> (String -> TextViewError) -> String -> FileError TextViewError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> TextViewError
TextView.TextViewAesonDecodeError)
(ExceptT String IO TextEnvelope
-> ExceptT (FileError TextViewError) IO TextEnvelope)
-> (Either String TextEnvelope -> ExceptT String IO TextEnvelope)
-> Either String TextEnvelope
-> ExceptT (FileError TextViewError) IO TextEnvelope
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either String TextEnvelope -> ExceptT String IO TextEnvelope
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either String TextEnvelope
-> ExceptT (FileError TextViewError) IO TextEnvelope)
-> Either String TextEnvelope
-> ExceptT (FileError TextViewError) IO TextEnvelope
forall a b. (a -> b) -> a -> b
$ ByteString -> Either String TextEnvelope
forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecodeStrict' ByteString
bs
readTextEnvelopeOfTypeFromFile
:: TextEnvelopeType
-> FilePath
-> IO (Either (FileError TextEnvelopeError) TextEnvelope)
readTextEnvelopeOfTypeFromFile :: TextEnvelopeType
-> String -> IO (Either (FileError TextViewError) TextEnvelope)
readTextEnvelopeOfTypeFromFile TextEnvelopeType
expectedType String
path =
ExceptT (FileError TextViewError) IO TextEnvelope
-> IO (Either (FileError TextViewError) TextEnvelope)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT (FileError TextViewError) IO TextEnvelope
-> IO (Either (FileError TextViewError) TextEnvelope))
-> ExceptT (FileError TextViewError) IO TextEnvelope
-> IO (Either (FileError TextViewError) TextEnvelope)
forall a b. (a -> b) -> a -> b
$ do
TextEnvelope
te <- IO (Either (FileError TextViewError) TextEnvelope)
-> ExceptT (FileError TextViewError) IO TextEnvelope
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (String -> IO (Either (FileError TextViewError) TextEnvelope)
readTextEnvelopeFromFile String
path)
(TextViewError -> FileError TextViewError)
-> ExceptT TextViewError IO ()
-> ExceptT (FileError TextViewError) IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT (String -> TextViewError -> FileError TextViewError
forall e. String -> e -> FileError e
FileError String
path) (ExceptT TextViewError IO ()
-> ExceptT (FileError TextViewError) IO ())
-> ExceptT TextViewError IO ()
-> ExceptT (FileError TextViewError) IO ()
forall a b. (a -> b) -> a -> b
$ Either TextViewError () -> ExceptT TextViewError IO ()
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either TextViewError () -> ExceptT TextViewError IO ())
-> Either TextViewError () -> ExceptT TextViewError IO ()
forall a b. (a -> b) -> a -> b
$
TextEnvelopeType -> TextEnvelope -> Either TextViewError ()
TextView.expectTextViewOfType TextEnvelopeType
expectedType TextEnvelope
te
TextEnvelope -> ExceptT (FileError TextViewError) IO TextEnvelope
forall (m :: * -> *) a. Monad m => a -> m a
return TextEnvelope
te
class Show e => Error e where
displayError :: e -> String
instance Error () where
displayError :: () -> String
displayError () = String
""
throwErrorAsException :: Error e => e -> IO a
throwErrorAsException :: e -> IO a
throwErrorAsException e
e = ErrorAsException -> IO a
forall e a. Exception e => e -> IO a
throwIO (e -> ErrorAsException
forall e. Error e => e -> ErrorAsException
ErrorAsException e
e)
data ErrorAsException where
ErrorAsException :: Error e => e -> ErrorAsException
instance Show ErrorAsException where
show :: ErrorAsException -> String
show (ErrorAsException e
e) = e -> String
forall a. Show a => a -> String
show e
e
instance Exception ErrorAsException where
displayException :: ErrorAsException -> String
displayException (ErrorAsException e
e) = e -> String
forall e. Error e => e -> String
displayError e
e
instance HasTypeProxy a => HasTypeProxy (VerificationKey a) where
data AsType (VerificationKey a) = AsVerificationKey (AsType a)
proxyToAsType :: Proxy (VerificationKey a) -> AsType (VerificationKey a)
proxyToAsType Proxy (VerificationKey a)
_ = AsType a -> AsType (VerificationKey a)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey (Proxy a -> AsType a
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType (Proxy a
forall k (t :: k). Proxy t
Proxy :: Proxy a))
instance HasTypeProxy a => HasTypeProxy (SigningKey a) where
data AsType (SigningKey a) = AsSigningKey (AsType a)
proxyToAsType :: Proxy (SigningKey a) -> AsType (SigningKey a)
proxyToAsType Proxy (SigningKey a)
_ = AsType a -> AsType (SigningKey a)
forall a. AsType a -> AsType (SigningKey a)
AsSigningKey (Proxy a -> AsType a
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType (Proxy a
forall k (t :: k). Proxy t
Proxy :: Proxy a))
instance HasTypeProxy a => HasTypeProxy (Hash a) where
data AsType (Hash a) = AsHash (AsType a)
proxyToAsType :: Proxy (Hash a) -> AsType (Hash a)
proxyToAsType Proxy (Hash a)
_ = AsType a -> AsType (Hash a)
forall a. AsType a -> AsType (Hash a)
AsHash (Proxy a -> AsType a
forall t. HasTypeProxy t => Proxy t -> AsType t
proxyToAsType (Proxy a
forall k (t :: k). Proxy t
Proxy :: Proxy a))
type family ShelleyKeyRole (keyrole :: Type) :: Shelley.KeyRole
type instance ShelleyKeyRole PaymentKey = Shelley.Payment
type instance ShelleyKeyRole GenesisKey = Shelley.Genesis
type instance ShelleyKeyRole GenesisUTxOKey = Shelley.Payment
type instance ShelleyKeyRole GenesisDelegateKey = Shelley.GenesisDelegate
type instance ShelleyKeyRole StakeKey = Shelley.Staking
type instance ShelleyKeyRole StakePoolKey = Shelley.StakePool
data ByronKey
instance HasTypeProxy ByronKey where
data AsType ByronKey = AsByronKey
proxyToAsType :: Proxy ByronKey -> AsType ByronKey
proxyToAsType Proxy ByronKey
_ = AsType ByronKey
AsByronKey
instance Key ByronKey where
newtype VerificationKey ByronKey =
ByronVerificationKey Byron.VerificationKey
deriving stock (VerificationKey ByronKey -> VerificationKey ByronKey -> Bool
(VerificationKey ByronKey -> VerificationKey ByronKey -> Bool)
-> (VerificationKey ByronKey -> VerificationKey ByronKey -> Bool)
-> Eq (VerificationKey ByronKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey ByronKey -> VerificationKey ByronKey -> Bool
$c/= :: VerificationKey ByronKey -> VerificationKey ByronKey -> Bool
== :: VerificationKey ByronKey -> VerificationKey ByronKey -> Bool
$c== :: VerificationKey ByronKey -> VerificationKey ByronKey -> Bool
Eq)
deriving (Int -> VerificationKey ByronKey -> ShowS
[VerificationKey ByronKey] -> ShowS
VerificationKey ByronKey -> String
(Int -> VerificationKey ByronKey -> ShowS)
-> (VerificationKey ByronKey -> String)
-> ([VerificationKey ByronKey] -> ShowS)
-> Show (VerificationKey ByronKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey ByronKey] -> ShowS
$cshowList :: [VerificationKey ByronKey] -> ShowS
show :: VerificationKey ByronKey -> String
$cshow :: VerificationKey ByronKey -> String
showsPrec :: Int -> VerificationKey ByronKey -> ShowS
$cshowsPrec :: Int -> VerificationKey ByronKey -> ShowS
Show, String -> VerificationKey ByronKey
(String -> VerificationKey ByronKey)
-> IsString (VerificationKey ByronKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey ByronKey
$cfromString :: String -> VerificationKey ByronKey
IsString) via UsingRawBytesHex (VerificationKey ByronKey)
deriving newtype (Typeable (VerificationKey ByronKey)
Typeable (VerificationKey ByronKey)
-> (VerificationKey ByronKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey ByronKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey ByronKey] -> Size)
-> ToCBOR (VerificationKey ByronKey)
VerificationKey ByronKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey ByronKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey ByronKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey ByronKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey ByronKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey ByronKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey ByronKey) -> Size
toCBOR :: VerificationKey ByronKey -> Encoding
$ctoCBOR :: VerificationKey ByronKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey ByronKey)
ToCBOR, Typeable (VerificationKey ByronKey)
Decoder s (VerificationKey ByronKey)
Typeable (VerificationKey ByronKey)
-> (forall s. Decoder s (VerificationKey ByronKey))
-> (Proxy (VerificationKey ByronKey) -> Text)
-> FromCBOR (VerificationKey ByronKey)
Proxy (VerificationKey ByronKey) -> Text
forall s. Decoder s (VerificationKey ByronKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey ByronKey) -> Text
$clabel :: Proxy (VerificationKey ByronKey) -> Text
fromCBOR :: Decoder s (VerificationKey ByronKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey ByronKey)
$cp1FromCBOR :: Typeable (VerificationKey ByronKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey ByronKey)
VerificationKey ByronKey -> ByteString
HasTypeProxy (VerificationKey ByronKey)
-> (VerificationKey ByronKey -> ByteString)
-> (AsType (VerificationKey ByronKey)
-> ByteString -> Either DecoderError (VerificationKey ByronKey))
-> SerialiseAsCBOR (VerificationKey ByronKey)
AsType (VerificationKey ByronKey)
-> ByteString -> Either DecoderError (VerificationKey ByronKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey ByronKey)
-> ByteString -> Either DecoderError (VerificationKey ByronKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey ByronKey)
-> ByteString -> Either DecoderError (VerificationKey ByronKey)
serialiseToCBOR :: VerificationKey ByronKey -> ByteString
$cserialiseToCBOR :: VerificationKey ByronKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey ByronKey)
SerialiseAsCBOR
newtype SigningKey ByronKey =
ByronSigningKey Byron.SigningKey
deriving (Int -> SigningKey ByronKey -> ShowS
[SigningKey ByronKey] -> ShowS
SigningKey ByronKey -> String
(Int -> SigningKey ByronKey -> ShowS)
-> (SigningKey ByronKey -> String)
-> ([SigningKey ByronKey] -> ShowS)
-> Show (SigningKey ByronKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey ByronKey] -> ShowS
$cshowList :: [SigningKey ByronKey] -> ShowS
show :: SigningKey ByronKey -> String
$cshow :: SigningKey ByronKey -> String
showsPrec :: Int -> SigningKey ByronKey -> ShowS
$cshowsPrec :: Int -> SigningKey ByronKey -> ShowS
Show, String -> SigningKey ByronKey
(String -> SigningKey ByronKey) -> IsString (SigningKey ByronKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey ByronKey
$cfromString :: String -> SigningKey ByronKey
IsString) via UsingRawBytesHex (SigningKey ByronKey)
deriving newtype (Typeable (SigningKey ByronKey)
Typeable (SigningKey ByronKey)
-> (SigningKey ByronKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey ByronKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey ByronKey] -> Size)
-> ToCBOR (SigningKey ByronKey)
SigningKey ByronKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey ByronKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey ByronKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey ByronKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey ByronKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey ByronKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey ByronKey) -> Size
toCBOR :: SigningKey ByronKey -> Encoding
$ctoCBOR :: SigningKey ByronKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey ByronKey)
ToCBOR, Typeable (SigningKey ByronKey)
Decoder s (SigningKey ByronKey)
Typeable (SigningKey ByronKey)
-> (forall s. Decoder s (SigningKey ByronKey))
-> (Proxy (SigningKey ByronKey) -> Text)
-> FromCBOR (SigningKey ByronKey)
Proxy (SigningKey ByronKey) -> Text
forall s. Decoder s (SigningKey ByronKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey ByronKey) -> Text
$clabel :: Proxy (SigningKey ByronKey) -> Text
fromCBOR :: Decoder s (SigningKey ByronKey)
$cfromCBOR :: forall s. Decoder s (SigningKey ByronKey)
$cp1FromCBOR :: Typeable (SigningKey ByronKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey ByronKey)
SigningKey ByronKey -> ByteString
HasTypeProxy (SigningKey ByronKey)
-> (SigningKey ByronKey -> ByteString)
-> (AsType (SigningKey ByronKey)
-> ByteString -> Either DecoderError (SigningKey ByronKey))
-> SerialiseAsCBOR (SigningKey ByronKey)
AsType (SigningKey ByronKey)
-> ByteString -> Either DecoderError (SigningKey ByronKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey ByronKey)
-> ByteString -> Either DecoderError (SigningKey ByronKey)
$cdeserialiseFromCBOR :: AsType (SigningKey ByronKey)
-> ByteString -> Either DecoderError (SigningKey ByronKey)
serialiseToCBOR :: SigningKey ByronKey -> ByteString
$cserialiseToCBOR :: SigningKey ByronKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey ByronKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType ByronKey -> Crypto.Seed -> SigningKey ByronKey
deterministicSigningKey :: AsType ByronKey -> Seed -> SigningKey ByronKey
deterministicSigningKey AsType ByronKey
AsByronKey Seed
seed =
SigningKey -> SigningKey ByronKey
ByronSigningKey ((VerificationKey, SigningKey) -> SigningKey
forall a b. (a, b) -> b
snd (Seed
-> (forall (m :: * -> *).
MonadRandom m =>
m (VerificationKey, SigningKey))
-> (VerificationKey, SigningKey)
forall a. Seed -> (forall (m :: * -> *). MonadRandom m => m a) -> a
Crypto.runMonadRandomWithSeed Seed
seed forall (m :: * -> *).
MonadRandom m =>
m (VerificationKey, SigningKey)
Byron.keyGen))
deterministicSigningKeySeedSize :: AsType ByronKey -> Word
deterministicSigningKeySeedSize :: AsType ByronKey -> Word
deterministicSigningKeySeedSize AsType ByronKey
AsByronKey = Word
32
getVerificationKey :: SigningKey ByronKey -> VerificationKey ByronKey
getVerificationKey :: SigningKey ByronKey -> VerificationKey ByronKey
getVerificationKey (ByronSigningKey sk) =
VerificationKey -> VerificationKey ByronKey
ByronVerificationKey (SigningKey -> VerificationKey
Byron.toVerification SigningKey
sk)
verificationKeyHash :: VerificationKey ByronKey -> Hash ByronKey
verificationKeyHash :: VerificationKey ByronKey -> Hash ByronKey
verificationKeyHash (ByronVerificationKey vkey) =
KeyHash -> Hash ByronKey
ByronKeyHash (VerificationKey -> KeyHash
Byron.hashKey VerificationKey
vkey)
instance SerialiseAsRawBytes (VerificationKey ByronKey) where
serialiseToRawBytes :: VerificationKey ByronKey -> ByteString
serialiseToRawBytes (ByronVerificationKey (Byron.VerificationKey xvk)) =
XPub -> ByteString
Crypto.HD.unXPub XPub
xvk
deserialiseFromRawBytes :: AsType (VerificationKey ByronKey)
-> ByteString -> Maybe (VerificationKey ByronKey)
deserialiseFromRawBytes (AsVerificationKey AsByronKey) ByteString
bs =
(String -> Maybe (VerificationKey ByronKey))
-> (XPub -> Maybe (VerificationKey ByronKey))
-> Either String XPub
-> Maybe (VerificationKey ByronKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (VerificationKey ByronKey)
-> String -> Maybe (VerificationKey ByronKey)
forall a b. a -> b -> a
const Maybe (VerificationKey ByronKey)
forall a. Maybe a
Nothing) (VerificationKey ByronKey -> Maybe (VerificationKey ByronKey)
forall a. a -> Maybe a
Just (VerificationKey ByronKey -> Maybe (VerificationKey ByronKey))
-> (XPub -> VerificationKey ByronKey)
-> XPub
-> Maybe (VerificationKey ByronKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerificationKey -> VerificationKey ByronKey
ByronVerificationKey (VerificationKey -> VerificationKey ByronKey)
-> (XPub -> VerificationKey) -> XPub -> VerificationKey ByronKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey
Byron.VerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub ByteString
bs)
instance SerialiseAsRawBytes (SigningKey ByronKey) where
serialiseToRawBytes :: SigningKey ByronKey -> ByteString
serialiseToRawBytes (ByronSigningKey (Byron.SigningKey xsk)) =
XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xsk
deserialiseFromRawBytes :: AsType (SigningKey ByronKey)
-> ByteString -> Maybe (SigningKey ByronKey)
deserialiseFromRawBytes (AsSigningKey AsByronKey) ByteString
bs =
(String -> Maybe (SigningKey ByronKey))
-> (XPrv -> Maybe (SigningKey ByronKey))
-> Either String XPrv
-> Maybe (SigningKey ByronKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (SigningKey ByronKey)
-> String -> Maybe (SigningKey ByronKey)
forall a b. a -> b -> a
const Maybe (SigningKey ByronKey)
forall a. Maybe a
Nothing) (SigningKey ByronKey -> Maybe (SigningKey ByronKey)
forall a. a -> Maybe a
Just (SigningKey ByronKey -> Maybe (SigningKey ByronKey))
-> (XPrv -> SigningKey ByronKey)
-> XPrv
-> Maybe (SigningKey ByronKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SigningKey -> SigningKey ByronKey
ByronSigningKey (SigningKey -> SigningKey ByronKey)
-> (XPrv -> SigningKey) -> XPrv -> SigningKey ByronKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey
Byron.SigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv ByteString
bs)
instance SerialiseAsBech32 (VerificationKey ByronKey) where
bech32PrefixFor :: VerificationKey ByronKey -> Text
bech32PrefixFor VerificationKey ByronKey
_ = Text
"addr_xvk"
bech32PrefixesPermitted :: AsType (VerificationKey ByronKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey ByronKey)
_ = [Text
"addr_xvk"]
instance SerialiseAsBech32 (SigningKey ByronKey) where
bech32PrefixFor :: SigningKey ByronKey -> Text
bech32PrefixFor SigningKey ByronKey
_ = Text
"addr_xsk"
bech32PrefixesPermitted :: AsType (SigningKey ByronKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey ByronKey)
_ = [Text
"addr_xsk"]
newtype instance Hash ByronKey = ByronKeyHash Byron.KeyHash
deriving (Hash ByronKey -> Hash ByronKey -> Bool
(Hash ByronKey -> Hash ByronKey -> Bool)
-> (Hash ByronKey -> Hash ByronKey -> Bool) -> Eq (Hash ByronKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash ByronKey -> Hash ByronKey -> Bool
$c/= :: Hash ByronKey -> Hash ByronKey -> Bool
== :: Hash ByronKey -> Hash ByronKey -> Bool
$c== :: Hash ByronKey -> Hash ByronKey -> Bool
Eq, Eq (Hash ByronKey)
Eq (Hash ByronKey)
-> (Hash ByronKey -> Hash ByronKey -> Ordering)
-> (Hash ByronKey -> Hash ByronKey -> Bool)
-> (Hash ByronKey -> Hash ByronKey -> Bool)
-> (Hash ByronKey -> Hash ByronKey -> Bool)
-> (Hash ByronKey -> Hash ByronKey -> Bool)
-> (Hash ByronKey -> Hash ByronKey -> Hash ByronKey)
-> (Hash ByronKey -> Hash ByronKey -> Hash ByronKey)
-> Ord (Hash ByronKey)
Hash ByronKey -> Hash ByronKey -> Bool
Hash ByronKey -> Hash ByronKey -> Ordering
Hash ByronKey -> Hash ByronKey -> Hash ByronKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash ByronKey -> Hash ByronKey -> Hash ByronKey
$cmin :: Hash ByronKey -> Hash ByronKey -> Hash ByronKey
max :: Hash ByronKey -> Hash ByronKey -> Hash ByronKey
$cmax :: Hash ByronKey -> Hash ByronKey -> Hash ByronKey
>= :: Hash ByronKey -> Hash ByronKey -> Bool
$c>= :: Hash ByronKey -> Hash ByronKey -> Bool
> :: Hash ByronKey -> Hash ByronKey -> Bool
$c> :: Hash ByronKey -> Hash ByronKey -> Bool
<= :: Hash ByronKey -> Hash ByronKey -> Bool
$c<= :: Hash ByronKey -> Hash ByronKey -> Bool
< :: Hash ByronKey -> Hash ByronKey -> Bool
$c< :: Hash ByronKey -> Hash ByronKey -> Bool
compare :: Hash ByronKey -> Hash ByronKey -> Ordering
$ccompare :: Hash ByronKey -> Hash ByronKey -> Ordering
$cp1Ord :: Eq (Hash ByronKey)
Ord, Int -> Hash ByronKey -> ShowS
[Hash ByronKey] -> ShowS
Hash ByronKey -> String
(Int -> Hash ByronKey -> ShowS)
-> (Hash ByronKey -> String)
-> ([Hash ByronKey] -> ShowS)
-> Show (Hash ByronKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash ByronKey] -> ShowS
$cshowList :: [Hash ByronKey] -> ShowS
show :: Hash ByronKey -> String
$cshow :: Hash ByronKey -> String
showsPrec :: Int -> Hash ByronKey -> ShowS
$cshowsPrec :: Int -> Hash ByronKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash ByronKey) where
serialiseToRawBytes :: Hash ByronKey -> ByteString
serialiseToRawBytes (ByronKeyHash (Byron.KeyHash vkh)) =
AbstractHash Blake2b_224 VerificationKey -> ByteString
forall algo a. AbstractHash algo a -> ByteString
Byron.abstractHashToBytes AbstractHash Blake2b_224 VerificationKey
vkh
deserialiseFromRawBytes :: AsType (Hash ByronKey) -> ByteString -> Maybe (Hash ByronKey)
deserialiseFromRawBytes (AsHash AsByronKey) ByteString
bs =
KeyHash -> Hash ByronKey
ByronKeyHash (KeyHash -> Hash ByronKey)
-> (AbstractHash Blake2b_224 VerificationKey -> KeyHash)
-> AbstractHash Blake2b_224 VerificationKey
-> Hash ByronKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractHash Blake2b_224 VerificationKey -> KeyHash
Byron.KeyHash (AbstractHash Blake2b_224 VerificationKey -> Hash ByronKey)
-> Maybe (AbstractHash Blake2b_224 VerificationKey)
-> Maybe (Hash ByronKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (AbstractHash Blake2b_224 VerificationKey)
forall algo a.
HashAlgorithm algo =>
ByteString -> Maybe (AbstractHash algo a)
Byron.abstractHashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey ByronKey) where
textEnvelopeType :: AsType (VerificationKey ByronKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey ByronKey)
_ = TextEnvelopeType
"PaymentVerificationKeyByron_ed25519_bip32"
instance HasTextEnvelope (SigningKey ByronKey) where
textEnvelopeType :: AsType (SigningKey ByronKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey ByronKey)
_ = TextEnvelopeType
"PaymentSigningKeyByron_ed25519_bip32"
instance CastVerificationKeyRole ByronKey PaymentExtendedKey where
castVerificationKey :: VerificationKey ByronKey -> VerificationKey PaymentExtendedKey
castVerificationKey (ByronVerificationKey vk) =
XPub -> VerificationKey PaymentExtendedKey
PaymentExtendedVerificationKey
(VerificationKey -> XPub
Byron.unVerificationKey VerificationKey
vk)
instance CastVerificationKeyRole ByronKey PaymentKey where
castVerificationKey :: VerificationKey ByronKey -> VerificationKey PaymentKey
castVerificationKey =
(VerificationKey PaymentExtendedKey -> VerificationKey PaymentKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey PaymentExtendedKey
-> VerificationKey PaymentKey)
(VerificationKey PaymentExtendedKey -> VerificationKey PaymentKey)
-> (VerificationKey ByronKey -> VerificationKey PaymentExtendedKey)
-> VerificationKey ByronKey
-> VerificationKey PaymentKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (VerificationKey ByronKey -> VerificationKey PaymentExtendedKey
forall keyroleA keyroleB.
CastVerificationKeyRole keyroleA keyroleB =>
VerificationKey keyroleA -> VerificationKey keyroleB
castVerificationKey :: VerificationKey ByronKey
-> VerificationKey PaymentExtendedKey)
data PaymentKey
instance HasTypeProxy PaymentKey where
data AsType PaymentKey = AsPaymentKey
proxyToAsType :: Proxy PaymentKey -> AsType PaymentKey
proxyToAsType Proxy PaymentKey
_ = AsType PaymentKey
AsPaymentKey
instance Key PaymentKey where
newtype VerificationKey PaymentKey =
PaymentVerificationKey (Shelley.VKey Shelley.Payment StandardCrypto)
deriving stock (VerificationKey PaymentKey -> VerificationKey PaymentKey -> Bool
(VerificationKey PaymentKey -> VerificationKey PaymentKey -> Bool)
-> (VerificationKey PaymentKey
-> VerificationKey PaymentKey -> Bool)
-> Eq (VerificationKey PaymentKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey PaymentKey -> VerificationKey PaymentKey -> Bool
$c/= :: VerificationKey PaymentKey -> VerificationKey PaymentKey -> Bool
== :: VerificationKey PaymentKey -> VerificationKey PaymentKey -> Bool
$c== :: VerificationKey PaymentKey -> VerificationKey PaymentKey -> Bool
Eq)
deriving (Int -> VerificationKey PaymentKey -> ShowS
[VerificationKey PaymentKey] -> ShowS
VerificationKey PaymentKey -> String
(Int -> VerificationKey PaymentKey -> ShowS)
-> (VerificationKey PaymentKey -> String)
-> ([VerificationKey PaymentKey] -> ShowS)
-> Show (VerificationKey PaymentKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey PaymentKey] -> ShowS
$cshowList :: [VerificationKey PaymentKey] -> ShowS
show :: VerificationKey PaymentKey -> String
$cshow :: VerificationKey PaymentKey -> String
showsPrec :: Int -> VerificationKey PaymentKey -> ShowS
$cshowsPrec :: Int -> VerificationKey PaymentKey -> ShowS
Show, String -> VerificationKey PaymentKey
(String -> VerificationKey PaymentKey)
-> IsString (VerificationKey PaymentKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey PaymentKey
$cfromString :: String -> VerificationKey PaymentKey
IsString) via UsingRawBytesHex (VerificationKey PaymentKey)
deriving newtype (Typeable (VerificationKey PaymentKey)
Typeable (VerificationKey PaymentKey)
-> (VerificationKey PaymentKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey PaymentKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey PaymentKey] -> Size)
-> ToCBOR (VerificationKey PaymentKey)
VerificationKey PaymentKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey PaymentKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey PaymentKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey PaymentKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey PaymentKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey PaymentKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey PaymentKey) -> Size
toCBOR :: VerificationKey PaymentKey -> Encoding
$ctoCBOR :: VerificationKey PaymentKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey PaymentKey)
ToCBOR, Typeable (VerificationKey PaymentKey)
Decoder s (VerificationKey PaymentKey)
Typeable (VerificationKey PaymentKey)
-> (forall s. Decoder s (VerificationKey PaymentKey))
-> (Proxy (VerificationKey PaymentKey) -> Text)
-> FromCBOR (VerificationKey PaymentKey)
Proxy (VerificationKey PaymentKey) -> Text
forall s. Decoder s (VerificationKey PaymentKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey PaymentKey) -> Text
$clabel :: Proxy (VerificationKey PaymentKey) -> Text
fromCBOR :: Decoder s (VerificationKey PaymentKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey PaymentKey)
$cp1FromCBOR :: Typeable (VerificationKey PaymentKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey PaymentKey)
VerificationKey PaymentKey -> ByteString
HasTypeProxy (VerificationKey PaymentKey)
-> (VerificationKey PaymentKey -> ByteString)
-> (AsType (VerificationKey PaymentKey)
-> ByteString -> Either DecoderError (VerificationKey PaymentKey))
-> SerialiseAsCBOR (VerificationKey PaymentKey)
AsType (VerificationKey PaymentKey)
-> ByteString -> Either DecoderError (VerificationKey PaymentKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey PaymentKey)
-> ByteString -> Either DecoderError (VerificationKey PaymentKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey PaymentKey)
-> ByteString -> Either DecoderError (VerificationKey PaymentKey)
serialiseToCBOR :: VerificationKey PaymentKey -> ByteString
$cserialiseToCBOR :: VerificationKey PaymentKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey PaymentKey)
SerialiseAsCBOR
newtype SigningKey PaymentKey =
PaymentSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
deriving (Int -> SigningKey PaymentKey -> ShowS
[SigningKey PaymentKey] -> ShowS
SigningKey PaymentKey -> String
(Int -> SigningKey PaymentKey -> ShowS)
-> (SigningKey PaymentKey -> String)
-> ([SigningKey PaymentKey] -> ShowS)
-> Show (SigningKey PaymentKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey PaymentKey] -> ShowS
$cshowList :: [SigningKey PaymentKey] -> ShowS
show :: SigningKey PaymentKey -> String
$cshow :: SigningKey PaymentKey -> String
showsPrec :: Int -> SigningKey PaymentKey -> ShowS
$cshowsPrec :: Int -> SigningKey PaymentKey -> ShowS
Show, String -> SigningKey PaymentKey
(String -> SigningKey PaymentKey)
-> IsString (SigningKey PaymentKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey PaymentKey
$cfromString :: String -> SigningKey PaymentKey
IsString) via UsingRawBytesHex (SigningKey PaymentKey)
deriving newtype (Typeable (SigningKey PaymentKey)
Typeable (SigningKey PaymentKey)
-> (SigningKey PaymentKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey PaymentKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey PaymentKey] -> Size)
-> ToCBOR (SigningKey PaymentKey)
SigningKey PaymentKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey PaymentKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey PaymentKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey PaymentKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey PaymentKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey PaymentKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey PaymentKey) -> Size
toCBOR :: SigningKey PaymentKey -> Encoding
$ctoCBOR :: SigningKey PaymentKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey PaymentKey)
ToCBOR, Typeable (SigningKey PaymentKey)
Decoder s (SigningKey PaymentKey)
Typeable (SigningKey PaymentKey)
-> (forall s. Decoder s (SigningKey PaymentKey))
-> (Proxy (SigningKey PaymentKey) -> Text)
-> FromCBOR (SigningKey PaymentKey)
Proxy (SigningKey PaymentKey) -> Text
forall s. Decoder s (SigningKey PaymentKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey PaymentKey) -> Text
$clabel :: Proxy (SigningKey PaymentKey) -> Text
fromCBOR :: Decoder s (SigningKey PaymentKey)
$cfromCBOR :: forall s. Decoder s (SigningKey PaymentKey)
$cp1FromCBOR :: Typeable (SigningKey PaymentKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey PaymentKey)
SigningKey PaymentKey -> ByteString
HasTypeProxy (SigningKey PaymentKey)
-> (SigningKey PaymentKey -> ByteString)
-> (AsType (SigningKey PaymentKey)
-> ByteString -> Either DecoderError (SigningKey PaymentKey))
-> SerialiseAsCBOR (SigningKey PaymentKey)
AsType (SigningKey PaymentKey)
-> ByteString -> Either DecoderError (SigningKey PaymentKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey PaymentKey)
-> ByteString -> Either DecoderError (SigningKey PaymentKey)
$cdeserialiseFromCBOR :: AsType (SigningKey PaymentKey)
-> ByteString -> Either DecoderError (SigningKey PaymentKey)
serialiseToCBOR :: SigningKey PaymentKey -> ByteString
$cserialiseToCBOR :: SigningKey PaymentKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey PaymentKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType PaymentKey -> Crypto.Seed -> SigningKey PaymentKey
deterministicSigningKey :: AsType PaymentKey -> Seed -> SigningKey PaymentKey
deterministicSigningKey AsType PaymentKey
AsPaymentKey Seed
seed =
SignKeyDSIGN StandardCrypto -> SigningKey PaymentKey
PaymentSigningKey (Seed -> SignKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
Crypto.genKeyDSIGN Seed
seed)
deterministicSigningKeySeedSize :: AsType PaymentKey -> Word
deterministicSigningKeySeedSize :: AsType PaymentKey -> Word
deterministicSigningKeySeedSize AsType PaymentKey
AsPaymentKey =
Proxy Ed25519DSIGN -> Word
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
Crypto.seedSizeDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey PaymentKey -> VerificationKey PaymentKey
getVerificationKey :: SigningKey PaymentKey -> VerificationKey PaymentKey
getVerificationKey (PaymentSigningKey sk) =
VKey 'Payment StandardCrypto -> VerificationKey PaymentKey
PaymentVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto) -> VKey 'Payment StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> VerKeyDSIGN v
Crypto.deriveVerKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk))
verificationKeyHash :: VerificationKey PaymentKey -> Hash PaymentKey
verificationKeyHash :: VerificationKey PaymentKey -> Hash PaymentKey
verificationKeyHash (PaymentVerificationKey vkey) =
KeyHash 'Payment StandardCrypto -> Hash PaymentKey
PaymentKeyHash (VKey 'Payment StandardCrypto -> KeyHash 'Payment StandardCrypto
forall crypto (kd :: KeyRole).
Crypto crypto =>
VKey kd crypto -> KeyHash kd crypto
Shelley.hashKey VKey 'Payment StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey PaymentKey) where
serialiseToRawBytes :: VerificationKey PaymentKey -> ByteString
serialiseToRawBytes (PaymentVerificationKey (Shelley.VKey vk)) =
VerKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> ByteString
Crypto.rawSerialiseVerKeyDSIGN VerKeyDSIGN Ed25519DSIGN
VerKeyDSIGN (DSIGN StandardCrypto)
vk
deserialiseFromRawBytes :: AsType (VerificationKey PaymentKey)
-> ByteString -> Maybe (VerificationKey PaymentKey)
deserialiseFromRawBytes (AsVerificationKey AsPaymentKey) ByteString
bs =
VKey 'Payment StandardCrypto -> VerificationKey PaymentKey
PaymentVerificationKey (VKey 'Payment StandardCrypto -> VerificationKey PaymentKey)
-> (VerKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto)
-> VerKeyDSIGN Ed25519DSIGN
-> VerificationKey PaymentKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (VerKeyDSIGN Ed25519DSIGN -> VerificationKey PaymentKey)
-> Maybe (VerKeyDSIGN Ed25519DSIGN)
-> Maybe (VerificationKey PaymentKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN ByteString
bs
instance SerialiseAsRawBytes (SigningKey PaymentKey) where
serialiseToRawBytes :: SigningKey PaymentKey -> ByteString
serialiseToRawBytes (PaymentSigningKey sk) =
SignKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> ByteString
Crypto.rawSerialiseSignKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey PaymentKey)
-> ByteString -> Maybe (SigningKey PaymentKey)
deserialiseFromRawBytes (AsSigningKey AsPaymentKey) ByteString
bs =
SignKeyDSIGN Ed25519DSIGN -> SigningKey PaymentKey
SignKeyDSIGN StandardCrypto -> SigningKey PaymentKey
PaymentSigningKey (SignKeyDSIGN Ed25519DSIGN -> SigningKey PaymentKey)
-> Maybe (SignKeyDSIGN Ed25519DSIGN)
-> Maybe (SigningKey PaymentKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SignKeyDSIGN v)
Crypto.rawDeserialiseSignKeyDSIGN ByteString
bs
instance SerialiseAsBech32 (VerificationKey PaymentKey) where
bech32PrefixFor :: VerificationKey PaymentKey -> Text
bech32PrefixFor VerificationKey PaymentKey
_ = Text
"addr_vk"
bech32PrefixesPermitted :: AsType (VerificationKey PaymentKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey PaymentKey)
_ = [Text
"addr_vk"]
instance SerialiseAsBech32 (SigningKey PaymentKey) where
bech32PrefixFor :: SigningKey PaymentKey -> Text
bech32PrefixFor SigningKey PaymentKey
_ = Text
"addr_sk"
bech32PrefixesPermitted :: AsType (SigningKey PaymentKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey PaymentKey)
_ = [Text
"addr_sk"]
newtype instance Hash PaymentKey =
PaymentKeyHash (Shelley.KeyHash Shelley.Payment StandardCrypto)
deriving (Hash PaymentKey -> Hash PaymentKey -> Bool
(Hash PaymentKey -> Hash PaymentKey -> Bool)
-> (Hash PaymentKey -> Hash PaymentKey -> Bool)
-> Eq (Hash PaymentKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash PaymentKey -> Hash PaymentKey -> Bool
$c/= :: Hash PaymentKey -> Hash PaymentKey -> Bool
== :: Hash PaymentKey -> Hash PaymentKey -> Bool
$c== :: Hash PaymentKey -> Hash PaymentKey -> Bool
Eq, Eq (Hash PaymentKey)
Eq (Hash PaymentKey)
-> (Hash PaymentKey -> Hash PaymentKey -> Ordering)
-> (Hash PaymentKey -> Hash PaymentKey -> Bool)
-> (Hash PaymentKey -> Hash PaymentKey -> Bool)
-> (Hash PaymentKey -> Hash PaymentKey -> Bool)
-> (Hash PaymentKey -> Hash PaymentKey -> Bool)
-> (Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey)
-> (Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey)
-> Ord (Hash PaymentKey)
Hash PaymentKey -> Hash PaymentKey -> Bool
Hash PaymentKey -> Hash PaymentKey -> Ordering
Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey
$cmin :: Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey
max :: Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey
$cmax :: Hash PaymentKey -> Hash PaymentKey -> Hash PaymentKey
>= :: Hash PaymentKey -> Hash PaymentKey -> Bool
$c>= :: Hash PaymentKey -> Hash PaymentKey -> Bool
> :: Hash PaymentKey -> Hash PaymentKey -> Bool
$c> :: Hash PaymentKey -> Hash PaymentKey -> Bool
<= :: Hash PaymentKey -> Hash PaymentKey -> Bool
$c<= :: Hash PaymentKey -> Hash PaymentKey -> Bool
< :: Hash PaymentKey -> Hash PaymentKey -> Bool
$c< :: Hash PaymentKey -> Hash PaymentKey -> Bool
compare :: Hash PaymentKey -> Hash PaymentKey -> Ordering
$ccompare :: Hash PaymentKey -> Hash PaymentKey -> Ordering
$cp1Ord :: Eq (Hash PaymentKey)
Ord, Int -> Hash PaymentKey -> ShowS
[Hash PaymentKey] -> ShowS
Hash PaymentKey -> String
(Int -> Hash PaymentKey -> ShowS)
-> (Hash PaymentKey -> String)
-> ([Hash PaymentKey] -> ShowS)
-> Show (Hash PaymentKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash PaymentKey] -> ShowS
$cshowList :: [Hash PaymentKey] -> ShowS
show :: Hash PaymentKey -> String
$cshow :: Hash PaymentKey -> String
showsPrec :: Int -> Hash PaymentKey -> ShowS
$cshowsPrec :: Int -> Hash PaymentKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash PaymentKey) where
serialiseToRawBytes :: Hash PaymentKey -> ByteString
serialiseToRawBytes (PaymentKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash PaymentKey) -> ByteString -> Maybe (Hash PaymentKey)
deserialiseFromRawBytes (AsHash AsPaymentKey) ByteString
bs =
KeyHash 'Payment StandardCrypto -> Hash PaymentKey
PaymentKeyHash (KeyHash 'Payment StandardCrypto -> Hash PaymentKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash PaymentKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> Hash PaymentKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash PaymentKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey PaymentKey) where
textEnvelopeType :: AsType (VerificationKey PaymentKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey PaymentKey)
_ = TextEnvelopeType
"PaymentVerificationKeyShelley_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey PaymentKey) where
textEnvelopeType :: AsType (SigningKey PaymentKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey PaymentKey)
_ = TextEnvelopeType
"PaymentSigningKeyShelley_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
data PaymentExtendedKey
instance HasTypeProxy PaymentExtendedKey where
data AsType PaymentExtendedKey = AsPaymentExtendedKey
proxyToAsType :: Proxy PaymentExtendedKey -> AsType PaymentExtendedKey
proxyToAsType Proxy PaymentExtendedKey
_ = AsType PaymentExtendedKey
AsPaymentExtendedKey
instance Key PaymentExtendedKey where
newtype VerificationKey PaymentExtendedKey =
PaymentExtendedVerificationKey Crypto.HD.XPub
deriving stock (VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool
(VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool)
-> (VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool)
-> Eq (VerificationKey PaymentExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool
$c/= :: VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool
== :: VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool
$c== :: VerificationKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey -> Bool
Eq)
deriving anyclass HasTypeProxy (VerificationKey PaymentExtendedKey)
VerificationKey PaymentExtendedKey -> ByteString
HasTypeProxy (VerificationKey PaymentExtendedKey)
-> (VerificationKey PaymentExtendedKey -> ByteString)
-> (AsType (VerificationKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey PaymentExtendedKey))
-> SerialiseAsCBOR (VerificationKey PaymentExtendedKey)
AsType (VerificationKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey PaymentExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey PaymentExtendedKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey PaymentExtendedKey)
serialiseToCBOR :: VerificationKey PaymentExtendedKey -> ByteString
$cserialiseToCBOR :: VerificationKey PaymentExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey PaymentExtendedKey)
SerialiseAsCBOR
deriving (Int -> VerificationKey PaymentExtendedKey -> ShowS
[VerificationKey PaymentExtendedKey] -> ShowS
VerificationKey PaymentExtendedKey -> String
(Int -> VerificationKey PaymentExtendedKey -> ShowS)
-> (VerificationKey PaymentExtendedKey -> String)
-> ([VerificationKey PaymentExtendedKey] -> ShowS)
-> Show (VerificationKey PaymentExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey PaymentExtendedKey] -> ShowS
$cshowList :: [VerificationKey PaymentExtendedKey] -> ShowS
show :: VerificationKey PaymentExtendedKey -> String
$cshow :: VerificationKey PaymentExtendedKey -> String
showsPrec :: Int -> VerificationKey PaymentExtendedKey -> ShowS
$cshowsPrec :: Int -> VerificationKey PaymentExtendedKey -> ShowS
Show, String -> VerificationKey PaymentExtendedKey
(String -> VerificationKey PaymentExtendedKey)
-> IsString (VerificationKey PaymentExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey PaymentExtendedKey
$cfromString :: String -> VerificationKey PaymentExtendedKey
IsString) via UsingRawBytesHex (VerificationKey PaymentExtendedKey)
newtype SigningKey PaymentExtendedKey =
PaymentExtendedSigningKey Crypto.HD.XPrv
deriving anyclass HasTypeProxy (SigningKey PaymentExtendedKey)
SigningKey PaymentExtendedKey -> ByteString
HasTypeProxy (SigningKey PaymentExtendedKey)
-> (SigningKey PaymentExtendedKey -> ByteString)
-> (AsType (SigningKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey PaymentExtendedKey))
-> SerialiseAsCBOR (SigningKey PaymentExtendedKey)
AsType (SigningKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey PaymentExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey PaymentExtendedKey)
$cdeserialiseFromCBOR :: AsType (SigningKey PaymentExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey PaymentExtendedKey)
serialiseToCBOR :: SigningKey PaymentExtendedKey -> ByteString
$cserialiseToCBOR :: SigningKey PaymentExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey PaymentExtendedKey)
SerialiseAsCBOR
deriving (Int -> SigningKey PaymentExtendedKey -> ShowS
[SigningKey PaymentExtendedKey] -> ShowS
SigningKey PaymentExtendedKey -> String
(Int -> SigningKey PaymentExtendedKey -> ShowS)
-> (SigningKey PaymentExtendedKey -> String)
-> ([SigningKey PaymentExtendedKey] -> ShowS)
-> Show (SigningKey PaymentExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey PaymentExtendedKey] -> ShowS
$cshowList :: [SigningKey PaymentExtendedKey] -> ShowS
show :: SigningKey PaymentExtendedKey -> String
$cshow :: SigningKey PaymentExtendedKey -> String
showsPrec :: Int -> SigningKey PaymentExtendedKey -> ShowS
$cshowsPrec :: Int -> SigningKey PaymentExtendedKey -> ShowS
Show, String -> SigningKey PaymentExtendedKey
(String -> SigningKey PaymentExtendedKey)
-> IsString (SigningKey PaymentExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey PaymentExtendedKey
$cfromString :: String -> SigningKey PaymentExtendedKey
IsString) via UsingRawBytesHex (SigningKey PaymentExtendedKey)
deterministicSigningKey :: AsType PaymentExtendedKey
-> Crypto.Seed
-> SigningKey PaymentExtendedKey
deterministicSigningKey :: AsType PaymentExtendedKey -> Seed -> SigningKey PaymentExtendedKey
deterministicSigningKey AsType PaymentExtendedKey
AsPaymentExtendedKey Seed
seed =
XPrv -> SigningKey PaymentExtendedKey
PaymentExtendedSigningKey
(ByteString -> ByteString -> XPrv
forall passPhrase seed.
(ByteArrayAccess passPhrase, ByteArrayAccess seed) =>
seed -> passPhrase -> XPrv
Crypto.HD.generate ByteString
seedbs ByteString
BS.empty)
where
(ByteString
seedbs, Seed
_) = Word -> Seed -> (ByteString, Seed)
Crypto.getBytesFromSeedT Word
32 Seed
seed
deterministicSigningKeySeedSize :: AsType PaymentExtendedKey -> Word
deterministicSigningKeySeedSize :: AsType PaymentExtendedKey -> Word
deterministicSigningKeySeedSize AsType PaymentExtendedKey
AsPaymentExtendedKey = Word
32
getVerificationKey :: SigningKey PaymentExtendedKey
-> VerificationKey PaymentExtendedKey
getVerificationKey :: SigningKey PaymentExtendedKey -> VerificationKey PaymentExtendedKey
getVerificationKey (PaymentExtendedSigningKey sk) =
XPub -> VerificationKey PaymentExtendedKey
PaymentExtendedVerificationKey (HasCallStack => XPrv -> XPub
XPrv -> XPub
Crypto.HD.toXPub XPrv
sk)
verificationKeyHash :: VerificationKey PaymentExtendedKey
-> Hash PaymentExtendedKey
verificationKeyHash :: VerificationKey PaymentExtendedKey -> Hash PaymentExtendedKey
verificationKeyHash (PaymentExtendedVerificationKey vk) =
KeyHash 'Payment StandardCrypto -> Hash PaymentExtendedKey
PaymentExtendedKeyHash
(KeyHash 'Payment StandardCrypto -> Hash PaymentExtendedKey)
-> (Hash Blake2b_224 XPub -> KeyHash 'Payment StandardCrypto)
-> Hash Blake2b_224 XPub
-> Hash PaymentExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash
(Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto)
-> (Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Hash Blake2b_224 XPub
-> KeyHash 'Payment StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_224 XPub -> Hash PaymentExtendedKey)
-> Hash Blake2b_224 XPub -> Hash PaymentExtendedKey
forall a b. (a -> b) -> a -> b
$ (XPub -> ByteString) -> XPub -> Hash Blake2b_224 XPub
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith XPub -> ByteString
Crypto.HD.xpubPublicKey XPub
vk
instance ToCBOR (VerificationKey PaymentExtendedKey) where
toCBOR :: VerificationKey PaymentExtendedKey -> Encoding
toCBOR (PaymentExtendedVerificationKey xpub) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPub -> ByteString
Crypto.HD.unXPub XPub
xpub)
instance FromCBOR (VerificationKey PaymentExtendedKey) where
fromCBOR :: Decoder s (VerificationKey PaymentExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (VerificationKey PaymentExtendedKey))
-> (XPub -> Decoder s (VerificationKey PaymentExtendedKey))
-> Either String XPub
-> Decoder s (VerificationKey PaymentExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (VerificationKey PaymentExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (VerificationKey PaymentExtendedKey
-> Decoder s (VerificationKey PaymentExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (VerificationKey PaymentExtendedKey
-> Decoder s (VerificationKey PaymentExtendedKey))
-> (XPub -> VerificationKey PaymentExtendedKey)
-> XPub
-> Decoder s (VerificationKey PaymentExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey PaymentExtendedKey
PaymentExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub (ByteString
bs :: ByteString))
instance ToCBOR (SigningKey PaymentExtendedKey) where
toCBOR :: SigningKey PaymentExtendedKey -> Encoding
toCBOR (PaymentExtendedSigningKey xprv) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv)
instance FromCBOR (SigningKey PaymentExtendedKey) where
fromCBOR :: Decoder s (SigningKey PaymentExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (SigningKey PaymentExtendedKey))
-> (XPrv -> Decoder s (SigningKey PaymentExtendedKey))
-> Either String XPrv
-> Decoder s (SigningKey PaymentExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (SigningKey PaymentExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (SigningKey PaymentExtendedKey
-> Decoder s (SigningKey PaymentExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (SigningKey PaymentExtendedKey
-> Decoder s (SigningKey PaymentExtendedKey))
-> (XPrv -> SigningKey PaymentExtendedKey)
-> XPrv
-> Decoder s (SigningKey PaymentExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey PaymentExtendedKey
PaymentExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv (ByteString
bs :: ByteString))
instance SerialiseAsRawBytes (VerificationKey PaymentExtendedKey) where
serialiseToRawBytes :: VerificationKey PaymentExtendedKey -> ByteString
serialiseToRawBytes (PaymentExtendedVerificationKey xpub) =
XPub -> ByteString
Crypto.HD.unXPub XPub
xpub
deserialiseFromRawBytes :: AsType (VerificationKey PaymentExtendedKey)
-> ByteString -> Maybe (VerificationKey PaymentExtendedKey)
deserialiseFromRawBytes (AsVerificationKey AsPaymentExtendedKey) ByteString
bs =
(String -> Maybe (VerificationKey PaymentExtendedKey))
-> (XPub -> Maybe (VerificationKey PaymentExtendedKey))
-> Either String XPub
-> Maybe (VerificationKey PaymentExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (VerificationKey PaymentExtendedKey)
-> String -> Maybe (VerificationKey PaymentExtendedKey)
forall a b. a -> b -> a
const Maybe (VerificationKey PaymentExtendedKey)
forall a. Maybe a
Nothing) (VerificationKey PaymentExtendedKey
-> Maybe (VerificationKey PaymentExtendedKey)
forall a. a -> Maybe a
Just (VerificationKey PaymentExtendedKey
-> Maybe (VerificationKey PaymentExtendedKey))
-> (XPub -> VerificationKey PaymentExtendedKey)
-> XPub
-> Maybe (VerificationKey PaymentExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey PaymentExtendedKey
PaymentExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub ByteString
bs)
instance SerialiseAsRawBytes (SigningKey PaymentExtendedKey) where
serialiseToRawBytes :: SigningKey PaymentExtendedKey -> ByteString
serialiseToRawBytes (PaymentExtendedSigningKey xprv) =
XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv
deserialiseFromRawBytes :: AsType (SigningKey PaymentExtendedKey)
-> ByteString -> Maybe (SigningKey PaymentExtendedKey)
deserialiseFromRawBytes (AsSigningKey AsPaymentExtendedKey) ByteString
bs =
(String -> Maybe (SigningKey PaymentExtendedKey))
-> (XPrv -> Maybe (SigningKey PaymentExtendedKey))
-> Either String XPrv
-> Maybe (SigningKey PaymentExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (SigningKey PaymentExtendedKey)
-> String -> Maybe (SigningKey PaymentExtendedKey)
forall a b. a -> b -> a
const Maybe (SigningKey PaymentExtendedKey)
forall a. Maybe a
Nothing) (SigningKey PaymentExtendedKey
-> Maybe (SigningKey PaymentExtendedKey)
forall a. a -> Maybe a
Just (SigningKey PaymentExtendedKey
-> Maybe (SigningKey PaymentExtendedKey))
-> (XPrv -> SigningKey PaymentExtendedKey)
-> XPrv
-> Maybe (SigningKey PaymentExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey PaymentExtendedKey
PaymentExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv ByteString
bs)
instance SerialiseAsBech32 (VerificationKey PaymentExtendedKey) where
bech32PrefixFor :: VerificationKey PaymentExtendedKey -> Text
bech32PrefixFor VerificationKey PaymentExtendedKey
_ = Text
"addr_xvk"
bech32PrefixesPermitted :: AsType (VerificationKey PaymentExtendedKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey PaymentExtendedKey)
_ = [Text
"addr_xvk"]
instance SerialiseAsBech32 (SigningKey PaymentExtendedKey) where
bech32PrefixFor :: SigningKey PaymentExtendedKey -> Text
bech32PrefixFor SigningKey PaymentExtendedKey
_ = Text
"addr_xsk"
bech32PrefixesPermitted :: AsType (SigningKey PaymentExtendedKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey PaymentExtendedKey)
_ = [Text
"addr_xsk"]
newtype instance Hash PaymentExtendedKey =
PaymentExtendedKeyHash (Shelley.KeyHash Shelley.Payment StandardCrypto)
deriving (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
(Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool)
-> (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool)
-> Eq (Hash PaymentExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
$c/= :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
== :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
$c== :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
Eq, Eq (Hash PaymentExtendedKey)
Eq (Hash PaymentExtendedKey)
-> (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Ordering)
-> (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool)
-> (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool)
-> (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool)
-> (Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool)
-> (Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey)
-> (Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey)
-> Ord (Hash PaymentExtendedKey)
Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Ordering
Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey
$cmin :: Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey
max :: Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey
$cmax :: Hash PaymentExtendedKey
-> Hash PaymentExtendedKey -> Hash PaymentExtendedKey
>= :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
$c>= :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
> :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
$c> :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
<= :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
$c<= :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
< :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
$c< :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Bool
compare :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Ordering
$ccompare :: Hash PaymentExtendedKey -> Hash PaymentExtendedKey -> Ordering
$cp1Ord :: Eq (Hash PaymentExtendedKey)
Ord, Int -> Hash PaymentExtendedKey -> ShowS
[Hash PaymentExtendedKey] -> ShowS
Hash PaymentExtendedKey -> String
(Int -> Hash PaymentExtendedKey -> ShowS)
-> (Hash PaymentExtendedKey -> String)
-> ([Hash PaymentExtendedKey] -> ShowS)
-> Show (Hash PaymentExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash PaymentExtendedKey] -> ShowS
$cshowList :: [Hash PaymentExtendedKey] -> ShowS
show :: Hash PaymentExtendedKey -> String
$cshow :: Hash PaymentExtendedKey -> String
showsPrec :: Int -> Hash PaymentExtendedKey -> ShowS
$cshowsPrec :: Int -> Hash PaymentExtendedKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash PaymentExtendedKey) where
serialiseToRawBytes :: Hash PaymentExtendedKey -> ByteString
serialiseToRawBytes (PaymentExtendedKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash PaymentExtendedKey)
-> ByteString -> Maybe (Hash PaymentExtendedKey)
deserialiseFromRawBytes (AsHash AsPaymentExtendedKey) ByteString
bs =
KeyHash 'Payment StandardCrypto -> Hash PaymentExtendedKey
PaymentExtendedKeyHash (KeyHash 'Payment StandardCrypto -> Hash PaymentExtendedKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash PaymentExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash PaymentExtendedKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash PaymentExtendedKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey PaymentExtendedKey) where
textEnvelopeType :: AsType (VerificationKey PaymentExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey PaymentExtendedKey)
_ = TextEnvelopeType
"PaymentExtendedVerificationKeyShelley_ed25519_bip32"
instance HasTextEnvelope (SigningKey PaymentExtendedKey) where
textEnvelopeType :: AsType (SigningKey PaymentExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey PaymentExtendedKey)
_ = TextEnvelopeType
"PaymentExtendedSigningKeyShelley_ed25519_bip32"
instance CastVerificationKeyRole PaymentExtendedKey PaymentKey where
castVerificationKey :: VerificationKey PaymentExtendedKey -> VerificationKey PaymentKey
castVerificationKey (PaymentExtendedVerificationKey vk) =
VKey 'Payment StandardCrypto -> VerificationKey PaymentKey
PaymentVerificationKey
(VKey 'Payment StandardCrypto -> VerificationKey PaymentKey)
-> (XPub -> VKey 'Payment StandardCrypto)
-> XPub
-> VerificationKey PaymentKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey
(VerKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto)
-> (XPub -> VerKeyDSIGN Ed25519DSIGN)
-> XPub
-> VKey 'Payment StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN
-> Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN
forall a. a -> Maybe a -> a
fromMaybe VerKeyDSIGN Ed25519DSIGN
forall a. a
impossible
(Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN)
-> (XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> XPub
-> VerKeyDSIGN Ed25519DSIGN
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN
(ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> (XPub -> ByteString) -> XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> ByteString
Crypto.HD.xpubPublicKey
(XPub -> VerificationKey PaymentKey)
-> XPub -> VerificationKey PaymentKey
forall a b. (a -> b) -> a -> b
$ XPub
vk
where
impossible :: a
impossible =
String -> a
forall a. HasCallStack => String -> a
error String
"castVerificationKey: byron and shelley key sizes do not match!"
data StakeKey
instance HasTypeProxy StakeKey where
data AsType StakeKey = AsStakeKey
proxyToAsType :: Proxy StakeKey -> AsType StakeKey
proxyToAsType Proxy StakeKey
_ = AsType StakeKey
AsStakeKey
instance Key StakeKey where
newtype VerificationKey StakeKey =
StakeVerificationKey (Shelley.VKey Shelley.Staking StandardCrypto)
deriving stock (VerificationKey StakeKey -> VerificationKey StakeKey -> Bool
(VerificationKey StakeKey -> VerificationKey StakeKey -> Bool)
-> (VerificationKey StakeKey -> VerificationKey StakeKey -> Bool)
-> Eq (VerificationKey StakeKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey StakeKey -> VerificationKey StakeKey -> Bool
$c/= :: VerificationKey StakeKey -> VerificationKey StakeKey -> Bool
== :: VerificationKey StakeKey -> VerificationKey StakeKey -> Bool
$c== :: VerificationKey StakeKey -> VerificationKey StakeKey -> Bool
Eq)
deriving newtype (Typeable (VerificationKey StakeKey)
Typeable (VerificationKey StakeKey)
-> (VerificationKey StakeKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakeKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakeKey] -> Size)
-> ToCBOR (VerificationKey StakeKey)
VerificationKey StakeKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakeKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakeKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakeKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakeKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakeKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakeKey) -> Size
toCBOR :: VerificationKey StakeKey -> Encoding
$ctoCBOR :: VerificationKey StakeKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey StakeKey)
ToCBOR, Typeable (VerificationKey StakeKey)
Decoder s (VerificationKey StakeKey)
Typeable (VerificationKey StakeKey)
-> (forall s. Decoder s (VerificationKey StakeKey))
-> (Proxy (VerificationKey StakeKey) -> Text)
-> FromCBOR (VerificationKey StakeKey)
Proxy (VerificationKey StakeKey) -> Text
forall s. Decoder s (VerificationKey StakeKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey StakeKey) -> Text
$clabel :: Proxy (VerificationKey StakeKey) -> Text
fromCBOR :: Decoder s (VerificationKey StakeKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey StakeKey)
$cp1FromCBOR :: Typeable (VerificationKey StakeKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey StakeKey)
VerificationKey StakeKey -> ByteString
HasTypeProxy (VerificationKey StakeKey)
-> (VerificationKey StakeKey -> ByteString)
-> (AsType (VerificationKey StakeKey)
-> ByteString -> Either DecoderError (VerificationKey StakeKey))
-> SerialiseAsCBOR (VerificationKey StakeKey)
AsType (VerificationKey StakeKey)
-> ByteString -> Either DecoderError (VerificationKey StakeKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey StakeKey)
-> ByteString -> Either DecoderError (VerificationKey StakeKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey StakeKey)
-> ByteString -> Either DecoderError (VerificationKey StakeKey)
serialiseToCBOR :: VerificationKey StakeKey -> ByteString
$cserialiseToCBOR :: VerificationKey StakeKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey StakeKey)
SerialiseAsCBOR
deriving (Int -> VerificationKey StakeKey -> ShowS
[VerificationKey StakeKey] -> ShowS
VerificationKey StakeKey -> String
(Int -> VerificationKey StakeKey -> ShowS)
-> (VerificationKey StakeKey -> String)
-> ([VerificationKey StakeKey] -> ShowS)
-> Show (VerificationKey StakeKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey StakeKey] -> ShowS
$cshowList :: [VerificationKey StakeKey] -> ShowS
show :: VerificationKey StakeKey -> String
$cshow :: VerificationKey StakeKey -> String
showsPrec :: Int -> VerificationKey StakeKey -> ShowS
$cshowsPrec :: Int -> VerificationKey StakeKey -> ShowS
Show, String -> VerificationKey StakeKey
(String -> VerificationKey StakeKey)
-> IsString (VerificationKey StakeKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey StakeKey
$cfromString :: String -> VerificationKey StakeKey
IsString) via UsingRawBytesHex (VerificationKey StakeKey)
newtype SigningKey StakeKey =
StakeSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
deriving newtype (Typeable (SigningKey StakeKey)
Typeable (SigningKey StakeKey)
-> (SigningKey StakeKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakeKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakeKey] -> Size)
-> ToCBOR (SigningKey StakeKey)
SigningKey StakeKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakeKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakeKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakeKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakeKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakeKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakeKey) -> Size
toCBOR :: SigningKey StakeKey -> Encoding
$ctoCBOR :: SigningKey StakeKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey StakeKey)
ToCBOR, Typeable (SigningKey StakeKey)
Decoder s (SigningKey StakeKey)
Typeable (SigningKey StakeKey)
-> (forall s. Decoder s (SigningKey StakeKey))
-> (Proxy (SigningKey StakeKey) -> Text)
-> FromCBOR (SigningKey StakeKey)
Proxy (SigningKey StakeKey) -> Text
forall s. Decoder s (SigningKey StakeKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey StakeKey) -> Text
$clabel :: Proxy (SigningKey StakeKey) -> Text
fromCBOR :: Decoder s (SigningKey StakeKey)
$cfromCBOR :: forall s. Decoder s (SigningKey StakeKey)
$cp1FromCBOR :: Typeable (SigningKey StakeKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey StakeKey)
SigningKey StakeKey -> ByteString
HasTypeProxy (SigningKey StakeKey)
-> (SigningKey StakeKey -> ByteString)
-> (AsType (SigningKey StakeKey)
-> ByteString -> Either DecoderError (SigningKey StakeKey))
-> SerialiseAsCBOR (SigningKey StakeKey)
AsType (SigningKey StakeKey)
-> ByteString -> Either DecoderError (SigningKey StakeKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey StakeKey)
-> ByteString -> Either DecoderError (SigningKey StakeKey)
$cdeserialiseFromCBOR :: AsType (SigningKey StakeKey)
-> ByteString -> Either DecoderError (SigningKey StakeKey)
serialiseToCBOR :: SigningKey StakeKey -> ByteString
$cserialiseToCBOR :: SigningKey StakeKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey StakeKey)
SerialiseAsCBOR
deriving (Int -> SigningKey StakeKey -> ShowS
[SigningKey StakeKey] -> ShowS
SigningKey StakeKey -> String
(Int -> SigningKey StakeKey -> ShowS)
-> (SigningKey StakeKey -> String)
-> ([SigningKey StakeKey] -> ShowS)
-> Show (SigningKey StakeKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey StakeKey] -> ShowS
$cshowList :: [SigningKey StakeKey] -> ShowS
show :: SigningKey StakeKey -> String
$cshow :: SigningKey StakeKey -> String
showsPrec :: Int -> SigningKey StakeKey -> ShowS
$cshowsPrec :: Int -> SigningKey StakeKey -> ShowS
Show, String -> SigningKey StakeKey
(String -> SigningKey StakeKey) -> IsString (SigningKey StakeKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey StakeKey
$cfromString :: String -> SigningKey StakeKey
IsString) via UsingRawBytesHex (SigningKey StakeKey)
deterministicSigningKey :: AsType StakeKey -> Crypto.Seed -> SigningKey StakeKey
deterministicSigningKey :: AsType StakeKey -> Seed -> SigningKey StakeKey
deterministicSigningKey AsType StakeKey
AsStakeKey Seed
seed =
SignKeyDSIGN StandardCrypto -> SigningKey StakeKey
StakeSigningKey (Seed -> SignKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
Crypto.genKeyDSIGN Seed
seed)
deterministicSigningKeySeedSize :: AsType StakeKey -> Word
deterministicSigningKeySeedSize :: AsType StakeKey -> Word
deterministicSigningKeySeedSize AsType StakeKey
AsStakeKey =
Proxy Ed25519DSIGN -> Word
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
Crypto.seedSizeDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey StakeKey -> VerificationKey StakeKey
getVerificationKey :: SigningKey StakeKey -> VerificationKey StakeKey
getVerificationKey (StakeSigningKey sk) =
VKey 'Staking StandardCrypto -> VerificationKey StakeKey
StakeVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto) -> VKey 'Staking StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> VerKeyDSIGN v
Crypto.deriveVerKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk))
verificationKeyHash :: VerificationKey StakeKey -> Hash StakeKey
verificationKeyHash :: VerificationKey StakeKey -> Hash StakeKey
verificationKeyHash (StakeVerificationKey vkey) =
KeyHash 'Staking StandardCrypto -> Hash StakeKey
StakeKeyHash (VKey 'Staking StandardCrypto -> KeyHash 'Staking StandardCrypto
forall crypto (kd :: KeyRole).
Crypto crypto =>
VKey kd crypto -> KeyHash kd crypto
Shelley.hashKey VKey 'Staking StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey StakeKey) where
serialiseToRawBytes :: VerificationKey StakeKey -> ByteString
serialiseToRawBytes (StakeVerificationKey (Shelley.VKey vk)) =
VerKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> ByteString
Crypto.rawSerialiseVerKeyDSIGN VerKeyDSIGN Ed25519DSIGN
VerKeyDSIGN (DSIGN StandardCrypto)
vk
deserialiseFromRawBytes :: AsType (VerificationKey StakeKey)
-> ByteString -> Maybe (VerificationKey StakeKey)
deserialiseFromRawBytes (AsVerificationKey AsStakeKey) ByteString
bs =
VKey 'Staking StandardCrypto -> VerificationKey StakeKey
StakeVerificationKey (VKey 'Staking StandardCrypto -> VerificationKey StakeKey)
-> (VerKeyDSIGN Ed25519DSIGN -> VKey 'Staking StandardCrypto)
-> VerKeyDSIGN Ed25519DSIGN
-> VerificationKey StakeKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Staking StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (VerKeyDSIGN Ed25519DSIGN -> VerificationKey StakeKey)
-> Maybe (VerKeyDSIGN Ed25519DSIGN)
-> Maybe (VerificationKey StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN ByteString
bs
instance SerialiseAsRawBytes (SigningKey StakeKey) where
serialiseToRawBytes :: SigningKey StakeKey -> ByteString
serialiseToRawBytes (StakeSigningKey sk) =
SignKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> ByteString
Crypto.rawSerialiseSignKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey StakeKey)
-> ByteString -> Maybe (SigningKey StakeKey)
deserialiseFromRawBytes (AsSigningKey AsStakeKey) ByteString
bs =
SignKeyDSIGN Ed25519DSIGN -> SigningKey StakeKey
SignKeyDSIGN StandardCrypto -> SigningKey StakeKey
StakeSigningKey (SignKeyDSIGN Ed25519DSIGN -> SigningKey StakeKey)
-> Maybe (SignKeyDSIGN Ed25519DSIGN) -> Maybe (SigningKey StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SignKeyDSIGN v)
Crypto.rawDeserialiseSignKeyDSIGN ByteString
bs
instance SerialiseAsBech32 (VerificationKey StakeKey) where
bech32PrefixFor :: VerificationKey StakeKey -> Text
bech32PrefixFor VerificationKey StakeKey
_ = Text
"stake_vk"
bech32PrefixesPermitted :: AsType (VerificationKey StakeKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey StakeKey)
_ = [Text
"stake_vk"]
instance SerialiseAsBech32 (SigningKey StakeKey) where
bech32PrefixFor :: SigningKey StakeKey -> Text
bech32PrefixFor SigningKey StakeKey
_ = Text
"stake_sk"
bech32PrefixesPermitted :: AsType (SigningKey StakeKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey StakeKey)
_ = [Text
"stake_sk"]
newtype instance Hash StakeKey =
StakeKeyHash (Shelley.KeyHash Shelley.Staking StandardCrypto)
deriving (Hash StakeKey -> Hash StakeKey -> Bool
(Hash StakeKey -> Hash StakeKey -> Bool)
-> (Hash StakeKey -> Hash StakeKey -> Bool) -> Eq (Hash StakeKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash StakeKey -> Hash StakeKey -> Bool
$c/= :: Hash StakeKey -> Hash StakeKey -> Bool
== :: Hash StakeKey -> Hash StakeKey -> Bool
$c== :: Hash StakeKey -> Hash StakeKey -> Bool
Eq, Eq (Hash StakeKey)
Eq (Hash StakeKey)
-> (Hash StakeKey -> Hash StakeKey -> Ordering)
-> (Hash StakeKey -> Hash StakeKey -> Bool)
-> (Hash StakeKey -> Hash StakeKey -> Bool)
-> (Hash StakeKey -> Hash StakeKey -> Bool)
-> (Hash StakeKey -> Hash StakeKey -> Bool)
-> (Hash StakeKey -> Hash StakeKey -> Hash StakeKey)
-> (Hash StakeKey -> Hash StakeKey -> Hash StakeKey)
-> Ord (Hash StakeKey)
Hash StakeKey -> Hash StakeKey -> Bool
Hash StakeKey -> Hash StakeKey -> Ordering
Hash StakeKey -> Hash StakeKey -> Hash StakeKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash StakeKey -> Hash StakeKey -> Hash StakeKey
$cmin :: Hash StakeKey -> Hash StakeKey -> Hash StakeKey
max :: Hash StakeKey -> Hash StakeKey -> Hash StakeKey
$cmax :: Hash StakeKey -> Hash StakeKey -> Hash StakeKey
>= :: Hash StakeKey -> Hash StakeKey -> Bool
$c>= :: Hash StakeKey -> Hash StakeKey -> Bool
> :: Hash StakeKey -> Hash StakeKey -> Bool
$c> :: Hash StakeKey -> Hash StakeKey -> Bool
<= :: Hash StakeKey -> Hash StakeKey -> Bool
$c<= :: Hash StakeKey -> Hash StakeKey -> Bool
< :: Hash StakeKey -> Hash StakeKey -> Bool
$c< :: Hash StakeKey -> Hash StakeKey -> Bool
compare :: Hash StakeKey -> Hash StakeKey -> Ordering
$ccompare :: Hash StakeKey -> Hash StakeKey -> Ordering
$cp1Ord :: Eq (Hash StakeKey)
Ord, Int -> Hash StakeKey -> ShowS
[Hash StakeKey] -> ShowS
Hash StakeKey -> String
(Int -> Hash StakeKey -> ShowS)
-> (Hash StakeKey -> String)
-> ([Hash StakeKey] -> ShowS)
-> Show (Hash StakeKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash StakeKey] -> ShowS
$cshowList :: [Hash StakeKey] -> ShowS
show :: Hash StakeKey -> String
$cshow :: Hash StakeKey -> String
showsPrec :: Int -> Hash StakeKey -> ShowS
$cshowsPrec :: Int -> Hash StakeKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash StakeKey) where
serialiseToRawBytes :: Hash StakeKey -> ByteString
serialiseToRawBytes (StakeKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash StakeKey) -> ByteString -> Maybe (Hash StakeKey)
deserialiseFromRawBytes (AsHash AsStakeKey) ByteString
bs =
KeyHash 'Staking StandardCrypto -> Hash StakeKey
StakeKeyHash (KeyHash 'Staking StandardCrypto -> Hash StakeKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash StakeKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> Hash StakeKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey StakeKey) where
textEnvelopeType :: AsType (VerificationKey StakeKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey StakeKey)
_ = TextEnvelopeType
"StakeVerificationKeyShelley_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey StakeKey) where
textEnvelopeType :: AsType (SigningKey StakeKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey StakeKey)
_ = TextEnvelopeType
"StakeSigningKeyShelley_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
data StakeExtendedKey
instance HasTypeProxy StakeExtendedKey where
data AsType StakeExtendedKey = AsStakeExtendedKey
proxyToAsType :: Proxy StakeExtendedKey -> AsType StakeExtendedKey
proxyToAsType Proxy StakeExtendedKey
_ = AsType StakeExtendedKey
AsStakeExtendedKey
instance Key StakeExtendedKey where
newtype VerificationKey StakeExtendedKey =
StakeExtendedVerificationKey Crypto.HD.XPub
deriving stock (VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool
(VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool)
-> (VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool)
-> Eq (VerificationKey StakeExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool
$c/= :: VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool
== :: VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool
$c== :: VerificationKey StakeExtendedKey
-> VerificationKey StakeExtendedKey -> Bool
Eq)
deriving anyclass HasTypeProxy (VerificationKey StakeExtendedKey)
VerificationKey StakeExtendedKey -> ByteString
HasTypeProxy (VerificationKey StakeExtendedKey)
-> (VerificationKey StakeExtendedKey -> ByteString)
-> (AsType (VerificationKey StakeExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey StakeExtendedKey))
-> SerialiseAsCBOR (VerificationKey StakeExtendedKey)
AsType (VerificationKey StakeExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey StakeExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey StakeExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey StakeExtendedKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey StakeExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey StakeExtendedKey)
serialiseToCBOR :: VerificationKey StakeExtendedKey -> ByteString
$cserialiseToCBOR :: VerificationKey StakeExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey StakeExtendedKey)
SerialiseAsCBOR
deriving (Int -> VerificationKey StakeExtendedKey -> ShowS
[VerificationKey StakeExtendedKey] -> ShowS
VerificationKey StakeExtendedKey -> String
(Int -> VerificationKey StakeExtendedKey -> ShowS)
-> (VerificationKey StakeExtendedKey -> String)
-> ([VerificationKey StakeExtendedKey] -> ShowS)
-> Show (VerificationKey StakeExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey StakeExtendedKey] -> ShowS
$cshowList :: [VerificationKey StakeExtendedKey] -> ShowS
show :: VerificationKey StakeExtendedKey -> String
$cshow :: VerificationKey StakeExtendedKey -> String
showsPrec :: Int -> VerificationKey StakeExtendedKey -> ShowS
$cshowsPrec :: Int -> VerificationKey StakeExtendedKey -> ShowS
Show, String -> VerificationKey StakeExtendedKey
(String -> VerificationKey StakeExtendedKey)
-> IsString (VerificationKey StakeExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey StakeExtendedKey
$cfromString :: String -> VerificationKey StakeExtendedKey
IsString) via UsingRawBytesHex (VerificationKey StakeExtendedKey)
newtype SigningKey StakeExtendedKey =
StakeExtendedSigningKey Crypto.HD.XPrv
deriving anyclass HasTypeProxy (SigningKey StakeExtendedKey)
SigningKey StakeExtendedKey -> ByteString
HasTypeProxy (SigningKey StakeExtendedKey)
-> (SigningKey StakeExtendedKey -> ByteString)
-> (AsType (SigningKey StakeExtendedKey)
-> ByteString -> Either DecoderError (SigningKey StakeExtendedKey))
-> SerialiseAsCBOR (SigningKey StakeExtendedKey)
AsType (SigningKey StakeExtendedKey)
-> ByteString -> Either DecoderError (SigningKey StakeExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey StakeExtendedKey)
-> ByteString -> Either DecoderError (SigningKey StakeExtendedKey)
$cdeserialiseFromCBOR :: AsType (SigningKey StakeExtendedKey)
-> ByteString -> Either DecoderError (SigningKey StakeExtendedKey)
serialiseToCBOR :: SigningKey StakeExtendedKey -> ByteString
$cserialiseToCBOR :: SigningKey StakeExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey StakeExtendedKey)
SerialiseAsCBOR
deriving (Int -> SigningKey StakeExtendedKey -> ShowS
[SigningKey StakeExtendedKey] -> ShowS
SigningKey StakeExtendedKey -> String
(Int -> SigningKey StakeExtendedKey -> ShowS)
-> (SigningKey StakeExtendedKey -> String)
-> ([SigningKey StakeExtendedKey] -> ShowS)
-> Show (SigningKey StakeExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey StakeExtendedKey] -> ShowS
$cshowList :: [SigningKey StakeExtendedKey] -> ShowS
show :: SigningKey StakeExtendedKey -> String
$cshow :: SigningKey StakeExtendedKey -> String
showsPrec :: Int -> SigningKey StakeExtendedKey -> ShowS
$cshowsPrec :: Int -> SigningKey StakeExtendedKey -> ShowS
Show, String -> SigningKey StakeExtendedKey
(String -> SigningKey StakeExtendedKey)
-> IsString (SigningKey StakeExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey StakeExtendedKey
$cfromString :: String -> SigningKey StakeExtendedKey
IsString) via UsingRawBytesHex (SigningKey StakeExtendedKey)
deterministicSigningKey :: AsType StakeExtendedKey
-> Crypto.Seed
-> SigningKey StakeExtendedKey
deterministicSigningKey :: AsType StakeExtendedKey -> Seed -> SigningKey StakeExtendedKey
deterministicSigningKey AsType StakeExtendedKey
AsStakeExtendedKey Seed
seed =
XPrv -> SigningKey StakeExtendedKey
StakeExtendedSigningKey
(ByteString -> ByteString -> XPrv
forall passPhrase seed.
(ByteArrayAccess passPhrase, ByteArrayAccess seed) =>
seed -> passPhrase -> XPrv
Crypto.HD.generate ByteString
seedbs ByteString
BS.empty)
where
(ByteString
seedbs, Seed
_) = Word -> Seed -> (ByteString, Seed)
Crypto.getBytesFromSeedT Word
32 Seed
seed
deterministicSigningKeySeedSize :: AsType StakeExtendedKey -> Word
deterministicSigningKeySeedSize :: AsType StakeExtendedKey -> Word
deterministicSigningKeySeedSize AsType StakeExtendedKey
AsStakeExtendedKey = Word
32
getVerificationKey :: SigningKey StakeExtendedKey
-> VerificationKey StakeExtendedKey
getVerificationKey :: SigningKey StakeExtendedKey -> VerificationKey StakeExtendedKey
getVerificationKey (StakeExtendedSigningKey sk) =
XPub -> VerificationKey StakeExtendedKey
StakeExtendedVerificationKey (HasCallStack => XPrv -> XPub
XPrv -> XPub
Crypto.HD.toXPub XPrv
sk)
verificationKeyHash :: VerificationKey StakeExtendedKey
-> Hash StakeExtendedKey
verificationKeyHash :: VerificationKey StakeExtendedKey -> Hash StakeExtendedKey
verificationKeyHash (StakeExtendedVerificationKey vk) =
KeyHash 'Staking StandardCrypto -> Hash StakeExtendedKey
StakeExtendedKeyHash
(KeyHash 'Staking StandardCrypto -> Hash StakeExtendedKey)
-> (Hash Blake2b_224 XPub -> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 XPub
-> Hash StakeExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash
(Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> (Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Hash Blake2b_224 XPub
-> KeyHash 'Staking StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_224 XPub -> Hash StakeExtendedKey)
-> Hash Blake2b_224 XPub -> Hash StakeExtendedKey
forall a b. (a -> b) -> a -> b
$ (XPub -> ByteString) -> XPub -> Hash Blake2b_224 XPub
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith XPub -> ByteString
Crypto.HD.xpubPublicKey XPub
vk
instance ToCBOR (VerificationKey StakeExtendedKey) where
toCBOR :: VerificationKey StakeExtendedKey -> Encoding
toCBOR (StakeExtendedVerificationKey xpub) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPub -> ByteString
Crypto.HD.unXPub XPub
xpub)
instance FromCBOR (VerificationKey StakeExtendedKey) where
fromCBOR :: Decoder s (VerificationKey StakeExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (VerificationKey StakeExtendedKey))
-> (XPub -> Decoder s (VerificationKey StakeExtendedKey))
-> Either String XPub
-> Decoder s (VerificationKey StakeExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (VerificationKey StakeExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (VerificationKey StakeExtendedKey
-> Decoder s (VerificationKey StakeExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (VerificationKey StakeExtendedKey
-> Decoder s (VerificationKey StakeExtendedKey))
-> (XPub -> VerificationKey StakeExtendedKey)
-> XPub
-> Decoder s (VerificationKey StakeExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey StakeExtendedKey
StakeExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub (ByteString
bs :: ByteString))
instance ToCBOR (SigningKey StakeExtendedKey) where
toCBOR :: SigningKey StakeExtendedKey -> Encoding
toCBOR (StakeExtendedSigningKey xprv) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv)
instance FromCBOR (SigningKey StakeExtendedKey) where
fromCBOR :: Decoder s (SigningKey StakeExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (SigningKey StakeExtendedKey))
-> (XPrv -> Decoder s (SigningKey StakeExtendedKey))
-> Either String XPrv
-> Decoder s (SigningKey StakeExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (SigningKey StakeExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (SigningKey StakeExtendedKey
-> Decoder s (SigningKey StakeExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (SigningKey StakeExtendedKey
-> Decoder s (SigningKey StakeExtendedKey))
-> (XPrv -> SigningKey StakeExtendedKey)
-> XPrv
-> Decoder s (SigningKey StakeExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey StakeExtendedKey
StakeExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv (ByteString
bs :: ByteString))
instance SerialiseAsRawBytes (VerificationKey StakeExtendedKey) where
serialiseToRawBytes :: VerificationKey StakeExtendedKey -> ByteString
serialiseToRawBytes (StakeExtendedVerificationKey xpub) =
XPub -> ByteString
Crypto.HD.unXPub XPub
xpub
deserialiseFromRawBytes :: AsType (VerificationKey StakeExtendedKey)
-> ByteString -> Maybe (VerificationKey StakeExtendedKey)
deserialiseFromRawBytes (AsVerificationKey AsStakeExtendedKey) ByteString
bs =
(String -> Maybe (VerificationKey StakeExtendedKey))
-> (XPub -> Maybe (VerificationKey StakeExtendedKey))
-> Either String XPub
-> Maybe (VerificationKey StakeExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (VerificationKey StakeExtendedKey)
-> String -> Maybe (VerificationKey StakeExtendedKey)
forall a b. a -> b -> a
const Maybe (VerificationKey StakeExtendedKey)
forall a. Maybe a
Nothing) (VerificationKey StakeExtendedKey
-> Maybe (VerificationKey StakeExtendedKey)
forall a. a -> Maybe a
Just (VerificationKey StakeExtendedKey
-> Maybe (VerificationKey StakeExtendedKey))
-> (XPub -> VerificationKey StakeExtendedKey)
-> XPub
-> Maybe (VerificationKey StakeExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey StakeExtendedKey
StakeExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub ByteString
bs)
instance SerialiseAsRawBytes (SigningKey StakeExtendedKey) where
serialiseToRawBytes :: SigningKey StakeExtendedKey -> ByteString
serialiseToRawBytes (StakeExtendedSigningKey xprv) =
XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv
deserialiseFromRawBytes :: AsType (SigningKey StakeExtendedKey)
-> ByteString -> Maybe (SigningKey StakeExtendedKey)
deserialiseFromRawBytes (AsSigningKey AsStakeExtendedKey) ByteString
bs =
(String -> Maybe (SigningKey StakeExtendedKey))
-> (XPrv -> Maybe (SigningKey StakeExtendedKey))
-> Either String XPrv
-> Maybe (SigningKey StakeExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (SigningKey StakeExtendedKey)
-> String -> Maybe (SigningKey StakeExtendedKey)
forall a b. a -> b -> a
const Maybe (SigningKey StakeExtendedKey)
forall a. Maybe a
Nothing) (SigningKey StakeExtendedKey -> Maybe (SigningKey StakeExtendedKey)
forall a. a -> Maybe a
Just (SigningKey StakeExtendedKey
-> Maybe (SigningKey StakeExtendedKey))
-> (XPrv -> SigningKey StakeExtendedKey)
-> XPrv
-> Maybe (SigningKey StakeExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey StakeExtendedKey
StakeExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv ByteString
bs)
instance SerialiseAsBech32 (VerificationKey StakeExtendedKey) where
bech32PrefixFor :: VerificationKey StakeExtendedKey -> Text
bech32PrefixFor VerificationKey StakeExtendedKey
_ = Text
"stake_xvk"
bech32PrefixesPermitted :: AsType (VerificationKey StakeExtendedKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey StakeExtendedKey)
_ = [Text
"stake_xvk"]
instance SerialiseAsBech32 (SigningKey StakeExtendedKey) where
bech32PrefixFor :: SigningKey StakeExtendedKey -> Text
bech32PrefixFor SigningKey StakeExtendedKey
_ = Text
"stake_xsk"
bech32PrefixesPermitted :: AsType (SigningKey StakeExtendedKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey StakeExtendedKey)
_ = [Text
"stake_xsk"]
newtype instance Hash StakeExtendedKey =
StakeExtendedKeyHash (Shelley.KeyHash Shelley.Staking StandardCrypto)
deriving (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
(Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool)
-> (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool)
-> Eq (Hash StakeExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
$c/= :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
== :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
$c== :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
Eq, Eq (Hash StakeExtendedKey)
Eq (Hash StakeExtendedKey)
-> (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Ordering)
-> (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool)
-> (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool)
-> (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool)
-> (Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool)
-> (Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey)
-> (Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey)
-> Ord (Hash StakeExtendedKey)
Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
Hash StakeExtendedKey -> Hash StakeExtendedKey -> Ordering
Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey
$cmin :: Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey
max :: Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey
$cmax :: Hash StakeExtendedKey
-> Hash StakeExtendedKey -> Hash StakeExtendedKey
>= :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
$c>= :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
> :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
$c> :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
<= :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
$c<= :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
< :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
$c< :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Bool
compare :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Ordering
$ccompare :: Hash StakeExtendedKey -> Hash StakeExtendedKey -> Ordering
$cp1Ord :: Eq (Hash StakeExtendedKey)
Ord, Int -> Hash StakeExtendedKey -> ShowS
[Hash StakeExtendedKey] -> ShowS
Hash StakeExtendedKey -> String
(Int -> Hash StakeExtendedKey -> ShowS)
-> (Hash StakeExtendedKey -> String)
-> ([Hash StakeExtendedKey] -> ShowS)
-> Show (Hash StakeExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash StakeExtendedKey] -> ShowS
$cshowList :: [Hash StakeExtendedKey] -> ShowS
show :: Hash StakeExtendedKey -> String
$cshow :: Hash StakeExtendedKey -> String
showsPrec :: Int -> Hash StakeExtendedKey -> ShowS
$cshowsPrec :: Int -> Hash StakeExtendedKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash StakeExtendedKey) where
serialiseToRawBytes :: Hash StakeExtendedKey -> ByteString
serialiseToRawBytes (StakeExtendedKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash StakeExtendedKey)
-> ByteString -> Maybe (Hash StakeExtendedKey)
deserialiseFromRawBytes (AsHash AsStakeExtendedKey) ByteString
bs =
KeyHash 'Staking StandardCrypto -> Hash StakeExtendedKey
StakeExtendedKeyHash (KeyHash 'Staking StandardCrypto -> Hash StakeExtendedKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash StakeExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash StakeExtendedKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash StakeExtendedKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey StakeExtendedKey) where
textEnvelopeType :: AsType (VerificationKey StakeExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey StakeExtendedKey)
_ = TextEnvelopeType
"StakeExtendedVerificationKeyShelley_ed25519_bip32"
instance HasTextEnvelope (SigningKey StakeExtendedKey) where
textEnvelopeType :: AsType (SigningKey StakeExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey StakeExtendedKey)
_ = TextEnvelopeType
"StakeExtendedSigningKeyShelley_ed25519_bip32"
instance CastVerificationKeyRole StakeExtendedKey StakeKey where
castVerificationKey :: VerificationKey StakeExtendedKey -> VerificationKey StakeKey
castVerificationKey (StakeExtendedVerificationKey vk) =
VKey 'Staking StandardCrypto -> VerificationKey StakeKey
StakeVerificationKey
(VKey 'Staking StandardCrypto -> VerificationKey StakeKey)
-> (XPub -> VKey 'Staking StandardCrypto)
-> XPub
-> VerificationKey StakeKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Staking StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey
(VerKeyDSIGN Ed25519DSIGN -> VKey 'Staking StandardCrypto)
-> (XPub -> VerKeyDSIGN Ed25519DSIGN)
-> XPub
-> VKey 'Staking StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN
-> Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN
forall a. a -> Maybe a -> a
fromMaybe VerKeyDSIGN Ed25519DSIGN
forall a. a
impossible
(Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN)
-> (XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> XPub
-> VerKeyDSIGN Ed25519DSIGN
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN
(ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> (XPub -> ByteString) -> XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> ByteString
Crypto.HD.xpubPublicKey
(XPub -> VerificationKey StakeKey)
-> XPub -> VerificationKey StakeKey
forall a b. (a -> b) -> a -> b
$ XPub
vk
where
impossible :: a
impossible =
String -> a
forall a. HasCallStack => String -> a
error String
"castVerificationKey: byron and shelley key sizes do not match!"
data GenesisKey
instance HasTypeProxy GenesisKey where
data AsType GenesisKey = AsGenesisKey
proxyToAsType :: Proxy GenesisKey -> AsType GenesisKey
proxyToAsType Proxy GenesisKey
_ = AsType GenesisKey
AsGenesisKey
instance Key GenesisKey where
newtype VerificationKey GenesisKey =
GenesisVerificationKey (Shelley.VKey Shelley.Genesis StandardCrypto)
deriving stock (VerificationKey GenesisKey -> VerificationKey GenesisKey -> Bool
(VerificationKey GenesisKey -> VerificationKey GenesisKey -> Bool)
-> (VerificationKey GenesisKey
-> VerificationKey GenesisKey -> Bool)
-> Eq (VerificationKey GenesisKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey GenesisKey -> VerificationKey GenesisKey -> Bool
$c/= :: VerificationKey GenesisKey -> VerificationKey GenesisKey -> Bool
== :: VerificationKey GenesisKey -> VerificationKey GenesisKey -> Bool
$c== :: VerificationKey GenesisKey -> VerificationKey GenesisKey -> Bool
Eq)
deriving (Int -> VerificationKey GenesisKey -> ShowS
[VerificationKey GenesisKey] -> ShowS
VerificationKey GenesisKey -> String
(Int -> VerificationKey GenesisKey -> ShowS)
-> (VerificationKey GenesisKey -> String)
-> ([VerificationKey GenesisKey] -> ShowS)
-> Show (VerificationKey GenesisKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey GenesisKey] -> ShowS
$cshowList :: [VerificationKey GenesisKey] -> ShowS
show :: VerificationKey GenesisKey -> String
$cshow :: VerificationKey GenesisKey -> String
showsPrec :: Int -> VerificationKey GenesisKey -> ShowS
$cshowsPrec :: Int -> VerificationKey GenesisKey -> ShowS
Show, String -> VerificationKey GenesisKey
(String -> VerificationKey GenesisKey)
-> IsString (VerificationKey GenesisKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey GenesisKey
$cfromString :: String -> VerificationKey GenesisKey
IsString) via UsingRawBytesHex (VerificationKey GenesisKey)
deriving newtype (Typeable (VerificationKey GenesisKey)
Typeable (VerificationKey GenesisKey)
-> (VerificationKey GenesisKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisKey] -> Size)
-> ToCBOR (VerificationKey GenesisKey)
VerificationKey GenesisKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisKey) -> Size
toCBOR :: VerificationKey GenesisKey -> Encoding
$ctoCBOR :: VerificationKey GenesisKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey GenesisKey)
ToCBOR, Typeable (VerificationKey GenesisKey)
Decoder s (VerificationKey GenesisKey)
Typeable (VerificationKey GenesisKey)
-> (forall s. Decoder s (VerificationKey GenesisKey))
-> (Proxy (VerificationKey GenesisKey) -> Text)
-> FromCBOR (VerificationKey GenesisKey)
Proxy (VerificationKey GenesisKey) -> Text
forall s. Decoder s (VerificationKey GenesisKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey GenesisKey) -> Text
$clabel :: Proxy (VerificationKey GenesisKey) -> Text
fromCBOR :: Decoder s (VerificationKey GenesisKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey GenesisKey)
$cp1FromCBOR :: Typeable (VerificationKey GenesisKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey GenesisKey)
VerificationKey GenesisKey -> ByteString
HasTypeProxy (VerificationKey GenesisKey)
-> (VerificationKey GenesisKey -> ByteString)
-> (AsType (VerificationKey GenesisKey)
-> ByteString -> Either DecoderError (VerificationKey GenesisKey))
-> SerialiseAsCBOR (VerificationKey GenesisKey)
AsType (VerificationKey GenesisKey)
-> ByteString -> Either DecoderError (VerificationKey GenesisKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey GenesisKey)
-> ByteString -> Either DecoderError (VerificationKey GenesisKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey GenesisKey)
-> ByteString -> Either DecoderError (VerificationKey GenesisKey)
serialiseToCBOR :: VerificationKey GenesisKey -> ByteString
$cserialiseToCBOR :: VerificationKey GenesisKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey GenesisKey)
SerialiseAsCBOR
newtype SigningKey GenesisKey =
GenesisSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
deriving (Int -> SigningKey GenesisKey -> ShowS
[SigningKey GenesisKey] -> ShowS
SigningKey GenesisKey -> String
(Int -> SigningKey GenesisKey -> ShowS)
-> (SigningKey GenesisKey -> String)
-> ([SigningKey GenesisKey] -> ShowS)
-> Show (SigningKey GenesisKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey GenesisKey] -> ShowS
$cshowList :: [SigningKey GenesisKey] -> ShowS
show :: SigningKey GenesisKey -> String
$cshow :: SigningKey GenesisKey -> String
showsPrec :: Int -> SigningKey GenesisKey -> ShowS
$cshowsPrec :: Int -> SigningKey GenesisKey -> ShowS
Show, String -> SigningKey GenesisKey
(String -> SigningKey GenesisKey)
-> IsString (SigningKey GenesisKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey GenesisKey
$cfromString :: String -> SigningKey GenesisKey
IsString) via UsingRawBytesHex (SigningKey GenesisKey)
deriving newtype (Typeable (SigningKey GenesisKey)
Typeable (SigningKey GenesisKey)
-> (SigningKey GenesisKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisKey] -> Size)
-> ToCBOR (SigningKey GenesisKey)
SigningKey GenesisKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisKey) -> Size
toCBOR :: SigningKey GenesisKey -> Encoding
$ctoCBOR :: SigningKey GenesisKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey GenesisKey)
ToCBOR, Typeable (SigningKey GenesisKey)
Decoder s (SigningKey GenesisKey)
Typeable (SigningKey GenesisKey)
-> (forall s. Decoder s (SigningKey GenesisKey))
-> (Proxy (SigningKey GenesisKey) -> Text)
-> FromCBOR (SigningKey GenesisKey)
Proxy (SigningKey GenesisKey) -> Text
forall s. Decoder s (SigningKey GenesisKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey GenesisKey) -> Text
$clabel :: Proxy (SigningKey GenesisKey) -> Text
fromCBOR :: Decoder s (SigningKey GenesisKey)
$cfromCBOR :: forall s. Decoder s (SigningKey GenesisKey)
$cp1FromCBOR :: Typeable (SigningKey GenesisKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey GenesisKey)
SigningKey GenesisKey -> ByteString
HasTypeProxy (SigningKey GenesisKey)
-> (SigningKey GenesisKey -> ByteString)
-> (AsType (SigningKey GenesisKey)
-> ByteString -> Either DecoderError (SigningKey GenesisKey))
-> SerialiseAsCBOR (SigningKey GenesisKey)
AsType (SigningKey GenesisKey)
-> ByteString -> Either DecoderError (SigningKey GenesisKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey GenesisKey)
-> ByteString -> Either DecoderError (SigningKey GenesisKey)
$cdeserialiseFromCBOR :: AsType (SigningKey GenesisKey)
-> ByteString -> Either DecoderError (SigningKey GenesisKey)
serialiseToCBOR :: SigningKey GenesisKey -> ByteString
$cserialiseToCBOR :: SigningKey GenesisKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey GenesisKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType GenesisKey -> Crypto.Seed -> SigningKey GenesisKey
deterministicSigningKey :: AsType GenesisKey -> Seed -> SigningKey GenesisKey
deterministicSigningKey AsType GenesisKey
AsGenesisKey Seed
seed =
SignKeyDSIGN StandardCrypto -> SigningKey GenesisKey
GenesisSigningKey (Seed -> SignKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
Crypto.genKeyDSIGN Seed
seed)
deterministicSigningKeySeedSize :: AsType GenesisKey -> Word
deterministicSigningKeySeedSize :: AsType GenesisKey -> Word
deterministicSigningKeySeedSize AsType GenesisKey
AsGenesisKey =
Proxy Ed25519DSIGN -> Word
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
Crypto.seedSizeDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey GenesisKey -> VerificationKey GenesisKey
getVerificationKey :: SigningKey GenesisKey -> VerificationKey GenesisKey
getVerificationKey (GenesisSigningKey sk) =
VKey 'Genesis StandardCrypto -> VerificationKey GenesisKey
GenesisVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto) -> VKey 'Genesis StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> VerKeyDSIGN v
Crypto.deriveVerKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk))
verificationKeyHash :: VerificationKey GenesisKey -> Hash GenesisKey
verificationKeyHash :: VerificationKey GenesisKey -> Hash GenesisKey
verificationKeyHash (GenesisVerificationKey vkey) =
KeyHash 'Genesis StandardCrypto -> Hash GenesisKey
GenesisKeyHash (VKey 'Genesis StandardCrypto -> KeyHash 'Genesis StandardCrypto
forall crypto (kd :: KeyRole).
Crypto crypto =>
VKey kd crypto -> KeyHash kd crypto
Shelley.hashKey VKey 'Genesis StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey GenesisKey) where
serialiseToRawBytes :: VerificationKey GenesisKey -> ByteString
serialiseToRawBytes (GenesisVerificationKey (Shelley.VKey vk)) =
VerKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> ByteString
Crypto.rawSerialiseVerKeyDSIGN VerKeyDSIGN Ed25519DSIGN
VerKeyDSIGN (DSIGN StandardCrypto)
vk
deserialiseFromRawBytes :: AsType (VerificationKey GenesisKey)
-> ByteString -> Maybe (VerificationKey GenesisKey)
deserialiseFromRawBytes (AsVerificationKey AsGenesisKey) ByteString
bs =
VKey 'Genesis StandardCrypto -> VerificationKey GenesisKey
GenesisVerificationKey (VKey 'Genesis StandardCrypto -> VerificationKey GenesisKey)
-> (VerKeyDSIGN Ed25519DSIGN -> VKey 'Genesis StandardCrypto)
-> VerKeyDSIGN Ed25519DSIGN
-> VerificationKey GenesisKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Genesis StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (VerKeyDSIGN Ed25519DSIGN -> VerificationKey GenesisKey)
-> Maybe (VerKeyDSIGN Ed25519DSIGN)
-> Maybe (VerificationKey GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN ByteString
bs
instance SerialiseAsRawBytes (SigningKey GenesisKey) where
serialiseToRawBytes :: SigningKey GenesisKey -> ByteString
serialiseToRawBytes (GenesisSigningKey sk) =
SignKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> ByteString
Crypto.rawSerialiseSignKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey GenesisKey)
-> ByteString -> Maybe (SigningKey GenesisKey)
deserialiseFromRawBytes (AsSigningKey AsGenesisKey) ByteString
bs =
SignKeyDSIGN Ed25519DSIGN -> SigningKey GenesisKey
SignKeyDSIGN StandardCrypto -> SigningKey GenesisKey
GenesisSigningKey (SignKeyDSIGN Ed25519DSIGN -> SigningKey GenesisKey)
-> Maybe (SignKeyDSIGN Ed25519DSIGN)
-> Maybe (SigningKey GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SignKeyDSIGN v)
Crypto.rawDeserialiseSignKeyDSIGN ByteString
bs
newtype instance Hash GenesisKey =
GenesisKeyHash (Shelley.KeyHash Shelley.Genesis StandardCrypto)
deriving (Hash GenesisKey -> Hash GenesisKey -> Bool
(Hash GenesisKey -> Hash GenesisKey -> Bool)
-> (Hash GenesisKey -> Hash GenesisKey -> Bool)
-> Eq (Hash GenesisKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash GenesisKey -> Hash GenesisKey -> Bool
$c/= :: Hash GenesisKey -> Hash GenesisKey -> Bool
== :: Hash GenesisKey -> Hash GenesisKey -> Bool
$c== :: Hash GenesisKey -> Hash GenesisKey -> Bool
Eq, Eq (Hash GenesisKey)
Eq (Hash GenesisKey)
-> (Hash GenesisKey -> Hash GenesisKey -> Ordering)
-> (Hash GenesisKey -> Hash GenesisKey -> Bool)
-> (Hash GenesisKey -> Hash GenesisKey -> Bool)
-> (Hash GenesisKey -> Hash GenesisKey -> Bool)
-> (Hash GenesisKey -> Hash GenesisKey -> Bool)
-> (Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey)
-> (Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey)
-> Ord (Hash GenesisKey)
Hash GenesisKey -> Hash GenesisKey -> Bool
Hash GenesisKey -> Hash GenesisKey -> Ordering
Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey
$cmin :: Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey
max :: Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey
$cmax :: Hash GenesisKey -> Hash GenesisKey -> Hash GenesisKey
>= :: Hash GenesisKey -> Hash GenesisKey -> Bool
$c>= :: Hash GenesisKey -> Hash GenesisKey -> Bool
> :: Hash GenesisKey -> Hash GenesisKey -> Bool
$c> :: Hash GenesisKey -> Hash GenesisKey -> Bool
<= :: Hash GenesisKey -> Hash GenesisKey -> Bool
$c<= :: Hash GenesisKey -> Hash GenesisKey -> Bool
< :: Hash GenesisKey -> Hash GenesisKey -> Bool
$c< :: Hash GenesisKey -> Hash GenesisKey -> Bool
compare :: Hash GenesisKey -> Hash GenesisKey -> Ordering
$ccompare :: Hash GenesisKey -> Hash GenesisKey -> Ordering
$cp1Ord :: Eq (Hash GenesisKey)
Ord, Int -> Hash GenesisKey -> ShowS
[Hash GenesisKey] -> ShowS
Hash GenesisKey -> String
(Int -> Hash GenesisKey -> ShowS)
-> (Hash GenesisKey -> String)
-> ([Hash GenesisKey] -> ShowS)
-> Show (Hash GenesisKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash GenesisKey] -> ShowS
$cshowList :: [Hash GenesisKey] -> ShowS
show :: Hash GenesisKey -> String
$cshow :: Hash GenesisKey -> String
showsPrec :: Int -> Hash GenesisKey -> ShowS
$cshowsPrec :: Int -> Hash GenesisKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash GenesisKey) where
serialiseToRawBytes :: Hash GenesisKey -> ByteString
serialiseToRawBytes (GenesisKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash GenesisKey) -> ByteString -> Maybe (Hash GenesisKey)
deserialiseFromRawBytes (AsHash AsGenesisKey) ByteString
bs =
KeyHash 'Genesis StandardCrypto -> Hash GenesisKey
GenesisKeyHash (KeyHash 'Genesis StandardCrypto -> Hash GenesisKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Genesis StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Genesis StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> Hash GenesisKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey GenesisKey) where
textEnvelopeType :: AsType (VerificationKey GenesisKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey GenesisKey)
_ = TextEnvelopeType
"GenesisVerificationKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey GenesisKey) where
textEnvelopeType :: AsType (SigningKey GenesisKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey GenesisKey)
_ = TextEnvelopeType
"GenesisSigningKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
data GenesisExtendedKey
instance HasTypeProxy GenesisExtendedKey where
data AsType GenesisExtendedKey = AsGenesisExtendedKey
proxyToAsType :: Proxy GenesisExtendedKey -> AsType GenesisExtendedKey
proxyToAsType Proxy GenesisExtendedKey
_ = AsType GenesisExtendedKey
AsGenesisExtendedKey
instance Key GenesisExtendedKey where
newtype VerificationKey GenesisExtendedKey =
GenesisExtendedVerificationKey Crypto.HD.XPub
deriving stock (VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool
(VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool)
-> (VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool)
-> Eq (VerificationKey GenesisExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool
$c/= :: VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool
== :: VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool
$c== :: VerificationKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey -> Bool
Eq)
deriving anyclass HasTypeProxy (VerificationKey GenesisExtendedKey)
VerificationKey GenesisExtendedKey -> ByteString
HasTypeProxy (VerificationKey GenesisExtendedKey)
-> (VerificationKey GenesisExtendedKey -> ByteString)
-> (AsType (VerificationKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisExtendedKey))
-> SerialiseAsCBOR (VerificationKey GenesisExtendedKey)
AsType (VerificationKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisExtendedKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisExtendedKey)
serialiseToCBOR :: VerificationKey GenesisExtendedKey -> ByteString
$cserialiseToCBOR :: VerificationKey GenesisExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey GenesisExtendedKey)
SerialiseAsCBOR
deriving (Int -> VerificationKey GenesisExtendedKey -> ShowS
[VerificationKey GenesisExtendedKey] -> ShowS
VerificationKey GenesisExtendedKey -> String
(Int -> VerificationKey GenesisExtendedKey -> ShowS)
-> (VerificationKey GenesisExtendedKey -> String)
-> ([VerificationKey GenesisExtendedKey] -> ShowS)
-> Show (VerificationKey GenesisExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey GenesisExtendedKey] -> ShowS
$cshowList :: [VerificationKey GenesisExtendedKey] -> ShowS
show :: VerificationKey GenesisExtendedKey -> String
$cshow :: VerificationKey GenesisExtendedKey -> String
showsPrec :: Int -> VerificationKey GenesisExtendedKey -> ShowS
$cshowsPrec :: Int -> VerificationKey GenesisExtendedKey -> ShowS
Show, String -> VerificationKey GenesisExtendedKey
(String -> VerificationKey GenesisExtendedKey)
-> IsString (VerificationKey GenesisExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey GenesisExtendedKey
$cfromString :: String -> VerificationKey GenesisExtendedKey
IsString) via UsingRawBytesHex (VerificationKey GenesisExtendedKey)
newtype SigningKey GenesisExtendedKey =
GenesisExtendedSigningKey Crypto.HD.XPrv
deriving anyclass HasTypeProxy (SigningKey GenesisExtendedKey)
SigningKey GenesisExtendedKey -> ByteString
HasTypeProxy (SigningKey GenesisExtendedKey)
-> (SigningKey GenesisExtendedKey -> ByteString)
-> (AsType (SigningKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisExtendedKey))
-> SerialiseAsCBOR (SigningKey GenesisExtendedKey)
AsType (SigningKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisExtendedKey)
$cdeserialiseFromCBOR :: AsType (SigningKey GenesisExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisExtendedKey)
serialiseToCBOR :: SigningKey GenesisExtendedKey -> ByteString
$cserialiseToCBOR :: SigningKey GenesisExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey GenesisExtendedKey)
SerialiseAsCBOR
deriving (Int -> SigningKey GenesisExtendedKey -> ShowS
[SigningKey GenesisExtendedKey] -> ShowS
SigningKey GenesisExtendedKey -> String
(Int -> SigningKey GenesisExtendedKey -> ShowS)
-> (SigningKey GenesisExtendedKey -> String)
-> ([SigningKey GenesisExtendedKey] -> ShowS)
-> Show (SigningKey GenesisExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey GenesisExtendedKey] -> ShowS
$cshowList :: [SigningKey GenesisExtendedKey] -> ShowS
show :: SigningKey GenesisExtendedKey -> String
$cshow :: SigningKey GenesisExtendedKey -> String
showsPrec :: Int -> SigningKey GenesisExtendedKey -> ShowS
$cshowsPrec :: Int -> SigningKey GenesisExtendedKey -> ShowS
Show, String -> SigningKey GenesisExtendedKey
(String -> SigningKey GenesisExtendedKey)
-> IsString (SigningKey GenesisExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey GenesisExtendedKey
$cfromString :: String -> SigningKey GenesisExtendedKey
IsString) via UsingRawBytesHex (SigningKey GenesisExtendedKey)
deterministicSigningKey :: AsType GenesisExtendedKey
-> Crypto.Seed
-> SigningKey GenesisExtendedKey
deterministicSigningKey :: AsType GenesisExtendedKey -> Seed -> SigningKey GenesisExtendedKey
deterministicSigningKey AsType GenesisExtendedKey
AsGenesisExtendedKey Seed
seed =
XPrv -> SigningKey GenesisExtendedKey
GenesisExtendedSigningKey
(ByteString -> ByteString -> XPrv
forall passPhrase seed.
(ByteArrayAccess passPhrase, ByteArrayAccess seed) =>
seed -> passPhrase -> XPrv
Crypto.HD.generate ByteString
seedbs ByteString
BS.empty)
where
(ByteString
seedbs, Seed
_) = Word -> Seed -> (ByteString, Seed)
Crypto.getBytesFromSeedT Word
32 Seed
seed
deterministicSigningKeySeedSize :: AsType GenesisExtendedKey -> Word
deterministicSigningKeySeedSize :: AsType GenesisExtendedKey -> Word
deterministicSigningKeySeedSize AsType GenesisExtendedKey
AsGenesisExtendedKey = Word
32
getVerificationKey :: SigningKey GenesisExtendedKey
-> VerificationKey GenesisExtendedKey
getVerificationKey :: SigningKey GenesisExtendedKey -> VerificationKey GenesisExtendedKey
getVerificationKey (GenesisExtendedSigningKey sk) =
XPub -> VerificationKey GenesisExtendedKey
GenesisExtendedVerificationKey (HasCallStack => XPrv -> XPub
XPrv -> XPub
Crypto.HD.toXPub XPrv
sk)
verificationKeyHash :: VerificationKey GenesisExtendedKey
-> Hash GenesisExtendedKey
verificationKeyHash :: VerificationKey GenesisExtendedKey -> Hash GenesisExtendedKey
verificationKeyHash (GenesisExtendedVerificationKey vk) =
KeyHash 'Staking StandardCrypto -> Hash GenesisExtendedKey
GenesisExtendedKeyHash
(KeyHash 'Staking StandardCrypto -> Hash GenesisExtendedKey)
-> (Hash Blake2b_224 XPub -> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 XPub
-> Hash GenesisExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash
(Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> (Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Hash Blake2b_224 XPub
-> KeyHash 'Staking StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_224 XPub -> Hash GenesisExtendedKey)
-> Hash Blake2b_224 XPub -> Hash GenesisExtendedKey
forall a b. (a -> b) -> a -> b
$ (XPub -> ByteString) -> XPub -> Hash Blake2b_224 XPub
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith XPub -> ByteString
Crypto.HD.xpubPublicKey XPub
vk
instance ToCBOR (VerificationKey GenesisExtendedKey) where
toCBOR :: VerificationKey GenesisExtendedKey -> Encoding
toCBOR (GenesisExtendedVerificationKey xpub) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPub -> ByteString
Crypto.HD.unXPub XPub
xpub)
instance FromCBOR (VerificationKey GenesisExtendedKey) where
fromCBOR :: Decoder s (VerificationKey GenesisExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (VerificationKey GenesisExtendedKey))
-> (XPub -> Decoder s (VerificationKey GenesisExtendedKey))
-> Either String XPub
-> Decoder s (VerificationKey GenesisExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (VerificationKey GenesisExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (VerificationKey GenesisExtendedKey
-> Decoder s (VerificationKey GenesisExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (VerificationKey GenesisExtendedKey
-> Decoder s (VerificationKey GenesisExtendedKey))
-> (XPub -> VerificationKey GenesisExtendedKey)
-> XPub
-> Decoder s (VerificationKey GenesisExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey GenesisExtendedKey
GenesisExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub (ByteString
bs :: ByteString))
instance ToCBOR (SigningKey GenesisExtendedKey) where
toCBOR :: SigningKey GenesisExtendedKey -> Encoding
toCBOR (GenesisExtendedSigningKey xprv) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv)
instance FromCBOR (SigningKey GenesisExtendedKey) where
fromCBOR :: Decoder s (SigningKey GenesisExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (SigningKey GenesisExtendedKey))
-> (XPrv -> Decoder s (SigningKey GenesisExtendedKey))
-> Either String XPrv
-> Decoder s (SigningKey GenesisExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (SigningKey GenesisExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (SigningKey GenesisExtendedKey
-> Decoder s (SigningKey GenesisExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (SigningKey GenesisExtendedKey
-> Decoder s (SigningKey GenesisExtendedKey))
-> (XPrv -> SigningKey GenesisExtendedKey)
-> XPrv
-> Decoder s (SigningKey GenesisExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey GenesisExtendedKey
GenesisExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv (ByteString
bs :: ByteString))
instance SerialiseAsRawBytes (VerificationKey GenesisExtendedKey) where
serialiseToRawBytes :: VerificationKey GenesisExtendedKey -> ByteString
serialiseToRawBytes (GenesisExtendedVerificationKey xpub) =
XPub -> ByteString
Crypto.HD.unXPub XPub
xpub
deserialiseFromRawBytes :: AsType (VerificationKey GenesisExtendedKey)
-> ByteString -> Maybe (VerificationKey GenesisExtendedKey)
deserialiseFromRawBytes (AsVerificationKey AsGenesisExtendedKey) ByteString
bs =
(String -> Maybe (VerificationKey GenesisExtendedKey))
-> (XPub -> Maybe (VerificationKey GenesisExtendedKey))
-> Either String XPub
-> Maybe (VerificationKey GenesisExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (VerificationKey GenesisExtendedKey)
-> String -> Maybe (VerificationKey GenesisExtendedKey)
forall a b. a -> b -> a
const Maybe (VerificationKey GenesisExtendedKey)
forall a. Maybe a
Nothing) (VerificationKey GenesisExtendedKey
-> Maybe (VerificationKey GenesisExtendedKey)
forall a. a -> Maybe a
Just (VerificationKey GenesisExtendedKey
-> Maybe (VerificationKey GenesisExtendedKey))
-> (XPub -> VerificationKey GenesisExtendedKey)
-> XPub
-> Maybe (VerificationKey GenesisExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey GenesisExtendedKey
GenesisExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub ByteString
bs)
instance SerialiseAsRawBytes (SigningKey GenesisExtendedKey) where
serialiseToRawBytes :: SigningKey GenesisExtendedKey -> ByteString
serialiseToRawBytes (GenesisExtendedSigningKey xprv) =
XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv
deserialiseFromRawBytes :: AsType (SigningKey GenesisExtendedKey)
-> ByteString -> Maybe (SigningKey GenesisExtendedKey)
deserialiseFromRawBytes (AsSigningKey AsGenesisExtendedKey) ByteString
bs =
(String -> Maybe (SigningKey GenesisExtendedKey))
-> (XPrv -> Maybe (SigningKey GenesisExtendedKey))
-> Either String XPrv
-> Maybe (SigningKey GenesisExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (SigningKey GenesisExtendedKey)
-> String -> Maybe (SigningKey GenesisExtendedKey)
forall a b. a -> b -> a
const Maybe (SigningKey GenesisExtendedKey)
forall a. Maybe a
Nothing) (SigningKey GenesisExtendedKey
-> Maybe (SigningKey GenesisExtendedKey)
forall a. a -> Maybe a
Just (SigningKey GenesisExtendedKey
-> Maybe (SigningKey GenesisExtendedKey))
-> (XPrv -> SigningKey GenesisExtendedKey)
-> XPrv
-> Maybe (SigningKey GenesisExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey GenesisExtendedKey
GenesisExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv ByteString
bs)
newtype instance Hash GenesisExtendedKey =
GenesisExtendedKeyHash (Shelley.KeyHash Shelley.Staking StandardCrypto)
deriving (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
(Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool)
-> (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool)
-> Eq (Hash GenesisExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
$c/= :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
== :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
$c== :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
Eq, Eq (Hash GenesisExtendedKey)
Eq (Hash GenesisExtendedKey)
-> (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Ordering)
-> (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool)
-> (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool)
-> (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool)
-> (Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool)
-> (Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey)
-> (Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey)
-> Ord (Hash GenesisExtendedKey)
Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Ordering
Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey
$cmin :: Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey
max :: Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey
$cmax :: Hash GenesisExtendedKey
-> Hash GenesisExtendedKey -> Hash GenesisExtendedKey
>= :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
$c>= :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
> :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
$c> :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
<= :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
$c<= :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
< :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
$c< :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Bool
compare :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Ordering
$ccompare :: Hash GenesisExtendedKey -> Hash GenesisExtendedKey -> Ordering
$cp1Ord :: Eq (Hash GenesisExtendedKey)
Ord, Int -> Hash GenesisExtendedKey -> ShowS
[Hash GenesisExtendedKey] -> ShowS
Hash GenesisExtendedKey -> String
(Int -> Hash GenesisExtendedKey -> ShowS)
-> (Hash GenesisExtendedKey -> String)
-> ([Hash GenesisExtendedKey] -> ShowS)
-> Show (Hash GenesisExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash GenesisExtendedKey] -> ShowS
$cshowList :: [Hash GenesisExtendedKey] -> ShowS
show :: Hash GenesisExtendedKey -> String
$cshow :: Hash GenesisExtendedKey -> String
showsPrec :: Int -> Hash GenesisExtendedKey -> ShowS
$cshowsPrec :: Int -> Hash GenesisExtendedKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash GenesisExtendedKey) where
serialiseToRawBytes :: Hash GenesisExtendedKey -> ByteString
serialiseToRawBytes (GenesisExtendedKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash GenesisExtendedKey)
-> ByteString -> Maybe (Hash GenesisExtendedKey)
deserialiseFromRawBytes (AsHash AsGenesisExtendedKey) ByteString
bs =
KeyHash 'Staking StandardCrypto -> Hash GenesisExtendedKey
GenesisExtendedKeyHash (KeyHash 'Staking StandardCrypto -> Hash GenesisExtendedKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisExtendedKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash GenesisExtendedKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey GenesisExtendedKey) where
textEnvelopeType :: AsType (VerificationKey GenesisExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey GenesisExtendedKey)
_ = TextEnvelopeType
"GenesisExtendedVerificationKey_ed25519_bip32"
instance HasTextEnvelope (SigningKey GenesisExtendedKey) where
textEnvelopeType :: AsType (SigningKey GenesisExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey GenesisExtendedKey)
_ = TextEnvelopeType
"GenesisExtendedSigningKey_ed25519_bip32"
instance CastVerificationKeyRole GenesisExtendedKey GenesisKey where
castVerificationKey :: VerificationKey GenesisExtendedKey -> VerificationKey GenesisKey
castVerificationKey (GenesisExtendedVerificationKey vk) =
VKey 'Genesis StandardCrypto -> VerificationKey GenesisKey
GenesisVerificationKey
(VKey 'Genesis StandardCrypto -> VerificationKey GenesisKey)
-> (XPub -> VKey 'Genesis StandardCrypto)
-> XPub
-> VerificationKey GenesisKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Genesis StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey
(VerKeyDSIGN Ed25519DSIGN -> VKey 'Genesis StandardCrypto)
-> (XPub -> VerKeyDSIGN Ed25519DSIGN)
-> XPub
-> VKey 'Genesis StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN
-> Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN
forall a. a -> Maybe a -> a
fromMaybe VerKeyDSIGN Ed25519DSIGN
forall a. a
impossible
(Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN)
-> (XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> XPub
-> VerKeyDSIGN Ed25519DSIGN
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN
(ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> (XPub -> ByteString) -> XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> ByteString
Crypto.HD.xpubPublicKey
(XPub -> VerificationKey GenesisKey)
-> XPub -> VerificationKey GenesisKey
forall a b. (a -> b) -> a -> b
$ XPub
vk
where
impossible :: a
impossible =
String -> a
forall a. HasCallStack => String -> a
error String
"castVerificationKey: byron and shelley key sizes do not match!"
data GenesisDelegateKey
instance HasTypeProxy GenesisDelegateKey where
data AsType GenesisDelegateKey = AsGenesisDelegateKey
proxyToAsType :: Proxy GenesisDelegateKey -> AsType GenesisDelegateKey
proxyToAsType Proxy GenesisDelegateKey
_ = AsType GenesisDelegateKey
AsGenesisDelegateKey
instance Key GenesisDelegateKey where
newtype VerificationKey GenesisDelegateKey =
GenesisDelegateVerificationKey (Shelley.VKey Shelley.GenesisDelegate StandardCrypto)
deriving stock (VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool
(VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool)
-> (VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool)
-> Eq (VerificationKey GenesisDelegateKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool
$c/= :: VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool
== :: VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool
$c== :: VerificationKey GenesisDelegateKey
-> VerificationKey GenesisDelegateKey -> Bool
Eq)
deriving (Int -> VerificationKey GenesisDelegateKey -> ShowS
[VerificationKey GenesisDelegateKey] -> ShowS
VerificationKey GenesisDelegateKey -> String
(Int -> VerificationKey GenesisDelegateKey -> ShowS)
-> (VerificationKey GenesisDelegateKey -> String)
-> ([VerificationKey GenesisDelegateKey] -> ShowS)
-> Show (VerificationKey GenesisDelegateKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey GenesisDelegateKey] -> ShowS
$cshowList :: [VerificationKey GenesisDelegateKey] -> ShowS
show :: VerificationKey GenesisDelegateKey -> String
$cshow :: VerificationKey GenesisDelegateKey -> String
showsPrec :: Int -> VerificationKey GenesisDelegateKey -> ShowS
$cshowsPrec :: Int -> VerificationKey GenesisDelegateKey -> ShowS
Show, String -> VerificationKey GenesisDelegateKey
(String -> VerificationKey GenesisDelegateKey)
-> IsString (VerificationKey GenesisDelegateKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey GenesisDelegateKey
$cfromString :: String -> VerificationKey GenesisDelegateKey
IsString) via UsingRawBytesHex (VerificationKey GenesisDelegateKey)
deriving newtype (Typeable (VerificationKey GenesisDelegateKey)
Typeable (VerificationKey GenesisDelegateKey)
-> (VerificationKey GenesisDelegateKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisDelegateKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisDelegateKey] -> Size)
-> ToCBOR (VerificationKey GenesisDelegateKey)
VerificationKey GenesisDelegateKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisDelegateKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisDelegateKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisDelegateKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisDelegateKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisDelegateKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisDelegateKey) -> Size
toCBOR :: VerificationKey GenesisDelegateKey -> Encoding
$ctoCBOR :: VerificationKey GenesisDelegateKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey GenesisDelegateKey)
ToCBOR, Typeable (VerificationKey GenesisDelegateKey)
Decoder s (VerificationKey GenesisDelegateKey)
Typeable (VerificationKey GenesisDelegateKey)
-> (forall s. Decoder s (VerificationKey GenesisDelegateKey))
-> (Proxy (VerificationKey GenesisDelegateKey) -> Text)
-> FromCBOR (VerificationKey GenesisDelegateKey)
Proxy (VerificationKey GenesisDelegateKey) -> Text
forall s. Decoder s (VerificationKey GenesisDelegateKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey GenesisDelegateKey) -> Text
$clabel :: Proxy (VerificationKey GenesisDelegateKey) -> Text
fromCBOR :: Decoder s (VerificationKey GenesisDelegateKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey GenesisDelegateKey)
$cp1FromCBOR :: Typeable (VerificationKey GenesisDelegateKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey GenesisDelegateKey)
VerificationKey GenesisDelegateKey -> ByteString
HasTypeProxy (VerificationKey GenesisDelegateKey)
-> (VerificationKey GenesisDelegateKey -> ByteString)
-> (AsType (VerificationKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateKey))
-> SerialiseAsCBOR (VerificationKey GenesisDelegateKey)
AsType (VerificationKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateKey)
serialiseToCBOR :: VerificationKey GenesisDelegateKey -> ByteString
$cserialiseToCBOR :: VerificationKey GenesisDelegateKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey GenesisDelegateKey)
SerialiseAsCBOR
newtype SigningKey GenesisDelegateKey =
GenesisDelegateSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
deriving (Int -> SigningKey GenesisDelegateKey -> ShowS
[SigningKey GenesisDelegateKey] -> ShowS
SigningKey GenesisDelegateKey -> String
(Int -> SigningKey GenesisDelegateKey -> ShowS)
-> (SigningKey GenesisDelegateKey -> String)
-> ([SigningKey GenesisDelegateKey] -> ShowS)
-> Show (SigningKey GenesisDelegateKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey GenesisDelegateKey] -> ShowS
$cshowList :: [SigningKey GenesisDelegateKey] -> ShowS
show :: SigningKey GenesisDelegateKey -> String
$cshow :: SigningKey GenesisDelegateKey -> String
showsPrec :: Int -> SigningKey GenesisDelegateKey -> ShowS
$cshowsPrec :: Int -> SigningKey GenesisDelegateKey -> ShowS
Show, String -> SigningKey GenesisDelegateKey
(String -> SigningKey GenesisDelegateKey)
-> IsString (SigningKey GenesisDelegateKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey GenesisDelegateKey
$cfromString :: String -> SigningKey GenesisDelegateKey
IsString) via UsingRawBytesHex (SigningKey GenesisDelegateKey)
deriving newtype (Typeable (SigningKey GenesisDelegateKey)
Typeable (SigningKey GenesisDelegateKey)
-> (SigningKey GenesisDelegateKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisDelegateKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisDelegateKey] -> Size)
-> ToCBOR (SigningKey GenesisDelegateKey)
SigningKey GenesisDelegateKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisDelegateKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisDelegateKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisDelegateKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisDelegateKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisDelegateKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisDelegateKey) -> Size
toCBOR :: SigningKey GenesisDelegateKey -> Encoding
$ctoCBOR :: SigningKey GenesisDelegateKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey GenesisDelegateKey)
ToCBOR, Typeable (SigningKey GenesisDelegateKey)
Decoder s (SigningKey GenesisDelegateKey)
Typeable (SigningKey GenesisDelegateKey)
-> (forall s. Decoder s (SigningKey GenesisDelegateKey))
-> (Proxy (SigningKey GenesisDelegateKey) -> Text)
-> FromCBOR (SigningKey GenesisDelegateKey)
Proxy (SigningKey GenesisDelegateKey) -> Text
forall s. Decoder s (SigningKey GenesisDelegateKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey GenesisDelegateKey) -> Text
$clabel :: Proxy (SigningKey GenesisDelegateKey) -> Text
fromCBOR :: Decoder s (SigningKey GenesisDelegateKey)
$cfromCBOR :: forall s. Decoder s (SigningKey GenesisDelegateKey)
$cp1FromCBOR :: Typeable (SigningKey GenesisDelegateKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey GenesisDelegateKey)
SigningKey GenesisDelegateKey -> ByteString
HasTypeProxy (SigningKey GenesisDelegateKey)
-> (SigningKey GenesisDelegateKey -> ByteString)
-> (AsType (SigningKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateKey))
-> SerialiseAsCBOR (SigningKey GenesisDelegateKey)
AsType (SigningKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateKey)
$cdeserialiseFromCBOR :: AsType (SigningKey GenesisDelegateKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateKey)
serialiseToCBOR :: SigningKey GenesisDelegateKey -> ByteString
$cserialiseToCBOR :: SigningKey GenesisDelegateKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey GenesisDelegateKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType GenesisDelegateKey -> Crypto.Seed -> SigningKey GenesisDelegateKey
deterministicSigningKey :: AsType GenesisDelegateKey -> Seed -> SigningKey GenesisDelegateKey
deterministicSigningKey AsType GenesisDelegateKey
AsGenesisDelegateKey Seed
seed =
SignKeyDSIGN StandardCrypto -> SigningKey GenesisDelegateKey
GenesisDelegateSigningKey (Seed -> SignKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
Crypto.genKeyDSIGN Seed
seed)
deterministicSigningKeySeedSize :: AsType GenesisDelegateKey -> Word
deterministicSigningKeySeedSize :: AsType GenesisDelegateKey -> Word
deterministicSigningKeySeedSize AsType GenesisDelegateKey
AsGenesisDelegateKey =
Proxy Ed25519DSIGN -> Word
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
Crypto.seedSizeDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey GenesisDelegateKey -> VerificationKey GenesisDelegateKey
getVerificationKey :: SigningKey GenesisDelegateKey -> VerificationKey GenesisDelegateKey
getVerificationKey (GenesisDelegateSigningKey sk) =
VKey 'GenesisDelegate StandardCrypto
-> VerificationKey GenesisDelegateKey
GenesisDelegateVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto)
-> VKey 'GenesisDelegate StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> VerKeyDSIGN v
Crypto.deriveVerKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk))
verificationKeyHash :: VerificationKey GenesisDelegateKey -> Hash GenesisDelegateKey
verificationKeyHash :: VerificationKey GenesisDelegateKey -> Hash GenesisDelegateKey
verificationKeyHash (GenesisDelegateVerificationKey vkey) =
KeyHash 'GenesisDelegate StandardCrypto -> Hash GenesisDelegateKey
GenesisDelegateKeyHash (VKey 'GenesisDelegate StandardCrypto
-> KeyHash 'GenesisDelegate StandardCrypto
forall crypto (kd :: KeyRole).
Crypto crypto =>
VKey kd crypto -> KeyHash kd crypto
Shelley.hashKey VKey 'GenesisDelegate StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey GenesisDelegateKey) where
serialiseToRawBytes :: VerificationKey GenesisDelegateKey -> ByteString
serialiseToRawBytes (GenesisDelegateVerificationKey (Shelley.VKey vk)) =
VerKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> ByteString
Crypto.rawSerialiseVerKeyDSIGN VerKeyDSIGN Ed25519DSIGN
VerKeyDSIGN (DSIGN StandardCrypto)
vk
deserialiseFromRawBytes :: AsType (VerificationKey GenesisDelegateKey)
-> ByteString -> Maybe (VerificationKey GenesisDelegateKey)
deserialiseFromRawBytes (AsVerificationKey AsGenesisDelegateKey) ByteString
bs =
VKey 'GenesisDelegate StandardCrypto
-> VerificationKey GenesisDelegateKey
GenesisDelegateVerificationKey (VKey 'GenesisDelegate StandardCrypto
-> VerificationKey GenesisDelegateKey)
-> (VerKeyDSIGN Ed25519DSIGN
-> VKey 'GenesisDelegate StandardCrypto)
-> VerKeyDSIGN Ed25519DSIGN
-> VerificationKey GenesisDelegateKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'GenesisDelegate StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (VerKeyDSIGN Ed25519DSIGN -> VerificationKey GenesisDelegateKey)
-> Maybe (VerKeyDSIGN Ed25519DSIGN)
-> Maybe (VerificationKey GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN ByteString
bs
instance SerialiseAsRawBytes (SigningKey GenesisDelegateKey) where
serialiseToRawBytes :: SigningKey GenesisDelegateKey -> ByteString
serialiseToRawBytes (GenesisDelegateSigningKey sk) =
SignKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> ByteString
Crypto.rawSerialiseSignKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey GenesisDelegateKey)
-> ByteString -> Maybe (SigningKey GenesisDelegateKey)
deserialiseFromRawBytes (AsSigningKey AsGenesisDelegateKey) ByteString
bs =
SignKeyDSIGN Ed25519DSIGN -> SigningKey GenesisDelegateKey
SignKeyDSIGN StandardCrypto -> SigningKey GenesisDelegateKey
GenesisDelegateSigningKey (SignKeyDSIGN Ed25519DSIGN -> SigningKey GenesisDelegateKey)
-> Maybe (SignKeyDSIGN Ed25519DSIGN)
-> Maybe (SigningKey GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SignKeyDSIGN v)
Crypto.rawDeserialiseSignKeyDSIGN ByteString
bs
newtype instance Hash GenesisDelegateKey =
GenesisDelegateKeyHash (Shelley.KeyHash Shelley.GenesisDelegate StandardCrypto)
deriving (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
(Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool)
-> (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool)
-> Eq (Hash GenesisDelegateKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
$c/= :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
== :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
$c== :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
Eq, Eq (Hash GenesisDelegateKey)
Eq (Hash GenesisDelegateKey)
-> (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Ordering)
-> (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool)
-> (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool)
-> (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool)
-> (Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool)
-> (Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey)
-> (Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey)
-> Ord (Hash GenesisDelegateKey)
Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Ordering
Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey
$cmin :: Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey
max :: Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey
$cmax :: Hash GenesisDelegateKey
-> Hash GenesisDelegateKey -> Hash GenesisDelegateKey
>= :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
$c>= :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
> :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
$c> :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
<= :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
$c<= :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
< :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
$c< :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Bool
compare :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Ordering
$ccompare :: Hash GenesisDelegateKey -> Hash GenesisDelegateKey -> Ordering
$cp1Ord :: Eq (Hash GenesisDelegateKey)
Ord, Int -> Hash GenesisDelegateKey -> ShowS
[Hash GenesisDelegateKey] -> ShowS
Hash GenesisDelegateKey -> String
(Int -> Hash GenesisDelegateKey -> ShowS)
-> (Hash GenesisDelegateKey -> String)
-> ([Hash GenesisDelegateKey] -> ShowS)
-> Show (Hash GenesisDelegateKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash GenesisDelegateKey] -> ShowS
$cshowList :: [Hash GenesisDelegateKey] -> ShowS
show :: Hash GenesisDelegateKey -> String
$cshow :: Hash GenesisDelegateKey -> String
showsPrec :: Int -> Hash GenesisDelegateKey -> ShowS
$cshowsPrec :: Int -> Hash GenesisDelegateKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash GenesisDelegateKey) where
serialiseToRawBytes :: Hash GenesisDelegateKey -> ByteString
serialiseToRawBytes (GenesisDelegateKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash GenesisDelegateKey)
-> ByteString -> Maybe (Hash GenesisDelegateKey)
deserialiseFromRawBytes (AsHash AsGenesisDelegateKey) ByteString
bs =
KeyHash 'GenesisDelegate StandardCrypto -> Hash GenesisDelegateKey
GenesisDelegateKeyHash (KeyHash 'GenesisDelegate StandardCrypto
-> Hash GenesisDelegateKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'GenesisDelegate StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisDelegateKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'GenesisDelegate StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisDelegateKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey GenesisDelegateKey) where
textEnvelopeType :: AsType (VerificationKey GenesisDelegateKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey GenesisDelegateKey)
_ = TextEnvelopeType
"GenesisDelegateVerificationKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey GenesisDelegateKey) where
textEnvelopeType :: AsType (SigningKey GenesisDelegateKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey GenesisDelegateKey)
_ = TextEnvelopeType
"GenesisDelegateSigningKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance CastVerificationKeyRole GenesisDelegateKey StakePoolKey where
castVerificationKey :: VerificationKey GenesisDelegateKey -> VerificationKey StakePoolKey
castVerificationKey (GenesisDelegateVerificationKey (Shelley.VKey vkey)) =
VKey 'StakePool StandardCrypto -> VerificationKey StakePoolKey
StakePoolVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto)
-> VKey 'StakePool StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey VerKeyDSIGN (DSIGN StandardCrypto)
vkey)
instance CastSigningKeyRole GenesisDelegateKey StakePoolKey where
castSigningKey :: SigningKey GenesisDelegateKey -> SigningKey StakePoolKey
castSigningKey (GenesisDelegateSigningKey skey) =
SignKeyDSIGN StandardCrypto -> SigningKey StakePoolKey
StakePoolSigningKey SignKeyDSIGN StandardCrypto
skey
data GenesisDelegateExtendedKey
instance HasTypeProxy GenesisDelegateExtendedKey where
data AsType GenesisDelegateExtendedKey = AsGenesisDelegateExtendedKey
proxyToAsType :: Proxy GenesisDelegateExtendedKey
-> AsType GenesisDelegateExtendedKey
proxyToAsType Proxy GenesisDelegateExtendedKey
_ = AsType GenesisDelegateExtendedKey
AsGenesisDelegateExtendedKey
instance Key GenesisDelegateExtendedKey where
newtype VerificationKey GenesisDelegateExtendedKey =
GenesisDelegateExtendedVerificationKey Crypto.HD.XPub
deriving stock (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool
(VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool)
-> (VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool)
-> Eq (VerificationKey GenesisDelegateExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool
$c/= :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool
== :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool
$c== :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey -> Bool
Eq)
deriving anyclass HasTypeProxy (VerificationKey GenesisDelegateExtendedKey)
VerificationKey GenesisDelegateExtendedKey -> ByteString
HasTypeProxy (VerificationKey GenesisDelegateExtendedKey)
-> (VerificationKey GenesisDelegateExtendedKey -> ByteString)
-> (AsType (VerificationKey GenesisDelegateExtendedKey)
-> ByteString
-> Either
DecoderError (VerificationKey GenesisDelegateExtendedKey))
-> SerialiseAsCBOR (VerificationKey GenesisDelegateExtendedKey)
AsType (VerificationKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateExtendedKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisDelegateExtendedKey)
serialiseToCBOR :: VerificationKey GenesisDelegateExtendedKey -> ByteString
$cserialiseToCBOR :: VerificationKey GenesisDelegateExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey GenesisDelegateExtendedKey)
SerialiseAsCBOR
deriving (Int -> VerificationKey GenesisDelegateExtendedKey -> ShowS
[VerificationKey GenesisDelegateExtendedKey] -> ShowS
VerificationKey GenesisDelegateExtendedKey -> String
(Int -> VerificationKey GenesisDelegateExtendedKey -> ShowS)
-> (VerificationKey GenesisDelegateExtendedKey -> String)
-> ([VerificationKey GenesisDelegateExtendedKey] -> ShowS)
-> Show (VerificationKey GenesisDelegateExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey GenesisDelegateExtendedKey] -> ShowS
$cshowList :: [VerificationKey GenesisDelegateExtendedKey] -> ShowS
show :: VerificationKey GenesisDelegateExtendedKey -> String
$cshow :: VerificationKey GenesisDelegateExtendedKey -> String
showsPrec :: Int -> VerificationKey GenesisDelegateExtendedKey -> ShowS
$cshowsPrec :: Int -> VerificationKey GenesisDelegateExtendedKey -> ShowS
Show, String -> VerificationKey GenesisDelegateExtendedKey
(String -> VerificationKey GenesisDelegateExtendedKey)
-> IsString (VerificationKey GenesisDelegateExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey GenesisDelegateExtendedKey
$cfromString :: String -> VerificationKey GenesisDelegateExtendedKey
IsString) via UsingRawBytesHex (VerificationKey GenesisDelegateExtendedKey)
newtype SigningKey GenesisDelegateExtendedKey =
GenesisDelegateExtendedSigningKey Crypto.HD.XPrv
deriving anyclass HasTypeProxy (SigningKey GenesisDelegateExtendedKey)
SigningKey GenesisDelegateExtendedKey -> ByteString
HasTypeProxy (SigningKey GenesisDelegateExtendedKey)
-> (SigningKey GenesisDelegateExtendedKey -> ByteString)
-> (AsType (SigningKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateExtendedKey))
-> SerialiseAsCBOR (SigningKey GenesisDelegateExtendedKey)
AsType (SigningKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateExtendedKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateExtendedKey)
$cdeserialiseFromCBOR :: AsType (SigningKey GenesisDelegateExtendedKey)
-> ByteString
-> Either DecoderError (SigningKey GenesisDelegateExtendedKey)
serialiseToCBOR :: SigningKey GenesisDelegateExtendedKey -> ByteString
$cserialiseToCBOR :: SigningKey GenesisDelegateExtendedKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey GenesisDelegateExtendedKey)
SerialiseAsCBOR
deriving (Int -> SigningKey GenesisDelegateExtendedKey -> ShowS
[SigningKey GenesisDelegateExtendedKey] -> ShowS
SigningKey GenesisDelegateExtendedKey -> String
(Int -> SigningKey GenesisDelegateExtendedKey -> ShowS)
-> (SigningKey GenesisDelegateExtendedKey -> String)
-> ([SigningKey GenesisDelegateExtendedKey] -> ShowS)
-> Show (SigningKey GenesisDelegateExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey GenesisDelegateExtendedKey] -> ShowS
$cshowList :: [SigningKey GenesisDelegateExtendedKey] -> ShowS
show :: SigningKey GenesisDelegateExtendedKey -> String
$cshow :: SigningKey GenesisDelegateExtendedKey -> String
showsPrec :: Int -> SigningKey GenesisDelegateExtendedKey -> ShowS
$cshowsPrec :: Int -> SigningKey GenesisDelegateExtendedKey -> ShowS
Show, String -> SigningKey GenesisDelegateExtendedKey
(String -> SigningKey GenesisDelegateExtendedKey)
-> IsString (SigningKey GenesisDelegateExtendedKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey GenesisDelegateExtendedKey
$cfromString :: String -> SigningKey GenesisDelegateExtendedKey
IsString) via UsingRawBytesHex (SigningKey GenesisDelegateExtendedKey)
deterministicSigningKey :: AsType GenesisDelegateExtendedKey
-> Crypto.Seed
-> SigningKey GenesisDelegateExtendedKey
deterministicSigningKey :: AsType GenesisDelegateExtendedKey
-> Seed -> SigningKey GenesisDelegateExtendedKey
deterministicSigningKey AsType GenesisDelegateExtendedKey
AsGenesisDelegateExtendedKey Seed
seed =
XPrv -> SigningKey GenesisDelegateExtendedKey
GenesisDelegateExtendedSigningKey
(ByteString -> ByteString -> XPrv
forall passPhrase seed.
(ByteArrayAccess passPhrase, ByteArrayAccess seed) =>
seed -> passPhrase -> XPrv
Crypto.HD.generate ByteString
seedbs ByteString
BS.empty)
where
(ByteString
seedbs, Seed
_) = Word -> Seed -> (ByteString, Seed)
Crypto.getBytesFromSeedT Word
32 Seed
seed
deterministicSigningKeySeedSize :: AsType GenesisDelegateExtendedKey -> Word
deterministicSigningKeySeedSize :: AsType GenesisDelegateExtendedKey -> Word
deterministicSigningKeySeedSize AsType GenesisDelegateExtendedKey
AsGenesisDelegateExtendedKey = Word
32
getVerificationKey :: SigningKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey
getVerificationKey :: SigningKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateExtendedKey
getVerificationKey (GenesisDelegateExtendedSigningKey sk) =
XPub -> VerificationKey GenesisDelegateExtendedKey
GenesisDelegateExtendedVerificationKey (HasCallStack => XPrv -> XPub
XPrv -> XPub
Crypto.HD.toXPub XPrv
sk)
verificationKeyHash :: VerificationKey GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
verificationKeyHash :: VerificationKey GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
verificationKeyHash (GenesisDelegateExtendedVerificationKey vk) =
KeyHash 'Staking StandardCrypto -> Hash GenesisDelegateExtendedKey
GenesisDelegateExtendedKeyHash
(KeyHash 'Staking StandardCrypto
-> Hash GenesisDelegateExtendedKey)
-> (Hash Blake2b_224 XPub -> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 XPub
-> Hash GenesisDelegateExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash
(Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> (Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Hash Blake2b_224 XPub
-> KeyHash 'Staking StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 XPub
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_224 XPub -> Hash GenesisDelegateExtendedKey)
-> Hash Blake2b_224 XPub -> Hash GenesisDelegateExtendedKey
forall a b. (a -> b) -> a -> b
$ (XPub -> ByteString) -> XPub -> Hash Blake2b_224 XPub
forall h a. HashAlgorithm h => (a -> ByteString) -> a -> Hash h a
Crypto.hashWith XPub -> ByteString
Crypto.HD.xpubPublicKey XPub
vk
instance ToCBOR (VerificationKey GenesisDelegateExtendedKey) where
toCBOR :: VerificationKey GenesisDelegateExtendedKey -> Encoding
toCBOR (GenesisDelegateExtendedVerificationKey xpub) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPub -> ByteString
Crypto.HD.unXPub XPub
xpub)
instance FromCBOR (VerificationKey GenesisDelegateExtendedKey) where
fromCBOR :: Decoder s (VerificationKey GenesisDelegateExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (VerificationKey GenesisDelegateExtendedKey))
-> (XPub -> Decoder s (VerificationKey GenesisDelegateExtendedKey))
-> Either String XPub
-> Decoder s (VerificationKey GenesisDelegateExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (VerificationKey GenesisDelegateExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (VerificationKey GenesisDelegateExtendedKey
-> Decoder s (VerificationKey GenesisDelegateExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (VerificationKey GenesisDelegateExtendedKey
-> Decoder s (VerificationKey GenesisDelegateExtendedKey))
-> (XPub -> VerificationKey GenesisDelegateExtendedKey)
-> XPub
-> Decoder s (VerificationKey GenesisDelegateExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey GenesisDelegateExtendedKey
GenesisDelegateExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub (ByteString
bs :: ByteString))
instance ToCBOR (SigningKey GenesisDelegateExtendedKey) where
toCBOR :: SigningKey GenesisDelegateExtendedKey -> Encoding
toCBOR (GenesisDelegateExtendedSigningKey xprv) =
ByteString -> Encoding
forall a. ToCBOR a => a -> Encoding
toCBOR (XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv)
instance FromCBOR (SigningKey GenesisDelegateExtendedKey) where
fromCBOR :: Decoder s (SigningKey GenesisDelegateExtendedKey)
fromCBOR = do
ByteString
bs <- Decoder s ByteString
forall a s. FromCBOR a => Decoder s a
fromCBOR
(String -> Decoder s (SigningKey GenesisDelegateExtendedKey))
-> (XPrv -> Decoder s (SigningKey GenesisDelegateExtendedKey))
-> Either String XPrv
-> Decoder s (SigningKey GenesisDelegateExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Decoder s (SigningKey GenesisDelegateExtendedKey)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (SigningKey GenesisDelegateExtendedKey
-> Decoder s (SigningKey GenesisDelegateExtendedKey)
forall (m :: * -> *) a. Monad m => a -> m a
return (SigningKey GenesisDelegateExtendedKey
-> Decoder s (SigningKey GenesisDelegateExtendedKey))
-> (XPrv -> SigningKey GenesisDelegateExtendedKey)
-> XPrv
-> Decoder s (SigningKey GenesisDelegateExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey GenesisDelegateExtendedKey
GenesisDelegateExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv (ByteString
bs :: ByteString))
instance SerialiseAsRawBytes (VerificationKey GenesisDelegateExtendedKey) where
serialiseToRawBytes :: VerificationKey GenesisDelegateExtendedKey -> ByteString
serialiseToRawBytes (GenesisDelegateExtendedVerificationKey xpub) =
XPub -> ByteString
Crypto.HD.unXPub XPub
xpub
deserialiseFromRawBytes :: AsType (VerificationKey GenesisDelegateExtendedKey)
-> ByteString -> Maybe (VerificationKey GenesisDelegateExtendedKey)
deserialiseFromRawBytes (AsVerificationKey AsGenesisDelegateExtendedKey) ByteString
bs =
(String -> Maybe (VerificationKey GenesisDelegateExtendedKey))
-> (XPub -> Maybe (VerificationKey GenesisDelegateExtendedKey))
-> Either String XPub
-> Maybe (VerificationKey GenesisDelegateExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (VerificationKey GenesisDelegateExtendedKey)
-> String -> Maybe (VerificationKey GenesisDelegateExtendedKey)
forall a b. a -> b -> a
const Maybe (VerificationKey GenesisDelegateExtendedKey)
forall a. Maybe a
Nothing) (VerificationKey GenesisDelegateExtendedKey
-> Maybe (VerificationKey GenesisDelegateExtendedKey)
forall a. a -> Maybe a
Just (VerificationKey GenesisDelegateExtendedKey
-> Maybe (VerificationKey GenesisDelegateExtendedKey))
-> (XPub -> VerificationKey GenesisDelegateExtendedKey)
-> XPub
-> Maybe (VerificationKey GenesisDelegateExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> VerificationKey GenesisDelegateExtendedKey
GenesisDelegateExtendedVerificationKey)
(ByteString -> Either String XPub
Crypto.HD.xpub ByteString
bs)
instance SerialiseAsRawBytes (SigningKey GenesisDelegateExtendedKey) where
serialiseToRawBytes :: SigningKey GenesisDelegateExtendedKey -> ByteString
serialiseToRawBytes (GenesisDelegateExtendedSigningKey xprv) =
XPrv -> ByteString
Crypto.HD.unXPrv XPrv
xprv
deserialiseFromRawBytes :: AsType (SigningKey GenesisDelegateExtendedKey)
-> ByteString -> Maybe (SigningKey GenesisDelegateExtendedKey)
deserialiseFromRawBytes (AsSigningKey AsGenesisDelegateExtendedKey) ByteString
bs =
(String -> Maybe (SigningKey GenesisDelegateExtendedKey))
-> (XPrv -> Maybe (SigningKey GenesisDelegateExtendedKey))
-> Either String XPrv
-> Maybe (SigningKey GenesisDelegateExtendedKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (SigningKey GenesisDelegateExtendedKey)
-> String -> Maybe (SigningKey GenesisDelegateExtendedKey)
forall a b. a -> b -> a
const Maybe (SigningKey GenesisDelegateExtendedKey)
forall a. Maybe a
Nothing) (SigningKey GenesisDelegateExtendedKey
-> Maybe (SigningKey GenesisDelegateExtendedKey)
forall a. a -> Maybe a
Just (SigningKey GenesisDelegateExtendedKey
-> Maybe (SigningKey GenesisDelegateExtendedKey))
-> (XPrv -> SigningKey GenesisDelegateExtendedKey)
-> XPrv
-> Maybe (SigningKey GenesisDelegateExtendedKey)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPrv -> SigningKey GenesisDelegateExtendedKey
GenesisDelegateExtendedSigningKey)
(ByteString -> Either String XPrv
forall bin. ByteArrayAccess bin => bin -> Either String XPrv
Crypto.HD.xprv ByteString
bs)
newtype instance Hash GenesisDelegateExtendedKey =
GenesisDelegateExtendedKeyHash (Shelley.KeyHash Shelley.Staking StandardCrypto)
deriving (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
(Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool)
-> Eq (Hash GenesisDelegateExtendedKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
$c/= :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
== :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
$c== :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
Eq, Eq (Hash GenesisDelegateExtendedKey)
Eq (Hash GenesisDelegateExtendedKey)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Ordering)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey)
-> (Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey)
-> Ord (Hash GenesisDelegateExtendedKey)
Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Ordering
Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
$cmin :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
max :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
$cmax :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey
>= :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
$c>= :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
> :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
$c> :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
<= :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
$c<= :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
< :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
$c< :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Bool
compare :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Ordering
$ccompare :: Hash GenesisDelegateExtendedKey
-> Hash GenesisDelegateExtendedKey -> Ordering
$cp1Ord :: Eq (Hash GenesisDelegateExtendedKey)
Ord, Int -> Hash GenesisDelegateExtendedKey -> ShowS
[Hash GenesisDelegateExtendedKey] -> ShowS
Hash GenesisDelegateExtendedKey -> String
(Int -> Hash GenesisDelegateExtendedKey -> ShowS)
-> (Hash GenesisDelegateExtendedKey -> String)
-> ([Hash GenesisDelegateExtendedKey] -> ShowS)
-> Show (Hash GenesisDelegateExtendedKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash GenesisDelegateExtendedKey] -> ShowS
$cshowList :: [Hash GenesisDelegateExtendedKey] -> ShowS
show :: Hash GenesisDelegateExtendedKey -> String
$cshow :: Hash GenesisDelegateExtendedKey -> String
showsPrec :: Int -> Hash GenesisDelegateExtendedKey -> ShowS
$cshowsPrec :: Int -> Hash GenesisDelegateExtendedKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash GenesisDelegateExtendedKey) where
serialiseToRawBytes :: Hash GenesisDelegateExtendedKey -> ByteString
serialiseToRawBytes (GenesisDelegateExtendedKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash GenesisDelegateExtendedKey)
-> ByteString -> Maybe (Hash GenesisDelegateExtendedKey)
deserialiseFromRawBytes (AsHash AsGenesisDelegateExtendedKey) ByteString
bs =
KeyHash 'Staking StandardCrypto -> Hash GenesisDelegateExtendedKey
GenesisDelegateExtendedKeyHash (KeyHash 'Staking StandardCrypto
-> Hash GenesisDelegateExtendedKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisDelegateExtendedKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Staking StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisDelegateExtendedKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash GenesisDelegateExtendedKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey GenesisDelegateExtendedKey) where
textEnvelopeType :: AsType (VerificationKey GenesisDelegateExtendedKey)
-> TextEnvelopeType
textEnvelopeType AsType (VerificationKey GenesisDelegateExtendedKey)
_ = TextEnvelopeType
"GenesisDelegateExtendedVerificationKey_ed25519_bip32"
instance HasTextEnvelope (SigningKey GenesisDelegateExtendedKey) where
textEnvelopeType :: AsType (SigningKey GenesisDelegateExtendedKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey GenesisDelegateExtendedKey)
_ = TextEnvelopeType
"GenesisDelegateExtendedSigningKey_ed25519_bip32"
instance CastVerificationKeyRole GenesisDelegateExtendedKey GenesisDelegateKey where
castVerificationKey :: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey GenesisDelegateKey
castVerificationKey (GenesisDelegateExtendedVerificationKey vk) =
VKey 'GenesisDelegate StandardCrypto
-> VerificationKey GenesisDelegateKey
GenesisDelegateVerificationKey
(VKey 'GenesisDelegate StandardCrypto
-> VerificationKey GenesisDelegateKey)
-> (XPub -> VKey 'GenesisDelegate StandardCrypto)
-> XPub
-> VerificationKey GenesisDelegateKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'GenesisDelegate StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey
(VerKeyDSIGN Ed25519DSIGN -> VKey 'GenesisDelegate StandardCrypto)
-> (XPub -> VerKeyDSIGN Ed25519DSIGN)
-> XPub
-> VKey 'GenesisDelegate StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN
-> Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN
forall a. a -> Maybe a -> a
fromMaybe VerKeyDSIGN Ed25519DSIGN
forall a. a
impossible
(Maybe (VerKeyDSIGN Ed25519DSIGN) -> VerKeyDSIGN Ed25519DSIGN)
-> (XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> XPub
-> VerKeyDSIGN Ed25519DSIGN
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN
(ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN))
-> (XPub -> ByteString) -> XPub -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XPub -> ByteString
Crypto.HD.xpubPublicKey
(XPub -> VerificationKey GenesisDelegateKey)
-> XPub -> VerificationKey GenesisDelegateKey
forall a b. (a -> b) -> a -> b
$ XPub
vk
where
impossible :: a
impossible =
String -> a
forall a. HasCallStack => String -> a
error String
"castVerificationKey: byron and shelley key sizes do not match!"
data GenesisUTxOKey
instance HasTypeProxy GenesisUTxOKey where
data AsType GenesisUTxOKey = AsGenesisUTxOKey
proxyToAsType :: Proxy GenesisUTxOKey -> AsType GenesisUTxOKey
proxyToAsType Proxy GenesisUTxOKey
_ = AsType GenesisUTxOKey
AsGenesisUTxOKey
instance Key GenesisUTxOKey where
newtype VerificationKey GenesisUTxOKey =
GenesisUTxOVerificationKey (Shelley.VKey Shelley.Payment StandardCrypto)
deriving stock (VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool
(VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool)
-> (VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool)
-> Eq (VerificationKey GenesisUTxOKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool
$c/= :: VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool
== :: VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool
$c== :: VerificationKey GenesisUTxOKey
-> VerificationKey GenesisUTxOKey -> Bool
Eq)
deriving (Int -> VerificationKey GenesisUTxOKey -> ShowS
[VerificationKey GenesisUTxOKey] -> ShowS
VerificationKey GenesisUTxOKey -> String
(Int -> VerificationKey GenesisUTxOKey -> ShowS)
-> (VerificationKey GenesisUTxOKey -> String)
-> ([VerificationKey GenesisUTxOKey] -> ShowS)
-> Show (VerificationKey GenesisUTxOKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey GenesisUTxOKey] -> ShowS
$cshowList :: [VerificationKey GenesisUTxOKey] -> ShowS
show :: VerificationKey GenesisUTxOKey -> String
$cshow :: VerificationKey GenesisUTxOKey -> String
showsPrec :: Int -> VerificationKey GenesisUTxOKey -> ShowS
$cshowsPrec :: Int -> VerificationKey GenesisUTxOKey -> ShowS
Show, String -> VerificationKey GenesisUTxOKey
(String -> VerificationKey GenesisUTxOKey)
-> IsString (VerificationKey GenesisUTxOKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey GenesisUTxOKey
$cfromString :: String -> VerificationKey GenesisUTxOKey
IsString) via UsingRawBytesHex (VerificationKey GenesisUTxOKey)
deriving newtype (Typeable (VerificationKey GenesisUTxOKey)
Typeable (VerificationKey GenesisUTxOKey)
-> (VerificationKey GenesisUTxOKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisUTxOKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisUTxOKey] -> Size)
-> ToCBOR (VerificationKey GenesisUTxOKey)
VerificationKey GenesisUTxOKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisUTxOKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisUTxOKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisUTxOKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey GenesisUTxOKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisUTxOKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey GenesisUTxOKey) -> Size
toCBOR :: VerificationKey GenesisUTxOKey -> Encoding
$ctoCBOR :: VerificationKey GenesisUTxOKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey GenesisUTxOKey)
ToCBOR, Typeable (VerificationKey GenesisUTxOKey)
Decoder s (VerificationKey GenesisUTxOKey)
Typeable (VerificationKey GenesisUTxOKey)
-> (forall s. Decoder s (VerificationKey GenesisUTxOKey))
-> (Proxy (VerificationKey GenesisUTxOKey) -> Text)
-> FromCBOR (VerificationKey GenesisUTxOKey)
Proxy (VerificationKey GenesisUTxOKey) -> Text
forall s. Decoder s (VerificationKey GenesisUTxOKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey GenesisUTxOKey) -> Text
$clabel :: Proxy (VerificationKey GenesisUTxOKey) -> Text
fromCBOR :: Decoder s (VerificationKey GenesisUTxOKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey GenesisUTxOKey)
$cp1FromCBOR :: Typeable (VerificationKey GenesisUTxOKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey GenesisUTxOKey)
VerificationKey GenesisUTxOKey -> ByteString
HasTypeProxy (VerificationKey GenesisUTxOKey)
-> (VerificationKey GenesisUTxOKey -> ByteString)
-> (AsType (VerificationKey GenesisUTxOKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisUTxOKey))
-> SerialiseAsCBOR (VerificationKey GenesisUTxOKey)
AsType (VerificationKey GenesisUTxOKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisUTxOKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey GenesisUTxOKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisUTxOKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey GenesisUTxOKey)
-> ByteString
-> Either DecoderError (VerificationKey GenesisUTxOKey)
serialiseToCBOR :: VerificationKey GenesisUTxOKey -> ByteString
$cserialiseToCBOR :: VerificationKey GenesisUTxOKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey GenesisUTxOKey)
SerialiseAsCBOR
newtype SigningKey GenesisUTxOKey =
GenesisUTxOSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
deriving (Int -> SigningKey GenesisUTxOKey -> ShowS
[SigningKey GenesisUTxOKey] -> ShowS
SigningKey GenesisUTxOKey -> String
(Int -> SigningKey GenesisUTxOKey -> ShowS)
-> (SigningKey GenesisUTxOKey -> String)
-> ([SigningKey GenesisUTxOKey] -> ShowS)
-> Show (SigningKey GenesisUTxOKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey GenesisUTxOKey] -> ShowS
$cshowList :: [SigningKey GenesisUTxOKey] -> ShowS
show :: SigningKey GenesisUTxOKey -> String
$cshow :: SigningKey GenesisUTxOKey -> String
showsPrec :: Int -> SigningKey GenesisUTxOKey -> ShowS
$cshowsPrec :: Int -> SigningKey GenesisUTxOKey -> ShowS
Show, String -> SigningKey GenesisUTxOKey
(String -> SigningKey GenesisUTxOKey)
-> IsString (SigningKey GenesisUTxOKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey GenesisUTxOKey
$cfromString :: String -> SigningKey GenesisUTxOKey
IsString) via UsingRawBytesHex (SigningKey GenesisUTxOKey)
deriving newtype (Typeable (SigningKey GenesisUTxOKey)
Typeable (SigningKey GenesisUTxOKey)
-> (SigningKey GenesisUTxOKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisUTxOKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisUTxOKey] -> Size)
-> ToCBOR (SigningKey GenesisUTxOKey)
SigningKey GenesisUTxOKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisUTxOKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisUTxOKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisUTxOKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey GenesisUTxOKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisUTxOKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey GenesisUTxOKey) -> Size
toCBOR :: SigningKey GenesisUTxOKey -> Encoding
$ctoCBOR :: SigningKey GenesisUTxOKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey GenesisUTxOKey)
ToCBOR, Typeable (SigningKey GenesisUTxOKey)
Decoder s (SigningKey GenesisUTxOKey)
Typeable (SigningKey GenesisUTxOKey)
-> (forall s. Decoder s (SigningKey GenesisUTxOKey))
-> (Proxy (SigningKey GenesisUTxOKey) -> Text)
-> FromCBOR (SigningKey GenesisUTxOKey)
Proxy (SigningKey GenesisUTxOKey) -> Text
forall s. Decoder s (SigningKey GenesisUTxOKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey GenesisUTxOKey) -> Text
$clabel :: Proxy (SigningKey GenesisUTxOKey) -> Text
fromCBOR :: Decoder s (SigningKey GenesisUTxOKey)
$cfromCBOR :: forall s. Decoder s (SigningKey GenesisUTxOKey)
$cp1FromCBOR :: Typeable (SigningKey GenesisUTxOKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey GenesisUTxOKey)
SigningKey GenesisUTxOKey -> ByteString
HasTypeProxy (SigningKey GenesisUTxOKey)
-> (SigningKey GenesisUTxOKey -> ByteString)
-> (AsType (SigningKey GenesisUTxOKey)
-> ByteString -> Either DecoderError (SigningKey GenesisUTxOKey))
-> SerialiseAsCBOR (SigningKey GenesisUTxOKey)
AsType (SigningKey GenesisUTxOKey)
-> ByteString -> Either DecoderError (SigningKey GenesisUTxOKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey GenesisUTxOKey)
-> ByteString -> Either DecoderError (SigningKey GenesisUTxOKey)
$cdeserialiseFromCBOR :: AsType (SigningKey GenesisUTxOKey)
-> ByteString -> Either DecoderError (SigningKey GenesisUTxOKey)
serialiseToCBOR :: SigningKey GenesisUTxOKey -> ByteString
$cserialiseToCBOR :: SigningKey GenesisUTxOKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey GenesisUTxOKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType GenesisUTxOKey -> Crypto.Seed -> SigningKey GenesisUTxOKey
deterministicSigningKey :: AsType GenesisUTxOKey -> Seed -> SigningKey GenesisUTxOKey
deterministicSigningKey AsType GenesisUTxOKey
AsGenesisUTxOKey Seed
seed =
SignKeyDSIGN StandardCrypto -> SigningKey GenesisUTxOKey
GenesisUTxOSigningKey (Seed -> SignKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
Crypto.genKeyDSIGN Seed
seed)
deterministicSigningKeySeedSize :: AsType GenesisUTxOKey -> Word
deterministicSigningKeySeedSize :: AsType GenesisUTxOKey -> Word
deterministicSigningKeySeedSize AsType GenesisUTxOKey
AsGenesisUTxOKey =
Proxy Ed25519DSIGN -> Word
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
Crypto.seedSizeDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey GenesisUTxOKey -> VerificationKey GenesisUTxOKey
getVerificationKey :: SigningKey GenesisUTxOKey -> VerificationKey GenesisUTxOKey
getVerificationKey (GenesisUTxOSigningKey sk) =
VKey 'Payment StandardCrypto -> VerificationKey GenesisUTxOKey
GenesisUTxOVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto) -> VKey 'Payment StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> VerKeyDSIGN v
Crypto.deriveVerKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk))
verificationKeyHash :: VerificationKey GenesisUTxOKey -> Hash GenesisUTxOKey
verificationKeyHash :: VerificationKey GenesisUTxOKey -> Hash GenesisUTxOKey
verificationKeyHash (GenesisUTxOVerificationKey vkey) =
KeyHash 'Payment StandardCrypto -> Hash GenesisUTxOKey
GenesisUTxOKeyHash (VKey 'Payment StandardCrypto -> KeyHash 'Payment StandardCrypto
forall crypto (kd :: KeyRole).
Crypto crypto =>
VKey kd crypto -> KeyHash kd crypto
Shelley.hashKey VKey 'Payment StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey GenesisUTxOKey) where
serialiseToRawBytes :: VerificationKey GenesisUTxOKey -> ByteString
serialiseToRawBytes (GenesisUTxOVerificationKey (Shelley.VKey vk)) =
VerKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> ByteString
Crypto.rawSerialiseVerKeyDSIGN VerKeyDSIGN Ed25519DSIGN
VerKeyDSIGN (DSIGN StandardCrypto)
vk
deserialiseFromRawBytes :: AsType (VerificationKey GenesisUTxOKey)
-> ByteString -> Maybe (VerificationKey GenesisUTxOKey)
deserialiseFromRawBytes (AsVerificationKey AsGenesisUTxOKey) ByteString
bs =
VKey 'Payment StandardCrypto -> VerificationKey GenesisUTxOKey
GenesisUTxOVerificationKey (VKey 'Payment StandardCrypto -> VerificationKey GenesisUTxOKey)
-> (VerKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto)
-> VerKeyDSIGN Ed25519DSIGN
-> VerificationKey GenesisUTxOKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'Payment StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (VerKeyDSIGN Ed25519DSIGN -> VerificationKey GenesisUTxOKey)
-> Maybe (VerKeyDSIGN Ed25519DSIGN)
-> Maybe (VerificationKey GenesisUTxOKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN ByteString
bs
instance SerialiseAsRawBytes (SigningKey GenesisUTxOKey) where
serialiseToRawBytes :: SigningKey GenesisUTxOKey -> ByteString
serialiseToRawBytes (GenesisUTxOSigningKey sk) =
SignKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> ByteString
Crypto.rawSerialiseSignKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey GenesisUTxOKey)
-> ByteString -> Maybe (SigningKey GenesisUTxOKey)
deserialiseFromRawBytes (AsSigningKey AsGenesisUTxOKey) ByteString
bs =
SignKeyDSIGN Ed25519DSIGN -> SigningKey GenesisUTxOKey
SignKeyDSIGN StandardCrypto -> SigningKey GenesisUTxOKey
GenesisUTxOSigningKey (SignKeyDSIGN Ed25519DSIGN -> SigningKey GenesisUTxOKey)
-> Maybe (SignKeyDSIGN Ed25519DSIGN)
-> Maybe (SigningKey GenesisUTxOKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SignKeyDSIGN v)
Crypto.rawDeserialiseSignKeyDSIGN ByteString
bs
newtype instance Hash GenesisUTxOKey =
GenesisUTxOKeyHash (Shelley.KeyHash Shelley.Payment StandardCrypto)
deriving (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
(Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool)
-> (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool)
-> Eq (Hash GenesisUTxOKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
$c/= :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
== :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
$c== :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
Eq, Eq (Hash GenesisUTxOKey)
Eq (Hash GenesisUTxOKey)
-> (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Ordering)
-> (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool)
-> (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool)
-> (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool)
-> (Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool)
-> (Hash GenesisUTxOKey
-> Hash GenesisUTxOKey -> Hash GenesisUTxOKey)
-> (Hash GenesisUTxOKey
-> Hash GenesisUTxOKey -> Hash GenesisUTxOKey)
-> Ord (Hash GenesisUTxOKey)
Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Ordering
Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Hash GenesisUTxOKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Hash GenesisUTxOKey
$cmin :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Hash GenesisUTxOKey
max :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Hash GenesisUTxOKey
$cmax :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Hash GenesisUTxOKey
>= :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
$c>= :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
> :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
$c> :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
<= :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
$c<= :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
< :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
$c< :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Bool
compare :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Ordering
$ccompare :: Hash GenesisUTxOKey -> Hash GenesisUTxOKey -> Ordering
$cp1Ord :: Eq (Hash GenesisUTxOKey)
Ord, Int -> Hash GenesisUTxOKey -> ShowS
[Hash GenesisUTxOKey] -> ShowS
Hash GenesisUTxOKey -> String
(Int -> Hash GenesisUTxOKey -> ShowS)
-> (Hash GenesisUTxOKey -> String)
-> ([Hash GenesisUTxOKey] -> ShowS)
-> Show (Hash GenesisUTxOKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash GenesisUTxOKey] -> ShowS
$cshowList :: [Hash GenesisUTxOKey] -> ShowS
show :: Hash GenesisUTxOKey -> String
$cshow :: Hash GenesisUTxOKey -> String
showsPrec :: Int -> Hash GenesisUTxOKey -> ShowS
$cshowsPrec :: Int -> Hash GenesisUTxOKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash GenesisUTxOKey) where
serialiseToRawBytes :: Hash GenesisUTxOKey -> ByteString
serialiseToRawBytes (GenesisUTxOKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType (Hash GenesisUTxOKey)
-> ByteString -> Maybe (Hash GenesisUTxOKey)
deserialiseFromRawBytes (AsHash AsGenesisUTxOKey) ByteString
bs =
KeyHash 'Payment StandardCrypto -> Hash GenesisUTxOKey
GenesisUTxOKeyHash (KeyHash 'Payment StandardCrypto -> Hash GenesisUTxOKey)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisUTxOKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'Payment StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> Hash GenesisUTxOKey)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe (Hash GenesisUTxOKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey GenesisUTxOKey) where
textEnvelopeType :: AsType (VerificationKey GenesisUTxOKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey GenesisUTxOKey)
_ = TextEnvelopeType
"GenesisUTxOVerificationKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey GenesisUTxOKey) where
textEnvelopeType :: AsType (SigningKey GenesisUTxOKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey GenesisUTxOKey)
_ = TextEnvelopeType
"GenesisUTxOSigningKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance CastVerificationKeyRole GenesisUTxOKey PaymentKey where
castVerificationKey :: VerificationKey GenesisUTxOKey -> VerificationKey PaymentKey
castVerificationKey (GenesisUTxOVerificationKey (Shelley.VKey vkey)) =
VKey 'Payment StandardCrypto -> VerificationKey PaymentKey
PaymentVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto) -> VKey 'Payment StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey VerKeyDSIGN (DSIGN StandardCrypto)
vkey)
instance CastSigningKeyRole GenesisUTxOKey PaymentKey where
castSigningKey :: SigningKey GenesisUTxOKey -> SigningKey PaymentKey
castSigningKey (GenesisUTxOSigningKey skey) =
SignKeyDSIGN StandardCrypto -> SigningKey PaymentKey
PaymentSigningKey SignKeyDSIGN StandardCrypto
skey
genesisUTxOPseudoTxIn :: NetworkId -> Hash GenesisUTxOKey -> TxIn
genesisUTxOPseudoTxIn :: NetworkId -> Hash GenesisUTxOKey -> TxIn
genesisUTxOPseudoTxIn NetworkId
nw (GenesisUTxOKeyHash kh) =
TxIn StandardShelley -> TxIn
fromShelleyTxIn (Addr StandardShelley -> TxIn StandardShelley
forall era. Era era => Addr era -> TxIn era
Shelley.initialFundsPseudoTxIn Addr StandardShelley
addr)
where
addr :: Addr StandardShelley
addr = Network
-> PaymentCredential StandardShelley
-> StakeReference StandardShelley
-> Addr StandardShelley
forall era.
Network -> PaymentCredential era -> StakeReference era -> Addr era
Shelley.Addr
(NetworkId -> Network
toShelleyNetwork NetworkId
nw)
(KeyHash 'Payment (Crypto StandardShelley)
-> PaymentCredential StandardShelley
forall (kr :: KeyRole) era.
KeyHash kr (Crypto era) -> Credential kr era
Shelley.KeyHashObj KeyHash 'Payment StandardCrypto
KeyHash 'Payment (Crypto StandardShelley)
kh)
StakeReference StandardShelley
forall era. StakeReference era
Shelley.StakeRefNull
fromShelleyTxIn :: Shelley.TxIn StandardShelley -> TxIn
fromShelleyTxIn :: TxIn StandardShelley -> TxIn
fromShelleyTxIn (Shelley.TxIn TxId StandardShelley
txid Natural
txix) =
TxId -> TxIx -> TxIn
TxIn (TxId StandardShelley -> TxId
fromShelleyTxId TxId StandardShelley
txid) (Word -> TxIx
TxIx (Natural -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
txix))
fromShelleyTxId :: Shelley.TxId StandardShelley -> TxId
fromShelleyTxId :: TxId StandardShelley -> TxId
fromShelleyTxId (Shelley.TxId Hash (Crypto StandardShelley) EraIndependentTxBody
h) =
Hash StandardCrypto () -> TxId
TxId (Hash Blake2b_256 EraIndependentTxBody -> Hash Blake2b_256 ()
forall h a b. Hash h a -> Hash h b
Crypto.castHash Hash Blake2b_256 EraIndependentTxBody
Hash (Crypto StandardShelley) EraIndependentTxBody
h)
data StakePoolKey
instance HasTypeProxy StakePoolKey where
data AsType StakePoolKey = AsStakePoolKey
proxyToAsType :: Proxy StakePoolKey -> AsType StakePoolKey
proxyToAsType Proxy StakePoolKey
_ = AsType StakePoolKey
AsStakePoolKey
instance Key StakePoolKey where
newtype VerificationKey StakePoolKey =
StakePoolVerificationKey (Shelley.VKey Shelley.StakePool StandardCrypto)
deriving stock (VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool
(VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool)
-> (VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool)
-> Eq (VerificationKey StakePoolKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool
$c/= :: VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool
== :: VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool
$c== :: VerificationKey StakePoolKey
-> VerificationKey StakePoolKey -> Bool
Eq)
deriving (Int -> VerificationKey StakePoolKey -> ShowS
[VerificationKey StakePoolKey] -> ShowS
VerificationKey StakePoolKey -> String
(Int -> VerificationKey StakePoolKey -> ShowS)
-> (VerificationKey StakePoolKey -> String)
-> ([VerificationKey StakePoolKey] -> ShowS)
-> Show (VerificationKey StakePoolKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey StakePoolKey] -> ShowS
$cshowList :: [VerificationKey StakePoolKey] -> ShowS
show :: VerificationKey StakePoolKey -> String
$cshow :: VerificationKey StakePoolKey -> String
showsPrec :: Int -> VerificationKey StakePoolKey -> ShowS
$cshowsPrec :: Int -> VerificationKey StakePoolKey -> ShowS
Show, String -> VerificationKey StakePoolKey
(String -> VerificationKey StakePoolKey)
-> IsString (VerificationKey StakePoolKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey StakePoolKey
$cfromString :: String -> VerificationKey StakePoolKey
IsString) via UsingRawBytesHex (VerificationKey StakePoolKey)
deriving newtype (Typeable (VerificationKey StakePoolKey)
Typeable (VerificationKey StakePoolKey)
-> (VerificationKey StakePoolKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakePoolKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakePoolKey] -> Size)
-> ToCBOR (VerificationKey StakePoolKey)
VerificationKey StakePoolKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakePoolKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakePoolKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakePoolKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey StakePoolKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakePoolKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey StakePoolKey) -> Size
toCBOR :: VerificationKey StakePoolKey -> Encoding
$ctoCBOR :: VerificationKey StakePoolKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey StakePoolKey)
ToCBOR, Typeable (VerificationKey StakePoolKey)
Decoder s (VerificationKey StakePoolKey)
Typeable (VerificationKey StakePoolKey)
-> (forall s. Decoder s (VerificationKey StakePoolKey))
-> (Proxy (VerificationKey StakePoolKey) -> Text)
-> FromCBOR (VerificationKey StakePoolKey)
Proxy (VerificationKey StakePoolKey) -> Text
forall s. Decoder s (VerificationKey StakePoolKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey StakePoolKey) -> Text
$clabel :: Proxy (VerificationKey StakePoolKey) -> Text
fromCBOR :: Decoder s (VerificationKey StakePoolKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey StakePoolKey)
$cp1FromCBOR :: Typeable (VerificationKey StakePoolKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey StakePoolKey)
VerificationKey StakePoolKey -> ByteString
HasTypeProxy (VerificationKey StakePoolKey)
-> (VerificationKey StakePoolKey -> ByteString)
-> (AsType (VerificationKey StakePoolKey)
-> ByteString
-> Either DecoderError (VerificationKey StakePoolKey))
-> SerialiseAsCBOR (VerificationKey StakePoolKey)
AsType (VerificationKey StakePoolKey)
-> ByteString -> Either DecoderError (VerificationKey StakePoolKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey StakePoolKey)
-> ByteString -> Either DecoderError (VerificationKey StakePoolKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey StakePoolKey)
-> ByteString -> Either DecoderError (VerificationKey StakePoolKey)
serialiseToCBOR :: VerificationKey StakePoolKey -> ByteString
$cserialiseToCBOR :: VerificationKey StakePoolKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey StakePoolKey)
SerialiseAsCBOR
newtype SigningKey StakePoolKey =
StakePoolSigningKey (Shelley.SignKeyDSIGN StandardCrypto)
deriving (Int -> SigningKey StakePoolKey -> ShowS
[SigningKey StakePoolKey] -> ShowS
SigningKey StakePoolKey -> String
(Int -> SigningKey StakePoolKey -> ShowS)
-> (SigningKey StakePoolKey -> String)
-> ([SigningKey StakePoolKey] -> ShowS)
-> Show (SigningKey StakePoolKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey StakePoolKey] -> ShowS
$cshowList :: [SigningKey StakePoolKey] -> ShowS
show :: SigningKey StakePoolKey -> String
$cshow :: SigningKey StakePoolKey -> String
showsPrec :: Int -> SigningKey StakePoolKey -> ShowS
$cshowsPrec :: Int -> SigningKey StakePoolKey -> ShowS
Show, String -> SigningKey StakePoolKey
(String -> SigningKey StakePoolKey)
-> IsString (SigningKey StakePoolKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey StakePoolKey
$cfromString :: String -> SigningKey StakePoolKey
IsString) via UsingRawBytesHex (SigningKey StakePoolKey)
deriving newtype (Typeable (SigningKey StakePoolKey)
Typeable (SigningKey StakePoolKey)
-> (SigningKey StakePoolKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakePoolKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakePoolKey] -> Size)
-> ToCBOR (SigningKey StakePoolKey)
SigningKey StakePoolKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakePoolKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakePoolKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakePoolKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey StakePoolKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakePoolKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey StakePoolKey) -> Size
toCBOR :: SigningKey StakePoolKey -> Encoding
$ctoCBOR :: SigningKey StakePoolKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey StakePoolKey)
ToCBOR, Typeable (SigningKey StakePoolKey)
Decoder s (SigningKey StakePoolKey)
Typeable (SigningKey StakePoolKey)
-> (forall s. Decoder s (SigningKey StakePoolKey))
-> (Proxy (SigningKey StakePoolKey) -> Text)
-> FromCBOR (SigningKey StakePoolKey)
Proxy (SigningKey StakePoolKey) -> Text
forall s. Decoder s (SigningKey StakePoolKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey StakePoolKey) -> Text
$clabel :: Proxy (SigningKey StakePoolKey) -> Text
fromCBOR :: Decoder s (SigningKey StakePoolKey)
$cfromCBOR :: forall s. Decoder s (SigningKey StakePoolKey)
$cp1FromCBOR :: Typeable (SigningKey StakePoolKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey StakePoolKey)
SigningKey StakePoolKey -> ByteString
HasTypeProxy (SigningKey StakePoolKey)
-> (SigningKey StakePoolKey -> ByteString)
-> (AsType (SigningKey StakePoolKey)
-> ByteString -> Either DecoderError (SigningKey StakePoolKey))
-> SerialiseAsCBOR (SigningKey StakePoolKey)
AsType (SigningKey StakePoolKey)
-> ByteString -> Either DecoderError (SigningKey StakePoolKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey StakePoolKey)
-> ByteString -> Either DecoderError (SigningKey StakePoolKey)
$cdeserialiseFromCBOR :: AsType (SigningKey StakePoolKey)
-> ByteString -> Either DecoderError (SigningKey StakePoolKey)
serialiseToCBOR :: SigningKey StakePoolKey -> ByteString
$cserialiseToCBOR :: SigningKey StakePoolKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey StakePoolKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType StakePoolKey -> Crypto.Seed -> SigningKey StakePoolKey
deterministicSigningKey :: AsType StakePoolKey -> Seed -> SigningKey StakePoolKey
deterministicSigningKey AsType StakePoolKey
AsStakePoolKey Seed
seed =
SignKeyDSIGN StandardCrypto -> SigningKey StakePoolKey
StakePoolSigningKey (Seed -> SignKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => Seed -> SignKeyDSIGN v
Crypto.genKeyDSIGN Seed
seed)
deterministicSigningKeySeedSize :: AsType StakePoolKey -> Word
deterministicSigningKeySeedSize :: AsType StakePoolKey -> Word
deterministicSigningKeySeedSize AsType StakePoolKey
AsStakePoolKey =
Proxy Ed25519DSIGN -> Word
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> Word
Crypto.seedSizeDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey StakePoolKey -> VerificationKey StakePoolKey
getVerificationKey :: SigningKey StakePoolKey -> VerificationKey StakePoolKey
getVerificationKey (StakePoolSigningKey sk) =
VKey 'StakePool StandardCrypto -> VerificationKey StakePoolKey
StakePoolVerificationKey (VerKeyDSIGN (DSIGN StandardCrypto)
-> VKey 'StakePool StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (SignKeyDSIGN Ed25519DSIGN -> VerKeyDSIGN Ed25519DSIGN
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> VerKeyDSIGN v
Crypto.deriveVerKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk))
verificationKeyHash :: VerificationKey StakePoolKey -> Hash StakePoolKey
verificationKeyHash :: VerificationKey StakePoolKey -> PoolId
verificationKeyHash (StakePoolVerificationKey vkey) =
KeyHash 'StakePool StandardCrypto -> PoolId
StakePoolKeyHash (VKey 'StakePool StandardCrypto -> KeyHash 'StakePool StandardCrypto
forall crypto (kd :: KeyRole).
Crypto crypto =>
VKey kd crypto -> KeyHash kd crypto
Shelley.hashKey VKey 'StakePool StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey StakePoolKey) where
serialiseToRawBytes :: VerificationKey StakePoolKey -> ByteString
serialiseToRawBytes (StakePoolVerificationKey (Shelley.VKey vk)) =
VerKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> ByteString
Crypto.rawSerialiseVerKeyDSIGN VerKeyDSIGN Ed25519DSIGN
VerKeyDSIGN (DSIGN StandardCrypto)
vk
deserialiseFromRawBytes :: AsType (VerificationKey StakePoolKey)
-> ByteString -> Maybe (VerificationKey StakePoolKey)
deserialiseFromRawBytes (AsVerificationKey AsStakePoolKey) ByteString
bs =
VKey 'StakePool StandardCrypto -> VerificationKey StakePoolKey
StakePoolVerificationKey (VKey 'StakePool StandardCrypto -> VerificationKey StakePoolKey)
-> (VerKeyDSIGN Ed25519DSIGN -> VKey 'StakePool StandardCrypto)
-> VerKeyDSIGN Ed25519DSIGN
-> VerificationKey StakePoolKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerKeyDSIGN Ed25519DSIGN -> VKey 'StakePool StandardCrypto
forall (kd :: KeyRole) crypto.
VerKeyDSIGN (DSIGN crypto) -> VKey kd crypto
Shelley.VKey (VerKeyDSIGN Ed25519DSIGN -> VerificationKey StakePoolKey)
-> Maybe (VerKeyDSIGN Ed25519DSIGN)
-> Maybe (VerificationKey StakePoolKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (VerKeyDSIGN v)
Crypto.rawDeserialiseVerKeyDSIGN ByteString
bs
instance SerialiseAsRawBytes (SigningKey StakePoolKey) where
serialiseToRawBytes :: SigningKey StakePoolKey -> ByteString
serialiseToRawBytes (StakePoolSigningKey sk) =
SignKeyDSIGN Ed25519DSIGN -> ByteString
forall v. DSIGNAlgorithm v => SignKeyDSIGN v -> ByteString
Crypto.rawSerialiseSignKeyDSIGN SignKeyDSIGN Ed25519DSIGN
SignKeyDSIGN StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey StakePoolKey)
-> ByteString -> Maybe (SigningKey StakePoolKey)
deserialiseFromRawBytes (AsSigningKey AsStakePoolKey) ByteString
bs =
SignKeyDSIGN Ed25519DSIGN -> SigningKey StakePoolKey
SignKeyDSIGN StandardCrypto -> SigningKey StakePoolKey
StakePoolSigningKey (SignKeyDSIGN Ed25519DSIGN -> SigningKey StakePoolKey)
-> Maybe (SignKeyDSIGN Ed25519DSIGN)
-> Maybe (SigningKey StakePoolKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyDSIGN Ed25519DSIGN)
forall v. DSIGNAlgorithm v => ByteString -> Maybe (SignKeyDSIGN v)
Crypto.rawDeserialiseSignKeyDSIGN ByteString
bs
instance SerialiseAsBech32 (VerificationKey StakePoolKey) where
bech32PrefixFor :: VerificationKey StakePoolKey -> Text
bech32PrefixFor VerificationKey StakePoolKey
_ = Text
"pool_vk"
bech32PrefixesPermitted :: AsType (VerificationKey StakePoolKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey StakePoolKey)
_ = [Text
"pool_vk"]
instance SerialiseAsBech32 (SigningKey StakePoolKey) where
bech32PrefixFor :: SigningKey StakePoolKey -> Text
bech32PrefixFor SigningKey StakePoolKey
_ = Text
"pool_sk"
bech32PrefixesPermitted :: AsType (SigningKey StakePoolKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey StakePoolKey)
_ = [Text
"pool_sk"]
newtype instance Hash StakePoolKey =
StakePoolKeyHash (Shelley.KeyHash Shelley.StakePool StandardCrypto)
deriving (PoolId -> PoolId -> Bool
(PoolId -> PoolId -> Bool)
-> (PoolId -> PoolId -> Bool) -> Eq PoolId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PoolId -> PoolId -> Bool
$c/= :: PoolId -> PoolId -> Bool
== :: PoolId -> PoolId -> Bool
$c== :: PoolId -> PoolId -> Bool
Eq, Eq PoolId
Eq PoolId
-> (PoolId -> PoolId -> Ordering)
-> (PoolId -> PoolId -> Bool)
-> (PoolId -> PoolId -> Bool)
-> (PoolId -> PoolId -> Bool)
-> (PoolId -> PoolId -> Bool)
-> (PoolId -> PoolId -> PoolId)
-> (PoolId -> PoolId -> PoolId)
-> Ord PoolId
PoolId -> PoolId -> Bool
PoolId -> PoolId -> Ordering
PoolId -> PoolId -> PoolId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PoolId -> PoolId -> PoolId
$cmin :: PoolId -> PoolId -> PoolId
max :: PoolId -> PoolId -> PoolId
$cmax :: PoolId -> PoolId -> PoolId
>= :: PoolId -> PoolId -> Bool
$c>= :: PoolId -> PoolId -> Bool
> :: PoolId -> PoolId -> Bool
$c> :: PoolId -> PoolId -> Bool
<= :: PoolId -> PoolId -> Bool
$c<= :: PoolId -> PoolId -> Bool
< :: PoolId -> PoolId -> Bool
$c< :: PoolId -> PoolId -> Bool
compare :: PoolId -> PoolId -> Ordering
$ccompare :: PoolId -> PoolId -> Ordering
$cp1Ord :: Eq PoolId
Ord, Int -> PoolId -> ShowS
[PoolId] -> ShowS
PoolId -> String
(Int -> PoolId -> ShowS)
-> (PoolId -> String) -> ([PoolId] -> ShowS) -> Show PoolId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PoolId] -> ShowS
$cshowList :: [PoolId] -> ShowS
show :: PoolId -> String
$cshow :: PoolId -> String
showsPrec :: Int -> PoolId -> ShowS
$cshowsPrec :: Int -> PoolId -> ShowS
Show)
instance SerialiseAsRawBytes (Hash StakePoolKey) where
serialiseToRawBytes :: PoolId -> ByteString
serialiseToRawBytes (StakePoolKeyHash (Shelley.KeyHash vkh)) =
Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
Hash (ADDRHASH StandardCrypto) (VerKeyDSIGN (DSIGN StandardCrypto))
vkh
deserialiseFromRawBytes :: AsType PoolId -> ByteString -> Maybe PoolId
deserialiseFromRawBytes (AsHash AsStakePoolKey) ByteString
bs =
KeyHash 'StakePool StandardCrypto -> PoolId
StakePoolKeyHash (KeyHash 'StakePool StandardCrypto -> PoolId)
-> (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'StakePool StandardCrypto)
-> Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> PoolId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN)
-> KeyHash 'StakePool StandardCrypto
forall (discriminator :: KeyRole) crypto.
Hash (ADDRHASH crypto) (VerKeyDSIGN (DSIGN crypto))
-> KeyHash discriminator crypto
Shelley.KeyHash (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN) -> PoolId)
-> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
-> Maybe PoolId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_224 (VerKeyDSIGN Ed25519DSIGN))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance SerialiseAsBech32 (Hash StakePoolKey) where
bech32PrefixFor :: PoolId -> Text
bech32PrefixFor PoolId
_ = Text
"pool"
bech32PrefixesPermitted :: AsType PoolId -> [Text]
bech32PrefixesPermitted AsType PoolId
_ = [Text
"pool"]
instance ToJSON (Hash StakePoolKey) where
toJSON :: PoolId -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (PoolId -> Text) -> PoolId -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PoolId -> Text
forall a. SerialiseAsBech32 a => a -> Text
serialiseToBech32
instance HasTextEnvelope (VerificationKey StakePoolKey) where
textEnvelopeType :: AsType (VerificationKey StakePoolKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey StakePoolKey)
_ = TextEnvelopeType
"StakePoolVerificationKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey StakePoolKey) where
textEnvelopeType :: AsType (SigningKey StakePoolKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey StakePoolKey)
_ = TextEnvelopeType
"StakePoolSigningKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy Ed25519DSIGN -> String
forall v (proxy :: * -> *). DSIGNAlgorithm v => proxy v -> String
Crypto.algorithmNameDSIGN Proxy Ed25519DSIGN
Proxy (DSIGN StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.DSIGN StandardCrypto)
proxy :: Proxy (DSIGN StandardCrypto)
proxy = Proxy (DSIGN StandardCrypto)
forall k (t :: k). Proxy t
Proxy
data KesKey
instance HasTypeProxy KesKey where
data AsType KesKey = AsKesKey
proxyToAsType :: Proxy KesKey -> AsType KesKey
proxyToAsType Proxy KesKey
_ = AsType KesKey
AsKesKey
instance Key KesKey where
newtype VerificationKey KesKey =
KesVerificationKey (Shelley.VerKeyKES StandardCrypto)
deriving stock (VerificationKey KesKey -> VerificationKey KesKey -> Bool
(VerificationKey KesKey -> VerificationKey KesKey -> Bool)
-> (VerificationKey KesKey -> VerificationKey KesKey -> Bool)
-> Eq (VerificationKey KesKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
$c/= :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
== :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
$c== :: VerificationKey KesKey -> VerificationKey KesKey -> Bool
Eq)
deriving (Int -> VerificationKey KesKey -> ShowS
[VerificationKey KesKey] -> ShowS
VerificationKey KesKey -> String
(Int -> VerificationKey KesKey -> ShowS)
-> (VerificationKey KesKey -> String)
-> ([VerificationKey KesKey] -> ShowS)
-> Show (VerificationKey KesKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey KesKey] -> ShowS
$cshowList :: [VerificationKey KesKey] -> ShowS
show :: VerificationKey KesKey -> String
$cshow :: VerificationKey KesKey -> String
showsPrec :: Int -> VerificationKey KesKey -> ShowS
$cshowsPrec :: Int -> VerificationKey KesKey -> ShowS
Show, String -> VerificationKey KesKey
(String -> VerificationKey KesKey)
-> IsString (VerificationKey KesKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey KesKey
$cfromString :: String -> VerificationKey KesKey
IsString) via UsingRawBytesHex (VerificationKey KesKey)
deriving newtype (Typeable (VerificationKey KesKey)
Typeable (VerificationKey KesKey)
-> (VerificationKey KesKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size)
-> ToCBOR (VerificationKey KesKey)
VerificationKey KesKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey KesKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey KesKey) -> Size
toCBOR :: VerificationKey KesKey -> Encoding
$ctoCBOR :: VerificationKey KesKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey KesKey)
ToCBOR, Typeable (VerificationKey KesKey)
Decoder s (VerificationKey KesKey)
Typeable (VerificationKey KesKey)
-> (forall s. Decoder s (VerificationKey KesKey))
-> (Proxy (VerificationKey KesKey) -> Text)
-> FromCBOR (VerificationKey KesKey)
Proxy (VerificationKey KesKey) -> Text
forall s. Decoder s (VerificationKey KesKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey KesKey) -> Text
$clabel :: Proxy (VerificationKey KesKey) -> Text
fromCBOR :: Decoder s (VerificationKey KesKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey KesKey)
$cp1FromCBOR :: Typeable (VerificationKey KesKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey KesKey)
VerificationKey KesKey -> ByteString
HasTypeProxy (VerificationKey KesKey)
-> (VerificationKey KesKey -> ByteString)
-> (AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey))
-> SerialiseAsCBOR (VerificationKey KesKey)
AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey KesKey)
-> ByteString -> Either DecoderError (VerificationKey KesKey)
serialiseToCBOR :: VerificationKey KesKey -> ByteString
$cserialiseToCBOR :: VerificationKey KesKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey KesKey)
SerialiseAsCBOR
newtype SigningKey KesKey =
KesSigningKey (Shelley.SignKeyKES StandardCrypto)
deriving (Int -> SigningKey KesKey -> ShowS
[SigningKey KesKey] -> ShowS
SigningKey KesKey -> String
(Int -> SigningKey KesKey -> ShowS)
-> (SigningKey KesKey -> String)
-> ([SigningKey KesKey] -> ShowS)
-> Show (SigningKey KesKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey KesKey] -> ShowS
$cshowList :: [SigningKey KesKey] -> ShowS
show :: SigningKey KesKey -> String
$cshow :: SigningKey KesKey -> String
showsPrec :: Int -> SigningKey KesKey -> ShowS
$cshowsPrec :: Int -> SigningKey KesKey -> ShowS
Show, String -> SigningKey KesKey
(String -> SigningKey KesKey) -> IsString (SigningKey KesKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey KesKey
$cfromString :: String -> SigningKey KesKey
IsString) via UsingRawBytesHex (SigningKey KesKey)
deriving newtype (Typeable (SigningKey KesKey)
Typeable (SigningKey KesKey)
-> (SigningKey KesKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size)
-> ToCBOR (SigningKey KesKey)
SigningKey KesKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey KesKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey KesKey) -> Size
toCBOR :: SigningKey KesKey -> Encoding
$ctoCBOR :: SigningKey KesKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey KesKey)
ToCBOR, Typeable (SigningKey KesKey)
Decoder s (SigningKey KesKey)
Typeable (SigningKey KesKey)
-> (forall s. Decoder s (SigningKey KesKey))
-> (Proxy (SigningKey KesKey) -> Text)
-> FromCBOR (SigningKey KesKey)
Proxy (SigningKey KesKey) -> Text
forall s. Decoder s (SigningKey KesKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey KesKey) -> Text
$clabel :: Proxy (SigningKey KesKey) -> Text
fromCBOR :: Decoder s (SigningKey KesKey)
$cfromCBOR :: forall s. Decoder s (SigningKey KesKey)
$cp1FromCBOR :: Typeable (SigningKey KesKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey KesKey)
SigningKey KesKey -> ByteString
HasTypeProxy (SigningKey KesKey)
-> (SigningKey KesKey -> ByteString)
-> (AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey))
-> SerialiseAsCBOR (SigningKey KesKey)
AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey)
$cdeserialiseFromCBOR :: AsType (SigningKey KesKey)
-> ByteString -> Either DecoderError (SigningKey KesKey)
serialiseToCBOR :: SigningKey KesKey -> ByteString
$cserialiseToCBOR :: SigningKey KesKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey KesKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType KesKey -> Crypto.Seed -> SigningKey KesKey
deterministicSigningKey :: AsType KesKey -> Seed -> SigningKey KesKey
deterministicSigningKey AsType KesKey
AsKesKey =
SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> SigningKey KesKey
SignKeyKES StandardCrypto -> SigningKey KesKey
KesSigningKey
(SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> SigningKey KesKey)
-> (Seed -> SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Seed
-> SigningKey KesKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MLockedSizedBytes 32
-> SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
forall v.
KESAlgorithm v =>
MLockedSizedBytes (SeedSizeKES v) -> SignKeyKES v
Crypto.genKeyKES
(MLockedSizedBytes 32
-> SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> (Seed -> MLockedSizedBytes 32)
-> Seed
-> SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> MLockedSizedBytes 32
forall (n :: Nat). KnownNat n => ByteString -> MLockedSizedBytes n
Crypto.mlsbFromByteString
(ByteString -> MLockedSizedBytes 32)
-> (Seed -> ByteString) -> Seed -> MLockedSizedBytes 32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seed -> ByteString
Crypto.getSeedBytes
deterministicSigningKeySeedSize :: AsType KesKey -> Word
deterministicSigningKeySeedSize :: AsType KesKey -> Word
deterministicSigningKeySeedSize AsType KesKey
AsKesKey =
Proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> Word
forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> Word
Crypto.seedSizeKES Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy :: Proxy (KES StandardCrypto)
proxy = Proxy (KES StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey KesKey -> VerificationKey KesKey
getVerificationKey :: SigningKey KesKey -> VerificationKey KesKey
getVerificationKey (KesSigningKey sk) =
VerKeyKES StandardCrypto -> VerificationKey KesKey
KesVerificationKey (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
forall v. KESAlgorithm v => SignKeyKES v -> VerKeyKES v
Crypto.deriveVerKeyKES SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
SignKeyKES StandardCrypto
sk)
verificationKeyHash :: VerificationKey KesKey -> Hash KesKey
verificationKeyHash :: VerificationKey KesKey -> Hash KesKey
verificationKeyHash (KesVerificationKey vkey) =
Hash StandardCrypto (VerKeyKES StandardCrypto) -> Hash KesKey
KesKeyHash (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall v h.
(KESAlgorithm v, HashAlgorithm h) =>
VerKeyKES v -> Hash h (VerKeyKES v)
Crypto.hashVerKeyKES VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
VerKeyKES StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey KesKey) where
serialiseToRawBytes :: VerificationKey KesKey -> ByteString
serialiseToRawBytes (KesVerificationKey vk) =
VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> ByteString
forall v. KESAlgorithm v => VerKeyKES v -> ByteString
Crypto.rawSerialiseVerKeyKES VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
VerKeyKES StandardCrypto
vk
deserialiseFromRawBytes :: AsType (VerificationKey KesKey)
-> ByteString -> Maybe (VerificationKey KesKey)
deserialiseFromRawBytes (AsVerificationKey AsKesKey) ByteString
bs =
VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> VerificationKey KesKey
VerKeyKES StandardCrypto -> VerificationKey KesKey
KesVerificationKey (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> VerificationKey KesKey)
-> Maybe (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Maybe (VerificationKey KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ByteString -> Maybe (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall v. KESAlgorithm v => ByteString -> Maybe (VerKeyKES v)
Crypto.rawDeserialiseVerKeyKES ByteString
bs
instance SerialiseAsRawBytes (SigningKey KesKey) where
serialiseToRawBytes :: SigningKey KesKey -> ByteString
serialiseToRawBytes (KesSigningKey sk) =
SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> ByteString
forall v. KESAlgorithm v => SignKeyKES v -> ByteString
Crypto.rawSerialiseSignKeyKES SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
SignKeyKES StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey KesKey)
-> ByteString -> Maybe (SigningKey KesKey)
deserialiseFromRawBytes (AsSigningKey AsKesKey) ByteString
bs =
SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256) -> SigningKey KesKey
SignKeyKES StandardCrypto -> SigningKey KesKey
KesSigningKey (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)
-> SigningKey KesKey)
-> Maybe (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Maybe (SigningKey KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
forall v. KESAlgorithm v => ByteString -> Maybe (SignKeyKES v)
Crypto.rawDeserialiseSignKeyKES ByteString
bs
instance SerialiseAsBech32 (VerificationKey KesKey) where
bech32PrefixFor :: VerificationKey KesKey -> Text
bech32PrefixFor VerificationKey KesKey
_ = Text
"kes_vk"
bech32PrefixesPermitted :: AsType (VerificationKey KesKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey KesKey)
_ = [Text
"kes_vk"]
instance SerialiseAsBech32 (SigningKey KesKey) where
bech32PrefixFor :: SigningKey KesKey -> Text
bech32PrefixFor SigningKey KesKey
_ = Text
"kes_sk"
bech32PrefixesPermitted :: AsType (SigningKey KesKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey KesKey)
_ = [Text
"kes_sk"]
newtype instance Hash KesKey =
KesKeyHash (Shelley.Hash StandardCrypto
(Shelley.VerKeyKES StandardCrypto))
deriving (Hash KesKey -> Hash KesKey -> Bool
(Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool) -> Eq (Hash KesKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash KesKey -> Hash KesKey -> Bool
$c/= :: Hash KesKey -> Hash KesKey -> Bool
== :: Hash KesKey -> Hash KesKey -> Bool
$c== :: Hash KesKey -> Hash KesKey -> Bool
Eq, Eq (Hash KesKey)
Eq (Hash KesKey)
-> (Hash KesKey -> Hash KesKey -> Ordering)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Bool)
-> (Hash KesKey -> Hash KesKey -> Hash KesKey)
-> (Hash KesKey -> Hash KesKey -> Hash KesKey)
-> Ord (Hash KesKey)
Hash KesKey -> Hash KesKey -> Bool
Hash KesKey -> Hash KesKey -> Ordering
Hash KesKey -> Hash KesKey -> Hash KesKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash KesKey -> Hash KesKey -> Hash KesKey
$cmin :: Hash KesKey -> Hash KesKey -> Hash KesKey
max :: Hash KesKey -> Hash KesKey -> Hash KesKey
$cmax :: Hash KesKey -> Hash KesKey -> Hash KesKey
>= :: Hash KesKey -> Hash KesKey -> Bool
$c>= :: Hash KesKey -> Hash KesKey -> Bool
> :: Hash KesKey -> Hash KesKey -> Bool
$c> :: Hash KesKey -> Hash KesKey -> Bool
<= :: Hash KesKey -> Hash KesKey -> Bool
$c<= :: Hash KesKey -> Hash KesKey -> Bool
< :: Hash KesKey -> Hash KesKey -> Bool
$c< :: Hash KesKey -> Hash KesKey -> Bool
compare :: Hash KesKey -> Hash KesKey -> Ordering
$ccompare :: Hash KesKey -> Hash KesKey -> Ordering
$cp1Ord :: Eq (Hash KesKey)
Ord, Int -> Hash KesKey -> ShowS
[Hash KesKey] -> ShowS
Hash KesKey -> String
(Int -> Hash KesKey -> ShowS)
-> (Hash KesKey -> String)
-> ([Hash KesKey] -> ShowS)
-> Show (Hash KesKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash KesKey] -> ShowS
$cshowList :: [Hash KesKey] -> ShowS
show :: Hash KesKey -> String
$cshow :: Hash KesKey -> String
showsPrec :: Int -> Hash KesKey -> ShowS
$cshowsPrec :: Int -> Hash KesKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash KesKey) where
serialiseToRawBytes :: Hash KesKey -> ByteString
serialiseToRawBytes (KesKeyHash vkh) =
Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
Hash StandardCrypto (VerKeyKES StandardCrypto)
vkh
deserialiseFromRawBytes :: AsType (Hash KesKey) -> ByteString -> Maybe (Hash KesKey)
deserialiseFromRawBytes (AsHash AsKesKey) ByteString
bs =
Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Hash KesKey
Hash StandardCrypto (VerKeyKES StandardCrypto) -> Hash KesKey
KesKeyHash (Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256))
-> Hash KesKey)
-> Maybe
(Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)))
-> Maybe (Hash KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString
-> Maybe
(Hash Blake2b_256 (VerKeyKES (Sum6KES Ed25519DSIGN Blake2b_256)))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey KesKey) where
textEnvelopeType :: AsType (VerificationKey KesKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey KesKey)
_ = TextEnvelopeType
"KesVerificationKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> String
forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> String
Crypto.algorithmNameKES Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy :: Proxy (KES StandardCrypto)
proxy = Proxy (KES StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey KesKey) where
textEnvelopeType :: AsType (SigningKey KesKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey KesKey)
_ = TextEnvelopeType
"KesSigningKey_"
TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy (Sum6KES Ed25519DSIGN Blake2b_256) -> String
forall v (proxy :: * -> *). KESAlgorithm v => proxy v -> String
Crypto.algorithmNameKES Proxy (Sum6KES Ed25519DSIGN Blake2b_256)
Proxy (KES StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.KES StandardCrypto)
proxy :: Proxy (KES StandardCrypto)
proxy = Proxy (KES StandardCrypto)
forall k (t :: k). Proxy t
Proxy
data VrfKey
instance HasTypeProxy VrfKey where
data AsType VrfKey = AsVrfKey
proxyToAsType :: Proxy VrfKey -> AsType VrfKey
proxyToAsType Proxy VrfKey
_ = AsType VrfKey
AsVrfKey
instance Key VrfKey where
newtype VerificationKey VrfKey =
VrfVerificationKey (Shelley.VerKeyVRF StandardCrypto)
deriving stock (VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
(VerificationKey VrfKey -> VerificationKey VrfKey -> Bool)
-> (VerificationKey VrfKey -> VerificationKey VrfKey -> Bool)
-> Eq (VerificationKey VrfKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
$c/= :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
== :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
$c== :: VerificationKey VrfKey -> VerificationKey VrfKey -> Bool
Eq)
deriving (Int -> VerificationKey VrfKey -> ShowS
[VerificationKey VrfKey] -> ShowS
VerificationKey VrfKey -> String
(Int -> VerificationKey VrfKey -> ShowS)
-> (VerificationKey VrfKey -> String)
-> ([VerificationKey VrfKey] -> ShowS)
-> Show (VerificationKey VrfKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VerificationKey VrfKey] -> ShowS
$cshowList :: [VerificationKey VrfKey] -> ShowS
show :: VerificationKey VrfKey -> String
$cshow :: VerificationKey VrfKey -> String
showsPrec :: Int -> VerificationKey VrfKey -> ShowS
$cshowsPrec :: Int -> VerificationKey VrfKey -> ShowS
Show, String -> VerificationKey VrfKey
(String -> VerificationKey VrfKey)
-> IsString (VerificationKey VrfKey)
forall a. (String -> a) -> IsString a
fromString :: String -> VerificationKey VrfKey
$cfromString :: String -> VerificationKey VrfKey
IsString) via UsingRawBytesHex (VerificationKey VrfKey)
deriving newtype (Typeable (VerificationKey VrfKey)
Typeable (VerificationKey VrfKey)
-> (VerificationKey VrfKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size)
-> ToCBOR (VerificationKey VrfKey)
VerificationKey VrfKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [VerificationKey VrfKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (VerificationKey VrfKey) -> Size
toCBOR :: VerificationKey VrfKey -> Encoding
$ctoCBOR :: VerificationKey VrfKey -> Encoding
$cp1ToCBOR :: Typeable (VerificationKey VrfKey)
ToCBOR, Typeable (VerificationKey VrfKey)
Decoder s (VerificationKey VrfKey)
Typeable (VerificationKey VrfKey)
-> (forall s. Decoder s (VerificationKey VrfKey))
-> (Proxy (VerificationKey VrfKey) -> Text)
-> FromCBOR (VerificationKey VrfKey)
Proxy (VerificationKey VrfKey) -> Text
forall s. Decoder s (VerificationKey VrfKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (VerificationKey VrfKey) -> Text
$clabel :: Proxy (VerificationKey VrfKey) -> Text
fromCBOR :: Decoder s (VerificationKey VrfKey)
$cfromCBOR :: forall s. Decoder s (VerificationKey VrfKey)
$cp1FromCBOR :: Typeable (VerificationKey VrfKey)
FromCBOR)
deriving anyclass HasTypeProxy (VerificationKey VrfKey)
VerificationKey VrfKey -> ByteString
HasTypeProxy (VerificationKey VrfKey)
-> (VerificationKey VrfKey -> ByteString)
-> (AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey))
-> SerialiseAsCBOR (VerificationKey VrfKey)
AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey)
$cdeserialiseFromCBOR :: AsType (VerificationKey VrfKey)
-> ByteString -> Either DecoderError (VerificationKey VrfKey)
serialiseToCBOR :: VerificationKey VrfKey -> ByteString
$cserialiseToCBOR :: VerificationKey VrfKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (VerificationKey VrfKey)
SerialiseAsCBOR
newtype SigningKey VrfKey =
VrfSigningKey (Shelley.SignKeyVRF StandardCrypto)
deriving (Int -> SigningKey VrfKey -> ShowS
[SigningKey VrfKey] -> ShowS
SigningKey VrfKey -> String
(Int -> SigningKey VrfKey -> ShowS)
-> (SigningKey VrfKey -> String)
-> ([SigningKey VrfKey] -> ShowS)
-> Show (SigningKey VrfKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningKey VrfKey] -> ShowS
$cshowList :: [SigningKey VrfKey] -> ShowS
show :: SigningKey VrfKey -> String
$cshow :: SigningKey VrfKey -> String
showsPrec :: Int -> SigningKey VrfKey -> ShowS
$cshowsPrec :: Int -> SigningKey VrfKey -> ShowS
Show, String -> SigningKey VrfKey
(String -> SigningKey VrfKey) -> IsString (SigningKey VrfKey)
forall a. (String -> a) -> IsString a
fromString :: String -> SigningKey VrfKey
$cfromString :: String -> SigningKey VrfKey
IsString) via UsingRawBytesHex (SigningKey VrfKey)
deriving newtype (Typeable (SigningKey VrfKey)
Typeable (SigningKey VrfKey)
-> (SigningKey VrfKey -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size)
-> ToCBOR (SigningKey VrfKey)
SigningKey VrfKey -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [SigningKey VrfKey] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (SigningKey VrfKey) -> Size
toCBOR :: SigningKey VrfKey -> Encoding
$ctoCBOR :: SigningKey VrfKey -> Encoding
$cp1ToCBOR :: Typeable (SigningKey VrfKey)
ToCBOR, Typeable (SigningKey VrfKey)
Decoder s (SigningKey VrfKey)
Typeable (SigningKey VrfKey)
-> (forall s. Decoder s (SigningKey VrfKey))
-> (Proxy (SigningKey VrfKey) -> Text)
-> FromCBOR (SigningKey VrfKey)
Proxy (SigningKey VrfKey) -> Text
forall s. Decoder s (SigningKey VrfKey)
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy (SigningKey VrfKey) -> Text
$clabel :: Proxy (SigningKey VrfKey) -> Text
fromCBOR :: Decoder s (SigningKey VrfKey)
$cfromCBOR :: forall s. Decoder s (SigningKey VrfKey)
$cp1FromCBOR :: Typeable (SigningKey VrfKey)
FromCBOR)
deriving anyclass HasTypeProxy (SigningKey VrfKey)
SigningKey VrfKey -> ByteString
HasTypeProxy (SigningKey VrfKey)
-> (SigningKey VrfKey -> ByteString)
-> (AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey))
-> SerialiseAsCBOR (SigningKey VrfKey)
AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey)
forall a.
HasTypeProxy a
-> (a -> ByteString)
-> (AsType a -> ByteString -> Either DecoderError a)
-> SerialiseAsCBOR a
deserialiseFromCBOR :: AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey)
$cdeserialiseFromCBOR :: AsType (SigningKey VrfKey)
-> ByteString -> Either DecoderError (SigningKey VrfKey)
serialiseToCBOR :: SigningKey VrfKey -> ByteString
$cserialiseToCBOR :: SigningKey VrfKey -> ByteString
$cp1SerialiseAsCBOR :: HasTypeProxy (SigningKey VrfKey)
SerialiseAsCBOR
deterministicSigningKey :: AsType VrfKey -> Crypto.Seed -> SigningKey VrfKey
deterministicSigningKey :: AsType VrfKey -> Seed -> SigningKey VrfKey
deterministicSigningKey AsType VrfKey
AsVrfKey Seed
seed =
SignKeyVRF StandardCrypto -> SigningKey VrfKey
VrfSigningKey (Seed -> SignKeyVRF PraosVRF
forall v. VRFAlgorithm v => Seed -> SignKeyVRF v
Crypto.genKeyVRF Seed
seed)
deterministicSigningKeySeedSize :: AsType VrfKey -> Word
deterministicSigningKeySeedSize :: AsType VrfKey -> Word
deterministicSigningKeySeedSize AsType VrfKey
AsVrfKey =
Proxy PraosVRF -> Word
forall v (proxy :: * -> *). VRFAlgorithm v => proxy v -> Word
Crypto.seedSizeVRF Proxy PraosVRF
Proxy (VRF StandardCrypto)
proxy
where
proxy :: Proxy (Shelley.VRF StandardCrypto)
proxy :: Proxy (VRF StandardCrypto)
proxy = Proxy (VRF StandardCrypto)
forall k (t :: k). Proxy t
Proxy
getVerificationKey :: SigningKey VrfKey -> VerificationKey VrfKey
getVerificationKey :: SigningKey VrfKey -> VerificationKey VrfKey
getVerificationKey (VrfSigningKey sk) =
VerKeyVRF StandardCrypto -> VerificationKey VrfKey
VrfVerificationKey (SignKeyVRF PraosVRF -> VerKeyVRF PraosVRF
forall v. VRFAlgorithm v => SignKeyVRF v -> VerKeyVRF v
Crypto.deriveVerKeyVRF SignKeyVRF PraosVRF
SignKeyVRF StandardCrypto
sk)
verificationKeyHash :: VerificationKey VrfKey -> Hash VrfKey
verificationKeyHash :: VerificationKey VrfKey -> Hash VrfKey
verificationKeyHash (VrfVerificationKey vkey) =
Hash StandardCrypto (VerKeyVRF StandardCrypto) -> Hash VrfKey
VrfKeyHash (VerKeyVRF PraosVRF -> Hash Blake2b_256 (VerKeyVRF PraosVRF)
forall v h.
(VRFAlgorithm v, HashAlgorithm h) =>
VerKeyVRF v -> Hash h (VerKeyVRF v)
Shelley.hashVerKeyVRF VerKeyVRF PraosVRF
VerKeyVRF StandardCrypto
vkey)
instance SerialiseAsRawBytes (VerificationKey VrfKey) where
serialiseToRawBytes :: VerificationKey VrfKey -> ByteString
serialiseToRawBytes (VrfVerificationKey vk) =
VerKeyVRF PraosVRF -> ByteString
forall v. VRFAlgorithm v => VerKeyVRF v -> ByteString
Crypto.rawSerialiseVerKeyVRF VerKeyVRF PraosVRF
VerKeyVRF StandardCrypto
vk
deserialiseFromRawBytes :: AsType (VerificationKey VrfKey)
-> ByteString -> Maybe (VerificationKey VrfKey)
deserialiseFromRawBytes (AsVerificationKey AsVrfKey) ByteString
bs =
VerKeyVRF PraosVRF -> VerificationKey VrfKey
VerKeyVRF StandardCrypto -> VerificationKey VrfKey
VrfVerificationKey (VerKeyVRF PraosVRF -> VerificationKey VrfKey)
-> Maybe (VerKeyVRF PraosVRF) -> Maybe (VerificationKey VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (VerKeyVRF PraosVRF)
forall v. VRFAlgorithm v => ByteString -> Maybe (VerKeyVRF v)
Crypto.rawDeserialiseVerKeyVRF ByteString
bs
instance SerialiseAsRawBytes (SigningKey VrfKey) where
serialiseToRawBytes :: SigningKey VrfKey -> ByteString
serialiseToRawBytes (VrfSigningKey sk) =
SignKeyVRF PraosVRF -> ByteString
forall v. VRFAlgorithm v => SignKeyVRF v -> ByteString
Crypto.rawSerialiseSignKeyVRF SignKeyVRF PraosVRF
SignKeyVRF StandardCrypto
sk
deserialiseFromRawBytes :: AsType (SigningKey VrfKey)
-> ByteString -> Maybe (SigningKey VrfKey)
deserialiseFromRawBytes (AsSigningKey AsVrfKey) ByteString
bs =
SignKeyVRF PraosVRF -> SigningKey VrfKey
SignKeyVRF StandardCrypto -> SigningKey VrfKey
VrfSigningKey (SignKeyVRF PraosVRF -> SigningKey VrfKey)
-> Maybe (SignKeyVRF PraosVRF) -> Maybe (SigningKey VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (SignKeyVRF PraosVRF)
forall v. VRFAlgorithm v => ByteString -> Maybe (SignKeyVRF v)
Crypto.rawDeserialiseSignKeyVRF ByteString
bs
instance SerialiseAsBech32 (VerificationKey VrfKey) where
bech32PrefixFor :: VerificationKey VrfKey -> Text
bech32PrefixFor VerificationKey VrfKey
_ = Text
"vrf_vk"
bech32PrefixesPermitted :: AsType (VerificationKey VrfKey) -> [Text]
bech32PrefixesPermitted AsType (VerificationKey VrfKey)
_ = [Text
"vrf_vk"]
instance SerialiseAsBech32 (SigningKey VrfKey) where
bech32PrefixFor :: SigningKey VrfKey -> Text
bech32PrefixFor SigningKey VrfKey
_ = Text
"vrf_sk"
bech32PrefixesPermitted :: AsType (SigningKey VrfKey) -> [Text]
bech32PrefixesPermitted AsType (SigningKey VrfKey)
_ = [Text
"vrf_sk"]
newtype instance Hash VrfKey =
VrfKeyHash (Shelley.Hash StandardCrypto
(Shelley.VerKeyVRF StandardCrypto))
deriving (Hash VrfKey -> Hash VrfKey -> Bool
(Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool) -> Eq (Hash VrfKey)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hash VrfKey -> Hash VrfKey -> Bool
$c/= :: Hash VrfKey -> Hash VrfKey -> Bool
== :: Hash VrfKey -> Hash VrfKey -> Bool
$c== :: Hash VrfKey -> Hash VrfKey -> Bool
Eq, Eq (Hash VrfKey)
Eq (Hash VrfKey)
-> (Hash VrfKey -> Hash VrfKey -> Ordering)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Bool)
-> (Hash VrfKey -> Hash VrfKey -> Hash VrfKey)
-> (Hash VrfKey -> Hash VrfKey -> Hash VrfKey)
-> Ord (Hash VrfKey)
Hash VrfKey -> Hash VrfKey -> Bool
Hash VrfKey -> Hash VrfKey -> Ordering
Hash VrfKey -> Hash VrfKey -> Hash VrfKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
$cmin :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
max :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
$cmax :: Hash VrfKey -> Hash VrfKey -> Hash VrfKey
>= :: Hash VrfKey -> Hash VrfKey -> Bool
$c>= :: Hash VrfKey -> Hash VrfKey -> Bool
> :: Hash VrfKey -> Hash VrfKey -> Bool
$c> :: Hash VrfKey -> Hash VrfKey -> Bool
<= :: Hash VrfKey -> Hash VrfKey -> Bool
$c<= :: Hash VrfKey -> Hash VrfKey -> Bool
< :: Hash VrfKey -> Hash VrfKey -> Bool
$c< :: Hash VrfKey -> Hash VrfKey -> Bool
compare :: Hash VrfKey -> Hash VrfKey -> Ordering
$ccompare :: Hash VrfKey -> Hash VrfKey -> Ordering
$cp1Ord :: Eq (Hash VrfKey)
Ord, Int -> Hash VrfKey -> ShowS
[Hash VrfKey] -> ShowS
Hash VrfKey -> String
(Int -> Hash VrfKey -> ShowS)
-> (Hash VrfKey -> String)
-> ([Hash VrfKey] -> ShowS)
-> Show (Hash VrfKey)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hash VrfKey] -> ShowS
$cshowList :: [Hash VrfKey] -> ShowS
show :: Hash VrfKey -> String
$cshow :: Hash VrfKey -> String
showsPrec :: Int -> Hash VrfKey -> ShowS
$cshowsPrec :: Int -> Hash VrfKey -> ShowS
Show)
instance SerialiseAsRawBytes (Hash VrfKey) where
serialiseToRawBytes :: Hash VrfKey -> ByteString
serialiseToRawBytes (VrfKeyHash vkh) =
Hash Blake2b_256 (VerKeyVRF PraosVRF) -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytes Hash Blake2b_256 (VerKeyVRF PraosVRF)
Hash StandardCrypto (VerKeyVRF StandardCrypto)
vkh
deserialiseFromRawBytes :: AsType (Hash VrfKey) -> ByteString -> Maybe (Hash VrfKey)
deserialiseFromRawBytes (AsHash AsVrfKey) ByteString
bs =
Hash Blake2b_256 (VerKeyVRF PraosVRF) -> Hash VrfKey
Hash StandardCrypto (VerKeyVRF StandardCrypto) -> Hash VrfKey
VrfKeyHash (Hash Blake2b_256 (VerKeyVRF PraosVRF) -> Hash VrfKey)
-> Maybe (Hash Blake2b_256 (VerKeyVRF PraosVRF))
-> Maybe (Hash VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Hash Blake2b_256 (VerKeyVRF PraosVRF))
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytes ByteString
bs
instance HasTextEnvelope (VerificationKey VrfKey) where
textEnvelopeType :: AsType (VerificationKey VrfKey) -> TextEnvelopeType
textEnvelopeType AsType (VerificationKey VrfKey)
_ = TextEnvelopeType
"VrfVerificationKey_" TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy PraosVRF -> String
forall v (proxy :: * -> *). VRFAlgorithm v => proxy v -> String
Crypto.algorithmNameVRF Proxy PraosVRF
Proxy (VRF StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.VRF StandardCrypto)
proxy :: Proxy (VRF StandardCrypto)
proxy = Proxy (VRF StandardCrypto)
forall k (t :: k). Proxy t
Proxy
instance HasTextEnvelope (SigningKey VrfKey) where
textEnvelopeType :: AsType (SigningKey VrfKey) -> TextEnvelopeType
textEnvelopeType AsType (SigningKey VrfKey)
_ = TextEnvelopeType
"VrfSigningKey_" TextEnvelopeType -> TextEnvelopeType -> TextEnvelopeType
forall a. Semigroup a => a -> a -> a
<> String -> TextEnvelopeType
forall a. IsString a => String -> a
fromString (Proxy PraosVRF -> String
forall v (proxy :: * -> *). VRFAlgorithm v => proxy v -> String
Crypto.algorithmNameVRF Proxy PraosVRF
Proxy (VRF StandardCrypto)
proxy)
where
proxy :: Proxy (Shelley.VRF StandardCrypto)
proxy :: Proxy (VRF StandardCrypto)
proxy = Proxy (VRF StandardCrypto)
forall k (t :: k). Proxy t
Proxy
(?!) :: Maybe a -> e -> Either e a
Maybe a
Nothing ?! :: Maybe a -> e -> Either e a
?! e
e = e -> Either e a
forall a b. a -> Either a b
Left e
e
Just a
x ?! e
_ = a -> Either e a
forall a b. b -> Either a b
Right a
x
(?!.) :: Either e a -> (e -> e') -> Either e' a
Left e
e ?!. :: Either e a -> (e -> e') -> Either e' a
?!. e -> e'
f = e' -> Either e' a
forall a b. a -> Either a b
Left (e -> e'
f e
e)
Right a
x ?!. e -> e'
_ = a -> Either e' a
forall a b. b -> Either a b
Right a
x