mirror of
https://github.com/logos-storage/plonky2-verifier.git
synced 2026-01-07 16:23:07 +00:00
calculate the degree of gate constraints
This commit is contained in:
parent
e49a0cfdba
commit
4b34d8df89
@ -124,6 +124,18 @@ straightLineOperCount (MkStraightLine{..}) = final where
|
|||||||
coms = map exprOperCount $ commits
|
coms = map exprOperCount $ commits
|
||||||
final = mconcat defs <> mconcat coms
|
final = mconcat defs <> mconcat coms
|
||||||
|
|
||||||
|
-- | Maximum degree of a gate's constraints
|
||||||
|
constraintDegree :: StraightLine -> Int
|
||||||
|
constraintDegree (MkStraightLine{..}) = maxdeg where
|
||||||
|
ndefs = length localdefs
|
||||||
|
table = array (0,ndefs-1) [ (i, exprDegree lkp rhs) | MkLocalDef i _ rhs <- localdefs ]
|
||||||
|
lkp var = case var of
|
||||||
|
LocalVar i _ -> table!i
|
||||||
|
ProofVar v -> case v of { PIV {} -> 0 ; _ -> 1 }
|
||||||
|
maxdeg = case commits of
|
||||||
|
[] -> 0
|
||||||
|
_ -> maximum (map (exprDegree lkp) commits)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
type Scope a = IntMap a
|
type Scope a = IntMap a
|
||||||
|
|||||||
@ -18,7 +18,7 @@ data PlonkyVar
|
|||||||
= SelV Int -- ^ selector variable
|
= SelV Int -- ^ selector variable
|
||||||
| ConstV Int -- ^ constant variable
|
| ConstV Int -- ^ constant variable
|
||||||
| WireV Int -- ^ wire variable
|
| WireV Int -- ^ wire variable
|
||||||
| PIV Int -- ^ public input hash variable
|
| PIV Int -- ^ public input hash variable (technically these are constants, not variables)
|
||||||
deriving (Eq,Ord,Show)
|
deriving (Eq,Ord,Show)
|
||||||
|
|
||||||
instance Pretty PlonkyVar where
|
instance Pretty PlonkyVar where
|
||||||
|
|||||||
@ -70,6 +70,11 @@ test_fibonacci = do
|
|||||||
let pubio_prg = gateProgram (PublicInputGate )
|
let pubio_prg = gateProgram (PublicInputGate )
|
||||||
let const_prg = gateProgram (ConstantGate 2)
|
let const_prg = gateProgram (ConstantGate 2)
|
||||||
|
|
||||||
|
putStrLn $ "maximum degree of constraints in ArithmeticGate = " ++ show (constraintDegree arith_prg)
|
||||||
|
putStrLn $ "maximum degree of constraints in PosiedonGate = " ++ show (constraintDegree posei_prg)
|
||||||
|
putStrLn $ "maximum degree of constraints in PublicInputGate = " ++ show (constraintDegree pubio_prg)
|
||||||
|
putStrLn $ "maximum degree of constraints in ConstGate = " ++ show (constraintDegree const_prg)
|
||||||
|
|
||||||
let arith_evals = runStraightLine (fmap fromBase arith_row) arith_prg
|
let arith_evals = runStraightLine (fmap fromBase arith_row) arith_prg
|
||||||
let posei_evals = runStraightLine (fmap fromBase posei_row) posei_prg
|
let posei_evals = runStraightLine (fmap fromBase posei_row) posei_prg
|
||||||
let const_evals = runStraightLine (fmap fromBase const_row) const_prg
|
let const_evals = runStraightLine (fmap fromBase const_row) const_prg
|
||||||
@ -92,5 +97,5 @@ test_fibonacci = do
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
main :: IO
|
main :: IO ()
|
||||||
main = test_fibonacci
|
main = test_fibonacci
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user