mirror of
https://github.com/pseXperiments/icicle.git
synced 2026-01-09 15:37:58 -05:00
add keccak tree builder (#555)
This commit is contained in:
@@ -35,7 +35,7 @@ void threadPoseidon(
|
||||
std::cerr << "CUDA error: " << cudaGetErrorString(err_result) << std::endl;
|
||||
return;
|
||||
}
|
||||
SpongeConfig column_config = default_sponge_config(ctx);
|
||||
HashConfig column_config = default_hash_config(ctx);
|
||||
cudaError_t err = poseidon->hash_many(layers, column_hashes, (size_t) size_partition, size_col, 1, column_config);
|
||||
checkCudaError(err);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ inline uint32_t tree_index(uint32_t level, uint32_t offset) { return (1 << level
|
||||
|
||||
// We assume the tree has leaves already set, compute all other levels
|
||||
void build_tree(
|
||||
const uint32_t tree_height, scalar_t* tree, Poseidon<scalar_t> &poseidon, SpongeConfig &config)
|
||||
const uint32_t tree_height, scalar_t* tree, Poseidon<scalar_t> &poseidon, HashConfig &config)
|
||||
{
|
||||
for (uint32_t level = tree_height - 1; level > 0; level--) {
|
||||
const uint32_t next_level = level - 1;
|
||||
@@ -67,7 +67,7 @@ uint32_t validate_proof(
|
||||
const uint32_t* proof_lr,
|
||||
const scalar_t* proof_hash,
|
||||
Poseidon<scalar_t> &poseidon,
|
||||
SpongeConfig &config)
|
||||
HashConfig &config)
|
||||
{
|
||||
scalar_t hashes_in[2], hash_out[1], level_hash;
|
||||
level_hash = hash;
|
||||
@@ -112,12 +112,12 @@ int main(int argc, char* argv[])
|
||||
std::cout << "Hashing blocks into tree leaves..." << std::endl;
|
||||
|
||||
Poseidon<scalar_t> poseidon(data_arity, ctx);
|
||||
SpongeConfig config = default_sponge_config(ctx);
|
||||
HashConfig config = default_hash_config(ctx);
|
||||
poseidon.hash_many(data, &tree[tree_index(leaf_level, 0)], tree_width, data_arity, 1, config);
|
||||
|
||||
std::cout << "3. Building Merkle tree" << std::endl;
|
||||
Poseidon<scalar_t> tree_poseidon(tree_arity, ctx);
|
||||
SpongeConfig tree_config = default_sponge_config(ctx);
|
||||
HashConfig tree_config = default_hash_config(ctx);
|
||||
build_tree(tree_height, tree, tree_poseidon, tree_config);
|
||||
|
||||
std::cout << "4. Generate membership proof" << std::endl;
|
||||
|
||||
@@ -2,7 +2,7 @@ use icicle_bls12_381::curve::ScalarField as F;
|
||||
|
||||
use icicle_cuda_runtime::device_context::DeviceContext;
|
||||
|
||||
use icicle_core::hash::{SpongeHash, SpongeConfig};
|
||||
use icicle_core::hash::{SpongeHash, HashConfig};
|
||||
use icicle_core::poseidon::Poseidon;
|
||||
use icicle_core::traits::FieldImpl;
|
||||
use icicle_cuda_runtime::memory::HostSlice;
|
||||
@@ -32,7 +32,7 @@ fn main() {
|
||||
);
|
||||
let ctx = DeviceContext::default();
|
||||
let poseidon = Poseidon::load(arity, &ctx).unwrap();
|
||||
let config = SpongeConfig::default();
|
||||
let config = HashConfig::default();
|
||||
|
||||
println!(
|
||||
"---------------------- Input size 2^{}={} ------------------------",
|
||||
|
||||
Reference in New Issue
Block a user