Skip to content

Commit

Permalink
rename PublicKey to FerveoPublicKey in python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed May 30, 2023
1 parent d9edeb7 commit 10cc1df
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ferveo-python/ferveo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
combine_decryption_shares_precomputed,
decrypt_with_shared_secret,
Keypair,
PublicKey,
FerveoPublicKey,
Validator,
Transcript,
Dkg,
Expand Down
10 changes: 5 additions & 5 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class Keypair:
def __bytes__(self) -> bytes:
...

def public_key(self) -> PublicKey:
def public_key(self) -> FerveoPublicKey:
...


class PublicKey:
class FerveoPublicKey:
@staticmethod
def from_bytes(data: bytes) -> PublicKey:
def from_bytes(data: bytes) -> FerveoPublicKey:
...

def __bytes__(self) -> bytes:
Expand All @@ -39,12 +39,12 @@ class PublicKey:

class Validator:

def __init__(self, address: str, public_key: PublicKey):
def __init__(self, address: str, public_key: FerveoPublicKey):
...

address: str

public_key: PublicKey
public_key: FerveoPublicKey


class Transcript:
Expand Down
2 changes: 1 addition & 1 deletion ferveo-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn ferveo_py(py: Python, m: &PyModule) -> PyResult<()> {

// Classes
m.add_class::<Keypair>()?;
m.add_class::<PublicKey>()?;
m.add_class::<FerveoPublicKey>()?;
m.add_class::<Validator>()?;
m.add_class::<Transcript>()?;
m.add_class::<Dkg>()?;
Expand Down
19 changes: 11 additions & 8 deletions ferveo/src/bindings_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,19 @@ impl Keypair {
to_py_bytes(&self.0)
}

pub fn public_key(&self) -> PublicKey {
PublicKey(self.0.public_key())
pub fn public_key(&self) -> FerveoPublicKey {
FerveoPublicKey(self.0.public_key())
}
}

#[pyclass(module = "ferveo")]
#[derive(
Clone, PartialEq, PartialOrd, Eq, derive_more::From, derive_more::AsRef,
)]
pub struct PublicKey(api::PublicKey);
pub struct FerveoPublicKey(api::PublicKey);

#[pymethods]
impl PublicKey {
impl FerveoPublicKey {
#[staticmethod]
pub fn from_bytes(bytes: &[u8]) -> PyResult<Self> {
from_py_bytes(bytes).map(Self)
Expand All @@ -317,7 +317,7 @@ impl PublicKey {
.0
.to_bytes()
.map_err(|err| FerveoPythonError::FerveoError(err.into()))?;
hash("PublicKey", &bytes)
hash("FerveoPublicKey", &bytes)
}
}

Expand All @@ -328,7 +328,10 @@ pub struct Validator(api::Validator);
#[pymethods]
impl Validator {
#[new]
pub fn new(address: String, public_key: &PublicKey) -> PyResult<Self> {
pub fn new(
address: String,
public_key: &FerveoPublicKey,
) -> PyResult<Self> {
let validator = api::Validator::new(address, public_key.0)
.map_err(|err| FerveoPythonError::Other(err.to_string()))?;
Ok(Self(validator))
Expand All @@ -340,8 +343,8 @@ impl Validator {
}

#[getter]
pub fn public_key(&self) -> PublicKey {
PublicKey(self.0.public_key)
pub fn public_key(&self) -> FerveoPublicKey {
FerveoPublicKey(self.0.public_key)
}
}

Expand Down

0 comments on commit 10cc1df

Please sign in to comment.