No method named `to_affine` found for struct `G1` in the current scope

I am trying to use this method to_affine (bn/ at master · zcash-hackworks/bn · GitHub) by calling G1::one().to_affine() in my main file but getting an error of no method found although in their test, they are calling in exactly same way (bn/ at master · zcash-hackworks/bn · GitHub). How can I used those method in my own code?

Are you using the master branch or are you uisng bn from from

Ah wait, the G1 exported from bn is not the one you see in the bn::groups module. You are using this wrapper struct wrapping bn::groups::G1. The wrapper does not implement to_affine, nor does it allow you access to the wrapped type. So the developers of bn want to keep that functionality private to their crate.

1 Like

Thanks for the info!!
I am using the bn crate. So, If I want to use it in my code, is there any way to do so??

Out of the box, no. My first step would be to ask the maintainers if they could expose the to_affine functionality in their public interface. I assume there's a reason why it is private, but maybe they didn't consider your use-case and are willing to update the crate once you tell them about it.

As a temporary fix you could create a fork of the repository, make the bn::groups module public and work with the types from that module directly. You can patch the bn dependency in your Cargo.toml with your fork.


Thank You so much! This was really helpful!!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.