From 9e33310ee741f009c35bdaad963768a290b5c43f Mon Sep 17 00:00:00 2001 From: "Brandon H. Gomes" Date: Fri, 4 Nov 2022 16:26:22 -0700 Subject: [PATCH] feat: add no-std support for insertion gate Signed-off-by: Brandon H. Gomes --- ecdsa/Cargo.toml | 1 - insertion/Cargo.toml | 6 +++++- insertion/src/insert_gadget.rs | 3 +++ insertion/src/insertion_gate.rs | 12 ++++++------ insertion/src/lib.rs | 3 +++ u32/Cargo.toml | 1 - 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ecdsa/Cargo.toml b/ecdsa/Cargo.toml index 602fbb09..ed84d5de 100644 --- a/ecdsa/Cargo.toml +++ b/ecdsa/Cargo.toml @@ -17,4 +17,3 @@ serde = { version = "1.0", default-features = false, features = ["derive"] } [dev-dependencies] rand = { version = "0.8.4", default-features = false, features = ["getrandom"] } - diff --git a/insertion/Cargo.toml b/insertion/Cargo.toml index afaefd4f..c007a975 100644 --- a/insertion/Cargo.toml +++ b/insertion/Cargo.toml @@ -5,5 +5,9 @@ version = "0.1.0" edition = "2021" [dependencies] -anyhow = "1.0.40" +anyhow = { version = "1.0.40", default-features = false } +plonky2 = { path = "../plonky2", default-features = false } + +[dev-dependencies] plonky2 = { path = "../plonky2" } + diff --git a/insertion/src/insert_gadget.rs b/insertion/src/insert_gadget.rs index dde8e940..1574d8fb 100644 --- a/insertion/src/insert_gadget.rs +++ b/insertion/src/insert_gadget.rs @@ -1,3 +1,6 @@ +use alloc::vec; +use alloc::vec::Vec; + use plonky2::field::extension::Extendable; use plonky2::hash::hash_types::RichField; use plonky2::iop::ext_target::ExtensionTarget; diff --git a/insertion/src/insertion_gate.rs b/insertion/src/insertion_gate.rs index a476002b..8019649a 100644 --- a/insertion/src/insertion_gate.rs +++ b/insertion/src/insertion_gate.rs @@ -1,3 +1,7 @@ +use alloc::boxed::Box; +use alloc::string::String; +use alloc::vec::Vec; +use alloc::{format, vec}; use core::marker::PhantomData; use core::ops::Range; @@ -317,18 +321,14 @@ impl, const D: usize> SimpleGenerator for Insert #[cfg(test)] mod tests { - use core::marker::PhantomData; - use anyhow::Result; use plonky2::field::goldilocks_field::GoldilocksField; - use plonky2::field::types::{Field, Sample}; - use plonky2::gates::gate::Gate; + use plonky2::field::types::Sample; use plonky2::gates::gate_testing::{test_eval_fns, test_low_degree}; use plonky2::hash::hash_types::HashOut; use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; - use plonky2::plonk::vars::EvaluationVars; - use crate::insertion_gate::InsertionGate; + use super::*; #[test] fn wire_indices() { diff --git a/insertion/src/lib.rs b/insertion/src/lib.rs index 15c91253..e71919dd 100644 --- a/insertion/src/lib.rs +++ b/insertion/src/lib.rs @@ -4,6 +4,9 @@ #![allow(clippy::len_without_is_empty)] #![allow(clippy::needless_range_loop)] #![allow(clippy::return_self_not_must_use)] +#![no_std] + +extern crate alloc; pub mod insert_gadget; pub mod insertion_gate; diff --git a/u32/Cargo.toml b/u32/Cargo.toml index af7676ed..273db263 100644 --- a/u32/Cargo.toml +++ b/u32/Cargo.toml @@ -12,4 +12,3 @@ plonky2 = { path = "../plonky2", default-features = false } [dev-dependencies] plonky2 = { path = "../plonky2", default-features = false, features = ["gate_testing"] } rand = { version = "0.8.4", default-features = false, features = ["getrandom"] } -