Skip to content

Commit

Permalink
fix: key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakowskiii committed Jul 28, 2023
1 parent 2347008 commit 0d699e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/handlers/subscribe_topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ pub async fn handler(
let mut rng: StdRng = StdRng::from_entropy();

let signing_secret = StaticSecret::from(rng.gen::<[u8; 32]>());
let signing_public = hex::encode(PublicKey::from(&signing_secret));
let signing_public = PublicKey::from(&signing_secret);
let topic = sha256::digest(signing_public.as_bytes());
let signing_public = hex::encode(signing_public);

let identity_secret = ed25519_dalek::SecretKey::generate(&mut rng);
let identity_public = hex::encode(ed25519_dalek::PublicKey::from(&identity_secret));

let public_key = hex::encode(signing_public.as_bytes());

let topic = sha256::digest(signing_public.as_bytes());
let project_data = ProjectData {
id: project_id.clone(),
signing_keypair: Keypair {
private_key: hex::encode(signing_secret.to_bytes()),
public_key: public_key.clone(),
public_key: signing_public.clone(),
},
identity_keypair: Keypair {
private_key: hex::encode(identity_secret.to_bytes()),
Expand All @@ -78,8 +77,9 @@ pub async fn handler(
};

info!(
"Saving project_info to database for project: {} with pubkey: {}, topic: {}",
project_id, public_key, topic
"Saving project_info to database for project: {} with signing pubkey: {} and identity \
pubkey: {}, topic: {}",
project_id, signing_public, identity_public, topic
);

db.collection::<ProjectData>("project_data")
Expand Down
12 changes: 6 additions & 6 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ PROJECT_ID to be set",
std::env::var("NOTIFY_PROJECT_SECRET").expect("NOTIFY_PROJECT_SECRET not set");

// Register project - generating subscribe topic
let dapp_pubkey_response: serde_json::Value = dbg!(http_client
let dapp_pubkey_response: serde_json::Value = http_client
.get(format!("{}/{}/subscribe-topic", &notify_url, &project_id))
.bearer_auth(&project_secret)
.send()
.await
.unwrap())
.json()
.await
.unwrap();
.unwrap()
.json()
.await
.unwrap();

// Get app public key
let dapp_pubkey = dapp_pubkey_response
.get("publicKey")
.get("subscribeTopicPublicKey")
.unwrap()
.as_str()
.unwrap();
Expand Down

0 comments on commit 0d699e5

Please sign in to comment.