Skip to content

Commit

Permalink
Merge pull request #735 from Chia-Network/chia-sha2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Sep 27, 2024
2 parents c6cd98f + 8479d9b commit b9db810
Show file tree
Hide file tree
Showing 35 changed files with 138 additions and 33 deletions.
24 changes: 19 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ chia-protocol = { workspace = true, optional = true }
chia-ssl = { workspace = true, optional = true }
chia-traits = { workspace = true, optional = true }
chia-puzzles = { workspace = true, optional = true }
chia-sha2 = { workspace = true, optional = true }
clvm-traits = { workspace = true, optional = true }
clvm-utils = { workspace = true, optional = true }
clvmr = { workspace = true }
Expand All @@ -76,6 +77,7 @@ default = [
"ssl",
"traits",
"puzzles",
"sha2",
"clvm-traits",
"clvm-utils"
]
Expand All @@ -87,10 +89,11 @@ protocol = ["dep:chia-protocol"]
ssl = ["dep:chia-ssl"]
traits = ["dep:chia-traits"]
puzzles = ["dep:chia-puzzles"]
sha2 = ["dep:chia-sha2"]
clvm-traits = ["dep:clvm-traits"]
clvm-utils = ["dep:clvm-utils"]

openssl = ["clvmr/openssl"]
openssl = ["chia-sha2/openssl", "clvmr/openssl"]

[profile.release]
lto = "thin"
Expand All @@ -105,6 +108,7 @@ chia-protocol = { path = "./crates/chia-protocol", version = "0.14.0" }
chia-ssl = { path = "./crates/chia-ssl", version = "0.11.0" }
chia-traits = { path = "./crates/chia-traits", version = "0.11.0" }
chia-puzzles = { path = "./crates/chia-puzzles", version = "0.14.0" }
chia-sha2 = { path = "./crates/chia-sha2", version = "0.14.0" }
clvm-traits = { path = "./crates/clvm-traits", version = "0.14.0" }
clvm-utils = { path = "./crates/clvm-utils", version = "0.14.0" }
clvm-derive = { path = "./crates/clvm-derive", version = "0.13.0" }
Expand Down Expand Up @@ -144,3 +148,4 @@ zstd = "0.13.2"
blocking-threadpool = "1.0.1"
libfuzzer-sys = "0.4"
wasm-bindgen = "0.2.93"
openssl = "0.10.66"
2 changes: 1 addition & 1 deletion crates/chia-bls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ arbitrary = ["dep:arbitrary"]

[dependencies]
chia-traits = { workspace = true }
chia-sha2 = { workspace = true }
chia_py_streamable_macro = { workspace = true, optional = true }
sha2 = { workspace = true }
clvmr = { workspace = true }
hkdf = { workspace = true }
blst = { workspace = true }
hex = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-bls/src/bls_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::Borrow;
use std::num::NonZeroUsize;

use clvmr::sha2::Sha256;
use chia_sha2::Sha256;
use lru::LruCache;

use crate::{aggregate_verify_gt, hash_to_g2};
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-bls/src/gtelement.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use blst::*;
use chia_sha2::Sha256;
use chia_traits::chia_error::Result;
use chia_traits::{read_bytes, Streamable};
use clvmr::sha2::Sha256;
#[cfg(feature = "py-bindings")]
use pyo3::exceptions::PyNotImplementedError;
#[cfg(feature = "py-bindings")]
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-bls/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::secret_key::is_all_zero;
use crate::{DerivableKey, Error, Result};

use blst::*;
use chia_sha2::Sha256;
use chia_traits::{read_bytes, Streamable};
use clvmr::sha2::Sha256;
#[cfg(feature = "py-bindings")]
use pyo3::exceptions::PyNotImplementedError;
#[cfg(feature = "py-bindings")]
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-bls/src/secret_key.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{DerivableKey, Error, PublicKey, Result};
use blst::*;
use chia_sha2::Sha256;
use chia_traits::{read_bytes, Streamable};
use clvmr::sha2::Sha256;
use hkdf::HkdfExtract;
#[cfg(feature = "py-bindings")]
use pyo3::exceptions::PyNotImplementedError;
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-bls/src/signature.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{Error, GTElement, PublicKey, Result, SecretKey};
use blst::*;
use chia_sha2::Sha256;
use chia_traits::{read_bytes, Streamable};
use clvmr::sha2::Sha256;
#[cfg(feature = "py-bindings")]
use pyo3::exceptions::PyNotImplementedError;
#[cfg(feature = "py-bindings")]
Expand Down
1 change: 1 addition & 0 deletions crates/chia-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pyo3 = { workspace = true, optional = true }
chia_streamable_macro = { workspace = true }
chia_py_streamable_macro = { workspace = true, optional = true }
clvm-utils = { workspace = true }
chia-sha2 = { workspace = true }
chia-traits = { workspace = true }
clvm-traits = { workspace = true }
chia-protocol = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/chia-consensus/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ clvmr = { workspace = true }
clvm-utils = { workspace = true }
clvm-traits = { workspace = true }
chia-protocol = { workspace = true }
chia-sha2 = { workspace = true }
chia-traits = { workspace = true }
chia-consensus = { workspace = true }
hex-literal = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/fuzz/fuzz_targets/merkle-set.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![no_main]
use chia_consensus::merkle_tree::{validate_merkle_proof, MerkleSet};
use clvmr::sha2::Sha256;
use chia_sha2::Sha256;
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/gen/coin_id.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chia_protocol::Bytes32;
use chia_sha2::Sha256;
use clvmr::allocator::{Allocator, NodePtr};
use clvmr::sha2::Sha256;

pub fn compute_coin_id(
a: &Allocator,
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/gen/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use crate::gen::spend_visitor::SpendVisitor;
use crate::gen::validation_error::check_nil;
use chia_bls::PublicKey;
use chia_protocol::Bytes32;
use chia_sha2::Sha256;
use clvmr::allocator::{Allocator, NodePtr, SExp};
use clvmr::cost::Cost;
use clvmr::sha2::Sha256;
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::hash::{Hash, Hasher};
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/gen/get_puzzle_and_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ mod test {
use crate::gen::flags::{ALLOW_BACKREFS, MEMPOOL_MODE};
use crate::gen::run_block_generator::{run_block_generator2, setup_generator_args};
use chia_protocol::Bytes32;
use chia_sha2::Sha256;
use clvm_traits::FromClvm;
use clvm_utils::tree_hash;
use clvmr::reduction::Reduction;
use clvmr::serde::node_from_bytes_backrefs;
use clvmr::sha2::Sha256;
use clvmr::{run_program, ChiaDialect};
use rstest::rstest;
use std::collections::HashSet;
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/merkle_set.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clvmr::sha2::Sha256;
use chia_sha2::Sha256;
use hex_literal::hex;

fn get_bit(val: &[u8; 32], bit: u8) -> u8 {
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use hex_literal::hex;

#[cfg(feature = "py-bindings")]
use chia_protocol::Bytes32;
use chia_sha2::Sha256;
#[cfg(feature = "py-bindings")]
use chia_traits::ChiaToPython;
use clvmr::sha2::Sha256;
#[cfg(feature = "py-bindings")]
use pyo3::exceptions::PyValueError;
#[cfg(feature = "py-bindings")]
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/spendbundle_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::spendbundle_conditions::get_conditions_from_spendbundle;
use chia_bls::GTElement;
use chia_bls::{aggregate_verify_gt, hash_to_g2};
use chia_protocol::SpendBundle;
use clvmr::sha2::Sha256;
use chia_sha2::Sha256;
use clvmr::LIMIT_HEAP;
use std::time::{Duration, Instant};

Expand Down
1 change: 1 addition & 0 deletions crates/chia-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ chia_streamable_macro = { workspace = true }
chia_py_streamable_macro = { workspace = true, optional = true }
clvmr = { workspace = true }
chia-traits = { workspace = true }
chia-sha2 = { workspace = true }
clvm-traits = { workspace = true, features = ["derive"] }
clvm-utils = { workspace = true }
chia-bls = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/chia-protocol/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true
[dependencies]
libfuzzer-sys = { workspace = true }
clvmr = { workspace = true }
chia-sha2 = { workspace = true }
chia-traits = { workspace = true }
clvm-traits = { workspace = true }
chia-protocol = { workspace = true, features = ["arbitrary"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-protocol/fuzz/fuzz_targets/streamable.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_main]
use arbitrary::{Arbitrary, Unstructured};
use chia_protocol::*;
use chia_sha2::Sha256;
use chia_traits::Streamable;
use clvmr::sha2::Sha256;
use libfuzzer_sys::fuzz_target;

pub fn test_streamable<T: Streamable + std::fmt::Debug + PartialEq>(obj: &T) {
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-protocol/src/bytes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chia_sha2::Sha256;
use chia_traits::{chia_error, read_bytes, Streamable};
use clvm_traits::{ClvmDecoder, ClvmEncoder, FromClvm, FromClvmError, ToClvm, ToClvmError};
use clvm_utils::TreeHash;
use clvmr::sha2::Sha256;
use clvmr::Atom;
use std::array::TryFromSliceError;
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-protocol/src/coin.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{Bytes32, BytesImpl};
use chia_sha2::Sha256;
use chia_streamable_macro::streamable;
use clvm_traits::{
clvm_list, destructure_list, match_list, ClvmDecoder, ClvmEncoder, FromClvm, FromClvmError,
ToClvm, ToClvmError,
};
use clvmr::sha2::Sha256;

#[cfg(feature = "py-bindings")]
use pyo3::exceptions::PyNotImplementedError;
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-protocol/src/program.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::bytes::Bytes;
use chia_sha2::Sha256;
use chia_traits::chia_error::{Error, Result};
use chia_traits::Streamable;
use clvm_traits::{FromClvm, FromClvmError, ToClvm, ToClvmError};
Expand All @@ -10,7 +11,6 @@ use clvmr::serde::{
node_from_bytes, node_from_bytes_backrefs, node_to_bytes, serialized_length_from_bytes,
serialized_length_from_bytes_trusted,
};
use clvmr::sha2::Sha256;
use clvmr::{Allocator, ChiaDialect};
#[cfg(feature = "py-bindings")]
use pyo3::prelude::*;
Expand Down
1 change: 1 addition & 0 deletions crates/chia-puzzles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ num-bigint = { workspace = true }
hex-literal = { workspace = true }
clvm-utils = { workspace = true }
clvm-traits = { workspace = true, features = ["chia-bls"] }
chia-sha2 = { workspace = true }
chia-bls = { workspace = true }
chia-protocol = { workspace = true }
arbitrary = { workspace = true, features = ["derive"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-puzzles/src/derive_synthetic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chia_bls::{PublicKey, SecretKey};
use clvmr::sha2::Sha256;
use chia_sha2::Sha256;
use hex_literal::hex;
use num_bigint::BigInt;

Expand Down
19 changes: 19 additions & 0 deletions crates/chia-sha2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "chia-sha2"
version = "0.14.0"
edition = "2021"
license = "Apache-2.0"
description = "A common wrapper around OpenSSL and sha2 implementations of sha256."
authors = ["Brandon Haggstrom <b.haggstrom@chia.net>"]
homepage = "https://github.com/Chia-Network/chia_rs"
repository = "https://github.com/Chia-Network/chia_rs"

[lints]
workspace = true

[features]
openssl = ["dep:openssl"]

[dependencies]
sha2 = { workspace = true }
openssl = { workspace = true, optional = true }
Loading

0 comments on commit b9db810

Please sign in to comment.