-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: Poseidon Hash Example Rust bindings #651
Comments
Thank you! |
You are right. To fix it you need to specify domain tag (or None)
We will update the docs soon. Thanks for letting us know. |
I also met a new issue. When I use this example to run the icicle_bn254-based Merkle Tree (but I replace the hash function here using Poseidon hash), I found I can't set the arity=2,but can to 3, but your markdown file shows that arity=2 could work. Once I set arity=2, rust gives me a Segmentation fault. |
You can either use arity=3 and the second parameter as None or arity=2 and the second parameter should be a pointer to scalar_t |
could you give a simple example? What does "pointer to scalar_t mean" ? I haven't been learning rust particularly long, so this will sound a bit foreign to me, thank you very much |
This markdown is old and relevant to v2. Please ignore it. We support arity to be 3 5 9 12 regardless of domain tag. But note that if you do use domain tag, then you need to supply one less input so input size should be 2 4 8 or 11 accordingly. But still arity should be 3 5 9 or 12 since this defines the hash. |
You mean, Arity is 2:1,4:1,8:1,11:1? |
Domain tag is a field element that is used by the Poseidon hasher to differentiate different applications of Poseidon. If you don't want to you pass Can you maybe describe what you want to achieve? |
Right, the arity is either 3:1 5:1 etc when no domain tag is used or 2:1 4:1 etc otherwise. Still the first param should be 3 5 etc. - this is the t parameter and actually not arity. Next version will support more cases. |
I want to build a Merkle Tree using ICICLE's Poseidon Hash, based on the ScalarField under the BLS12-381 curve, and I want Airty to be 2: 1, which means that this is a binary Merkle Tree, so I may need to add domain_tag as you described, can I just use "Some(domain_tag_field_element)"? Or I still have to make some other changes, Thank you! |
So yes you could use Poseidon3 and use a domain-tag so that you only need 2 inputs per node and effectively build a binary tree. You can then open a single element as leaf or two elements (or more but I think it would not make much sense in your case).
About the segmentation fault, didn't you get an error when constructing the hasher object? specifically this one
Anyway we will make sure to fix the docs and generate a clear error soon. |
Description
Your developer manual says that using Poseidon Hash's API is as follows:
It suggests that you should instantiate a poseidon_hasher as follows
let poseidon_hasher = Poseidon::new::<ScalarField>(arity as u32).unwrap();
But actually I got an error:
When I checked my local as well as the github repo on the this path:
icicle/wrappers/rust/icicle-core/src/poseidon/mod.rs
There is a problem reported by the compiler, I would like to request the official update for this API, thank you!
Reproduce
Just run the example rust bindings in your developer manual.
Expected Behavior
Work
Environment
Please complete the following information:
OS + Version: Centos 7
Cargo Version: 1.80
The text was updated successfully, but these errors were encountered: