Commands
In this article, we will list all the useful commands in Keelung.
You can feed a Keelung program into the interpreter to test and see if it is working as expected.
interpret :: FieldType -> Comp t -> [Integer] -> [Integer] -> IO [Integer]
We provide shorthands like
gf181
for interpret GF181
. Here are all the other shorthands of interpret
:gf181 = interpret GF181 :: Comp t -> [GF181] -> [GF181] -> IO [N GF181]
bn128 = interpret BN128 :: Comp t -> [BN128] -> [BN128] -> IO [N BN128]
b64 = interpret B64 :: Comp t -> [B64 ] -> [B64 ] -> IO [N B64 ]
Take
square
for example:square :: Comp Field
square = do
x <- input Public
return (x * x)
If we apply
[2]
as the public input and []
as the private input to interpret GF181 square
, we'd get:stack repl
> interpret GF181 square [2] []
[4]
To generate R1CS constraints, specify the type of field to use and a Keelung program into the
compile
function:compile :: FieldType -> Comp t -> IO (Either Error (R1CS Integer))
Take
square
for example, we'd get:stack repl
> compile GF181 square
Right R1CS {
Constriant (1):
Ordinary constriants (1):
$1 * $1 = $0
Variables (2):
Output variable : $0
Public Input variable : $1
}
The command for generating a proof is almost identical to that of
interpret
, except that instead of getting a list of outputs, you get a proof file named proof
in the current working directory.generate :: FieldType -> Comp t -> [Integer] -> [Integer] -> IO ()
Last modified 3mo ago