lorentz-0.15.0: EDSL for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lorentz.Bytes

Description

Type-safe operations with bytes-like data.

Synopsis

Documentation

class (KnownValue bs, ToT bs ~ ToT ByteString) => BytesLike bs where Source #

Everything which is represented as bytes inside.

Methods

toBytes :: bs -> ByteString Source #

Instances

Instances details
BytesLike ByteString Source # 
Instance details

Defined in Lorentz.Bytes

Typeable a => BytesLike (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

(Typeable alg, Typeable a) => BytesLike (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

toBytes :: Hash alg a -> ByteString Source #

Packed

newtype Packed a Source #

Represents a ByteString resulting from packing a value of type a.

This is not guaranteed to keep some packed value, and unpack can fail. We do so because often we need to accept values of such type from user, and also because there is no simple way to check validity of packed data without performing full unpack. So this wrapper is rather a hint for users.

Constructors

Packed 

Fields

Instances

Instances details
Generic (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (Packed a) :: Type -> Type #

Methods

from :: Packed a -> Rep (Packed a) x #

to :: Rep (Packed a) x -> Packed a #

Show (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

showsPrec :: Int -> Packed a -> ShowS #

show :: Packed a -> String #

showList :: [Packed a] -> ShowS #

Buildable (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

build :: Packed a -> Builder #

Eq (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

(==) :: Packed a -> Packed a -> Bool #

(/=) :: Packed a -> Packed a -> Bool #

Ord (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

compare :: Packed a -> Packed a -> Ordering #

(<) :: Packed a -> Packed a -> Bool #

(<=) :: Packed a -> Packed a -> Bool #

(>) :: Packed a -> Packed a -> Bool #

(>=) :: Packed a -> Packed a -> Bool #

max :: Packed a -> Packed a -> Packed a #

min :: Packed a -> Packed a -> Packed a #

HasAnnotation (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Typeable a => BytesLike (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

HasRPCRepr (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (Packed a)

TypeHasDoc a => TypeHasDoc (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (Packed a) :: FieldDescriptions #

IsoValue (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (Packed a) :: T #

Methods

toVal :: Packed a -> Value (ToT (Packed a)) #

fromVal :: Value (ToT (Packed a)) -> Packed a #

CanCastTo (Packed a :: Type) ByteString Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Packed a) -> Proxy ByteString -> () Source #

CanCastTo a b => CanCastTo (Packed a :: Type) (Packed b :: Type) Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Packed a) -> Proxy (Packed b) -> () Source #

type Rep (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (Packed a) = D1 ('MetaData "Packed" "Lorentz.Bytes" "lorentz-0.15.0-inplace" 'True) (C1 ('MetaCons "Packed" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPacked") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
type AsRPC (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

type AsRPC (Packed a) = Packed a
type TypeDocFieldDescriptions (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (Packed a) Source # 
Instance details

Defined in Lorentz.Bytes

Signatures

newtype TSignature a Source #

Represents a signature, where signed data has given type.

Since we usually sign a packed data, a common pattern for this type is TSignature (Packed signedData). If you don't want to use Packed, use plain TSignature ByteString instead.

Constructors

TSignature 

Instances

Instances details
Generic (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (TSignature a) :: Type -> Type #

Methods

from :: TSignature a -> Rep (TSignature a) x #

to :: Rep (TSignature a) x -> TSignature a #

Show (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Buildable (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

build :: TSignature a -> Builder #

HasAnnotation (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

HasRPCRepr (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (TSignature a)

TypeHasDoc a => TypeHasDoc (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (TSignature a) :: FieldDescriptions #

IsoValue (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (TSignature a) :: T #

CanCastTo (TSignature a :: Type) ByteString Source # 
Instance details

Defined in Lorentz.Coercions

CanCastTo a b => CanCastTo (TSignature a :: Type) (TSignature b :: Type) Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (TSignature a) -> Proxy (TSignature b) -> () Source #

type Rep (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (TSignature a) = D1 ('MetaData "TSignature" "Lorentz.Bytes" "lorentz-0.15.0-inplace" 'True) (C1 ('MetaCons "TSignature" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTSignature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Signature)))
type AsRPC (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

type AsRPC (TSignature a) = TSignature a
type TypeDocFieldDescriptions (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (TSignature a) Source # 
Instance details

Defined in Lorentz.Bytes

lSign :: (MonadRandom m, BytesLike a) => SecretKey -> a -> m (TSignature a) Source #

Sign data using SecretKey

Hashes

newtype Hash (alg :: HashAlgorithmKind) a Source #

Hash of type t evaluated from data of type a.

Constructors

UnsafeHash 

Fields

Instances

Instances details
CanCastTo (Hash alg a :: Type) ByteString Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Hash alg a) -> Proxy ByteString -> () Source #

(CanCastTo alg1 alg2, CanCastTo a1 a2) => CanCastTo (Hash alg1 a1 :: Type) (Hash alg2 a2 :: Type) Source # 
Instance details

Defined in Lorentz.Coercions

Methods

castDummy :: Proxy (Hash alg1 a1) -> Proxy (Hash alg2 a2) -> () Source #

Generic (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (Hash alg a) :: Type -> Type #

Methods

from :: Hash alg a -> Rep (Hash alg a) x #

to :: Rep (Hash alg a) x -> Hash alg a #

Show (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

showsPrec :: Int -> Hash alg a -> ShowS #

show :: Hash alg a -> String #

showList :: [Hash alg a] -> ShowS #

Buildable (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

build :: Hash alg a -> Builder #

Eq (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

(==) :: Hash alg a -> Hash alg a -> Bool #

(/=) :: Hash alg a -> Hash alg a -> Bool #

Ord (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

compare :: Hash alg a -> Hash alg a -> Ordering #

(<) :: Hash alg a -> Hash alg a -> Bool #

(<=) :: Hash alg a -> Hash alg a -> Bool #

(>) :: Hash alg a -> Hash alg a -> Bool #

(>=) :: Hash alg a -> Hash alg a -> Bool #

max :: Hash alg a -> Hash alg a -> Hash alg a #

min :: Hash alg a -> Hash alg a -> Hash alg a #

HasAnnotation (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

(Typeable alg, Typeable a) => BytesLike (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

toBytes :: Hash alg a -> ByteString Source #

HasRPCRepr (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (Hash alg a)

(KnownHashAlgorithm alg, TypeHasDoc a) => TypeHasDoc (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (Hash alg a) :: FieldDescriptions #

Methods

typeDocName :: Proxy (Hash alg a) -> Text #

typeDocMdDescription :: Markdown #

typeDocMdReference :: Proxy (Hash alg a) -> WithinParens -> Markdown #

typeDocDependencies :: Proxy (Hash alg a) -> [SomeDocDefinitionItem] #

typeDocHaskellRep :: TypeDocHaskellRep (Hash alg a) #

typeDocMichelsonRep :: TypeDocMichelsonRep (Hash alg a) #

IsoValue (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (Hash alg a) :: T #

Methods

toVal :: Hash alg a -> Value (ToT (Hash alg a)) #

fromVal :: Value (ToT (Hash alg a)) -> Hash alg a #

type Rep (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (Hash alg a) = D1 ('MetaData "Hash" "Lorentz.Bytes" "lorentz-0.15.0-inplace" 'True) (C1 ('MetaCons "UnsafeHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
type AsRPC (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type AsRPC (Hash alg a) = Hash alg a
type TypeDocFieldDescriptions (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type TypeDocFieldDescriptions (Hash alg a) = '[] :: [(Symbol, (Maybe Symbol, [(Symbol, Symbol)]))]
type ToT (Hash alg a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (Hash alg a) = ToT ByteString

data DHashAlgorithm Source #

Documentation item for hash algorithms.

Instances

Instances details
Eq DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

Ord DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

DocItem DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type DocItemPlacement DHashAlgorithm :: DocItemPlacementKind #

type DocItemReferenced DHashAlgorithm :: DocItemReferencedKind #

type DocItemPlacement DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

type DocItemReferenced DHashAlgorithm Source # 
Instance details

Defined in Lorentz.Bytes

class Typeable alg => KnownHashAlgorithm (alg :: HashAlgorithmKind) where Source #

Hash algorithm used in Tezos.

Minimal complete definition

computeHash, toHash

Methods

hashAlgorithmName :: Proxy alg -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: BytesLike bs => (bs ': s) :-> (Hash alg bs ': s) Source #

Instances

Instances details
KnownHashAlgorithm Blake2b Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Blake2b -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Blake2b bs ': s) Source #

KnownHashAlgorithm Keccak Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Keccak -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Keccak bs ': s) Source #

KnownHashAlgorithm Sha256 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha256 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha256 bs ': s) Source #

KnownHashAlgorithm Sha3 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha3 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha3 bs ': s) Source #

KnownHashAlgorithm Sha512 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha512 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha512 bs ': s) Source #

toHashHs :: forall alg bs. (BytesLike bs, KnownHashAlgorithm alg) => bs -> Hash alg bs Source #

Evaluate hash in Haskell world.

data Sha256 :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Sha256 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha256 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha256 bs ': s) Source #

data Sha512 :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Sha512 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha512 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha512 bs ': s) Source #

data Blake2b :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Blake2b Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Blake2b -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Blake2b bs ': s) Source #

data Sha3 :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Sha3 Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Sha3 -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Sha3 bs ': s) Source #

data Keccak :: HashAlgorithmKind Source #

Instances

Instances details
KnownHashAlgorithm Keccak Source # 
Instance details

Defined in Lorentz.Bytes

Methods

hashAlgorithmName :: Proxy Keccak -> Text Source #

computeHash :: ByteString -> ByteString Source #

toHash :: forall bs (s :: [Type]). BytesLike bs => (bs ': s) :-> (Hash Keccak bs ': s) Source #

Typed Chest

newtype ChestT a Source #

Constructors

ChestT 

Fields

Instances

Instances details
Generic (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (ChestT a) :: Type -> Type #

Methods

from :: ChestT a -> Rep (ChestT a) x #

to :: Rep (ChestT a) x -> ChestT a #

HasAnnotation (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

HasRPCRepr (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (ChestT a)

TypeHasDoc a => TypeHasDoc (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (ChestT a) :: FieldDescriptions #

IsoValue (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (ChestT a) :: T #

Methods

toVal :: ChestT a -> Value (ToT (ChestT a)) #

fromVal :: Value (ToT (ChestT a)) -> ChestT a #

type Rep (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (ChestT a) = D1 ('MetaData "ChestT" "Lorentz.Bytes" "lorentz-0.15.0-inplace" 'True) (C1 ('MetaCons "ChestT" 'PrefixI 'True) (S1 ('MetaSel ('Just "unChestT") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Chest)))
type AsRPC (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type AsRPC (ChestT a) = ChestT a
type TypeDocFieldDescriptions (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (ChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (ChestT a) = ToT Chest

data OpenChestT a Source #

Instances

Instances details
Generic (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type Rep (OpenChestT a) :: Type -> Type #

Methods

from :: OpenChestT a -> Rep (OpenChestT a) x #

to :: Rep (OpenChestT a) x -> OpenChestT a #

Show a => Show (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Eq a => Eq (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Methods

(==) :: OpenChestT a -> OpenChestT a -> Bool #

(/=) :: OpenChestT a -> OpenChestT a -> Bool #

HasAnnotation a => HasAnnotation (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

HasRPCRepr a => HasRPCRepr (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type AsRPC (OpenChestT a)

TypeHasDoc a => TypeHasDoc (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type TypeDocFieldDescriptions (OpenChestT a) :: FieldDescriptions #

IsoValue a => IsoValue (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

Associated Types

type ToT (OpenChestT a) :: T #

type Rep (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type Rep (OpenChestT a) = D1 ('MetaData "OpenChestT" "Lorentz.Bytes" "lorentz-0.15.0-inplace" 'False) (C1 ('MetaCons "ChestContentT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "ChestOpenFailedT" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Bool)))
type AsRPC (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type AsRPC (OpenChestT a) = OpenChestT (AsRPC a)
type TypeDocFieldDescriptions (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (OpenChestT a) Source # 
Instance details

Defined in Lorentz.Bytes

type ToT (OpenChestT a) = GValueType (Rep (OpenChestT a))

openChestT :: BytesLike a => (ChestKey ': (ChestT a ': (Natural ': s))) :-> (OpenChestT a ': s) Source #

Deprecated: Due to a vulnerability discovered in time-lock protocol, OPEN_CHEST is temporarily deprecated since Lima