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

Build failure for libp2p-noise crate #2582

Closed
emmyoh opened this issue Mar 21, 2022 · 6 comments
Closed

Build failure for libp2p-noise crate #2582

emmyoh opened this issue Mar 21, 2022 · 6 comments

Comments

@emmyoh
Copy link

emmyoh commented Mar 21, 2022

Error:

error[E0282]: type annotations needed
   --> /home/emil/.cargo/registry/src/github.com-1ecc6299db9ec823/libp2p-noise-0.32.0/src/protocol/x25519.rs:221:45
    |
221 |         curve25519_sk.copy_from_slice(&hash.as_ref()[..32]);
    |                                        -----^^^^^^--
    |                                        |    |
    |                                        |    cannot infer type for type parameter `T` declared on the trait `AsRef`
    |                                        this method call resolves to `&T`
    |
    = note: type must be known at this point

For more information about this error, try `rustc --explain E0282`.
error: could not compile `libp2p-noise` due to previous error

Rust toolchain: nightly-x86_64-unknown-linux-gnu
Cargo version: cargo 1.61.0-nightly (65c8266 2022-03-09)
Rust compiler version: rustc 1.61.0-nightly (1bfe40d11 2022-03-18)

@mxinden
Copy link
Member

mxinden commented Mar 22, 2022

Which version of the libp2p-noise crate are you using?

Note that this code has changed last year:

pub fn from_ed25519(ed25519_sk: &ed25519::SecretKey) -> Self {
// An Ed25519 public key is derived off the left half of the SHA512 of the
// secret scalar, hence a matching conversion of the secret key must do
// the same to yield a Curve25519 keypair with the same public key.
// let ed25519_sk = ed25519::SecretKey::from(ed);
let mut curve25519_sk: [u8; 32] = [0; 32];
let hash = Sha512::digest(ed25519_sk.as_ref());
curve25519_sk.copy_from_slice(&hash[..32]);
let sk = SecretKey(X25519(curve25519_sk)); // Copy
curve25519_sk.zeroize();
sk
}

@emmyoh
Copy link
Author

emmyoh commented Mar 28, 2022

Which version of the libp2p-noise crate are you using?

Note that this code has changed last year:

pub fn from_ed25519(ed25519_sk: &ed25519::SecretKey) -> Self {
// An Ed25519 public key is derived off the left half of the SHA512 of the
// secret scalar, hence a matching conversion of the secret key must do
// the same to yield a Curve25519 keypair with the same public key.
// let ed25519_sk = ed25519::SecretKey::from(ed);
let mut curve25519_sk: [u8; 32] = [0; 32];
let hash = Sha512::digest(ed25519_sk.as_ref());
curve25519_sk.copy_from_slice(&hash[..32]);
let sk = SecretKey(X25519(curve25519_sk)); // Copy
curve25519_sk.zeroize();
sk
}

Running cargo tree on my project shows that I'm using libp2p-noise v0.32.0, which is the latest published release on crates.io.

@tdelabro
Copy link

We got the same issue. @emmyoh did you fixed it ?

@emmyoh
Copy link
Author

emmyoh commented Apr 15, 2022

We got the same issue. @emmyoh did you fixed it ?

Unfortunately, @tdelabro, I could not find a solution. Would appreciate if a maintainer/contributor of this crate could help (attempting replication, debugging, assigning someone, etc?)

@elenaf9
Copy link
Contributor

elenaf9 commented Apr 15, 2022

The latest released version of libp2p-noise is v0.35.0: https://crates.io/crates/libp2p-noise/0.35.0. As @mxinden pointed out, the code that is not compiling changed last year in #2264, which was part of release v0.33.0. So updating to a version >= 0.33.0 should fix your issue.

@emmyoh
Copy link
Author

emmyoh commented Apr 16, 2022

Hi @elenaf9, you appear to be correct. I'm not sure where I saw that v0.32.0 was the latest version, but clearly it's not. Closing.

@emmyoh emmyoh closed this as completed Apr 16, 2022
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

4 participants