Skip to content

Commit

Permalink
Merge pull request #421 from helium/madninja/simple_sign_verify
Browse files Browse the repository at this point in the history
Simplifies sign and verify
  • Loading branch information
madninja committed Apr 12, 2023
2 parents ec44eeb + 3fc7960 commit a9c0361
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 140 deletions.
113 changes: 62 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions src/beaconer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

use crate::{
gateway::{self, BeaconResp},
impl_msg_sign, region_watcher,
region_watcher,
service::{entropy::EntropyService, poc::PocIotService},
settings::Settings,
sync, Base64, Keypair, MsgSign, PacketUp, RegionParams, Result,
sign, sync, Base64, Keypair, PacketUp, RegionParams, Result,
};
use futures::TryFutureExt;
use helium_proto::{services::poc_lora, Message as ProtoMessage};
Expand All @@ -22,9 +22,6 @@ use xxhash_rust::xxh64::xxh64;
/// will only change when this process or task restarts.
const BEACON_INTERVAL_JITTER_PERCENTAGE: u64 = 10;

impl_msg_sign!(poc_lora::LoraBeaconReportReqV1, signature);
impl_msg_sign!(poc_lora::LoraWitnessReportReqV1, signature);

/// Message types that can be sent to `Beaconer`'s inbox.
#[derive(Debug)]
pub enum Message {
Expand Down Expand Up @@ -189,7 +186,7 @@ impl Beaconer {
report.tx_power = conducted_power;
report.tmst = tmst;
report.pub_key = self.keypair.public_key().to_vec();
report.signature = report.sign(self.keypair.clone()).await?;
report.signature = sign(self.keypair.clone(), report.encode_to_vec()).await?;
Ok(report)
}

Expand All @@ -199,7 +196,7 @@ impl Beaconer {
) -> Result<poc_lora::LoraWitnessReportReqV1> {
let mut report = poc_lora::LoraWitnessReportReqV1::try_from(packet)?;
report.pub_key = self.keypair.public_key().to_vec();
report.signature = report.sign(self.keypair.clone()).await?;
report.signature = sign(self.keypair.clone(), report.encode_to_vec()).await?;
Ok(report)
}

Expand Down
Loading

0 comments on commit a9c0361

Please sign in to comment.