Merge #536: Make compilable on aarch64 (M1)
700f6e1d6fc9f4fcbfeeffc00a49c655be8ce671 make compilable on aarch64 (M1) (raphjaph)
Pull request description:
I ran into some issues while trying to build this on an M1 Mac. First, the `bip39` crate was somehow not being imported correctly and secondly there wasn't a way to just use the `hardware_randomness()` if `cpu_randomness()` wasn't available. Not sure how to do the `#[cfg]` stuff correctly so feel free to close and do another way. Just wanted to post somewhere in case someone else runs into this.
ACKs for top commit:
darosior:
utACK 700f6e1d6fc9f4fcbfeeffc00a49c655be8ce671
Tree-SHA512: 01113ef48d103348159f366e70eacbae9b5fa9b255dc758e9b24ae079c2f2468eefc792b58ce3bc25e3e89e5b7719eba8ef6d60fbecfd726f42a62d55c5b46e0
This commit is contained in:
commit
11ed7bf7aa
@ -60,11 +60,11 @@ base64 = "0.13"
|
||||
# Used for generating mnemonics
|
||||
getrandom = "0.2"
|
||||
|
||||
# Used for the hot signer
|
||||
bip39 = "2.0"
|
||||
|
||||
# Additional entropy for generating mnemonics
|
||||
[target.'cfg(target_arch = "x86")'.dependencies]
|
||||
rdrand = "0.8"
|
||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||
rdrand = "0.8"
|
||||
|
||||
# Used for the hot signer
|
||||
bip39 = "2.0"
|
||||
|
||||
@ -41,11 +41,6 @@ fn cpu_randomness() -> Result<Option<[u8; 32]>, RandomnessError> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
|
||||
fn hardware_randomness() -> Result<Option<[u8; 32]>, RandomnessError> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
// OS-generated randomness. See https://docs.rs/getrandom/latest/getrandom/#supported-targets
|
||||
// (basically this calls `getrandom()` or polls `/dev/urandom` on Linux, `BCryptGenRandom` on
|
||||
// Windows, and `getentropy()` / `/dev/random` on Mac.
|
||||
@ -82,9 +77,11 @@ fn additional_data() -> Result<[u8; 32], RandomnessError> {
|
||||
pub fn random_bytes() -> Result<[u8; 32], RandomnessError> {
|
||||
let mut engine = sha256::HashEngine::default();
|
||||
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
if let Some(bytes) = cpu_randomness()? {
|
||||
engine.input(&bytes);
|
||||
}
|
||||
|
||||
engine.input(&system_randomness()?);
|
||||
engine.input(&additional_data()?);
|
||||
// TODO: add more sources of randomness
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user