symbolic-base-0.1.0.0: ZkFold Symbolic compiler and zero-knowledge proof protocols
Safe HaskellSafe-Inferred
LanguageHaskell2010

ZkFold.Symbolic.Data.JWT

Synopsis

Documentation

data Certificate ctx Source #

RSA Public key with Key ID

Constructors

Certificate 

Fields

Instances

Instances details
Generic (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Rep (Certificate ctx) :: Type -> Type #

Methods

from :: Certificate ctx -> Rep (Certificate ctx) x #

to :: Rep (Certificate ctx) x -> Certificate ctx #

(Show (PublicKey 2048 ctx), Show (VarByteString 320 ctx)) => Show (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

showsPrec :: Int -> Certificate ctx -> ShowS #

show :: Certificate ctx -> String #

showList :: [Certificate ctx] -> ShowS #

(NFData (PublicKey 2048 ctx), NFData (VarByteString 320 ctx)) => NFData (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

rnf :: Certificate ctx -> () #

(Eq (PublicKey 2048 ctx), Eq (VarByteString 320 ctx)) => Eq (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

(==) :: Certificate ctx -> Certificate ctx -> Bool #

(/=) :: Certificate ctx -> Certificate ctx -> Bool #

(SymbolicData (PublicKey 2048 ctx), Symbolic ctx) => SymbolicData (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Context (Certificate ctx) :: (Type -> Type) -> Type Source #

type Support (Certificate ctx) Source #

type Layout (Certificate ctx) :: Type -> Type Source #

type Payload (Certificate ctx) :: Type -> Type Source #

(SymbolicInput (PublicKey 2048 ctx), Symbolic ctx) => SymbolicInput (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (Certificate ctx) = D1 ('MetaData "Certificate" "ZkFold.Symbolic.Data.JWT" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Certificate" 'PrefixI 'True) (S1 ('MetaSel ('Just "pubKid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 320 ctx)) :*: S1 ('MetaSel ('Just "pubKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PublicKey 2048 ctx))))
type Context (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Layout (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Payload (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Support (Certificate ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

data SigningKey ctx Source #

RSA Private key with Key ID

Constructors

SigningKey 

Fields

Instances

Instances details
Generic (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Rep (SigningKey ctx) :: Type -> Type #

Methods

from :: SigningKey ctx -> Rep (SigningKey ctx) x #

to :: Rep (SigningKey ctx) x -> SigningKey ctx #

(Show (PrivateKey 2048 ctx), Show (VarByteString 320 ctx)) => Show (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

showsPrec :: Int -> SigningKey ctx -> ShowS #

show :: SigningKey ctx -> String #

showList :: [SigningKey ctx] -> ShowS #

(NFData (PrivateKey 2048 ctx), NFData (VarByteString 320 ctx)) => NFData (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

rnf :: SigningKey ctx -> () #

(Eq (PrivateKey 2048 ctx), Eq (VarByteString 320 ctx)) => Eq (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

(==) :: SigningKey ctx -> SigningKey ctx -> Bool #

(/=) :: SigningKey ctx -> SigningKey ctx -> Bool #

(SymbolicData (PrivateKey 2048 ctx), Symbolic ctx) => SymbolicData (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Context (SigningKey ctx) :: (Type -> Type) -> Type Source #

type Support (SigningKey ctx) Source #

type Layout (SigningKey ctx) :: Type -> Type Source #

type Payload (SigningKey ctx) :: Type -> Type Source #

(SymbolicInput (PrivateKey 2048 ctx), Symbolic ctx) => SymbolicInput (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

isValid :: SigningKey ctx -> Bool (Context (SigningKey ctx)) Source #

type Rep (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (SigningKey ctx) = D1 ('MetaData "SigningKey" "ZkFold.Symbolic.Data.JWT" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "SigningKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "prvKid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 320 ctx)) :*: S1 ('MetaSel ('Just "prvKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PrivateKey 2048 ctx))))
type Context (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Layout (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Layout (SigningKey ctx) = GLayout (Rep (SigningKey ctx))
type Payload (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Support (SigningKey ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

data TokenHeader ctx Source #

Json Web Token header with information about encryption algorithm and signature

Constructors

TokenHeader 

Fields

Instances

Instances details
Symbolic ctx => FromJSON (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Generic (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Rep (TokenHeader ctx) :: Type -> Type #

Methods

from :: TokenHeader ctx -> Rep (TokenHeader ctx) x #

to :: Rep (TokenHeader ctx) x -> TokenHeader ctx #

(Show (ctx (Vector 72)), Show (ctx (Vector 320)), Show (ctx (Vector 32)), Show (ctx Par1)) => Show (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

showsPrec :: Int -> TokenHeader ctx -> ShowS #

show :: TokenHeader ctx -> String #

showList :: [TokenHeader ctx] -> ShowS #

(NFData (ctx (Vector 72)), NFData (ctx (Vector 320)), NFData (ctx (Vector 32)), NFData (ctx Par1)) => NFData (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

rnf :: TokenHeader ctx -> () #

(Eq (ctx (Vector 72)), Eq (ctx (Vector 320)), Eq (ctx (Vector 32)), Eq (ctx Par1)) => Eq (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

(==) :: TokenHeader ctx -> TokenHeader ctx -> Bool #

(/=) :: TokenHeader ctx -> TokenHeader ctx -> Bool #

Symbolic ctx => SymbolicData (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Context (TokenHeader ctx) :: (Type -> Type) -> Type Source #

type Support (TokenHeader ctx) Source #

type Layout (TokenHeader ctx) :: Type -> Type Source #

type Payload (TokenHeader ctx) :: Type -> Type Source #

Symbolic ctx => SymbolicInput (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

(Symbolic ctx, Context (TokenHeader ctx) ~ ctx, NFData (VarByteString (MaxLength (TokenHeader ctx)) ctx)) => IsSymbolicJSON (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type MaxLength (TokenHeader ctx) :: Natural Source #

type Rep (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (TokenHeader ctx) = D1 ('MetaData "TokenHeader" "ZkFold.Symbolic.Data.JWT" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "TokenHeader" 'PrefixI 'True) (S1 ('MetaSel ('Just "hdAlg") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 72 ctx)) :*: (S1 ('MetaSel ('Just "hdKid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 320 ctx)) :*: S1 ('MetaSel ('Just "hdTyp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 32 ctx)))))
type Context (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Layout (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Payload (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Support (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type MaxLength (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type MaxLength (TokenHeader ctx) = 648

data TokenPayload ctx Source #

Json Web Token payload with information about the issuer, bearer and TTL

Constructors

TokenPayload 

Fields

Instances

Instances details
Symbolic ctx => Arbitrary (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

arbitrary :: Gen (TokenPayload ctx) #

shrink :: TokenPayload ctx -> [TokenPayload ctx] #

Symbolic ctx => FromJSON (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Generic (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Rep (TokenPayload ctx) :: Type -> Type #

Methods

from :: TokenPayload ctx -> Rep (TokenPayload ctx) x #

to :: Rep (TokenPayload ctx) x -> TokenPayload ctx #

(Show (ctx (Vector 40)), Show (ctx (Vector 80)), Show (ctx (Vector 256)), Show (ctx (Vector 512)), Show (ctx (Vector 1024)), Show (ctx Par1)) => Show (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

(Eq (ctx (Vector 40)), Eq (ctx (Vector 80)), Eq (ctx (Vector 256)), Eq (ctx (Vector 512)), Eq (ctx (Vector 1024)), Eq (ctx Par1)) => Eq (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

(==) :: TokenPayload ctx -> TokenPayload ctx -> Bool #

(/=) :: TokenPayload ctx -> TokenPayload ctx -> Bool #

Symbolic ctx => SymbolicData (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Context (TokenPayload ctx) :: (Type -> Type) -> Type Source #

type Support (TokenPayload ctx) Source #

type Layout (TokenPayload ctx) :: Type -> Type Source #

type Payload (TokenPayload ctx) :: Type -> Type Source #

Symbolic ctx => SymbolicInput (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

(Symbolic ctx, Context (TokenPayload ctx) ~ ctx) => IsSymbolicJSON (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type MaxLength (TokenPayload ctx) :: Natural Source #

type Rep (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (TokenPayload ctx) = D1 ('MetaData "TokenPayload" "ZkFold.Symbolic.Data.JWT" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "TokenPayload" 'PrefixI 'True) (((S1 ('MetaSel ('Just "plIss") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 256 ctx)) :*: (S1 ('MetaSel ('Just "plAzp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 1024 ctx)) :*: S1 ('MetaSel ('Just "plAud") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 1024 ctx)))) :*: ((S1 ('MetaSel ('Just "plSub") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 256 ctx)) :*: S1 ('MetaSel ('Just "plHd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 256 ctx))) :*: (S1 ('MetaSel ('Just "plEmail") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 512 ctx)) :*: S1 ('MetaSel ('Just "plEmailVerified") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 40 ctx))))) :*: ((S1 ('MetaSel ('Just "plAtHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 256 ctx)) :*: (S1 ('MetaSel ('Just "plName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 512 ctx)) :*: S1 ('MetaSel ('Just "plPicture") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 1024 ctx)))) :*: ((S1 ('MetaSel ('Just "plGivenName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 256 ctx)) :*: S1 ('MetaSel ('Just "plFamilyName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 256 ctx))) :*: (S1 ('MetaSel ('Just "plIat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 80 ctx)) :*: S1 ('MetaSel ('Just "plExp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (VarByteString 80 ctx)))))))
type Context (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Layout (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Payload (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Support (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type MaxLength (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type MaxLength (TokenPayload ctx) = 7088

type Signature keyLen ctx = ByteString keyLen ctx Source #

data ClientSecret ctx Source #

Constructors

ClientSecret 

Fields

Instances

Instances details
Generic (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Rep (ClientSecret ctx) :: Type -> Type #

Methods

from :: ClientSecret ctx -> Rep (ClientSecret ctx) x #

to :: Rep (ClientSecret ctx) x -> ClientSecret ctx #

(NFData (TokenHeader ctx), NFData (TokenPayload ctx), NFData (Signature 2048 ctx)) => NFData (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Methods

rnf :: ClientSecret ctx -> () #

Symbolic ctx => SymbolicData (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type Context (ClientSecret ctx) :: (Type -> Type) -> Type Source #

type Support (ClientSecret ctx) Source #

type Layout (ClientSecret ctx) :: Type -> Type Source #

type Payload (ClientSecret ctx) :: Type -> Type Source #

Symbolic ctx => SymbolicInput (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Rep (ClientSecret ctx) = D1 ('MetaData "ClientSecret" "ZkFold.Symbolic.Data.JWT" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "ClientSecret" 'PrefixI 'True) (S1 ('MetaSel ('Just "csHeader") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TokenHeader ctx)) :*: (S1 ('MetaSel ('Just "csPayload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TokenPayload ctx)) :*: S1 ('MetaSel ('Just "csSignature") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Signature 2048 ctx)))))
type Context (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Layout (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Payload (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

type Support (ClientSecret ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

class IsSymbolicJSON a where Source #

Associated Types

type MaxLength a :: Natural Source #

Instances

Instances details
(Symbolic ctx, Context (TokenHeader ctx) ~ ctx, NFData (VarByteString (MaxLength (TokenHeader ctx)) ctx)) => IsSymbolicJSON (TokenHeader ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type MaxLength (TokenHeader ctx) :: Natural Source #

(Symbolic ctx, Context (TokenPayload ctx) ~ ctx) => IsSymbolicJSON (TokenPayload ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.JWT

Associated Types

type MaxLength (TokenPayload ctx) :: Natural Source #

type SecretBits ctx = (NFData (ctx (Vector 8)), NFData (ctx (Vector 648)), NFData (ctx (Vector 864)), NFData (ctx (Vector 9456)), NFData (ctx (Vector 10328)), NFData (ctx Par1)) Source #

secretBits :: forall ctx. Symbolic ctx => SecretBits ctx => ClientSecret ctx -> VarByteString 10328 ctx Source #

Client secret as a ByteString: ASCII(base64UrlEncode(header) + "." + base64UrlEncode(payload))

toAsciiBits :: forall a ctx. IsSymbolicJSON a => Context a ~ ctx => KnownNat (MaxLength a) => Symbolic ctx => NFData (ctx (Vector 8)) => NFData (ctx (Vector (ASCII (Next6 (MaxLength a))))) => a -> VarByteString (ASCII (Next6 (MaxLength a))) ctx Source #

signPayload :: (SecretBits ctx, RSA 2048 10328 ctx) => SigningKey ctx -> TokenPayload ctx -> ClientSecret ctx Source #

Sign token payload and form a ClientSecret

verifySignature :: (SecretBits ctx, RSA 2048 10328 ctx) => Certificate ctx -> ClientSecret ctx -> (Bool ctx, ByteString 256 ctx) Source #

Verify that the given JWT was correctly signed with a matching key (i.e. Key IDs match and the signature is correct).