Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data AllIssuerKeys c (r ∷ KeyRole) = AllIssuerKeys {
- aikCold ∷ KeyPair r
- aikVrf ∷ VRFKeyPair c
- aikHot ∷ NonEmpty (KESPeriod, KESKeyPair c)
- aikColdKeyHash ∷ KeyHash r
- data VRFKeyPair c = VRFKeyPair {
- vrfSignKey ∷ !(SignKeyVRF (VRF c))
- vrfVerKey ∷ !(VerKeyVRF (VRF c))
- data KESKeyPair c = KESKeyPair {
- kesSignKey ∷ !(UnsoundPureSignKeyKES (KES c))
- kesVerKey ∷ !(VerKeyKES (KES c))
- data GenEnv era = GenEnv {
- geKeySpace ∷ KeySpace era
- geScriptSpapce ∷ ScriptSpace era
- geConstants ∷ Constants
- data ScriptSpace era = ScriptSpace {
- ssScripts3 ∷ [TwoPhase3ArgInfo era]
- ssScripts2 ∷ [TwoPhase2ArgInfo era]
- ssHash3 ∷ Map ScriptHash (TwoPhase3ArgInfo era)
- ssHash2 ∷ Map ScriptHash (TwoPhase2ArgInfo era)
- data TwoPhase3ArgInfo era = TwoPhase3ArgInfo {
- getScript3 ∷ Script era
- getHash3 ∷ ScriptHash
- getData3 ∷ Data
- getRedeemer3 ∷ (Data, Natural, Natural)
- getSucceeds3 ∷ Bool
- data TwoPhase2ArgInfo era = TwoPhase2ArgInfo {
- getScript2 ∷ Script era
- getHash2 ∷ ScriptHash
- getRedeemer2 ∷ (Data, Natural, Natural)
- getSucceeds2 ∷ Bool
- type ScriptInfo era = (Map ScriptHash (TwoPhase3ArgInfo era), Map ScriptHash (TwoPhase2ArgInfo era))
- data KeySpace era = KeySpace_ {
- ksCoreNodes ∷ [(GenesisKeyPair MockCrypto, AllIssuerKeys MockCrypto 'GenesisDelegate)]
- ksGenesisDelegates ∷ [AllIssuerKeys MockCrypto 'GenesisDelegate]
- ksStakePools ∷ [AllIssuerKeys MockCrypto 'StakePool]
- ksKeyPairs ∷ KeyPairs
- ksMSigScripts ∷ [(Script era, Script era)]
- ksIndexedPaymentKeys ∷ Map (KeyHash 'Payment) (KeyPair 'Payment)
- ksIndexedStakingKeys ∷ Map (KeyHash 'Staking) (KeyPair 'Staking)
- ksIndexedGenDelegates ∷ Map (KeyHash 'GenesisDelegate) (AllIssuerKeys MockCrypto 'GenesisDelegate)
- ksIndexedPayScripts ∷ Map ScriptHash (Script era, Script era)
- ksIndexedStakeScripts ∷ Map ScriptHash (Script era, Script era)
- pattern KeySpace ∷ ∀ era. ScriptClass era ⇒ [(GenesisKeyPair MockCrypto, AllIssuerKeys MockCrypto 'GenesisDelegate)] → [AllIssuerKeys MockCrypto 'GenesisDelegate] → [AllIssuerKeys MockCrypto 'StakePool] → KeyPairs → [(Script era, Script era)] → KeySpace era
- newtype NatNonce = NatNonce Natural
- findPayKeyPairAddr ∷ Addr → Map (KeyHash 'Payment) (KeyPair 'Payment) → KeyPair 'Payment
- findPayKeyPairCred ∷ ∀ kr. Credential kr → Map (KeyHash kr) (KeyPair kr) → KeyPair kr
- findPayScriptFromCred ∷ ∀ era. Credential 'Witness → Map ScriptHash (Script era, Script era) → (Script era, Script era)
- findStakeScriptFromCred ∷ Credential 'Witness → Map ScriptHash (Script era, Script era) → (Script era, Script era)
- findPayScriptFromAddr ∷ ∀ era. Addr → Map ScriptHash (Script era, Script era) → (Script era, Script era)
- genBool ∷ Gen Bool
- genCoinList ∷ Integer → Integer → Int → Gen [Coin]
- genInteger ∷ Integer → Integer → Gen Integer
- genNatural ∷ Natural → Natural → Gen Natural
- genWord64 ∷ Word64 → Word64 → Gen Word64
- genTxOut ∷ ∀ era. EraTxOut era ⇒ Gen (Value era) → [Addr] → Gen [TxOut era]
- genesisCoins ∷ TxId → [TxOut era] → UTxO era
- increasingProbabilityAt ∷ Gen a → (a, a) → Gen a
- pickStakeKey ∷ KeyPairs → Gen (VKey 'Staking)
- mkAddr ∷ (KeyPair 'Payment, KeyPair 'Staking) → Addr
- mkCred ∷ ∀ (kr ∷ KeyRole). KeyPair kr → Credential kr
- mkBlock ∷ ∀ era (r ∷ KeyRole) c. (Crypto c, EraSegWits era, Signable (VRF c) Seed, Signable (KES c) (BHBody c)) ⇒ HashHeader → AllIssuerKeys c r → [Tx era] → SlotNo → BlockNo → Nonce → Word → Word → OCert c → Block (BHeader c) era
- mkBlockFakeVRF ∷ ∀ era (r ∷ KeyRole) c. (Crypto c, EraSegWits era, Signable (VRF c) (WithResult Seed), Signable (KES c) (BHBody c)) ⇒ HashHeader → AllIssuerKeys c r → [Tx era] → SlotNo → BlockNo → Nonce → NatNonce → UnitInterval → Word → Word → OCert c → Block (BHeader c) era
- mkOCert ∷ ∀ c (r ∷ KeyRole). Crypto c ⇒ AllIssuerKeys c r → Word64 → KESPeriod → OCert c
- getKESPeriodRenewalNo ∷ AllIssuerKeys h r → KESPeriod → Integer
- tooLateInEpoch ∷ SlotNo → Bool
- data RawSeed = RawSeed !Word64 !Word64 !Word64 !Word64 !Word64
- mkKeyPair ∷ ∀ kd. RawSeed → (SignKeyDSIGN DSIGN, VKey kd)
- mkKeyPairs ∷ Word64 → (KeyPair kr, KeyPair kr')
- mkGenKey ∷ RawSeed → (SignKeyDSIGN DSIGN, VKey kd)
- genesisAccountState ∷ AccountState
- genCoin ∷ Integer → Integer → Gen Coin
- type PreAlonzo era = TxWits era ~ ShelleyTxWits era
- hashData ∷ Data → DataHash
- findPlutus ∷ ∀ era. GenEnv era → ScriptHash → (Script era, StrictMaybe DataHash)
Documentation
data AllIssuerKeys c (r ∷ KeyRole) Source #
AllIssuerKeys | |
|
Instances
(Show (SignKeyVRF (VRF c)), Show (VerKeyVRF (VRF c)), Show (VerKeyKES (KES c))) ⇒ Show (AllIssuerKeys c r) | |
Defined in Test.Cardano.Protocol.TPraos.Create showsPrec ∷ Int → AllIssuerKeys c r → ShowS # show ∷ AllIssuerKeys c r → String # showList ∷ [AllIssuerKeys c r] → ShowS # |
data VRFKeyPair c Source #
VRFKeyPair | |
|
Instances
(Show (SignKeyVRF (VRF c)), Show (VerKeyVRF (VRF c))) ⇒ Show (VRFKeyPair c) | |
Defined in Test.Cardano.Protocol.Crypto.VRF showsPrec ∷ Int → VRFKeyPair c → ShowS # show ∷ VRFKeyPair c → String # showList ∷ [VRFKeyPair c] → ShowS # |
data KESKeyPair c Source #
KESKeyPair | |
|
Instances
Show (VerKeyKES (KES c)) ⇒ Show (KESKeyPair c) | |
Defined in Test.Cardano.Protocol.Crypto.KES showsPrec ∷ Int → KESKeyPair c → ShowS # show ∷ KESKeyPair c → String # showList ∷ [KESKeyPair c] → ShowS # |
Generator environment.
GenEnv | |
|
Instances
data ScriptSpace era Source #
ScriptSpace | |
|
Instances
Show (Script era) ⇒ Show (ScriptSpace era) Source # | |
Defined in Test.Cardano.Ledger.Shelley.Generator.Core showsPrec ∷ Int → ScriptSpace era → ShowS # show ∷ ScriptSpace era → String # showList ∷ [ScriptSpace era] → ShowS # |
data TwoPhase3ArgInfo era Source #
TwoPhase3ArgInfo | |
|
Instances
Show (Script era) ⇒ Show (TwoPhase3ArgInfo era) Source # | |
Defined in Test.Cardano.Ledger.Shelley.Generator.Core showsPrec ∷ Int → TwoPhase3ArgInfo era → ShowS # show ∷ TwoPhase3ArgInfo era → String # showList ∷ [TwoPhase3ArgInfo era] → ShowS # |
data TwoPhase2ArgInfo era Source #
TwoPhase2ArgInfo | |
|
Instances
Show (Script era) ⇒ Show (TwoPhase2ArgInfo era) Source # | |
Defined in Test.Cardano.Ledger.Shelley.Generator.Core showsPrec ∷ Int → TwoPhase2ArgInfo era → ShowS # show ∷ TwoPhase2ArgInfo era → String # showList ∷ [TwoPhase2ArgInfo era] → ShowS # |
type ScriptInfo era = (Map ScriptHash (TwoPhase3ArgInfo era), Map ScriptHash (TwoPhase2ArgInfo era)) Source #
Collection of all keys which are required to generate a trace.
These are the _only_ keys which should be involved in the trace.
pattern KeySpace ∷ ∀ era. ScriptClass era ⇒ [(GenesisKeyPair MockCrypto, AllIssuerKeys MockCrypto 'GenesisDelegate)] → [AllIssuerKeys MockCrypto 'GenesisDelegate] → [AllIssuerKeys MockCrypto 'StakePool] → KeyPairs → [(Script era, Script era)] → KeySpace era Source #
We provide our own nonces to mkBlock
, which we then wish to recover as
the output of the VRF functions. In general, however, we just derive them
from a natural. Since the nonce is a hash, we do not want to recover it to
find a preimage. In testing, therefore, we just wrap the raw natural, which
we then encode into the fake VRF implementation.
findPayKeyPairAddr ∷ Addr → Map (KeyHash 'Payment) (KeyPair 'Payment) → KeyPair 'Payment Source #
Find first matching key pair for address. Returns the matching key pair
where the first element of the pair matched the hash in addr
.
findPayKeyPairCred ∷ ∀ kr. Credential kr → Map (KeyHash kr) (KeyPair kr) → KeyPair kr Source #
Find first matching key pair for a credential. Returns the matching key pair
where the first element of the pair matched the hash in addr
.
findPayScriptFromCred ∷ ∀ era. Credential 'Witness → Map ScriptHash (Script era, Script era) → (Script era, Script era) Source #
Find matching multisig scripts for a credential.
findStakeScriptFromCred ∷ Credential 'Witness → Map ScriptHash (Script era, Script era) → (Script era, Script era) Source #
Find first matching script for a credential.
findPayScriptFromAddr ∷ ∀ era. Addr → Map ScriptHash (Script era, Script era) → (Script era, Script era) Source #
Find first matching multisig script for an address.
genCoinList ∷ Integer → Integer → Int → Gen [Coin] Source #
Generates a list of Coin
values of length between lower
and upper
and with values between minCoin
and maxCoin
.
genNatural ∷ Natural → Natural → Gen Natural Source #
Generator for a natural number between lower
and upper
genesisCoins ∷ TxId → [TxOut era] → UTxO era Source #
Creates the UTxO for a new ledger with the specified genesis TxId and transaction outputs.
increasingProbabilityAt ∷ Gen a → (a, a) → Gen a Source #
Generate values the given distribution in 90% of the cases, and values at the bounds of the range in 10% of the cases.
This can be used to generate enough extreme values. The exponential and
linear distributions provided by hedgehog
will generate a small percentage
of these (0-1%).
pickStakeKey ∷ KeyPairs → Gen (VKey 'Staking) Source #
Select one random verification staking key from list of pairs of KeyPair.
∷ ∀ era (r ∷ KeyRole) c. (Crypto c, EraSegWits era, Signable (VRF c) Seed, Signable (KES c) (BHBody c)) | |
⇒ HashHeader | Hash of previous block |
→ AllIssuerKeys c r | All keys in the stake pool |
→ [Tx era] | Transactions to record |
→ SlotNo | Current slot |
→ BlockNo | Block numberchain lengthchain "difficulty" |
→ Nonce | EpochNo nonce |
→ Word | Period of KES (key evolving signature scheme) |
→ Word | KES period of key registration |
→ OCert c | Operational certificate |
→ Block (BHeader c) era |
∷ ∀ era (r ∷ KeyRole) c. (Crypto c, EraSegWits era, Signable (VRF c) (WithResult Seed), Signable (KES c) (BHBody c)) | |
⇒ HashHeader | Hash of previous block |
→ AllIssuerKeys c r | All keys in the stake pool |
→ [Tx era] | Transactions to record |
→ SlotNo | Current slot |
→ BlockNo | Block number/chain length/chain "difficulty" |
→ Nonce | EpochNo nonce |
→ NatNonce | Block nonce |
→ UnitInterval | Praos leader value |
→ Word | Period of KES (key evolving signature scheme) |
→ Word | KES period of key registration |
→ OCert c | Operational certificate |
→ Block (BHeader c) era |
Create a block with a faked VRF result.
getKESPeriodRenewalNo ∷ AllIssuerKeys h r → KESPeriod → Integer Source #
Takes a sequence of KES hot keys and checks to see whether there is one whose range contains the current KES period. If so, return its index in the list of hot keys.
tooLateInEpoch ∷ SlotNo → Bool Source #
True if the given slot is within the last `2 * stabilityWindow` slots of the current epoch.
mkKeyPair ∷ ∀ kd. RawSeed → (SignKeyDSIGN DSIGN, VKey kd) Source #
For testing purposes, generate a deterministic key pair given a seed.
mkGenKey ∷ RawSeed → (SignKeyDSIGN DSIGN, VKey kd) Source #
For testing purposes, generate a deterministic genesis key pair given a seed.
genesisAccountState ∷ AccountState Source #
Account with empty treasury
type PreAlonzo era = TxWits era ~ ShelleyTxWits era Source #
For use in the Serialisation and Example Tests, which assume Shelley, Allegra, or Mary Eras.
findPlutus ∷ ∀ era. GenEnv era → ScriptHash → (Script era, StrictMaybe DataHash) Source #
Find the preallocated Script from its Hash.