mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 13:23:10 +00:00
fmt clippy
This commit is contained in:
parent
63cca0f30f
commit
b22de50107
@ -117,7 +117,8 @@ impl AccountPublicMask {
|
||||
impl Account {
|
||||
pub fn new() -> Self {
|
||||
let key_holder = AddressKeyHolder::new_os_random();
|
||||
let public_key = nssa::PublicKey::new_from_private_key(key_holder.get_pub_account_signing_key());
|
||||
let public_key =
|
||||
nssa::PublicKey::new_from_private_key(key_holder.get_pub_account_signing_key());
|
||||
let address = nssa::Address::from_public_key(&public_key);
|
||||
let balance = 0;
|
||||
let utxos = HashMap::new();
|
||||
@ -132,7 +133,8 @@ impl Account {
|
||||
|
||||
pub fn new_with_balance(balance: u64) -> Self {
|
||||
let key_holder = AddressKeyHolder::new_os_random();
|
||||
let public_key = nssa::PublicKey::new_from_private_key(key_holder.get_pub_account_signing_key());
|
||||
let public_key =
|
||||
nssa::PublicKey::new_from_private_key(key_holder.get_pub_account_signing_key());
|
||||
let address = nssa::Address::from_public_key(&public_key);
|
||||
let utxos = HashMap::new();
|
||||
|
||||
|
||||
@ -11,4 +11,3 @@ pub use signature::PrivateKey;
|
||||
pub use signature::PublicKey;
|
||||
pub use signature::Signature;
|
||||
pub use state::V01State;
|
||||
|
||||
|
||||
@ -6,4 +6,3 @@ mod witness_set;
|
||||
pub use message::Message;
|
||||
pub use transaction::PublicTransaction;
|
||||
pub use witness_set::WitnessSet;
|
||||
|
||||
|
||||
@ -10,7 +10,12 @@ impl WitnessSet {
|
||||
let message_bytes = message.to_bytes();
|
||||
let signatures_and_public_keys = private_keys
|
||||
.iter()
|
||||
.map(|&key| (Signature::new(key, &message_bytes), PublicKey::new_from_private_key(key)))
|
||||
.map(|&key| {
|
||||
(
|
||||
Signature::new(key, &message_bytes),
|
||||
PublicKey::new_from_private_key(key),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
Self {
|
||||
signatures_and_public_keys,
|
||||
|
||||
@ -6,7 +6,7 @@ impl PublicKey {
|
||||
pub(crate) fn from_cursor(cursor: &mut Cursor<&[u8]>) -> Result<Self, NssaError> {
|
||||
let mut value = [0u8; 32];
|
||||
cursor.read_exact(&mut value)?;
|
||||
Ok(Self::try_new(value)?)
|
||||
Self::try_new(value)
|
||||
}
|
||||
|
||||
pub(crate) fn to_bytes(&self) -> &[u8] {
|
||||
|
||||
@ -48,7 +48,7 @@ mod bip340_test_vectors;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::{PublicKey, Signature, signature::bip340_test_vectors};
|
||||
use crate::{Signature, signature::bip340_test_vectors};
|
||||
|
||||
impl Signature {
|
||||
pub(crate) fn new_for_tests(value: [u8; 64]) -> Self {
|
||||
|
||||
@ -43,6 +43,7 @@ mod test {
|
||||
assert!(matches!(result, Err(NssaError::InvalidPublicKey)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_try_new_invalid_public_key_from_bip340_test_vector_14() {
|
||||
let value_invalid_key = [
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
@ -54,11 +55,12 @@ mod test {
|
||||
assert!(matches!(result, Err(NssaError::InvalidPublicKey)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_try_new_valid_public_keys() {
|
||||
for (i, test_vector) in bip340_test_vectors::test_vectors().into_iter().enumerate() {
|
||||
let expected_public_key = test_vector.pubkey;
|
||||
let public_key = PublicKey::try_new(*expected_public_key.value()).unwrap();
|
||||
assert_eq!(public_key, expected_public_key);
|
||||
assert_eq!(public_key, expected_public_key, "Failed on test vector {i}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user