Skip to content

Commit

Permalink
Merge pull request #117 from fjarri/bump-deps
Browse files Browse the repository at this point in the history
Bump `k256` and `PyO3`
  • Loading branch information
fjarri authored Feb 18, 2023
2 parents 89aa0b6 + cb6d4b4 commit 4ce7d09
Show file tree
Hide file tree
Showing 16 changed files with 379 additions and 82 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/umbral-pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
rust:
- 1.58.0 # MSRV
- 1.60.0 # MSRV
- stable
target:
- wasm32-unknown-unknown
Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
rust:
- 1.58.0 # MSRV
- 1.60.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -67,7 +67,7 @@ jobs:
strategy:
matrix:
rust:
- 1.58.0 # MSRV
- 1.60.0 # MSRV
- stable
steps:
- uses: actions/checkout@v2
Expand All @@ -83,7 +83,7 @@ jobs:
matrix:
include:
- target: x86_64-unknown-linux-gnu
rust: 1.58.0 # MSRV
rust: 1.60.0 # MSRV
- target: x86_64-unknown-linux-gnu
rust: stable

Expand Down
39 changes: 23 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,34 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [Unreleased]
## 0.9.0 - under development

Under construction.
### Changed

- Bumped MSRV to 1.60. ([#117])
- Bumped `k256` to 0.12 and PyO3 to `0.18`. ([#117])

## [0.8.1] - 2023-01-17

### Changed
### Added

- Added `ReencryptionEvidence` structure that can be used in e.g. Ethereum contracts to verify the reencryption validity (see its docstring for the list of checks). ([#107])
- Made `Parameters` and `CurvePoint` public (necessary for the evidence to work). Made `Parameters::u` public, and added a public `CurvePoint::coordinates()` method. ([#107])
- Made `hash_to_cfrag_verification()` public. ([#107])
- Added `VerifiedCapsuleFrag::to_bytes_simple()`. ([#107])
- Added `RecoverableSignature` type with limited functionality. ([#117])
- Added `Signature::try_from_be_bytes()`. ([#117])
- Added `PublicKey::recover_from_prehash()`. ([#117])

- Bumped MSRV to 1.58. (#[107])

[#107]: https://github.com/nucypher/rust-umbral/pull/107
[#117]: https://github.com/nucypher/rust-umbral/pull/117


## [0.8.1] - 2023-01-17

### Added

- Added `Signature::to_be_bytes()`, `Capsule::to_bytes_simple()`, and `CapsuleFrag::to_bytes_simple()` to use in Ethereum contracts. ([#115])
- Added `ReencryptionEvidence` structure that can be used in e.g. Ethereum contracts to verify the reencryption validity (see its docstring for the list of checks). (#[107])
- Made `Parameters` and `CurvePoint` public (necessary for the evidence to work). Made `Parameters::u` public, and added a public `CurvePoint::coordinates()` method. (#[107])
- Made `hash_to_cfrag_verification()` public. (#[107])
- Added `VerifiedCapsuleFrag::to_bytes_simple()`. (#[107])


### Fixed
Expand All @@ -32,7 +41,6 @@ Under construction.


[#115]: https://github.com/nucypher/rust-umbral/pull/115
[#107]: https://github.com/nucypher/rust-umbral/pull/107


## [0.8.0] - 2023-01-15
Expand All @@ -44,7 +52,7 @@ Under construction.
- Removed `VerifiedCapsuleFrag::from_verified_bytes()` and `VerifiedKeyFrag::from_verified_bytes()`. For this behavior, deserialize into `CapsuleFrag` or `KeyFrag` and call `skip_verification()`. ([#110])
- `Capsule` no longer implements `Copy`. ([#110])
- Removed default serialization methods for `PublicKey` and `Signature` in the bindings; use `to_compressed_bytes()`/`to_der_bytes()` instead. ([#110])
- Bumped `rmp-serde` to 1, `base64` to 0.21, and `pyo3` to 0.17. (#[114])
- Bumped `rmp-serde` to 1, `base64` to 0.21, and `pyo3` to 0.17. ([#114])


### Added
Expand All @@ -58,7 +66,7 @@ Under construction.

### Fixed

- A typo in the error message that could be returned from `CapsuleFrag.verify()` - it erroneously mentioned `KeyFrag`. (#[105])
- A typo in the error message that could be returned from `CapsuleFrag.verify()` - it erroneously mentioned `KeyFrag`. ([#105])


[#105]: https://github.com/nucypher/rust-umbral/pull/105
Expand All @@ -71,10 +79,10 @@ Under construction.

### Changed

- Replaced `AsBackend`/`FromBackend`, `.inner()`, `.new()`, and `pub backend` with derived `AsRef`/`From`/`Into` where appropriate. (#[103])
- Using a workaround with `wasm-bindgen-derive` to support `Option<&T>` and `&Vec<T>` arguments, and `Vec<T>` return values in WASM bindings. Generating correct TypeScript signatures in all the relevant cases. Affected API: `Capsule.decryptReencrypted()`, `KeyFrag.verify()`, `generate_kfrags()`. (#[103])
- Replaced `AsBackend`/`FromBackend`, `.inner()`, `.new()`, and `pub backend` with derived `AsRef`/`From`/`Into` where appropriate. ([#103])
- Using a workaround with `wasm-bindgen-derive` to support `Option<&T>` and `&Vec<T>` arguments, and `Vec<T>` return values in WASM bindings. Generating correct TypeScript signatures in all the relevant cases. Affected API: `Capsule.decryptReencrypted()`, `KeyFrag.verify()`, `generate_kfrags()`. ([#103])
- Removed `serde` usage in WASM bindings. ([#103])
- `encrypt()` now returns an actual tuple in WASM bindings instead of a special object. (#[103])
- `encrypt()` now returns an actual tuple in WASM bindings instead of a special object. ([#103])


### Added
Expand Down Expand Up @@ -246,7 +254,6 @@ the corresponding methods in Python and WASM bindings. ([#84])

- Initial release.

[Unreleased]: https://github.com/nucypher/rust-umbral/compare/v0.8.1...HEAD
[0.2.0]: https://github.com/nucypher/rust-umbral/releases/tag/v0.2.0
[0.3.0]: https://github.com/nucypher/rust-umbral/releases/tag/v0.3.0
[0.4.0]: https://github.com/nucypher/rust-umbral/releases/tag/v0.4.0
Expand Down
2 changes: 1 addition & 1 deletion umbral-pre-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ umbral-pre = { path = "../umbral-pre", features = ["bindings-python"] }
# Unfortunately, we (for the time being?) cannot use a re-exported `pyo3`
# from the main `umbral-pre`, since `pyo3` macros and `pip` build need an explicit dependency.
# This version has to be matched with the one in `umbral-pre`.
pyo3 = "0.17"
pyo3 = "0.18"
Empty file modified umbral-pre-python/LICENSE
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions umbral-pre-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fn _umbral(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<PublicKey>()?;
m.add_class::<Signer>()?;
m.add_class::<Signature>()?;
m.add_class::<RecoverableSignature>()?;
m.add_class::<Capsule>()?;
m.add_class::<KeyFrag>()?;
m.add_class::<VerifiedKeyFrag>()?;
Expand Down
1 change: 1 addition & 0 deletions umbral-pre-python/umbral_pre/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
PublicKey,
Signer,
Signature,
RecoverableSignature,
Capsule,
KeyFrag,
VerifiedKeyFrag,
Expand Down
18 changes: 18 additions & 0 deletions umbral-pre-python/umbral_pre/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class PublicKey:
def to_compressed_bytes(self) -> bytes:
...

@staticmethod
def recover_from_prehash(prehash: bytes, signature: RecoverableSignature) -> PublicKey:
...


class Signer:

Expand All @@ -80,6 +84,20 @@ class Signature:
def to_der_bytes(self) -> bytes:
...

@staticmethod
def from_be_bytes(data: bytes) -> Signature:
...

def to_be_bytes(self) -> bytes:
...


class RecoverableSignature:

@staticmethod
def from_be_bytes(data: bytes) -> Signature:
...

def to_be_bytes(self) -> bytes:
...

Expand Down
Empty file modified umbral-pre-wasm/LICENSE
100755 → 100644
Empty file.
7 changes: 3 additions & 4 deletions umbral-pre/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "umbral-pre"
version = "0.8.1"
version = "0.9.0-dev"
authors = ["Bogdan Opanchuk <[email protected]>"]
edition = "2021"
license = "GPL-3.0-only"
Expand All @@ -10,15 +10,15 @@ readme = "README.md"
categories = ["cryptography", "no-std"]

[dependencies]
k256 = { version = "0.11", default-features = false, features = ["ecdsa", "arithmetic", "hash2curve"] }
k256 = { version = "0.12", default-features = false, features = ["ecdsa", "arithmetic", "hash2curve"] }
sha2 = { version = "0.10", default-features = false }
chacha20poly1305 = { version = "0.10", default-features = false, features = ["alloc"] }
hkdf = { version = "0.12", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
base64 = { version = "0.21", default-features = false, features = ["alloc"] }
rmp-serde = { version = "1", optional = true }
pyo3 = { version = "0.17", optional = true }
pyo3 = { version = "0.18", optional = true }
js-sys = { version = "0.3", optional = true }
wasm-bindgen = { version = "0.2.74", optional = true }
derive_more = { version = "0.99", optional = true, default_features = false, features = ["as_ref", "from", "into"] }
Expand All @@ -27,7 +27,6 @@ wasm-bindgen-derive = { version = "0.1", optional = true }
# These packages are among the dependencies of the packages above.
# Their versions should be updated when the main packages above are updated.
generic-array = { version = "0.14.6", features = ["zeroize"] }
ecdsa = { version = "0.14.4" } # Pin patch version to enable ZeroizeOnDrop for SigningKey
rand_core = { version = "0.6", default-features = false }
getrandom = { version = "0.2", optional = true, default-features = false }
subtle = { version = "2.4", default-features = false }
Expand Down
Empty file modified umbral-pre/LICENSE
100755 → 100644
Empty file.
52 changes: 50 additions & 2 deletions umbral-pre/src/bindings_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ impl PublicKey {
.map(Self::from)
}

#[staticmethod]
fn recover_from_prehash(prehash: &[u8], signature: &RecoverableSignature) -> PyResult<Self> {
umbral_pre::PublicKey::recover_from_prehash(prehash, signature.as_ref())
.map_err(map_py_value_err)
.map(Self::from)
}

fn to_compressed_bytes(&self) -> PyObject {
let serialized = self.backend.to_compressed_bytes();
Python::with_gil(|py| PyBytes::new(py, &serialized).into())
Expand Down Expand Up @@ -244,6 +251,13 @@ impl Signature {
Python::with_gil(|py| PyBytes::new(py, &serialized).into())
}

#[staticmethod]
fn from_be_bytes(data: &[u8]) -> PyResult<Self> {
umbral_pre::Signature::try_from_be_bytes(data)
.map_err(map_py_value_err)
.map(Self::from)
}

fn to_be_bytes(&self) -> PyObject {
let serialized = self.backend.to_be_bytes();
Python::with_gil(|py| PyBytes::new(py, &serialized).into())
Expand All @@ -266,6 +280,39 @@ impl Signature {
}
}

#[pyclass(module = "umbral")]
#[derive(PartialEq, Eq, derive_more::AsRef, derive_more::From)]
pub struct RecoverableSignature {
backend: umbral_pre::RecoverableSignature,
}

#[pymethods]
impl RecoverableSignature {
#[staticmethod]
fn from_be_bytes(data: &[u8]) -> PyResult<Self> {
umbral_pre::RecoverableSignature::try_from_be_bytes(data)
.map_err(map_py_value_err)
.map(Self::from)
}

fn to_be_bytes(&self) -> PyObject {
let serialized = self.backend.to_be_bytes();
Python::with_gil(|py| PyBytes::new(py, &serialized).into())
}

fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult<bool> {
richcmp(self, other, op)
}

fn __hash__(&self) -> i64 {
hash(&self.backend.to_be_bytes())
}

fn __str__(&self) -> PyResult<String> {
Ok(format!("{}", self.backend))
}
}

#[pyclass(module = "umbral")]
#[derive(Clone, PartialEq, derive_more::AsRef, derive_more::From, derive_more::Into)]
pub struct Capsule {
Expand Down Expand Up @@ -652,15 +699,16 @@ impl ReencryptionEvidence {
verifying_pk: &PublicKey,
delegating_pk: &PublicKey,
receiving_pk: &PublicKey,
) -> Self {
) -> PyResult<Self> {
umbral_pre::ReencryptionEvidence::new(
&capsule.backend.clone(),
&vcfrag.backend.clone(),
&verifying_pk.backend.clone(),
&delegating_pk.backend.clone(),
&receiving_pk.backend.clone(),
)
.into()
.map(Self::from)
.map_err(map_py_value_err)
}

#[staticmethod]
Expand Down
Loading

0 comments on commit 4ce7d09

Please sign in to comment.