cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

data Payment Source #

Role of a payment key or credential.

data Stake Source #

Role of a staking key or credential.

data Guard Source #

Role of a Dijkstra transaction guard credential.

data DRep Source #

Role of a delegated representative's voting credential.

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 Genesis Source #

Role of a genesis key authorizing delegation or a legacy protocol update.

data GenesisDelegate Source #

Role of a delegate authorized by a genesis key.

data StakePool Source #

Role of a stake pool operator's key hash.

data KeyHash purpose Source #

A 28-byte key hash. Hashes in different roles are distinct types; importing bytes assigns their role.

Instances

Instances details
Show (KeyHash purpose) Source # 
Instance details

Defined in Cometa.Credential

Methods

showsPrec :: Int -> KeyHash purpose -> ShowS #

show :: KeyHash purpose -> String #

showList :: [KeyHash purpose] -> ShowS #

Eq (KeyHash purpose) Source # 
Instance details

Defined in Cometa.Credential

Methods

(==) :: KeyHash purpose -> KeyHash purpose -> Bool #

(/=) :: KeyHash purpose -> KeyHash purpose -> Bool #

Ord (KeyHash purpose) Source # 
Instance details

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.

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

Instances details
Show (Credential purpose) Source # 
Instance details

Defined in Cometa.Credential

Methods

showsPrec :: Int -> Credential purpose -> ShowS #

show :: Credential purpose -> String #

showList :: [Credential purpose] -> ShowS #

Eq (Credential purpose) Source # 
Instance details

Defined in Cometa.Credential

Methods

(==) :: Credential purpose -> Credential purpose -> Bool #

(/=) :: Credential purpose -> Credential purpose -> Bool #

Ord (Credential purpose) Source # 
Instance details

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.