Function solana_program::poseidon::hashv

source ·
pub fn hashv(
    parameters: Parameters,
    endianness: Endianness,
    vals: &[&[u8]]
) -> Result<PoseidonHash, PoseidonSyscallError>
Expand description

Return a Poseidon hash for the given data with the given elliptic curve and endianness.

Examples

use solana_program::poseidon::{hashv, Endianness, Parameters};

let input1 = [1u8; 32];
let input2 = [2u8; 32];

let hash = hashv(Parameters::Bn254X5, Endianness::BigEndian, &[&input1, &input2]).unwrap();
assert_eq!(
    hash.to_bytes(),
    [
        13, 84, 225, 147, 143, 138, 140, 28, 125, 235, 94, 3, 85, 242, 99, 25, 32, 123,
        132, 254, 156, 162, 206, 27, 38, 231, 53, 200, 41, 130, 25, 144
    ]
);

let hash = hashv(Parameters::Bn254X5, Endianness::LittleEndian, &[&input1, &input2]).unwrap();
assert_eq!(
    hash.to_bytes(),
    [
        144, 25, 130, 41, 200, 53, 231, 38, 27, 206, 162, 156, 254, 132, 123, 32, 25, 99,
        242, 85, 3, 94, 235, 125, 28, 140, 138, 143, 147, 225, 84, 13
    ]
);