parent
7395697a68
commit
3b9d515d00
7 changed files with 60 additions and 20 deletions
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
|
@ -7,14 +7,39 @@ on:
|
|||
types: [opened, repoened, synchronize]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test Rust ${{matrix.toolchain}} on ${{matrix.os}}
|
||||
build:
|
||||
name: Build ${{matrix.toolchain}} on ${{matrix.os}} with ${{matrix.args}}
|
||||
runs-on: ${{matrix.os}}-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolchain: [stable, nightly]
|
||||
os: [ubuntu]
|
||||
target: [wasm32-unknown-unknown]
|
||||
args: [--no-default-features --target wasm32-unknown-unknown]
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- name: Install rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{matrix.toolchain}}
|
||||
override: true
|
||||
- run: rustup target add ${{matrix.target}}
|
||||
- name: Test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: ${{matrix.args}}
|
||||
|
||||
test:
|
||||
name: Test ${{matrix.toolchain}} on ${{matrix.os}} with ${{matrix.features}}
|
||||
runs-on: ${{matrix.os}}-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
toolchain: [stable, nightly]
|
||||
os: [ubuntu]
|
||||
features: [--all-features, --no-default-features]
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- name: Install rust
|
||||
|
@ -26,25 +51,29 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: ${{matrix.features}}
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
name: Clippy with ${{matrix.features}}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
features: [--all-features, --no-default-features]
|
||||
steps:
|
||||
- uses: actions/checkout@main
|
||||
- name: Install minimal stable with clippy
|
||||
- name: Install minimal nightly with clippy
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
toolchain: nightly
|
||||
components: clippy
|
||||
override: true
|
||||
|
||||
- name: Clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --all -- -D clippy::all -D warnings
|
||||
args: --all ${{matrix.features}} -- -D clippy::all -D warnings
|
||||
|
||||
rustfmt:
|
||||
name: rustfmt
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -10,10 +10,14 @@ categories = ["cryptography", "no-std"]
|
|||
keywords = ["miden", "crypto", "hash", "merkle"]
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["std", "winter_crypto/default", "winter_math/default", "winter_utils/default"]
|
||||
std = ["winter_crypto/std", "winter_math/std", "winter_utils/std"]
|
||||
|
||||
[dependencies]
|
||||
winter_crypto = { version = "0.4.1", package = "winter-crypto" }
|
||||
winter_math = { version = "0.4.1", package = "winter-math" }
|
||||
winter_utils = { version = "0.4.1", package = "winter-utils" }
|
||||
winter_crypto = { version = "0.4.1", package = "winter-crypto", default-features = false }
|
||||
winter_math = { version = "0.4.1", package = "winter-math", default-features = false }
|
||||
winter_utils = { version = "0.4.1", package = "winter-utils", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = "1.0.0"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::DIGEST_SIZE;
|
||||
use crate::{
|
||||
ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Felt, Serializable,
|
||||
StarkField, ZERO,
|
||||
StarkField, String, ZERO,
|
||||
};
|
||||
use core::ops::Deref;
|
||||
|
||||
|
@ -59,9 +59,9 @@ impl Deserializable for RpoDigest256 {
|
|||
for inner in inner.iter_mut() {
|
||||
let e = source.read_u64()?;
|
||||
if e >= Felt::MODULUS {
|
||||
return Err(DeserializationError::InvalidValue(
|
||||
"Value not in the appropriate range".to_owned(),
|
||||
));
|
||||
return Err(DeserializationError::InvalidValue(String::from(
|
||||
"Value not in the appropriate range",
|
||||
)));
|
||||
}
|
||||
*inner = Felt::new(e);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[cfg_attr(test, macro_use)]
|
||||
extern crate alloc;
|
||||
|
||||
pub use winter_crypto::{Digest, ElementHasher, Hasher as HashFn};
|
||||
pub use winter_math::{
|
||||
fields::{f64::BaseElement as Felt, QuadExtension},
|
||||
|
@ -5,6 +11,7 @@ pub use winter_math::{
|
|||
};
|
||||
pub use winter_utils::{
|
||||
collections::{BTreeMap, Vec},
|
||||
string::String,
|
||||
uninit_vector, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable,
|
||||
SliceReader,
|
||||
};
|
||||
|
|
|
@ -57,7 +57,7 @@ impl MerklePathSet {
|
|||
let pos = 2u64.pow(self.total_depth) + index;
|
||||
|
||||
// Index of the leaf path in map. Paths of neighboring leaves are stored in one key-value pair
|
||||
let half_pos = (pos / 2) as u64;
|
||||
let half_pos = pos / 2;
|
||||
|
||||
let mut extended_path = path;
|
||||
if is_even(pos) {
|
||||
|
@ -104,7 +104,7 @@ impl MerklePathSet {
|
|||
}
|
||||
|
||||
let pos = 2u64.pow(depth) + index;
|
||||
let index = (pos / 2) as u64;
|
||||
let index = pos / 2;
|
||||
|
||||
match self.paths.get(&index) {
|
||||
None => Err(MerkleError::NodeNotInSet(index)),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::MerkleError;
|
||||
use crate::{
|
||||
hash::{merge, Digest},
|
||||
log2, uninit_vector, Felt, FieldElement, Word,
|
||||
log2, uninit_vector, Felt, FieldElement, Vec, Word,
|
||||
};
|
||||
use core::slice;
|
||||
|
||||
|
@ -80,7 +80,7 @@ impl MerkleTree {
|
|||
return Err(MerkleError::InvalidIndex(depth, index));
|
||||
}
|
||||
|
||||
let pos = 2usize.pow(depth as u32) + (index as usize);
|
||||
let pos = 2_usize.pow(depth) + (index as usize);
|
||||
Ok(self.nodes[pos])
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ impl MerkleTree {
|
|||
}
|
||||
|
||||
let mut path = Vec::with_capacity(depth as usize);
|
||||
let mut pos = 2usize.pow(depth as u32) + (index as usize);
|
||||
let mut pos = 2_usize.pow(depth) + (index as usize);
|
||||
|
||||
while pos > 1 {
|
||||
path.push(self.nodes[pos ^ 1]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::Word;
|
||||
use crate::{Vec, Word};
|
||||
|
||||
#[cfg(test)]
|
||||
use crate::{Felt, ZERO};
|
||||
|
|
Loading…
Add table
Reference in a new issue