Skip to content

Commit

Permalink
halo2_poseidon: Add no-std support
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Dec 16, 2024
1 parent c91cc5c commit e6897ef
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions halo2_poseidon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ readme = "README.md"
categories = ["cryptography"]

[dependencies]
bitvec = "1"
ff = "0.13"
bitvec = { version = "1", default-features = false }
ff = { version = "0.13", default-features = false }
group = "0.13"
pasta_curves = "0.5"

Expand Down
2 changes: 1 addition & 1 deletion halo2_poseidon/src/grain.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The Grain LFSR in self-shrinking mode, as used by Poseidon.
use std::marker::PhantomData;
use core::marker::PhantomData;

use bitvec::prelude::*;
use group::ff::{Field, FromUniformBytes, PrimeField};
Expand Down
15 changes: 11 additions & 4 deletions halo2_poseidon/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
//! The Poseidon algebraic hash function.
use std::convert::TryInto;
use std::fmt;
use std::iter;
use std::marker::PhantomData;
#![no_std]

#[macro_use]
extern crate alloc;

use alloc::string::String;
use alloc::vec::Vec;
use core::convert::TryInto;
use core::fmt;
use core::iter;
use core::marker::PhantomData;

use group::ff::{Field, FromUniformBytes, PrimeField};

Expand Down
2 changes: 2 additions & 0 deletions halo2_poseidon/src/mds.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use ff::FromUniformBytes;

use super::{grain::Grain, Mds};
Expand Down
6 changes: 5 additions & 1 deletion halo2_poseidon/src/p128pow5t3.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec::Vec;

use ff::Field;
use pasta_curves::{pallas::Base as Fp, vesta::Base as Fq};

Expand Down Expand Up @@ -66,8 +68,10 @@ impl Spec<Fq, 3, 2> for P128Pow5T3 {

#[cfg(test)]
mod tests {
use alloc::vec::Vec;
use core::marker::PhantomData;

use ff::{Field, FromUniformBytes, PrimeField};
use std::marker::PhantomData;

use super::{
super::{fp, fq},
Expand Down
2 changes: 2 additions & 0 deletions halo2_poseidon/src/test_vectors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Test vectors for [`OrchardNullifier`].

Check warning on line 1 in halo2_poseidon/src/test_vectors.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

unresolved link to `OrchardNullifier`

Check warning on line 1 in halo2_poseidon/src/test_vectors.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

unresolved link to `OrchardNullifier`
use alloc::vec::Vec;

pub struct PermuteTestVector {
pub initial_state: [[u8; 32]; 3],
pub final_state: [[u8; 32]; 3],
Expand Down

0 comments on commit e6897ef

Please sign in to comment.