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 s j.(Functor s, NFData1 s, Binary (Rep s), NFData (Rep s), Ord (Rep s), Functor j, Binary (Rep j), NFData (Rep j), Ord (Rep j)) => CircuitFold {
- foldStep :: ArithmeticCircuit a U1 (j :*: s) s
- foldSeed :: s v
- foldStream :: Infinite (j w)
- foldCount :: v
- foldResult :: s v
- data Var a i
- data SysVar i
- = InVar (Rep i)
- | NewVar ByteString
- data WitVar p 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
- 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, Representable p, Representable i) => ArithmeticCircuit a p i o -> p a -> i a -> Map ByteString a
- eval :: (Arithmetic a, Representable p, Representable i, Functor o) => ArithmeticCircuit a p i o -> p a -> i a -> o a
- eval1 :: (Arithmetic a, Representable p, Representable i) => ArithmeticCircuit a p i Par1 -> p a -> i a -> a
- exec :: (Arithmetic a, Functor o) => ArithmeticCircuit a U1 U1 o -> o a
- exec1 :: Arithmetic 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, 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 s j.(Functor s, NFData1 s, Binary (Rep s), NFData (Rep s), Ord (Rep s), Functor 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
InVar (Rep i) | |
NewVar ByteString |
Instances
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.
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, Representable p, Representable i) => ArithmeticCircuit a p i o -> p a -> i a -> Map ByteString a Source #
eval :: (Arithmetic 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, 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, Functor o) => ArithmeticCircuit a U1 U1 o -> o a Source #
Evaluates the arithmetic circuit with no inputs.
exec1 :: Arithmetic 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, 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.