Skip to content

Commit c245a1b

Browse files
committed
fixup! core/key: fix arbitrary impls
1 parent c6487e5 commit c245a1b

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

crates/core/src/key/ed25519.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,7 @@ impl arbitrary::Arbitrary<'_> for PublicKey {
400400
fn arbitrary(
401401
u: &mut arbitrary::Unstructured<'_>,
402402
) -> arbitrary::Result<Self> {
403-
let seed: [u8; 32] = u
404-
.bytes(u.len())?
405-
.try_into()
406-
.map_err(|_| arbitrary::Error::NotEnoughData)?;
403+
let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?;
407404
let sk = ed25519_consensus::SigningKey::from(seed);
408405
Ok(Self(sk.verification_key()))
409406
}
@@ -419,10 +416,7 @@ impl arbitrary::Arbitrary<'_> for Signature {
419416
fn arbitrary(
420417
u: &mut arbitrary::Unstructured<'_>,
421418
) -> arbitrary::Result<Self> {
422-
let seed: [u8; 32] = u
423-
.bytes(u.len())?
424-
.try_into()
425-
.map_err(|_| arbitrary::Error::NotEnoughData)?;
419+
let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?;
426420
let sk = ed25519_consensus::SigningKey::from(seed);
427421
Ok(Self(sk.sign(&[0_u8])))
428422
}

crates/core/src/key/secp256k1.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,7 @@ impl arbitrary::Arbitrary<'_> for PublicKey {
605605
u: &mut arbitrary::Unstructured<'_>,
606606
) -> arbitrary::Result<Self> {
607607
use rand::SeedableRng;
608-
let seed: [u8; 32] = u
609-
.bytes(u.len())?
610-
.try_into()
611-
.map_err(|_| arbitrary::Error::NotEnoughData)?;
608+
let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?;
612609
Ok(Self(
613610
k256::SecretKey::random(&mut rand::rngs::StdRng::from_seed(seed))
614611
.public_key(),
@@ -627,10 +624,7 @@ impl arbitrary::Arbitrary<'_> for Signature {
627624
u: &mut arbitrary::Unstructured<'_>,
628625
) -> arbitrary::Result<Self> {
629626
use rand::SeedableRng;
630-
let seed: [u8; 32] = u
631-
.bytes(u.len())?
632-
.try_into()
633-
.map_err(|_| arbitrary::Error::NotEnoughData)?;
627+
let seed: [u8; 32] = arbitrary::Arbitrary::arbitrary(u)?;
634628
let sk =
635629
k256::SecretKey::random(&mut rand::rngs::StdRng::from_seed(seed));
636630
let sig_key = k256::ecdsa::SigningKey::from(&sk);

0 commit comments

Comments
 (0)