Skip to content

Commit

Permalink
Fix Python bindings for SigningKey/PrivateKey/PublicKey encode meth…
Browse files Browse the repository at this point in the history
…od incorectly returning `list[int]` instead of `bytes`
  • Loading branch information
touilleMan authored and FirelightFlagboy committed Nov 8, 2024
1 parent 3e22a9b commit f497ccc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl SigningKey {
PyBytes::new_bound(py, self.0.sign_only_signature(data).as_slice())
}

fn encode(&self) -> [u8; libparsec_types::SigningKey::SIZE] {
self.0.to_bytes()
fn encode<'py>(&self, py: Python<'py>) -> Bound<'py, PyBytes> {
PyBytes::new_bound(py, &self.0.to_bytes())
}
}

Expand Down Expand Up @@ -293,8 +293,8 @@ impl PrivateKey {
}
}

fn encode(&self) -> [u8; libparsec_types::PrivateKey::SIZE] {
self.0.to_bytes()
fn encode<'py>(&self, py: Python<'py>) -> Bound<'py, PyBytes> {
PyBytes::new_bound(py, &self.0.to_bytes())
}

fn generate_shared_secret_key(&self, peer_public_key: &PublicKey) -> SecretKey {
Expand Down Expand Up @@ -335,8 +335,8 @@ impl PublicKey {
Ok(PyBytes::new_bound(py, &self.0.encrypt_for_self(bytes)))
}

fn encode(&self) -> &[u8] {
self.0.as_ref()
fn encode<'py>(&self, py: Python<'py>) -> Bound<'py, PyBytes> {
PyBytes::new_bound(py, self.0.as_ref())
}
}

Expand Down

0 comments on commit f497ccc

Please sign in to comment.