| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Credential
Description
Role-specific credentials for payments, staking, governance and guards.
Hashes contain exactly 28 bytes. Equality and ordering compare kind and bytes;
diagnostic Show output is not an interchange encoding.
import qualified Cometa.Credential as Credential import qualified Cometa.Error import qualified Data.ByteString as ByteString payment :: Either Cometa.Error.Error (Credential.Credential Credential.Payment) payment = Credential.KeyCredential $ Credential.keyHashFromBytes (ByteString.replicate 28 0)
Synopsis
- data Payment
- data Stake
- data Guard
- data DRep
- data CommitteeHot
- data CommitteeCold
- data Genesis
- data GenesisDelegate
- data StakePool
- data KeyHash purpose
- keyHashFromBytes :: ByteString -> Either Error (KeyHash purpose)
- keyHashBytes :: KeyHash purpose -> ByteString
- data ScriptHash
- scriptHashFromBytes :: ByteString -> Either Error ScriptHash
- scriptHashBytes :: ScriptHash -> ByteString
- data Credential purpose
- = KeyCredential !(KeyHash purpose)
- | ScriptCredential !ScriptHash
- fromPublicKey :: PublicKey -> IO (Either Error (Credential purpose))
- encodeCbor :: Credential purpose -> ByteString
- decodeCbor :: ByteString -> Either Error (Credential purpose)
Documentation
data CommitteeHot Source #
Role of a constitutional committee member's voting credential.
data CommitteeCold Source #
Role of a constitutional committee member's authorization credential.
data GenesisDelegate Source #
Role of a delegate authorized by a genesis key.
A 28-byte key hash. Hashes in different roles are distinct types; importing bytes assigns their role.
Instances
| Show (KeyHash purpose) Source # | |
| Eq (KeyHash purpose) Source # | |
| Ord (KeyHash purpose) Source # | |
Defined in Cometa.Credential Methods compare :: KeyHash purpose -> KeyHash purpose -> Ordering # (<) :: KeyHash purpose -> KeyHash purpose -> Bool # (<=) :: KeyHash purpose -> KeyHash purpose -> Bool # (>) :: KeyHash purpose -> KeyHash purpose -> Bool # (>=) :: KeyHash purpose -> KeyHash purpose -> Bool # max :: KeyHash purpose -> KeyHash purpose -> KeyHash purpose # min :: KeyHash purpose -> KeyHash purpose -> KeyHash purpose # | |
keyHashFromBytes :: ByteString -> Either Error (KeyHash purpose) Source #
Import a key hash without hashing. Any length except 28 returns
InvalidCredentialHashLength with the actual byte count.
keyHashBytes :: KeyHash purpose -> ByteString Source #
Exact key-hash bytes.
data ScriptHash Source #
A 28-byte script hash, usable in any credential role.
Instances
| Show ScriptHash Source # | |
Defined in Cometa.Credential Methods showsPrec :: Int -> ScriptHash -> ShowS # show :: ScriptHash -> String # showList :: [ScriptHash] -> ShowS # | |
| Eq ScriptHash Source # | |
Defined in Cometa.Credential | |
| Ord ScriptHash Source # | |
Defined in Cometa.Credential Methods compare :: ScriptHash -> ScriptHash -> Ordering # (<) :: ScriptHash -> ScriptHash -> Bool # (<=) :: ScriptHash -> ScriptHash -> Bool # (>) :: ScriptHash -> ScriptHash -> Bool # (>=) :: ScriptHash -> ScriptHash -> Bool # max :: ScriptHash -> ScriptHash -> ScriptHash # min :: ScriptHash -> ScriptHash -> ScriptHash # | |
scriptHashFromBytes :: ByteString -> Either Error ScriptHash Source #
Import a script hash without hashing. Any length except 28 returns
InvalidCredentialHashLength with the actual byte count.
scriptHashBytes :: ScriptHash -> ByteString Source #
Exact script-hash bytes.
data Credential purpose Source #
A key or script controlling the role selected by the type parameter. Ordering places key credentials before script credentials, then compares bytes.
Constructors
| KeyCredential !(KeyHash purpose) | Authority identified by a key hash in this role. |
| ScriptCredential !ScriptHash | Authority identified by a script hash. |
Instances
| Show (Credential purpose) Source # | |
Defined in Cometa.Credential Methods showsPrec :: Int -> Credential purpose -> ShowS # show :: Credential purpose -> String # showList :: [Credential purpose] -> ShowS # | |
| Eq (Credential purpose) Source # | |
Defined in Cometa.Credential Methods (==) :: Credential purpose -> Credential purpose -> Bool # (/=) :: Credential purpose -> Credential purpose -> Bool # | |
| Ord (Credential purpose) Source # | |
Defined in Cometa.Credential Methods compare :: Credential purpose -> Credential purpose -> Ordering # (<) :: Credential purpose -> Credential purpose -> Bool # (<=) :: Credential purpose -> Credential purpose -> Bool # (>) :: Credential purpose -> Credential purpose -> Bool # (>=) :: Credential purpose -> Credential purpose -> Bool # max :: Credential purpose -> Credential purpose -> Credential purpose # min :: Credential purpose -> Credential purpose -> Credential purpose # | |
fromPublicKey :: PublicKey -> IO (Either Error (Credential purpose)) Source #
Hash a verification key using BLAKE2b-224 and assign the requested role.
The caller selects the credential role through the result type. Native failures
return NativeError; unexpected digest lengths return
NativeContractViolation.
encodeCbor :: Credential purpose -> ByteString Source #
Encode the credential kind and 28-byte hash as a two-element CBOR array. This produces a fresh definite-length encoding; it does not hash the value.
decodeCbor :: ByteString -> Either Error (Credential purpose) Source #
Decode exactly one credential array, checking its kind and hash length.
Definite and indefinite arrays and byte strings are accepted. Trailing data
and other shapes return InvalidCredentialCbor; invalid hash lengths return
InvalidCredentialHashLength. The result type selects the credential role.