Skip to content

Commit

Permalink
apply pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 11, 2023
1 parent 50511ff commit 7cbe65d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
20 changes: 10 additions & 10 deletions ferveo-python/ferveo/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class Keypair:
...

@staticmethod
def from_secure_randomness(bytes: bytes) -> Keypair:
def from_secure_randomness(secure_randomness: bytes) -> Keypair:
...

@staticmethod
def secure_randomness_size() -> int:
...

@staticmethod
def from_bytes(bytes: bytes) -> Keypair:
def from_bytes(data: bytes) -> Keypair:
...

def __bytes__(self) -> bytes:
Expand All @@ -27,7 +27,7 @@ class Keypair:
@final
class FerveoPublicKey:
@staticmethod
def from_bytes(bytes: bytes) -> FerveoPublicKey:
def from_bytes(data: bytes) -> FerveoPublicKey:
...

def __bytes__(self) -> bytes:
Expand All @@ -53,7 +53,7 @@ class Validator:
@final
class Transcript:
@staticmethod
def from_bytes(bytes: bytes) -> Transcript:
def from_bytes(data: bytes) -> Transcript:
...

def __bytes__(self) -> bytes:
Expand All @@ -62,7 +62,7 @@ class Transcript:
@final
class DkgPublicKey:
@staticmethod
def from_bytes(bytes: bytes) -> DkgPublicKey:
def from_bytes(data: bytes) -> DkgPublicKey:
...

def __bytes__(self) -> bytes:
Expand Down Expand Up @@ -109,7 +109,7 @@ class Dkg:
@final
class Ciphertext:
@staticmethod
def from_bytes(bytes: bytes) -> Ciphertext:
def from_bytes(data: bytes) -> Ciphertext:
...

def __bytes__(self) -> bytes:
Expand All @@ -118,15 +118,15 @@ class Ciphertext:
@final
class DecryptionShareSimple:
@staticmethod
def from_bytes(bytes: bytes) -> DecryptionShareSimple:
def from_bytes(data: bytes) -> DecryptionShareSimple:
...

def __bytes__(self) -> bytes:
...
@final
class DecryptionSharePrecomputed:
@staticmethod
def from_bytes(bytes: bytes) -> DecryptionSharePrecomputed:
def from_bytes(data: bytes) -> DecryptionSharePrecomputed:
...

def __bytes__(self) -> bytes:
Expand Down Expand Up @@ -160,7 +160,7 @@ class AggregatedTranscript:
...

@staticmethod
def from_bytes(bytes: bytes) -> AggregatedTranscript:
def from_bytes(data: bytes) -> AggregatedTranscript:
...

def __bytes__(self) -> bytes:
Expand All @@ -170,7 +170,7 @@ class AggregatedTranscript:
class SharedSecret:

@staticmethod
def from_bytes(bytes: bytes) -> SharedSecret:
def from_bytes(data: bytes) -> SharedSecret:
...

def __bytes__(self) -> bytes:
Expand Down
7 changes: 4 additions & 3 deletions ferveo-python/test/test_ferveo.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ def test_precomputed_tdec_doesnt_have_enough_messages():

PARAMS = [
(1, FerveoVariant.simple),
(3, FerveoVariant.simple),
(4, FerveoVariant.simple),
(7, FerveoVariant.simple),
(8, FerveoVariant.simple),
(32, FerveoVariant.simple),
(1, FerveoVariant.precomputed),
(3, FerveoVariant.precomputed),
(4, FerveoVariant.precomputed),
(7, FerveoVariant.precomputed),
(8, FerveoVariant.precomputed),
(32, FerveoVariant.precomputed),

]

TEST_CASES_WITH_THRESHOLD_RANGE = []
Expand Down
24 changes: 12 additions & 12 deletions ferveo/src/bindings_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ macro_rules! generate_bytes_serialization {
#[pymethods]
impl $struct_name {
#[staticmethod]
pub fn from_bytes(bytes: &[u8]) -> PyResult<Self> {
from_py_bytes(bytes).map(Self)
#[pyo3(signature = (data))]
pub fn from_bytes(data: &[u8]) -> PyResult<Self> {
from_py_bytes(data).map(Self)
}

fn __bytes__(&self) -> PyResult<PyObject> {
Expand All @@ -193,13 +194,11 @@ macro_rules! generate_boxed_bytes_serialization {
#[pymethods]
impl $struct_name {
#[staticmethod]
#[pyo3(signature = (bytes))]
pub fn from_bytes(bytes: &[u8]) -> PyResult<Self> {
Ok($struct_name(
$inner_struct_name::from_bytes(bytes).map_err(|err| {
FerveoPythonError::Other(err.to_string())
})?,
))
#[pyo3(signature = (data))]
pub fn from_bytes(data: &[u8]) -> PyResult<Self> {
Ok($struct_name($inner_struct_name::from_bytes(data).map_err(
|err| FerveoPythonError::Other(err.to_string()),
)?))
}

fn __bytes__(&self) -> PyResult<PyObject> {
Expand Down Expand Up @@ -304,9 +303,10 @@ impl Keypair {
}

#[staticmethod]
pub fn from_secure_randomness(bytes: &[u8]) -> PyResult<Self> {
let keypair = api::Keypair::from_secure_randomness(bytes)
.map_err(|err| FerveoPythonError::Other(err.to_string()))?;
pub fn from_secure_randomness(secure_randomness: &[u8]) -> PyResult<Self> {
let keypair =
api::Keypair::from_secure_randomness(secure_randomness)
.map_err(|err| FerveoPythonError::Other(err.to_string()))?;
Ok(Self(keypair))
}

Expand Down

0 comments on commit 7cbe65d

Please sign in to comment.