Skip to content

Commit

Permalink
Revert "BIP Compatibility test (#327)"
Browse files Browse the repository at this point in the history
This reverts commit 7c68775.
  • Loading branch information
zqhxuyuan committed Mar 31, 2023
1 parent f6606ca commit f4c6fe6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 51 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [\#328](https://github.com/Manta-Network/manta-rs/pull/328) Expose reset wallet method.

### Changed
- [\#327](https://github.com/Manta-Network/manta-rs/pull/327) Update BIP32 to v0.4.0.

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion manta-pay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ websocket = [
[dependencies]
aes-gcm = { version = "0.9.4", default-features = false, features = ["aes", "alloc"] }
bip0039 = { version = "0.10.1", optional = true, default-features = false }
bip32 = { version = "0.4.0", optional = true, default-features = false, features = ["bip39", "secp256k1"] }
bip32 = { version = "0.3.0", optional = true, default-features = false, features = ["bip39", "secp256k1"] }
blake2 = { version = "0.10.6", default-features = false }
bs58 = { version = "0.4.0", optional = true, default-features = false, features = ["alloc"] }
clap = { version = "4.1.8", optional = true, default-features = false, features = ["color", "derive", "std", "suggestions", "unicode", "wrap_help"] }
Expand Down
49 changes: 0 additions & 49 deletions manta-pay/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,52 +306,3 @@ impl TryFrom<String> for Mnemonic {
Self::new(string.as_str())
}
}

/// Testing framework
#[cfg(test)]
pub mod test {
use crate::key::{Calamari, CoinType, KeySecret, Manta, Testnet};
use manta_crypto::rand::{ChaCha12Rng, SeedableRng};

/// Hardcoded testnet secret key value in bytes for the BIP32 0.3.0 version
const SECRET_KEY_TESTNET: [u8; 32] = [
55, 177, 88, 96, 186, 231, 197, 20, 152, 186, 220, 249, 99, 7, 206, 216, 161, 49, 179, 32,
62, 26, 87, 161, 13, 69, 41, 84, 20, 146, 126, 20,
];

/// Hardcoded manta secret key value in bytes for the BIP32 0.3.0 version
const SECRET_KEY_MANTA: [u8; 32] = [
228, 135, 94, 228, 192, 30, 201, 41, 57, 204, 21, 73, 71, 4, 79, 69, 6, 223, 159, 72, 196,
237, 14, 159, 211, 248, 36, 248, 128, 71, 142, 251,
];

/// Hardcoded calamari secret key value in bytes for the BIP32 0.3.0 version
const SECRET_KEY_CALAMARI: [u8; 32] = [
170, 5, 152, 195, 158, 157, 166, 172, 135, 10, 191, 238, 53, 71, 37, 124, 103, 223, 17,
194, 178, 237, 231, 204, 21, 14, 23, 174, 90, 248, 129, 208,
];

/// Computes a secret key and asserts it is equal to the hardcoded `value`.
#[inline]
pub fn secret_key_generation<C>(value: [u8; 32])
where
C: CoinType,
{
let mut rng = ChaCha12Rng::from_seed([0u8; 32]);
let xpr_secret_key = KeySecret::<C>::sample(&mut rng)
.xpr_secret_key(&Default::default())
.to_bytes();
assert_eq!(
xpr_secret_key, value,
"BIP32 version is not backward-compatible with 0.3.0."
);
}

/// Runs the test above for [`Testnet`], [`Manta`] and [`Calamari`].
#[test]
fn secret_key_generation_test() {
secret_key_generation::<Testnet>(SECRET_KEY_TESTNET);
secret_key_generation::<Manta>(SECRET_KEY_MANTA);
secret_key_generation::<Calamari>(SECRET_KEY_CALAMARI);
}
}

0 comments on commit f4c6fe6

Please sign in to comment.