Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit dae5d75

Browse files
ordiandvdplm
authored andcommitted
Upgrade ethereum types (#10670)
* cargo upgrade "ethereum-types" --all --allow-prerelease * [ethash] fix compilation errors * [ethkey] fix compilation errors * [journaldb] fix compilation errors * [dir] fix compilation errors * [ethabi] update to 0.7 * wip * [eip-712] fix compilation errors * [ethjson] fix compilation errors * [Cargo.toml] add TODO to remove patches * [ethstore] fix compilation errors * use patched keccak-hash with new primitive-types * wip * [ethcore-network-devp2p] fix compilation errors * [vm] fix compilation errors * [common-types, evm, wasm] fix compilation errors * [ethcore-db] Require AsRef instead of Deref for keys * [ethcore-blockchain] fix some compilation errors * [blooms-db] fix compilation errors Thanks a lot @dvdplm :) * we don't need no rlp ethereum feature * [ethcore] fix some compilation errors * [parity-ipfs-api] fix compilation error * [ethcore-light] fix compilation errors * [Cargo.lock] update parity-common * [ethcore-private-tx] fix some compilation errors * wip * [ethcore-private-tx] fix compilation errors * [parity-updater] fix compilation errors * [parity-rpc] fix compilation errors * [parity-bin] fix other compilation errors * update to new ethereum-types * update keccak-hash * [fastmap] fix compilation in tests * [blooms-db] fix compilation in tests * [common-types] fix compilation in tests * [triehash-ethereum] fix compilation in tests * [ethkey] fix compilation in tests * [pwasm-run-test] fix compilation errors * [wasm] fix compilation errors * [ethjson] fix compilation in tests * [eip-712] fix compilation in tests * [ethcore-blockchain] fix compilation in tests * [ethstore] fix compilation in tests * [ethstore-accounts] fix compilation in tests * [parity-hash-fetch] fix compilation in tests * [parity-whisper] fix compilation in tests * [ethcore-miner] fix compilation in tests * [ethcore-network-devp2p] fix compilation in tests * [*] upgrade rand to 0.6 * [evm] get rid of num-bigint conversions * [ethcore] downgrade trie-standardmap and criterion * [ethcore] fix some warnings * [ethcore] fix compilation in tests * [evmbin] fix compilation in tests * [updater] fix compilation in tests * [ethash] fix compilation in tests * [ethcore-secretstore] fix compilation in tests * [ethcore-sync] fix compilation in tests * [parity-rpc] fix compilation in tests * [ethcore] finally fix compilation in tests FUCK YEAH!!! * [ethstore] lazy_static is unused * [ethcore] fix test * fix up bad merge * [Cargo.toml] remove unused patches * [*] replace some git dependencies with crates.io * [Cargo.toml] remove unused lazy_static * [*] clean up * [ethcore] fix transaction_filter_deprecated test * [private-tx] fix serialization tests * fix more serialization tests * [ethkey] fix smoky test * [rpc] fix tests, please? * [ethcore] remove commented out code * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * [ethstore] remove unused dev-dependency * [ethcore] remove resolved TODO * [*] resolve keccak-hash TODO * [*] s/Address::default()/Address::zero() * [rpc] remove Subscribers::new_test * [rpc] remove EthPubSubClient::new_test * [ethcore] use trie-standardmap from crates.io * [dir] fix db_root_path * [ethcore] simplify snapshot::tests::helpers::fill_storage * Apply suggestions from code review Co-Authored-By: David <dvdplm@gmail.com> * [ethcore-secretstore] resolve TODO in serialization * [ethcore-network-devp2p] resolve TODO in save_key * [Cargo.lock] update triehash * [*] use ethabi from crates.io * [ethkey] use secp256k1 from master branch * [Cargo.lock] update eth-secp256k1
1 parent 33d3bfa commit dae5d75

File tree

274 files changed

+2723
-2280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+2723
-2280
lines changed

Cargo.lock

+365-221
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ ethcore-network = { path = "util/network" }
4545
ethcore-private-tx = { path = "ethcore/private-tx" }
4646
ethcore-service = { path = "ethcore/service" }
4747
ethcore-sync = { path = "ethcore/sync" }
48-
ethereum-types = "0.4"
48+
ethereum-types = "0.6.0"
4949
ethkey = { path = "accounts/ethkey" }
5050
ethstore = { path = "accounts/ethstore" }
5151
node-filter = { path = "ethcore/node-filter" }
52-
rlp = { version = "0.3.0", features = ["ethereum"] }
52+
rlp = "0.4.0"
5353
cli-signer= { path = "cli-signer" }
5454
parity-daemonize = "0.3"
5555
parity-hash-fetch = { path = "updater/hash-fetch" }
@@ -63,7 +63,7 @@ parity-whisper = { path = "whisper" }
6363
parity-path = "0.1"
6464
dir = { path = "util/dir" }
6565
panic_hook = { path = "util/panic-hook" }
66-
keccak-hash = "0.1"
66+
keccak-hash = "0.2.0"
6767
migration-rocksdb = { path = "util/migration-rocksdb" }
6868
kvdb = "0.1"
6969
kvdb-rocksdb = "0.1.3"
@@ -81,7 +81,6 @@ pretty_assertions = "0.1"
8181
ipnetwork = "0.12.6"
8282
tempdir = "0.3"
8383
fake-fetch = { path = "util/fake-fetch" }
84-
lazy_static = "1.2.0"
8584

8685
[target.'cfg(windows)'.dependencies]
8786
winapi = { version = "0.3.4", features = ["winsock2", "winuser", "shellapi"] }

accounts/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ serde_derive = "1.0"
1717
serde_json = "1.0"
1818

1919
[dev-dependencies]
20-
ethereum-types = "0.4"
20+
ethereum-types = "0.6.0"
2121
tempdir = "0.3"

accounts/ethkey/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ byteorder = "1.0"
88
edit-distance = "2.0"
99
parity-crypto = "0.4.0"
1010
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
11-
ethereum-types = "0.4"
11+
ethereum-types = "0.6.0"
1212
lazy_static = "1.0"
1313
log = "0.4"
1414
memzero = { path = "../../util/memzero" }
1515
parity-wordlist = "1.2"
1616
quick-error = "1.2.2"
17-
rand = "0.4"
17+
rand = "0.6"
1818
rustc-hex = "1.0"
1919
serde = "1.0"
2020
serde_derive = "1.0"

accounts/ethkey/src/brain_prefix.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Generator for BrainPrefix {
4747
for _ in 0..self.iterations {
4848
let phrase = wordlist::random_phrase(self.no_of_words);
4949
let keypair = Brain::new(phrase.clone()).generate().unwrap();
50-
if keypair.address().starts_with(&self.prefix) {
50+
if keypair.address().as_ref().starts_with(&self.prefix) {
5151
self.last_phrase = phrase;
5252
return Ok(keypair)
5353
}
@@ -65,6 +65,6 @@ mod tests {
6565
fn prefix_generator() {
6666
let prefix = vec![0x00u8];
6767
let keypair = BrainPrefix::new(prefix.clone(), usize::max_value(), 12).generate().unwrap();
68-
assert!(keypair.address().starts_with(&prefix));
68+
assert!(keypair.address().as_bytes().starts_with(&prefix));
6969
}
7070
}

accounts/ethkey/src/crypto.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub mod ecdh {
5757
};
5858

5959
let publ = key::PublicKey::from_slice(context, &pdata)?;
60-
let sec = key::SecretKey::from_slice(context, &secret)?;
60+
let sec = key::SecretKey::from_slice(context, secret.as_bytes())?;
6161
let shared = ecdh::SharedSecret::new_raw(context, &publ, &sec);
6262

6363
Secret::from_unsafe_slice(&shared[0..32])
@@ -89,12 +89,12 @@ pub mod ecies {
8989
msg[0] = 0x04u8;
9090
{
9191
let msgd = &mut msg[1..];
92-
msgd[0..64].copy_from_slice(r.public());
92+
msgd[0..64].copy_from_slice(r.public().as_bytes());
9393
let iv = H128::random();
94-
msgd[64..80].copy_from_slice(&iv);
94+
msgd[64..80].copy_from_slice(iv.as_bytes());
9595
{
9696
let cipher = &mut msgd[(64 + 16)..(64 + 16 + plain.len())];
97-
aes::encrypt_128_ctr(ekey, &iv, plain, cipher)?;
97+
aes::encrypt_128_ctr(ekey, iv.as_bytes(), plain, cipher)?;
9898
}
9999
let mut hmac = hmac::Signer::with(&mkey);
100100
{
@@ -156,7 +156,7 @@ pub mod ecies {
156156
let mut hasher = digest::Hasher::sha256();
157157
let ctrs = [(ctr >> 24) as u8, (ctr >> 16) as u8, (ctr >> 8) as u8, ctr as u8];
158158
hasher.update(&ctrs);
159-
hasher.update(secret);
159+
hasher.update(secret.as_bytes());
160160
hasher.update(s1);
161161
let d = hasher.finish();
162162
&mut dest[written..(written + 32)].copy_from_slice(&d);

accounts/ethkey/src/extended.rs

+55-38
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Label for H256 {
6464
fn len() -> usize { 32 }
6565

6666
fn store(&self, target: &mut [u8]) {
67-
self.copy_to(&mut target[0..32]);
67+
(&mut target[0..32]).copy_from_slice(self.as_bytes());
6868
}
6969
}
7070

@@ -180,7 +180,7 @@ impl ExtendedKeyPair {
180180
pub fn with_seed(seed: &[u8]) -> Result<ExtendedKeyPair, DerivationError> {
181181
let (master_key, chain_code) = derivation::seed_pair(seed);
182182
Ok(ExtendedKeyPair::with_secret(
183-
Secret::from_unsafe_slice(&*master_key).map_err(|_| DerivationError::InvalidSeed)?,
183+
Secret::from_unsafe_slice(master_key.as_bytes()).map_err(|_| DerivationError::InvalidSeed)?,
184184
chain_code,
185185
))
186186
}
@@ -208,12 +208,13 @@ impl ExtendedKeyPair {
208208
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
209209
mod derivation {
210210
use parity_crypto::hmac;
211-
use ethereum_types::{U256, U512, H512, H256};
211+
use ethereum_types::{BigEndianHash, U256, U512, H512, H256};
212212
use secp256k1::key::{SecretKey, PublicKey};
213213
use SECP256K1;
214214
use keccak;
215215
use math::curve_order;
216216
use super::{Label, Derivation};
217+
use std::convert::TryInto;
217218

218219
#[derive(Debug)]
219220
pub enum Error {
@@ -237,18 +238,18 @@ mod derivation {
237238
}
238239

239240
fn hmac_pair(data: &[u8], private_key: H256, chain_code: H256) -> (H256, H256) {
240-
let private: U256 = private_key.into();
241+
let private: U256 = private_key.into_uint();
241242

242243
// produces 512-bit derived hmac (I)
243-
let skey = hmac::SigKey::sha512(&*chain_code);
244+
let skey = hmac::SigKey::sha512(chain_code.as_bytes());
244245
let i_512 = hmac::sign(&skey, &data[..]);
245246

246247
// left most 256 bits are later added to original private key
247-
let hmac_key: U256 = H256::from_slice(&i_512[0..32]).into();
248+
let hmac_key: U256 = H256::from_slice(&i_512[0..32]).into_uint();
248249
// right most 256 bits are new chain code for later derivations
249-
let next_chain_code = H256::from(&i_512[32..64]);
250+
let next_chain_code = H256::from_slice(&i_512[32..64]);
250251

251-
let child_key = private_add(hmac_key, private).into();
252+
let child_key = BigEndianHash::from_uint(&private_add(hmac_key, private));
252253
(child_key, next_chain_code)
253254
}
254255

@@ -257,7 +258,7 @@ mod derivation {
257258
fn private_soft<T>(private_key: H256, chain_code: H256, index: T) -> (H256, H256) where T: Label {
258259
let mut data = vec![0u8; 33 + T::len()];
259260

260-
let sec_private = SecretKey::from_slice(&SECP256K1, &*private_key)
261+
let sec_private = SecretKey::from_slice(&SECP256K1, private_key.as_bytes())
261262
.expect("Caller should provide valid private key");
262263
let sec_public = PublicKey::from_secret_key(&SECP256K1, &sec_private)
263264
.expect("Caller should provide valid private key");
@@ -276,7 +277,7 @@ mod derivation {
276277
// corresponding public keys of the original and derived private keys
277278
fn private_hard<T>(private_key: H256, chain_code: H256, index: T) -> (H256, H256) where T: Label {
278279
let mut data: Vec<u8> = vec![0u8; 33 + T::len()];
279-
let private: U256 = private_key.into();
280+
let private: U256 = private_key.into_uint();
280281

281282
// 0x00 (padding) -- private_key -- index
282283
// 0 -- 1..33 -- 33..end
@@ -293,9 +294,8 @@ mod derivation {
293294

294295
// todo: surely can be optimized
295296
fn modulo(u1: U512, u2: U256) -> U256 {
296-
let dv = u1 / U512::from(u2);
297-
let md = u1 - (dv * U512::from(u2));
298-
md.into()
297+
let m = u1 % U512::from(u2);
298+
m.try_into().expect("U512 modulo U256 should fit into U256; qed")
299299
}
300300

301301
pub fn public<T>(public_key: H512, chain_code: H256, derivation: Derivation<T>) -> Result<(H512, H256), Error> where T: Label {
@@ -306,7 +306,7 @@ mod derivation {
306306

307307
let mut public_sec_raw = [0u8; 65];
308308
public_sec_raw[0] = 4;
309-
public_sec_raw[1..65].copy_from_slice(&*public_key);
309+
public_sec_raw[1..65].copy_from_slice(public_key.as_bytes());
310310
let public_sec = PublicKey::from_slice(&SECP256K1, &public_sec_raw).map_err(|_| Error::InvalidPoint)?;
311311
let public_serialized = public_sec.serialize_vec(&SECP256K1, true);
312312

@@ -317,15 +317,15 @@ mod derivation {
317317
index.store(&mut data[33..(33 + T::len())]);
318318

319319
// HMAC512SHA produces [derived private(256); new chain code(256)]
320-
let skey = hmac::SigKey::sha512(&*chain_code);
320+
let skey = hmac::SigKey::sha512(chain_code.as_bytes());
321321
let i_512 = hmac::sign(&skey, &data[..]);
322322

323-
let new_private = H256::from(&i_512[0..32]);
324-
let new_chain_code = H256::from(&i_512[32..64]);
323+
let new_private = H256::from_slice(&i_512[0..32]);
324+
let new_chain_code = H256::from_slice(&i_512[32..64]);
325325

326326
// Generated private key can (extremely rarely) be out of secp256k1 key field
327-
if curve_order() <= new_private.clone().into() { return Err(Error::MissingIndex); }
328-
let new_private_sec = SecretKey::from_slice(&SECP256K1, &*new_private)
327+
if curve_order() <= new_private.into_uint() { return Err(Error::MissingIndex); }
328+
let new_private_sec = SecretKey::from_slice(&SECP256K1, new_private.as_bytes())
329329
.expect("Private key belongs to the field [0..CURVE_ORDER) (checked above); So initializing can never fail; qed");
330330
let mut new_public = PublicKey::from_secret_key(&SECP256K1, &new_private_sec)
331331
.expect("Valid private key produces valid public key");
@@ -337,7 +337,7 @@ mod derivation {
337337
let serialized = new_public.serialize_vec(&SECP256K1, false);
338338

339339
Ok((
340-
H512::from(&serialized[1..65]),
340+
H512::from_slice(&serialized[1..65]),
341341
new_chain_code,
342342
))
343343
}
@@ -348,18 +348,18 @@ mod derivation {
348348

349349
pub fn chain_code(secret: H256) -> H256 {
350350
// 10,000 rounds of sha3
351-
let mut running_sha3 = sha3(&*secret);
352-
for _ in 0..99999 { running_sha3 = sha3(&*running_sha3); }
351+
let mut running_sha3 = sha3(secret.as_bytes());
352+
for _ in 0..99999 { running_sha3 = sha3(running_sha3.as_bytes()); }
353353
running_sha3
354354
}
355355

356356
pub fn point(secret: H256) -> Result<H512, Error> {
357-
let sec = SecretKey::from_slice(&SECP256K1, &*secret)
357+
let sec = SecretKey::from_slice(&SECP256K1, secret.as_bytes())
358358
.map_err(|_| Error::InvalidPoint)?;
359359
let public_sec = PublicKey::from_secret_key(&SECP256K1, &sec)
360360
.map_err(|_| Error::InvalidPoint)?;
361361
let serialized = public_sec.serialize_vec(&SECP256K1, false);
362-
Ok(H512::from(&serialized[1..65]))
362+
Ok(H512::from_slice(&serialized[1..65]))
363363
}
364364

365365
pub fn seed_pair(seed: &[u8]) -> (H256, H256) {
@@ -378,12 +378,13 @@ mod tests {
378378
use super::{ExtendedSecret, ExtendedPublic, ExtendedKeyPair};
379379
use secret::Secret;
380380
use std::str::FromStr;
381-
use ethereum_types::{H128, H256};
381+
use ethereum_types::{H128, H256, H512};
382382
use super::{derivation, Derivation};
383383

384384
fn master_chain_basic() -> (H256, H256) {
385385
let seed = H128::from_str("000102030405060708090a0b0c0d0e0f")
386386
.expect("Seed should be valid H128")
387+
.as_bytes()
387388
.to_vec();
388389

389390
derivation::seed_pair(&*seed)
@@ -399,35 +400,47 @@ mod tests {
399400
#[test]
400401
fn smoky() {
401402
let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap();
402-
let extended_secret = ExtendedSecret::with_code(secret.clone(), 0u64.into());
403+
let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::zero());
403404

404405
// hardened
405406
assert_eq!(&**extended_secret.as_raw(), &*secret);
406-
assert_eq!(&**extended_secret.derive(2147483648.into()).as_raw(), &"0927453daed47839608e414a3738dfad10aed17c459bbd9ab53f89b026c834b6".into());
407-
assert_eq!(&**extended_secret.derive(2147483649.into()).as_raw(), &"44238b6a29c6dcbe9b401364141ba11e2198c289a5fed243a1c11af35c19dc0f".into());
407+
assert_eq!(
408+
**extended_secret.derive(2147483648.into()).as_raw(),
409+
H256::from_str("0927453daed47839608e414a3738dfad10aed17c459bbd9ab53f89b026c834b6").unwrap(),
410+
);
411+
assert_eq!(
412+
**extended_secret.derive(2147483649.into()).as_raw(),
413+
H256::from_str("44238b6a29c6dcbe9b401364141ba11e2198c289a5fed243a1c11af35c19dc0f").unwrap(),
414+
);
408415

409416
// normal
410-
assert_eq!(&**extended_secret.derive(0.into()).as_raw(), &"bf6a74e3f7b36fc4c96a1e12f31abc817f9f5904f5a8fc27713163d1f0b713f6".into());
411-
assert_eq!(&**extended_secret.derive(1.into()).as_raw(), &"bd4fca9eb1f9c201e9448c1eecd66e302d68d4d313ce895b8c134f512205c1bc".into());
412-
assert_eq!(&**extended_secret.derive(2.into()).as_raw(), &"86932b542d6cab4d9c65490c7ef502d89ecc0e2a5f4852157649e3251e2a3268".into());
417+
assert_eq!(**extended_secret.derive(0.into()).as_raw(), H256::from_str("bf6a74e3f7b36fc4c96a1e12f31abc817f9f5904f5a8fc27713163d1f0b713f6").unwrap());
418+
assert_eq!(**extended_secret.derive(1.into()).as_raw(), H256::from_str("bd4fca9eb1f9c201e9448c1eecd66e302d68d4d313ce895b8c134f512205c1bc").unwrap());
419+
assert_eq!(**extended_secret.derive(2.into()).as_raw(), H256::from_str("86932b542d6cab4d9c65490c7ef502d89ecc0e2a5f4852157649e3251e2a3268").unwrap());
413420

414421
let extended_public = ExtendedPublic::from_secret(&extended_secret).expect("Extended public should be created");
415422
let derived_public = extended_public.derive(0.into()).expect("First derivation of public should succeed");
416-
assert_eq!(&*derived_public.public(), &"f7b3244c96688f92372bfd4def26dc4151529747bab9f188a4ad34e141d47bd66522ff048bc6f19a0a4429b04318b1a8796c000265b4fa200dae5f6dda92dd94".into());
423+
assert_eq!(
424+
*derived_public.public(),
425+
H512::from_str("f7b3244c96688f92372bfd4def26dc4151529747bab9f188a4ad34e141d47bd66522ff048bc6f19a0a4429b04318b1a8796c000265b4fa200dae5f6dda92dd94").unwrap(),
426+
);
417427

418428
let keypair = ExtendedKeyPair::with_secret(
419429
Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap(),
420-
064.into(),
430+
H256::from_low_u64_be(64),
431+
);
432+
assert_eq!(
433+
**keypair.derive(2147483648u32.into()).expect("Derivation of keypair should succeed").secret().as_raw(),
434+
H256::from_str("edef54414c03196557cf73774bc97a645c9a1df2164ed34f0c2a78d1375a930c").unwrap(),
421435
);
422-
assert_eq!(&**keypair.derive(2147483648u32.into()).expect("Derivation of keypair should succeed").secret().as_raw(), &"edef54414c03196557cf73774bc97a645c9a1df2164ed34f0c2a78d1375a930c".into());
423436
}
424437

425438
#[test]
426439
fn h256_soft_match() {
427440
let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap();
428441
let derivation_secret = H256::from_str("51eaf04f9dbbc1417dc97e789edd0c37ecda88bac490434e367ea81b71b7b015").unwrap();
429442

430-
let extended_secret = ExtendedSecret::with_code(secret.clone(), 0u64.into());
443+
let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::zero());
431444
let extended_public = ExtendedPublic::from_secret(&extended_secret).expect("Extended public should be created");
432445

433446
let derived_secret0 = extended_secret.derive(Derivation::Soft(derivation_secret));
@@ -442,15 +455,18 @@ mod tests {
442455
fn h256_hard() {
443456
let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap();
444457
let derivation_secret = H256::from_str("51eaf04f9dbbc1417dc97e789edd0c37ecda88bac490434e367ea81b71b7b015").unwrap();
445-
let extended_secret = ExtendedSecret::with_code(secret.clone(), 1u64.into());
458+
let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::from_low_u64_be(1));
446459

447-
assert_eq!(&**extended_secret.derive(Derivation::Hard(derivation_secret)).as_raw(), &"2bc2d696fb744d77ff813b4a1ef0ad64e1e5188b622c54ba917acc5ebc7c5486".into());
460+
assert_eq!(
461+
**extended_secret.derive(Derivation::Hard(derivation_secret)).as_raw(),
462+
H256::from_str("2bc2d696fb744d77ff813b4a1ef0ad64e1e5188b622c54ba917acc5ebc7c5486").unwrap(),
463+
);
448464
}
449465

450466
#[test]
451467
fn match_() {
452468
let secret = Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65").unwrap();
453-
let extended_secret = ExtendedSecret::with_code(secret.clone(), 1.into());
469+
let extended_secret = ExtendedSecret::with_code(secret.clone(), H256::from_low_u64_be(1));
454470
let extended_public = ExtendedPublic::from_secret(&extended_secret).expect("Extended public should be created");
455471

456472
let derived_secret0 = extended_secret.derive(0.into());
@@ -465,6 +481,7 @@ mod tests {
465481
fn test_seeds() {
466482
let seed = H128::from_str("000102030405060708090a0b0c0d0e0f")
467483
.expect("Seed should be valid H128")
484+
.as_bytes()
468485
.to_vec();
469486

470487
// private key from bitcoin test vector

0 commit comments

Comments
 (0)