Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more specific about what certificate format is expected in NodeMetadataPayload #13

Merged
merged 2 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Renamed `staker_address` to `staking_provider_address` in `NodeMetadataPayload` fields and `RevocationOrder::new` parameters. ([#10])
- Renamed `NodeMetadataPayload.decentralized_identity_evidence` to `operator_signature`. ([#10])
- Declared `NodeMetadataPayload.operator_signature` as `recoverable::Signature` instead of just a byte array. This allows the user to detect an invalid signature on `NodeMetadata` creation. ([#11])
- Renamed `NodeMetadataPayload.certificate_bytes` to `certificate_der` (although it is not deserialized on the Rust side, so the DER format is not strictly enforced). ([#13])


[#10]: https://github.com/nucypher/nucypher-core/pull/10
[#11]: https://github.com/nucypher/nucypher-core/pull/11
[#13]: https://github.com/nucypher/nucypher-core/pull/13


## [0.0.4] - 2022-02-09
Expand Down
8 changes: 4 additions & 4 deletions nucypher-core-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl NodeMetadataPayload {
timestamp_epoch: u32,
verifying_key: &PublicKey,
encrypting_key: &PublicKey,
certificate_bytes: &[u8],
certificate_der: &[u8],
host: &str,
port: u16,
operator_signature: Option<[u8; RECOVERABLE_SIGNATURE_SIZE]>,
Expand All @@ -747,7 +747,7 @@ impl NodeMetadataPayload {
timestamp_epoch,
verifying_key: verifying_key.backend,
encrypting_key: encrypting_key.backend,
certificate_bytes: certificate_bytes.into(),
certificate_der: certificate_der.into(),
host: host.to_string(),
port,
operator_signature: signature,
Expand Down Expand Up @@ -803,8 +803,8 @@ impl NodeMetadataPayload {
}

#[getter]
fn certificate_bytes(&self) -> &[u8] {
self.backend.certificate_bytes.as_ref()
fn certificate_der(&self) -> &[u8] {
self.backend.certificate_der.as_ref()
}

fn derive_operator_address(&self) -> PyResult<PyObject> {
Expand Down
8 changes: 4 additions & 4 deletions nucypher-core-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ impl NodeMetadataPayload {
timestamp_epoch: u32,
verifying_key: &PublicKey,
encrypting_key: &PublicKey,
certificate_bytes: &[u8],
certificate_der: &[u8],
host: &str,
port: u16,
operator_signature: Option<Vec<u8>>,
Expand All @@ -849,7 +849,7 @@ impl NodeMetadataPayload {
timestamp_epoch,
verifying_key: *verifying_key.inner(), // TODO: Use * instead of clone everywhere
encrypting_key: *encrypting_key.inner(),
certificate_bytes: certificate_bytes.into(),
certificate_der: certificate_der.into(),
host: host.to_string(),
port,
operator_signature: signature,
Expand Down Expand Up @@ -899,8 +899,8 @@ impl NodeMetadataPayload {
}

#[wasm_bindgen(method, getter)]
pub fn certificate_bytes(&self) -> Box<[u8]> {
self.0.certificate_bytes.clone()
pub fn certificate_der(&self) -> Box<[u8]> {
self.0.certificate_der.clone()
}

#[wasm_bindgen(js_name = deriveOperatorAddress)]
Expand Down
4 changes: 2 additions & 2 deletions nucypher-core-wasm/tests/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn make_node_metadata() -> NodeMetadata {
let timestamp_epoch = 1546300800;
let verifying_key = signing_key.public_key();
let encrypting_key = SecretKey::random().public_key();
let certificate_bytes = b"certificate_bytes";
let certificate_der = b"certificate_der";
let host = "https://localhost.com";
let port = 443;
let operator_signature =
Expand All @@ -93,7 +93,7 @@ fn make_node_metadata() -> NodeMetadata {
timestamp_epoch,
&verifying_key,
&encrypting_key,
certificate_bytes,
certificate_der,
host,
port,
operator_signature,
Expand Down
4 changes: 2 additions & 2 deletions nucypher-core/src/node_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ pub struct NodeMetadataPayload {
pub verifying_key: PublicKey,
/// The node's encrypting key.
pub encrypting_key: PublicKey,
/// The node's SSL certificate (serialized in PEM format).
/// The node's SSL certificate (serialized in DER format).
#[serde(with = "serde_bytes")]
pub certificate_bytes: Box<[u8]>,
pub certificate_der: Box<[u8]>,
/// The hostname of the node's REST service.
pub host: String,
/// The port of the node's REST service.
Expand Down