Impl zcash_deserialize for secp256k1::PublicKey

This commit is contained in:
Deirdre Connolly 2020-03-13 15:36:29 -04:00 committed by Deirdre Connolly
parent 3fbfd10f2c
commit 532bbaf460
1 changed files with 5 additions and 2 deletions

View File

@ -12,7 +12,10 @@ impl ZcashSerialize for PublicKey {
}
impl ZcashDeserialize for PublicKey {
fn zcash_deserialize<R: io::Read>(mut _reader: R) -> Result<Self, SerializationError> {
unimplemented!();
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
let mut bytes = [0; 33];
reader.read_exact(&mut bytes[..])?;
Self::from_slice(&bytes[..])
.map_err(|_| SerializationError::Parse("weird secp256k1 compressed public key"))
}
}