Skip to content

Commit

Permalink
Merge branch 'feat/init-stdlib' into feat/multiplexer
Browse files Browse the repository at this point in the history
  • Loading branch information
katat committed Oct 25, 2024
2 parents 45af223 + 34cf5c4 commit 753f358
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/snarkjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ fi
DIR_PATH=$1
CURVE=$2

# Init stdlib in .noname/release/src/stdlib instead of downloading
echo "Overriding stdlib in .noname/release/src/stdlib..."
mkdir -p ~/.noname/release/src/stdlib/ && cp -r /app/noname/src/stdlib/* ~/.noname/release/src/stdlib/

# Ensure the circuit directory exists and is initialized
echo "Initializing a new Noname package..."
noname new --path circuit_noname
Expand Down
6 changes: 4 additions & 2 deletions src/cli/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use camino::Utf8PathBuf as PathBuf;
use miette::{Context, IntoDiagnostic, Result};
use serde::{Deserialize, Serialize};

use crate::stdlib::STDLIB_DIRECTORY;

use super::{
manifest::{read_manifest, Manifest},
NONAME_DIRECTORY, PACKAGE_DIRECTORY, RELEASE_DIRECTORY,
Expand Down Expand Up @@ -248,7 +250,7 @@ pub(crate) fn path_to_stdlib() -> PathBuf {
.expect("invalid UTF8 path");
let noname_dir = home_dir.join(NONAME_DIRECTORY);

noname_dir.join(RELEASE_DIRECTORY).join("src/stdlib/native")
noname_dir.join(RELEASE_DIRECTORY).join(STDLIB_DIRECTORY)
}

/// download package from github
Expand Down Expand Up @@ -278,7 +280,7 @@ pub fn download_stdlib() -> Result<()> {
// Hardcoded repository details and target branch
let repo_owner = "zksecurity";
let repo_name = "noname";
let target_branch = "release";
let target_branch = "main";
let repo_url = format!(
"https://github.com/{owner}/{repo}.git",
owner = repo_owner,
Expand Down
4 changes: 0 additions & 4 deletions src/stdlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ pub fn init_stdlib_dep<B: Backend>(
for lib in libs {
let module = UserRepo::new(&format!("std/{}", lib));
let prefix_stdlib = Path::new(path_prefix);
println!(
"Loading stdlib: {}",
prefix_stdlib.join(format!("{lib}/lib.no")).display()
);
let code = std::fs::read_to_string(prefix_stdlib.join(format!("{lib}/lib.no"))).unwrap();
node_id =
typecheck_next_file(tast, Some(module), sources, lib.to_string(), code, 0).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions src/stdlib/native/bits/lib.no
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
hint fn nth_bit(value: Field, const nth: Field) -> Field;

// Convert a bit array to a Field
fn from_bits(bits: [Bool; LEN]) -> Field {
let mut lc1 = 0;
let mut e2 = 1;
Expand All @@ -12,6 +13,7 @@ fn from_bits(bits: [Bool; LEN]) -> Field {
return lc1;
}

// Convert a Field to a bit array
fn to_bits(const LEN: Field, value: Field) -> [Bool; LEN] {
let mut bits = [false; LEN];
let mut lc1 = 0;
Expand Down

0 comments on commit 753f358

Please sign in to comment.