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

ARM - Aarch64 #25

Open
DaanA32 opened this issue Jan 29, 2021 · 2 comments
Open

ARM - Aarch64 #25

DaanA32 opened this issue Jan 29, 2021 · 2 comments

Comments

@DaanA32
Copy link

DaanA32 commented Jan 29, 2021

Hi Ragnaroek,

I've implemented the sse.rs and most of the m128d and m128i for aarch64, unfortunately the Raspberry Pi 4B doesn't have the crypto extension.
Therefore I was unable to verify if the AESE instruction works, although it does compile when using RUSTFLAGS='-C target_feature=+aes'.
I was wondering what your preferred way of seperating the different architectures would be.

https://github.com/DaanA32/mithril/tree/aarch64

@Ragnaroek
Copy link
Owner

Hi DaanA32,

nice things in your commit!

To be honest, I haven't put much thought into a support for a different architecture. I'm still working on the x86 implementation and this will take some time.
But this is definitely something I want to do in the future. Maybe I would go with the cfg feature of Rust.
Also a pure software based implementation as a fallback would be nice, to support CPUs without the AES extension (like the Raspberry you mentioned).
But this would purely for freedom of mining reasons (everybody with a CPU should be able to mine Monero). I'm currently focusing on performance and I guess this is something not in the near future.

@DaanA32
Copy link
Author

DaanA32 commented Jan 30, 2021

I would suggest either using cnf_if for the aes part of m128i
eg:

pub fn aesenc(&self, key: m128i) -> m128i {
    cnf_if {
        if #[cfg(target_feature='crypto')] {
            // HARDWARE IMPL
        } else {
            // SOFTWARE IMPL
        }
    }
}

Or a trait based approach

#[cfg(target_feature='crypto')]
trait Aes for m128i {
    // HARDWARE IMPL
}

#[cfg(not(target_feature='crypto'))]
trait Aes for m128i {
    // SOFTWARE IMPL
}

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

2 participants