Skip to content
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

Trailing zeros for poseidon channel cannot return values between 3 and 7 #839

Open
ajgara opened this issue Sep 17, 2024 · 0 comments
Open

Comments

@ajgara
Copy link

ajgara commented Sep 17, 2024

fn trailing_zeros(&self) -> u32 {

This is because Felts have 252 bits and it's mixing big endian with little endian. Is this the expected behaviour? Using little endian or reversing the bytes are alternative options.

For example, when running this test:

#[test]
    pub fn test_trailing_zeros() {
        let mut counter = vec![0; 128];
        let mut channel = Poseidon252Channel::default();

        for i in 0..100000 {
            channel.mix_nonce(i);
            let index: usize = channel.trailing_zeros().try_into().unwrap();
            counter[index] = counter[index] + 1;
        }

        println!("{:?}", counter);
    }

It outputs the following distribution of trailing_zeros():

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant