I am attempting to utilize altbn254 syscalls with Solana (1.17.14), but cannot compile due to an unresolved import of convert_endianness.

This is my cargo.toml

name = "program"
version = "0.1.0"
edition = "2021"

ahash = "=0.8.6"
ark-bn254 = "0.4.0"
ark-ec = "0.4.2"
ark-ff = "0.4.2"
ark-serialize = "0.4.2"
solana-program = "=1.17.14"

ark-std = "0.4.0"
array-bytes = "6.2.2"
serde = "1.0.195"
serde_json = "1.0.111"

crate-type = ["cdylib", "lib"]

In lib.rs:

use solana_program::alt_bn128::compression::prelude::convert_endianness;

Compiling with cargo build-bpf yields:

error[E0432]: unresolved import `solana_program::alt_bn128::compression::prelude::convert_endianness`
 --> src/lib.rs:5:5
5 | use solana_program::alt_bn128::compression::prelude::convert_endianness;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `convert_endianness` in `alt_bn128::compression::prelude`

However, the function does exist and should be available for use: https://docs.rs/solana-program/1.17.14/solana_program/alt_bn128/compression/prelude/fn.convert_endianness.html

Am I missing something in my Cargo.toml? How can I proceed?

1 Answer 1


It looks like the convert_endianness function isn't available in on-chain programs. If you look at the source code, all usage is gated with #[cfg(not(target_os = "solana"))], like here https://docs.rs/solana-program/1.17.14/src/solana_program/alt_bn128/compression.rs.html#65

You'll need to use functions that are available in the #[cfg(target_os = "solana")] section at https://docs.rs/solana-program/1.17.14/src/solana_program/alt_bn128/compression.rs.html#186

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.