Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data AllIssuerKeys v (r ∷ KeyRole) = AllIssuerKeys {
- aikCold ∷ KeyPair r v
- aikVrf ∷ VRFKeyPair v
- aikHot ∷ NonEmpty (KESPeriod, KESKeyPair v)
- aikColdKeyHash ∷ KeyHash r v
- data VRFKeyPair c = VRFKeyPair {
- vrfSignKey ∷ !(SignKeyVRF c)
- vrfVerKey ∷ !(VerKeyVRF c)
- data KESKeyPair c = KESKeyPair {
- kesSignKey ∷ !(SignKeyKES c)
- kesVerKey ∷ !(VerKeyKES 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 (EraCrypto era)) (TwoPhase3ArgInfo era)
- ssHash2 ∷ Map (ScriptHash (EraCrypto era)) (TwoPhase2ArgInfo era)
- data TwoPhase3ArgInfo era = TwoPhase3ArgInfo {
- getScript3 ∷ Script era
- getHash3 ∷ ScriptHash (EraCrypto era)
- getData3 ∷ Data
- getRedeemer3 ∷ (Data, Natural, Natural)
- getSucceeds3 ∷ Bool
- data TwoPhase2ArgInfo era = TwoPhase2ArgInfo {
- getScript2 ∷ Script era
- getHash2 ∷ ScriptHash (EraCrypto era)
- getRedeemer2 ∷ (Data, Natural, Natural)
- getSucceeds2 ∷ Bool
- type ScriptInfo era = (Map (ScriptHash (EraCrypto era)) (TwoPhase3ArgInfo era), Map (ScriptHash (EraCrypto era)) (TwoPhase2ArgInfo era))
- data KeySpace era = KeySpace_ {
- ksCoreNodes ∷ [(GenesisKeyPair (EraCrypto era), AllIssuerKeys (EraCrypto era) 'GenesisDelegate)]
- ksGenesisDelegates ∷ [AllIssuerKeys (EraCrypto era) 'GenesisDelegate]
- ksStakePools ∷ [AllIssuerKeys (EraCrypto era) 'StakePool]
- ksKeyPairs ∷ KeyPairs (EraCrypto era)
- ksMSigScripts ∷ [(Script era, Script era)]
- ksIndexedPaymentKeys ∷ Map (KeyHash 'Payment (EraCrypto era)) (KeyPair 'Payment (EraCrypto era))
- ksIndexedStakingKeys ∷ Map (KeyHash 'Staking (EraCrypto era)) (KeyPair 'Staking (EraCrypto era))
- ksIndexedGenDelegates ∷ Map (KeyHash 'GenesisDelegate (EraCrypto era)) (AllIssuerKeys (EraCrypto era) 'GenesisDelegate)
- ksIndexedPayScripts ∷ Map (ScriptHash (EraCrypto era)) (Script era, Script era)
- ksIndexedStakeScripts ∷ Map (ScriptHash (EraCrypto era)) (Script era, Script era)
- pattern KeySpace ∷ ∀ era. ScriptClass era ⇒ [(GenesisKeyPair (EraCrypto era), AllIssuerKeys (EraCrypto era) 'GenesisDelegate)] → [AllIssuerKeys (EraCrypto era) 'GenesisDelegate] → [AllIssuerKeys (EraCrypto era) 'StakePool] → KeyPairs (EraCrypto era) → [(Script era, Script era)] → KeySpace era
- newtype NatNonce = NatNonce Natural
- findPayKeyPairAddr ∷ ∀ era. Addr (EraCrypto era) → Map (KeyHash 'Payment (EraCrypto era)) (KeyPair 'Payment (EraCrypto era)) → KeyPair 'Payment (EraCrypto era)
- findPayKeyPairCred ∷ ∀ era kr. Credential kr (EraCrypto era) → Map (KeyHash kr (EraCrypto era)) (KeyPair kr (EraCrypto era)) → KeyPair kr (EraCrypto era)
- findPayScriptFromCred ∷ ∀ era. Credential 'Witness (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era)
- findStakeScriptFromCred ∷ Credential 'Witness (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era)
- findPayScriptFromAddr ∷ ∀ era. Addr (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (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 (EraCrypto era)] → Gen [TxOut era]
- genesisCoins ∷ TxId (EraCrypto era) → [TxOut era] → UTxO era
- increasingProbabilityAt ∷ Gen a → (a, a) → Gen a
- pickStakeKey ∷ KeyPairs c → Gen (VKey 'Staking c)
- mkAddr ∷ Crypto c ⇒ (KeyPair 'Payment c, KeyPair 'Staking c) → Addr c
- mkCred ∷ ∀ c (kr ∷ KeyRole). Crypto c ⇒ KeyPair kr c → Credential kr c
- unitIntervalToNatural ∷ UnitInterval → Natural
- mkBlock ∷ ∀ era (r ∷ KeyRole). (EraSegWits era, Signable (VRF (EraCrypto era)) Seed, Signable (KES (EraCrypto era)) (BHBody (EraCrypto era))) ⇒ HashHeader (EraCrypto era) → AllIssuerKeys (EraCrypto era) r → [Tx era] → SlotNo → BlockNo → Nonce → Word → Word → OCert (EraCrypto era) → Block (BHeader (EraCrypto era)) era
- mkBlockHeader ∷ Mock c ⇒ ProtVer → HashHeader c → AllIssuerKeys c r → SlotNo → BlockNo → Nonce → Word → Word → OCert c → Word32 → Hash c EraIndependentBlockBody → BHeader c
- mkBlockFakeVRF ∷ ∀ era (r ∷ KeyRole). (EraSegWits era, Signable (VRF (EraCrypto era)) (WithResult Seed), Signable (KES (EraCrypto era)) (BHBody (EraCrypto era))) ⇒ HashHeader (EraCrypto era) → AllIssuerKeys (EraCrypto era) r → [Tx era] → SlotNo → BlockNo → Nonce → NatNonce → UnitInterval → Word → Word → OCert (EraCrypto era) → Block (BHeader (EraCrypto era)) era
- mkOCert ∷ ∀ c (r ∷ KeyRole). (Crypto c, Signable (DSIGN c) (OCertSignable 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 ∷ ∀ c kd. DSIGNAlgorithm (DSIGN c) ⇒ RawSeed → (SignKeyDSIGN (DSIGN c), VKey kd c)
- mkKeyPairs ∷ DSIGNAlgorithm (DSIGN c) ⇒ Word64 → (KeyPair kr c, KeyPair kr' c)
- mkGenKey ∷ DSIGNAlgorithm (DSIGN c) ⇒ RawSeed → (SignKeyDSIGN (DSIGN c), VKey kd c)
- genesisAccountState ∷ AccountState
- genCoin ∷ Integer → Integer → Gen Coin
- type PreAlonzo era = TxWits era ~ ShelleyTxWits era
- hashData ∷ ∀ era. Era era ⇒ Data → DataHash (EraCrypto era)
- findPlutus ∷ ∀ era. Era era ⇒ GenEnv era → ScriptHash (EraCrypto era) → (Script era, StrictMaybe (DataHash (EraCrypto era)))
Documentation
data AllIssuerKeys v (r ∷ KeyRole) Source #
AllIssuerKeys | |
|
Instances
Crypto v ⇒ Show (AllIssuerKeys v r) | |
Defined in Test.Cardano.Protocol.TPraos.Create |
data VRFKeyPair c Source #
VRFKeyPair | |
|
Instances
(Show (SignKeyVRF (VRF c)), Show (VerKeyVRF (VRF c))) ⇒ Show (VRFKeyPair c) | |
Defined in Test.Cardano.Protocol.Crypto.VRF |
data KESKeyPair c Source #
KESKeyPair | |
|
Instances
(Show (SignKeyKES (KES c)), Show (VerKeyKES (KES c))) ⇒ Show (KESKeyPair c) | |
Defined in Test.Cardano.Protocol.Crypto.KES |
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 |
data TwoPhase3ArgInfo era Source #
TwoPhase3ArgInfo | |
|
Instances
Show (Script era) ⇒ Show (TwoPhase3ArgInfo era) Source # | |
Defined in Test.Cardano.Ledger.Shelley.Generator.Core |
data TwoPhase2ArgInfo era Source #
TwoPhase2ArgInfo | |
|
Instances
Show (Script era) ⇒ Show (TwoPhase2ArgInfo era) Source # | |
Defined in Test.Cardano.Ledger.Shelley.Generator.Core |
type ScriptInfo era = (Map (ScriptHash (EraCrypto era)) (TwoPhase3ArgInfo era), Map (ScriptHash (EraCrypto era)) (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 (EraCrypto era), AllIssuerKeys (EraCrypto era) 'GenesisDelegate)] → [AllIssuerKeys (EraCrypto era) 'GenesisDelegate] → [AllIssuerKeys (EraCrypto era) 'StakePool] → KeyPairs (EraCrypto era) → [(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 ∷ ∀ era. Addr (EraCrypto era) → Map (KeyHash 'Payment (EraCrypto era)) (KeyPair 'Payment (EraCrypto era)) → KeyPair 'Payment (EraCrypto era) 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 ∷ ∀ era kr. Credential kr (EraCrypto era) → Map (KeyHash kr (EraCrypto era)) (KeyPair kr (EraCrypto era)) → KeyPair kr (EraCrypto era) 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 (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era) Source #
Find matching multisig scripts for a credential.
findStakeScriptFromCred ∷ Credential 'Witness (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (Script era, Script era) → (Script era, Script era) Source #
Find first matching script for a credential.
findPayScriptFromAddr ∷ ∀ era. Addr (EraCrypto era) → Map (ScriptHash (EraCrypto era)) (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
genTxOut ∷ ∀ era. EraTxOut era ⇒ Gen (Value era) → [Addr (EraCrypto era)] → Gen [TxOut era] Source #
genesisCoins ∷ TxId (EraCrypto era) → [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 c → Gen (VKey 'Staking c) Source #
Select one random verification staking key from list of pairs of KeyPair.
unitIntervalToNatural ∷ UnitInterval → Natural Source #
Deprecated: This function has been made private in cardano-protocol-tpraos:testlib. Open an issue if you need it
Try to map the unit interval to a natural number. We don't care whether
this is surjective. But it should be right inverse to fromNatural
- that
is, one should be able to recover the UnitInterval
value used here.
∷ ∀ era (r ∷ KeyRole). (EraSegWits era, Signable (VRF (EraCrypto era)) Seed, Signable (KES (EraCrypto era)) (BHBody (EraCrypto era))) | |
⇒ HashHeader (EraCrypto era) | Hash of previous block |
→ AllIssuerKeys (EraCrypto era) 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 (EraCrypto era) | Operational certificate |
→ Block (BHeader (EraCrypto era)) era |
∷ Mock c | |
⇒ ProtVer | |
→ HashHeader c | Hash of previous block |
→ AllIssuerKeys c r | All keys in the stake pool |
→ 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 |
→ Word32 | Block size |
→ Hash c EraIndependentBlockBody | Block body hash |
→ BHeader c |
∷ ∀ era (r ∷ KeyRole). (EraSegWits era, Signable (VRF (EraCrypto era)) (WithResult Seed), Signable (KES (EraCrypto era)) (BHBody (EraCrypto era))) | |
⇒ HashHeader (EraCrypto era) | Hash of previous block |
→ AllIssuerKeys (EraCrypto era) 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 (EraCrypto era) | Operational certificate |
→ Block (BHeader (EraCrypto era)) era |
Create a block with a faked VRF result.
mkOCert ∷ ∀ c (r ∷ KeyRole). (Crypto c, Signable (DSIGN c) (OCertSignable c)) ⇒ AllIssuerKeys c r → Word64 → KESPeriod → OCert c Source #
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 ∷ ∀ c kd. DSIGNAlgorithm (DSIGN c) ⇒ RawSeed → (SignKeyDSIGN (DSIGN c), VKey kd c) Source #
For testing purposes, generate a deterministic key pair given a seed.
mkKeyPairs ∷ DSIGNAlgorithm (DSIGN c) ⇒ Word64 → (KeyPair kr c, KeyPair kr' c) Source #
mkGenKey ∷ DSIGNAlgorithm (DSIGN c) ⇒ RawSeed → (SignKeyDSIGN (DSIGN c), VKey kd c) 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. Era era ⇒ GenEnv era → ScriptHash (EraCrypto era) → (Script era, StrictMaybe (DataHash (EraCrypto era))) Source #
Find the preallocated Script from its Hash.