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

ZkFold.Symbolic.Data.VarByteString

Synopsis

Documentation

data VarByteString (maxLen :: Natural) (context :: (Type -> Type) -> Type) Source #

A ByteString that has length unknown at compile time but guaranteed to not exceed maxLen. The unassigned buffer space (i.e. bits past bsLength) should be set to zero at all times.

TODO: Declare all the instances ByteString has for VarByteString

Constructors

VarByteString 

Fields

Instances

Instances details
(Symbolic ctx, (m * 8) ~ n, KnownNat m) => FromConstant ByteString (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

(Symbolic ctx, KnownNat n) => FromConstant Natural (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

(Symbolic ctx, KnownSymbol s, m ~ Length s, (m * 8) ~ l, KnownNat m) => IsTypeString s (VarByteString l ctx) Source #

Construct a VarByteString from a type-level string calculating its length automatically

Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

fromType :: VarByteString l ctx Source #

(Symbolic ctx, KnownNat n) => Conditional (Bool ctx) (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

bool :: VarByteString n ctx -> VarByteString n ctx -> Bool ctx -> VarByteString n ctx Source #

(KnownNat maxLen, Symbolic ctx) => Arbitrary (VarByteString maxLen ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

arbitrary :: Gen (VarByteString maxLen ctx) #

shrink :: VarByteString maxLen ctx -> [VarByteString maxLen ctx] #

(Symbolic ctx, KnownNat m, (m * 8) ~ n) => FromJSON (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

(Symbolic ctx, (m * 8) ~ n, KnownNat m) => IsString (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

fromString :: String -> VarByteString n ctx #

Generic (VarByteString maxLen context) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Associated Types

type Rep (VarByteString maxLen context) :: Type -> Type #

Methods

from :: VarByteString maxLen context -> Rep (VarByteString maxLen context) x #

to :: Rep (VarByteString maxLen context) x -> VarByteString maxLen context #

(Show (ctx (Vector n)), Show (ctx Par1)) => Show (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

showsPrec :: Int -> VarByteString n ctx -> ShowS #

show :: VarByteString n ctx -> String #

showList :: [VarByteString n ctx] -> ShowS #

(NFData (ctx (Vector n)), NFData (ctx Par1)) => NFData (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

rnf :: VarByteString n ctx -> () #

(Eq (ctx (Vector n)), Eq (ctx Par1)) => Eq (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

(==) :: VarByteString n ctx -> VarByteString n ctx -> Bool #

(/=) :: VarByteString n ctx -> VarByteString n ctx -> Bool #

(KnownNat n, Symbolic ctx) => SymbolicData (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Associated Types

type Context (VarByteString n ctx) :: (Type -> Type) -> Type Source #

type Support (VarByteString n ctx) Source #

type Layout (VarByteString n ctx) :: Type -> Type Source #

type Payload (VarByteString n ctx) :: Type -> Type Source #

(Symbolic ctx, KnownNat n) => Eq (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Associated Types

type BooleanOf (VarByteString n ctx) Source #

(KnownNat n, Symbolic ctx) => SymbolicInput (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

Methods

isValid :: VarByteString n ctx -> Bool (Context (VarByteString n ctx)) Source #

type Rep (VarByteString maxLen context) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

type Rep (VarByteString maxLen context) = D1 ('MetaData "VarByteString" "ZkFold.Symbolic.Data.VarByteString" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "VarByteString" 'PrefixI 'True) (S1 ('MetaSel ('Just "bsLength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FieldElement context)) :*: S1 ('MetaSel ('Just "bsBuffer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ByteString maxLen context))))
type Context (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

type Layout (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

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

Defined in ZkFold.Symbolic.Data.VarByteString

type Support (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

type BooleanOf (VarByteString n ctx) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.VarByteString

fromNatural :: forall n ctx. (Symbolic ctx, KnownNat n) => Natural -> Natural -> VarByteString n ctx Source #

fromByteString :: forall n ctx. (Symbolic ctx, KnownNat n) => ByteString n ctx -> VarByteString n ctx Source #

toAsciiString :: forall n p. (KnownNat (Div n 8), (Div n 8 * 8) ~ n, KnownNat p) => VarByteString n (Interpreter (Zp p)) -> String Source #

append :: forall m n ctx. Symbolic ctx => KnownNat m => KnownNat (m + n) => VarByteString m ctx -> VarByteString n ctx -> VarByteString (m + n) ctx Source #

Join two variable-length ByteStrings and move all the unsaaigned space towards lower indices. Let u denote the unassigned space. Then, uu1010 append u10010 == uuu101010010

(@+) :: forall m n ctx. Symbolic ctx => KnownNat m => KnownNat (m + n) => VarByteString m ctx -> VarByteString n ctx -> VarByteString (m + n) ctx infixl 6 Source #

shiftL :: forall n ctx. Symbolic ctx => KnownNat n => ByteString n ctx -> FieldElement ctx -> ByteString n ctx Source #

shiftR :: forall n ctx. Symbolic ctx => KnownNat n => ByteString n ctx -> FieldElement ctx -> ByteString n ctx Source #

wipeUnassigned :: forall n ctx. Symbolic ctx => KnownNat n => VarByteString n ctx -> VarByteString n ctx Source #

Set all the unassigned bits to zero