You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is better hygiene, to also defend against the private - public key mismatching we found on ed25519 libs. The pub key can be derived during deserialization. Creating a similar issue in Sui repo.
The text was updated successfully, but these errors were encountered:
we actually already does this when decoding from base64:
in fastcrypto (errors instead of silently expanding from privkey):
let secret = <T as KeyPair>::PrivKey::from_bytes(&bytes[..sk_length])?;
let kp: T = secret.into();
if kp.public().as_ref() != &bytes[sk_length..] {
return Err(eyre::eyre!("Invalid keypair"));
}
in sui (only reads the privkey bytes and expand the kp):
let sk = Secp256k1PrivateKey::from_bytes(
bytes
.get(1 + Secp256k1PublicKey::LENGTH..)
.ok_or_else(|| eyre::eyre!("Invalid length"))?,
)?;
Ok(SuiKeyPair::Secp256k1(<Secp256k1KeyPair as From<
Secp256k1PrivateKey,
>>::from(sk)))
we can do this for encoding as well
SuiKeyPair::Ed25519(kp) => {
let kp1 = kp.copy();
bytes.extend_from_slice(&[self.public().flag()]);
bytes.extend_from_slice(kp.public().as_ref()); // change this to pubkey::from(kp.private())
bytes.extend_from_slice(kp1.private().as_ref());
}
This is better hygiene, to also defend against the private - public key mismatching we found on ed25519 libs. The pub key can be derived during deserialization. Creating a similar issue in Sui repo.
The text was updated successfully, but these errors were encountered: