Skip to content

Commit

Permalink
Merge pull request #1663 from zcash/pczt-no-std
Browse files Browse the repository at this point in the history
pczt: Enable the base crate to be no-std compatible
  • Loading branch information
str4d authored Dec 17, 2024
2 parents 382afe7 + d11d428 commit 8c59e25
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pczt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rand_core = { workspace = true, optional = true }
# Encoding
postcard = { version = "1", features = ["alloc"] }
serde.workspace = true
serde_with = "3"
serde_with = { version = "3", default-features = false, features = ["alloc", "macros"] }

# Payment protocols
# - Transparent
Expand Down
6 changes: 4 additions & 2 deletions pczt/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::collections::BTreeMap;
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;

use getset::Getters;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -199,7 +201,7 @@ pub(crate) struct Zip32Derivation {

#[cfg(test)]
mod tests {
use std::collections::BTreeMap;
use alloc::collections::BTreeMap;

use super::Global;

Expand Down
7 changes: 7 additions & 0 deletions pczt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
//! - Transaction Extractor (anyone can execute)
//! - Creates bindingSig and extracts the final transaction.
#![no_std]

#[macro_use]
extern crate alloc;

use alloc::vec::Vec;

use getset::Getters;
use serde::{Deserialize, Serialize};

Expand Down
5 changes: 4 additions & 1 deletion pczt/src/orchard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{cmp::Ordering, collections::BTreeMap};
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::Ordering;

#[cfg(feature = "orchard")]
use ff::PrimeField;
Expand Down
3 changes: 2 additions & 1 deletion pczt/src/roles/combiner/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::BTreeMap;
use alloc::collections::BTreeMap;
use alloc::vec::Vec;

use crate::Pczt;

Expand Down
2 changes: 1 addition & 1 deletion pczt/src/roles/creator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use alloc::collections::BTreeMap;

use crate::{
common::{
Expand Down
2 changes: 1 addition & 1 deletion pczt/src/roles/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl Authorization for EffectsOnly {
type SaplingAuth = sapling::bundle::EffectsOnly;
type OrchardAuth = orchard::bundle::EffectsOnly;
#[cfg(zcash_unstable = "zfuture")]
type TzeAuth = std::convert::Infallible;
type TzeAuth = core::convert::Infallible;
}

/// Errors that can occur while creating signatures for a PCZT.
Expand Down
4 changes: 2 additions & 2 deletions pczt/src/roles/tx_extractor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::marker::PhantomData;
use core::marker::PhantomData;

use rand_core::OsRng;
use zcash_primitives::{
Expand Down Expand Up @@ -155,7 +155,7 @@ impl Authorization for Unbound {
type SaplingAuth = ::sapling::pczt::Unbound;
type OrchardAuth = ::orchard::pczt::Unbound;
#[cfg(zcash_unstable = "zfuture")]
type TzeAuth = std::convert::Infallible;
type TzeAuth = core::convert::Infallible;
}

/// Errors that can occur while extracting a transaction from a PCZT.
Expand Down
3 changes: 3 additions & 0 deletions pczt/src/roles/updater/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use alloc::string::String;
use alloc::vec::Vec;

use crate::{common::Global, Pczt};

#[cfg(feature = "orchard")]
Expand Down
6 changes: 4 additions & 2 deletions pczt/src/sapling.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::cmp::Ordering;
use std::collections::BTreeMap;
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::Ordering;

use getset::Getters;
use serde::{Deserialize, Serialize};
Expand Down
5 changes: 4 additions & 1 deletion pczt/src/transparent.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{cmp::Ordering, collections::BTreeMap};
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::Ordering;

use crate::{
common::{Global, Zip32Derivation},
Expand Down

0 comments on commit 8c59e25

Please sign in to comment.