Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data ArithmeticCircuit a p i o = ArithmeticCircuit {
- acSystem :: Map ByteString (Constraint a i)
- acRange :: MonoidalMap a (Set (SysVar i))
- acWitness :: Map ByteString (CircuitWitness a p i)
- acFold :: Map ByteString (CircuitFold a (Var a i) (CircuitWitness a p i))
- acOutput :: o (Var a i)
- data CircuitFold a v w = forall p s j.(Binary (Rep p), Representable p, Traversable s, Representable s, NFData1 s, Binary (Rep s), NFData (Rep s), Ord (Rep s), Representable j, Binary (Rep j), NFData (Rep j), Ord (Rep j)) => CircuitFold {
- foldStep :: ArithmeticCircuit a p (s :*: j) s
- foldStepP :: p (CircuitWitness a p (s :*: j))
- foldSeed :: s v
- foldSeedP :: p w
- foldStream :: Infinite (j w)
- foldCount :: v
- data Var a i
- data SysVar i
- data NewVar
- data WitVar p i
- = WExVar (Rep p)
- | WFoldVar ByteString ByteString
- | WSysVar (SysVar i)
- type VarField = Zp (2 ^ (32 * 8))
- type Arithmetic a = (ResidueField Natural a, Eq a, Ord a, NFData a)
- type Constraint c i = Poly c (SysVar i) Natural
- emptyCircuit :: ArithmeticCircuit a p i U1
- naturalCircuit :: (Arithmetic a, Representable p, Representable i, Traversable o, Binary a, Binary (Rep p), Binary (Rep i), Ord (Rep i)) => (forall x. p x -> i x -> o x) -> ArithmeticCircuit a p i o
- idCircuit :: (Representable i, Semiring a) => ArithmeticCircuit a p i i
- acInput :: (Representable i, Semiring a) => i (Var a i)
- getAllVars :: forall a p i o. (Representable i, Foldable i) => ArithmeticCircuit a p i o -> [SysVar i]
- crown :: ArithmeticCircuit a p i g -> f (Var a i) -> ArithmeticCircuit a p i f
- hlmap :: (Representable i, Representable j, Ord (Rep j), Functor o) => (forall x. j x -> i x) -> ArithmeticCircuit a p i o -> ArithmeticCircuit a p j o
- hpmap :: (Representable p, Representable q) => (forall x. q x -> p x) -> ArithmeticCircuit a p i o -> ArithmeticCircuit a q i o
- witnessGenerator :: (Arithmetic a, Binary a, Representable p, Representable i) => ArithmeticCircuit a p i o -> p a -> i a -> Map NewVar a
- eval :: (Arithmetic a, Binary a, Representable p, Representable i, Functor o) => ArithmeticCircuit a p i o -> p a -> i a -> o a
- eval1 :: (Arithmetic a, Binary a, Representable p, Representable i) => ArithmeticCircuit a p i Par1 -> p a -> i a -> a
- exec :: (Arithmetic a, Binary a, Functor o) => ArithmeticCircuit a U1 U1 o -> o a
- exec1 :: (Arithmetic a, Binary a) => ArithmeticCircuit a U1 U1 Par1 -> a
- apply :: (Eq a, Field a, Ord (Rep j), Representable i, Functor o) => i a -> ArithmeticCircuit a p (i :*: j) o -> ArithmeticCircuit a p j o
- indexW :: (Arithmetic a, Binary a, Representable p, Representable i) => ArithmeticCircuit a p i o -> p a -> i a -> Var a i -> a
- witToVar :: forall a p i. (Finite a, Binary a, Binary (Rep p), Binary (Rep i)) => WitnessF a (WitVar p i) -> ByteString
Documentation
data ArithmeticCircuit a p i o Source #
Arithmetic circuit in the form of a system of polynomial constraints.
ArithmeticCircuit | |
|
Instances
data CircuitFold a v w Source #
forall p s j.(Binary (Rep p), Representable p, Traversable s, Representable s, NFData1 s, Binary (Rep s), NFData (Rep s), Ord (Rep s), Representable j, Binary (Rep j), NFData (Rep j), Ord (Rep j)) => CircuitFold | |
|
Instances
Bifunctor (CircuitFold a) Source # | |
Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Internal bimap :: (a0 -> b) -> (c -> d) -> CircuitFold a a0 c -> CircuitFold a b d # first :: (a0 -> b) -> CircuitFold a a0 c -> CircuitFold a b c # second :: (b -> c) -> CircuitFold a a0 b -> CircuitFold a a0 c # | |
Functor (CircuitFold a v) Source # | |
Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Internal fmap :: (a0 -> b) -> CircuitFold a v a0 -> CircuitFold a v b # (<$) :: a0 -> CircuitFold a v b -> CircuitFold a v a0 # | |
(NFData a, NFData v) => NFData (CircuitFold a v w) Source # | |
Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Internal rnf :: CircuitFold a v w -> () # |
Instances
Instances
Instances
FromJSON NewVar Source # | |
FromJSONKey NewVar Source # | |
ToJSON NewVar Source # | |
ToJSONKey NewVar Source # | |
Generic NewVar Source # | |
Show NewVar Source # | |
Binary NewVar Source # | |
NFData NewVar Source # | |
Eq NewVar Source # | |
Ord NewVar Source # | |
type Rep NewVar Source # | |
Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Var type Rep NewVar = D1 ('MetaData "NewVar" "ZkFold.Symbolic.Compiler.ArithmeticCircuit.Var" "symbolic-base-0.1.0.0-inplace" 'False) (C1 ('MetaCons "EqVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)) :+: C1 ('MetaCons "FoldVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
WExVar (Rep p) | |
WFoldVar ByteString ByteString | |
WSysVar (SysVar i) |
type Arithmetic a = (ResidueField Natural a, Eq a, Ord a, NFData a) Source #
Field of residues with decidable equality and ordering
is called an `arithmetic'
field.
type Constraint c i = Poly c (SysVar i) Natural Source #
The type that represents a constraint in the arithmetic circuit.
emptyCircuit :: ArithmeticCircuit a p i U1 Source #
naturalCircuit :: (Arithmetic a, Representable p, Representable i, Traversable o, Binary a, Binary (Rep p), Binary (Rep i), Ord (Rep i)) => (forall x. p x -> i x -> o x) -> ArithmeticCircuit a p i o Source #
Given a natural transformation
from payload p
and input i
to output o
,
returns a corresponding arithmetic circuit
where outputs computing the payload are unconstrained.
idCircuit :: (Representable i, Semiring a) => ArithmeticCircuit a p i i Source #
Identity circuit which returns its input i
and doesn't use the payload.
getAllVars :: forall a p i o. (Representable i, Foldable i) => ArithmeticCircuit a p i o -> [SysVar i] Source #
crown :: ArithmeticCircuit a p i g -> f (Var a i) -> ArithmeticCircuit a p i f Source #
hlmap :: (Representable i, Representable j, Ord (Rep j), Functor o) => (forall x. j x -> i x) -> ArithmeticCircuit a p i o -> ArithmeticCircuit a p j o Source #
hpmap :: (Representable p, Representable q) => (forall x. q x -> p x) -> ArithmeticCircuit a p i o -> ArithmeticCircuit a q i o Source #
witnessGenerator :: (Arithmetic a, Binary a, Representable p, Representable i) => ArithmeticCircuit a p i o -> p a -> i a -> Map NewVar a Source #
eval :: (Arithmetic a, Binary a, Representable p, Representable i, Functor o) => ArithmeticCircuit a p i o -> p a -> i a -> o a Source #
Evaluates the arithmetic circuit using the supplied input map.
eval1 :: (Arithmetic a, Binary a, Representable p, Representable i) => ArithmeticCircuit a p i Par1 -> p a -> i a -> a Source #
Evaluates the arithmetic circuit with one output using the supplied input map.
exec :: (Arithmetic a, Binary a, Functor o) => ArithmeticCircuit a U1 U1 o -> o a Source #
Evaluates the arithmetic circuit with no inputs.
exec1 :: (Arithmetic a, Binary a) => ArithmeticCircuit a U1 U1 Par1 -> a Source #
Evaluates the arithmetic circuit with no inputs and one output.
apply :: (Eq a, Field a, Ord (Rep j), Representable i, Functor o) => i a -> ArithmeticCircuit a p (i :*: j) o -> ArithmeticCircuit a p j o Source #
Applies the values of the first couple of inputs to the arithmetic circuit.
indexW :: (Arithmetic a, Binary a, Representable p, Representable i) => ArithmeticCircuit a p i o -> p a -> i a -> Var a i -> a Source #
witToVar :: forall a p i. (Finite a, Binary a, Binary (Rep p), Binary (Rep i)) => WitnessF a (WitVar p i) -> ByteString Source #
Generates new variable index given a witness for it.
It is a root hash (sha256) of a Merkle tree which is obtained from witness:
- Due to parametricity, the only operations inside witness are
operations from
WitnessField
interface; Thus witness can be viewed as an AST of a
WitnessField
"language" where:- leafs are
fromConstant
calls and variables; - nodes are algebraic operations;
- root is the witness value for new variable.
- leafs are
- To inspect this AST, we instantiate witness with a special inspector type
whose
WitnessField
instances perform inspection. - Inspector type used here,
MerkleHash
, treats AST as a Merkle tree and performs the calculation of hashes for it. - Thus the result of running the witness with
MerkleHash
as aWitnessField
is a root hash of a Merkle tree for a witness.