feat: add no-std support

closes #5
This commit is contained in:
Victor Lopez
2022-11-22 13:35:27 +01:00
parent 7395697a68
commit 3b9d515d00
7 changed files with 60 additions and 20 deletions

View File

@@ -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)),

View File

@@ -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]);

View File

@@ -1,4 +1,4 @@
use crate::Word;
use crate::{Vec, Word};
#[cfg(test)]
use crate::{Felt, ZERO};