Skip to content

Commit

Permalink
Update Rust backend build settings and function
Browse files Browse the repository at this point in the history
Updated the Rust backend build process and removed superfluous code. The Github Actions workflow will now strip the release binary to reduce its size. The build settings for the Rust backend have been optimized in Cargo.toml and updated the version. In addition, unused code for hashing the shared point's x-coordinate in the main.rs file has been removed.
  • Loading branch information
arkavo-com committed Jul 10, 2024
1 parent 82e8ca5 commit 4faec81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
source $HOME/.cargo/env
rustup target add ${{ matrix.target }}
cargo build --release --target ${{ matrix.target }}
strip target/${{ matrix.target }}/release/backend-rust
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[package]
name = "backend-rust"
version = "0.5.0"
version = "0.6.0"
edition = "2021"

[profile.release]
target-cpu = "native"
opt-level = 3
lto = true
codegen-units = 1
# cargo flamegraph
#[profile.release]
#debug = true

[dependencies]
Expand Down
10 changes: 1 addition & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use p256::{elliptic_curve::sec1::ToEncodedPoint, PublicKey, SecretKey};
use p256::ecdh::EphemeralSecret;
use rand_core::{OsRng, RngCore};
use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use sha2::Sha256;
use tokio::net::TcpListener;
use tokio_native_tls::TlsAcceptor;
use tokio_tungstenite::accept_async;
Expand Down Expand Up @@ -478,16 +478,8 @@ fn custom_ecdh(
// Extract the x-coordinate as the shared secret
let x_coordinate = shared_point.x();
let shared_secret = x_coordinate.to_vec();

// println!("Raw shared secret: {}", hex::encode(&shared_secret));

// Hash the x-coordinate using SHA-256
let mut hasher = Sha256::new();
hasher.update(x_coordinate);
// let hashed_secret = hasher.finalize().to_vec();

// println!("Hashed shared secret: {}", hex::encode(&hashed_secret));

Ok(shared_secret)
}

Expand Down

0 comments on commit 4faec81

Please sign in to comment.