Skip to content

Commit

Permalink
Add Noir support to sindri init command
Browse files Browse the repository at this point in the history
This adds a basic project template directory for Noir which contains a project
asserting `X == Y`.

Merges #25

LGTM given by: @katiemckeon
  • Loading branch information
sangaline authored Dec 4, 2023
1 parent 4f15486 commit 5c150ad
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/cli/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,36 @@ export const initCommand = new Command()
packageName,
provingScheme,
});
} else if (circuitType === "noir") {
const packageName = await input({
message: "Noir Package Name:",
default: circuitName
.toLowerCase()
.replace(/^[^a-z0-9_]*/, "")
.replace(/-+/g, "-"),
validate: (input): boolean | string => {
if (input.length === 0) {
return "You must specify a package name.";
}
if (!/^[a-z0-9_]+(?:-[a-z0-9_]+)*$$/.test(input)) {
return (
"Package names must begin with a lowercase letter, number, or underscore, and only " +
"be followed by lowercase or numeric characters and underscores (optionally " +
"separated hyphens)."
);
}
return true;
},
});
const provingScheme: "barretenberg" = await select({
message: "Proving Scheme:",
default: "barretenberg",
choices: [{ name: "Barretenberg", value: "barretenberg" }],
});
Object.assign(context, {
packageName,
provingScheme,
});
} else {
logger.fatal(`Sorry, ${circuitType} is not yet supported.`);
return process.exit(1);
Expand Down
3 changes: 3 additions & 0 deletions templates/noir/.sindriignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/targets/
Prover.toml
Verifier.toml
7 changes: 7 additions & 0 deletions templates/noir/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "{{ packageName }}"
type = "bin"
authors = [""]
compiler_version = "0.19.3"

[dependencies]
2 changes: 2 additions & 0 deletions templates/noir/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
X = 5
Y = 5
6 changes: 6 additions & 0 deletions templates/noir/sindri.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://forge.sindri.app/api/v1/sindri-manifest-schema.json",
"name": "{{ circuitName }}",
"circuitType": "noir",
"provingScheme": "{{ provingScheme }}"
}
6 changes: 6 additions & 0 deletions templates/noir/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Define the main function for the circuit.
fn main(X: Field, Y: pub Field) {
// Put your code here...
// Enforce the constraint that X must equal Y.
assert(X == Y);
}

0 comments on commit 5c150ad

Please sign in to comment.