Skip to content

Commit

Permalink
no_std flag
Browse files Browse the repository at this point in the history
  • Loading branch information
z-tech committed Jul 24, 2024
1 parent a66df7c commit 3ec4311
Show file tree
Hide file tree
Showing 29 changed files with 60 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ jobs:
check_no_std:
name: Check no_std
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ authors = ["arkworks contributors"]
edition = "2021"

[dependencies]
ark-crypto-primitives = { version="^0.4.0", features = ["merkle_tree", "sponge"] }
ark-crypto-primitives = { default-features = false, features = ["merkle_tree", "sponge"], version="^0.4.0" }
ark-ff = { version = "0.4" }
ark-poly = { version = "0.4.2" }
ark-std = { version="^0.4.0" }
ark-serialize = { version = "0.4" }
ark-test-curves = { version = "0.4", features = [ "bls12_381_curve" ] }
blake2 = { version = "0.10" }
blake3 = { version = "1.5.0" }
itertools = "0.13.0"
lazy_static = { version = "1.4" }
poseidon-paramgen = { version = "0.4" }
rand = { version = "0.8" }
sha3 = { version = "0.10" }
itertools = "0.13.0"

[patch.crates-io]
ark-crypto-primitives = { git= "https://github.com/arkworks-rs/crypto-primitives" }
Expand Down
1 change: 1 addition & 0 deletions src/crypto/fs/blake3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ark_crypto_primitives::sponge::{Absorb, CryptographicSponge};
use ark_std::{vec, vec::Vec};
use blake3::Hasher;

#[derive(Default, Clone, Copy)]
Expand Down
6 changes: 5 additions & 1 deletion src/crypto/merkle_tree/blake2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{borrow::Borrow, marker::PhantomData};
use ark_std::{
borrow::Borrow,
marker::PhantomData,
{vec, vec::Vec},
};

use ark_crypto_primitives::{
crh::{CRHScheme, TwoToOneCRHScheme},
Expand Down
6 changes: 5 additions & 1 deletion src/crypto/merkle_tree/blake3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{borrow::Borrow, marker::PhantomData};
use ark_std::{
borrow::Borrow,
marker::PhantomData,
{vec, vec::Vec},
};

use super::HashCounter;
use ark_crypto_primitives::{
Expand Down
6 changes: 5 additions & 1 deletion src/crypto/merkle_tree/mock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{borrow::Borrow, marker::PhantomData};
use ark_std::{
borrow::Borrow,
marker::PhantomData,
{vec, vec::Vec},
};

use ark_crypto_primitives::{
crh::{CRHScheme, TwoToOneCRHScheme},
Expand Down
13 changes: 9 additions & 4 deletions src/crypto/merkle_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ pub mod mock;
pub mod poseidon;
pub mod sha3;

use std::{borrow::Borrow, marker::PhantomData, sync::atomic::AtomicUsize};
use ark_std::{
borrow::Borrow,
marker::PhantomData,
sync::atomic::AtomicUsize,
{vec, vec::Vec},
};

use ark_crypto_primitives::crh::CRHScheme;
use ark_serialize::CanonicalSerialize;
Expand All @@ -24,19 +29,19 @@ impl HashCounter {
pub(crate) fn add() -> usize {
HASH_COUNTER
.counter
.fetch_add(1, std::sync::atomic::Ordering::SeqCst)
.fetch_add(1, ark_std::sync::atomic::Ordering::SeqCst)
}

pub fn reset() {
HASH_COUNTER
.counter
.store(0, std::sync::atomic::Ordering::SeqCst)
.store(0, ark_std::sync::atomic::Ordering::SeqCst)
}

pub fn get() -> usize {
HASH_COUNTER
.counter
.load(std::sync::atomic::Ordering::SeqCst)
.load(ark_std::sync::atomic::Ordering::SeqCst)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/merkle_tree/poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::Borrow, marker::PhantomData};
use ark_std::{borrow::Borrow, marker::PhantomData, vec::Vec};

use ark_crypto_primitives::crh::poseidon;
use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
Expand Down
6 changes: 5 additions & 1 deletion src/crypto/merkle_tree/sha3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{borrow::Borrow, marker::PhantomData};
use ark_std::{
borrow::Borrow,
marker::PhantomData,
{vec, vec::Vec},
};

use super::HashCounter;
use ark_crypto_primitives::{
Expand Down
2 changes: 1 addition & 1 deletion src/direct/ldt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ark_crypto_primitives::{
sponge::{Absorb, CryptographicSponge},
};
use ark_ff::FftField;
use ark_std::marker::PhantomData;
use ark_std::{marker::PhantomData, vec::Vec};

use crate::{
direct::{config::DirectConfig, prover::DirectProver, verifier::DirectVerifier},
Expand Down
1 change: 1 addition & 0 deletions src/direct/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ark_crypto_primitives::{
sponge::{Absorb, CryptographicSponge},
};
use ark_ff::FftField;
use ark_std::vec::Vec;

use crate::utils::squeeze_integer;

Expand Down
2 changes: 1 addition & 1 deletion src/direct/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ark_crypto_primitives::{
};

use ark_ff::FftField;
use ark_std::marker::PhantomData;
use ark_std::{marker::PhantomData, vec::Vec};

use crate::{
direct::{config::DirectConfig, proof::DirectProof},
Expand Down
2 changes: 1 addition & 1 deletion src/direct/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ark_crypto_primitives::{
sponge::{Absorb, CryptographicSponge},
};
use ark_ff::FftField;
use ark_std::marker::PhantomData;
use ark_std::{marker::PhantomData, vec::Vec};

use crate::{
direct::{config::DirectConfig, proof::DirectProof},
Expand Down
5 changes: 2 additions & 3 deletions src/domain.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::ops::Deref;

use ark_ff::FftField;
use ark_poly::{
EvaluationDomain, GeneralEvaluationDomain, MixedRadixEvaluationDomain, Radix2EvaluationDomain,
};
use ark_std::ops::Deref;

#[derive(Debug, Clone)]
pub struct Domain<F: FftField> {
Expand Down Expand Up @@ -164,7 +163,7 @@ impl<F: FftField> Deref for Domain<F> {

#[cfg(test)]
mod tests {
use std::collections::HashSet;
use ark_std::collections::HashSet;

use super::*;
use crate::crypto::fields::Field64 as TestField;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![no_std]
pub mod crypto;
pub mod direct;
pub mod domain;
Expand Down
1 change: 1 addition & 0 deletions src/poly_utils/bs08.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ark_ff::Field;
use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial, Polynomial};
use ark_std::{vec, vec::Vec};

use crate::utils;

Expand Down
1 change: 1 addition & 0 deletions src/poly_utils/folding.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ark_ff::Field;
use ark_poly::{univariate::DensePolynomial, Polynomial};
use ark_std::vec::Vec;

use crate::poly_utils::interpolation;

Expand Down
1 change: 1 addition & 0 deletions src/poly_utils/interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use ark_ff::{batch_inversion, FftField, Field};
use ark_poly::{
univariate::DensePolynomial, DenseUVPolynomial, Evaluations, Polynomial, Radix2EvaluationDomain,
};
use ark_std::{vec, vec::Vec};

use crate::utils;

Expand Down
2 changes: 2 additions & 0 deletions src/poly_utils/quotient.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ark_ff::{FftField, Field};
use ark_poly::{univariate::DensePolynomial, Polynomial};
use ark_std::vec::Vec;

use super::interpolation;

Expand Down Expand Up @@ -67,6 +68,7 @@ pub fn quotient_with_hint<'a, F: Field>(
#[cfg(test)]
mod tests {
use ark_poly::DenseUVPolynomial;
use ark_std::vec;
use rand::Rng;

use super::*;
Expand Down
1 change: 1 addition & 0 deletions src/stir/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use ark_crypto_primitives::{
merkle_tree::{Config as MerkleConfig, LeafParam, TwoToOneParam},
sponge::CryptographicSponge,
};
use ark_std::vec::Vec;

pub struct STIRConfig<M: MerkleConfig, S: CryptographicSponge> {
pub folding_factor: usize,
Expand Down
1 change: 1 addition & 0 deletions src/stir/ldt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use ark_crypto_primitives::{
};
use ark_ff::{FftField, PrimeField};
use ark_std::marker::PhantomData;
use ark_std::vec::Vec;

pub struct STIR<F, M, S, W>
where
Expand Down
1 change: 1 addition & 0 deletions src/stir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod tests {
use ark_poly::univariate::DensePolynomial;
use ark_poly::DenseUVPolynomial;
use ark_std::test_rng;
use ark_std::vec;

use crate::{
crypto::{fields::Field256, fs, merkle_tree},
Expand Down
1 change: 1 addition & 0 deletions src/stir/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ark_crypto_primitives::{
};
use ark_ff::{batch_inversion, Field};
use ark_poly::{univariate::DensePolynomial, Polynomial};
use ark_std::vec::Vec;

use super::config::STIRConfig;

Expand Down
1 change: 1 addition & 0 deletions src/stir/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ark_crypto_primitives::{
use ark_ff::{FftField, PrimeField};
use ark_poly::Polynomial;
use ark_std::marker::PhantomData;
use ark_std::vec::Vec;

use crate::{
ldt::Prover,
Expand Down
1 change: 1 addition & 0 deletions src/stir/prover_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ark_crypto_primitives::{
};
use ark_ff::{FftField, PrimeField};
use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial, EvaluationDomain, Polynomial};
use ark_std::{vec, vec::Vec};

use crate::{
domain::Domain,
Expand Down
1 change: 1 addition & 0 deletions src/stir/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ark_crypto_primitives::{
use ark_ff::{FftField, PrimeField};
use ark_poly::Polynomial;
use ark_std::marker::PhantomData;
use ark_std::vec::Vec;

use crate::{
ldt::Verifier,
Expand Down
1 change: 1 addition & 0 deletions src/stir/verifier_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ark_poly::{
univariate::DensePolynomial, DenseUVPolynomial, EvaluationDomain, Polynomial,
Radix2EvaluationDomain,
};
use ark_std::{vec, vec::Vec};
use itertools::izip;

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::BTreeSet;
use ark_std::{collections::BTreeSet, vec, vec::Vec};

use ark_crypto_primitives::sponge::CryptographicSponge;

Expand Down
1 change: 1 addition & 0 deletions src/witness/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ark_crypto_primitives::{
};
use ark_ff::FftField;
use ark_poly::{univariate::DensePolynomial, Polynomial};
use ark_std::vec::Vec;

use crate::{
domain::Domain,
Expand Down

0 comments on commit 3ec4311

Please sign in to comment.