mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Overhaul crypto (Schnorr/Ristretto, HDKD, BIP39) (#1795)
* Rijig to Ristretto * Rebuild wasm * adds compatibility test with the wasm module * Add Ed25519-BIP39 support * Bump subkey version * Update CLI output * New keys. * Standard phrase/password/path keys. * Subkey uses S-URI for secrets * Move everything to use new HDKD crypto. * Test fixes * Ignore old test vector. * fix the ^^ old test vector. * Fix tests * Test fixes * Cleanups * Fix broken key conversion logic in grandpa CC @rphmeier * Remove legacy Keyring usage * Traitify `Pair` * Replace Ed25519AuthorityId with ed25519::Public * Expunge Ed25519AuthorityId type! * Replace Sr25519AuthorityId with sr25519::Public * Remove dodgy crypto type-punning conversions * Fix some tests * Avoid trait * Deduplicate DeriveJunction string decode * Remove cruft code * Fix test * Minor removals * Build fix * Subkey supports sign and verify * Inspect works for public key URIs * Remove more crypto type-punning * Fix typo * Fix tests
This commit is contained in:
@@ -453,7 +453,7 @@ mod tests {
|
||||
use super::*;
|
||||
use futures::Stream;
|
||||
use parity_codec::Encode;
|
||||
use test_runtime::{Block, Extrinsic, Transfer, H256};
|
||||
use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId};
|
||||
use assert_matches::assert_matches;
|
||||
use crate::watcher;
|
||||
|
||||
@@ -493,7 +493,7 @@ mod tests {
|
||||
/// Returns a block hash given the block id.
|
||||
fn block_id_to_hash(&self, at: &BlockId<Self::Block>) -> Result<Option<BlockHash<Self>>, Self::Error> {
|
||||
Ok(match at {
|
||||
BlockId::Number(num) => Some(H256::from_low_u64_be(*num)),
|
||||
BlockId::Number(num) => Some(H256::from_low_u64_be(*num)).into(),
|
||||
BlockId::Hash(_) => None,
|
||||
})
|
||||
}
|
||||
@@ -502,7 +502,7 @@ mod tests {
|
||||
fn hash_and_length(&self, uxt: &ExtrinsicFor<Self>) -> (Self::Hash, usize) {
|
||||
let len = uxt.encode().len();
|
||||
(
|
||||
(uxt.transfer().from.to_low_u64_be() << 5) + uxt.transfer().nonce,
|
||||
(H256::from(uxt.transfer().from.clone()).to_low_u64_be() << 5) + uxt.transfer().nonce,
|
||||
len
|
||||
)
|
||||
}
|
||||
@@ -524,8 +524,8 @@ mod tests {
|
||||
|
||||
// when
|
||||
let hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
@@ -539,8 +539,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let uxt = uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
});
|
||||
@@ -564,21 +564,21 @@ mod tests {
|
||||
|
||||
// when
|
||||
let _hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
let _hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 1,
|
||||
})).unwrap();
|
||||
// future doesn't count
|
||||
let _hash = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 3,
|
||||
})).unwrap();
|
||||
@@ -600,20 +600,20 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let hash1 = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
let hash2 = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 1,
|
||||
})).unwrap();
|
||||
let hash3 = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 3,
|
||||
})).unwrap();
|
||||
@@ -636,8 +636,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let hash1 = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
@@ -662,8 +662,8 @@ mod tests {
|
||||
}, TestApi::default());
|
||||
|
||||
let hash1 = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 1,
|
||||
})).unwrap();
|
||||
@@ -671,8 +671,8 @@ mod tests {
|
||||
|
||||
// when
|
||||
let hash2 = pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(2),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 10,
|
||||
})).unwrap();
|
||||
@@ -697,8 +697,8 @@ mod tests {
|
||||
|
||||
// when
|
||||
pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 1,
|
||||
})).unwrap_err();
|
||||
@@ -717,8 +717,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
@@ -733,7 +733,7 @@ mod tests {
|
||||
// then
|
||||
let mut stream = watcher.into_stream().wait();
|
||||
assert_eq!(stream.next(), Some(Ok(watcher::Status::Ready)));
|
||||
assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalised(H256::from_low_u64_be(2)))));
|
||||
assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalised(H256::from_low_u64_be(2).into()))));
|
||||
assert_eq!(stream.next(), None);
|
||||
}
|
||||
|
||||
@@ -742,8 +742,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
@@ -758,7 +758,7 @@ mod tests {
|
||||
// then
|
||||
let mut stream = watcher.into_stream().wait();
|
||||
assert_eq!(stream.next(), Some(Ok(watcher::Status::Ready)));
|
||||
assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalised(H256::from_low_u64_be(2)))));
|
||||
assert_eq!(stream.next(), Some(Ok(watcher::Status::Finalised(H256::from_low_u64_be(2).into()))));
|
||||
assert_eq!(stream.next(), None);
|
||||
}
|
||||
|
||||
@@ -767,8 +767,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let watcher = pool.submit_and_watch(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 1,
|
||||
})).unwrap();
|
||||
@@ -777,8 +777,8 @@ mod tests {
|
||||
|
||||
// when
|
||||
pool.submit_one(&BlockId::Number(0), uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
})).unwrap();
|
||||
@@ -795,8 +795,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let uxt = uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
});
|
||||
@@ -819,8 +819,8 @@ mod tests {
|
||||
// given
|
||||
let pool = pool();
|
||||
let uxt = uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
});
|
||||
@@ -853,8 +853,8 @@ mod tests {
|
||||
}, TestApi::default());
|
||||
|
||||
let xt = uxt(Transfer {
|
||||
from: H256::from_low_u64_be(1),
|
||||
to: H256::from_low_u64_be(2),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
});
|
||||
@@ -863,8 +863,8 @@ mod tests {
|
||||
|
||||
// when
|
||||
let xt = uxt(Transfer {
|
||||
from: H256::from_low_u64_be(2),
|
||||
to: H256::from_low_u64_be(1),
|
||||
from: AccountId::from_h256(H256::from_low_u64_be(2)),
|
||||
to: AccountId::from_h256(H256::from_low_u64_be(1)),
|
||||
amount: 4,
|
||||
nonce: 1,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user