Skip to content

Commit

Permalink
Merge pull request #3 from karma-coin/signature
Browse files Browse the repository at this point in the history
Verification evidence signature
  • Loading branch information
avive authored Aug 20, 2023
2 parents 26e1a35 + 89d1621 commit 879b271
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions crates/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ features = ["std", "u64_backend", "serde"]
version = "1"
features = ["serde"]

[dependencies.sp-rpc]
git = "https://github.com/karma-coin/karmachain"

[dev-dependencies]
nix = "0.26.2"
14 changes: 11 additions & 3 deletions crates/server/src/services/verifier/verify_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::Deserialize;
use sp_core::{
crypto::{AccountId32, Ss58Codec},
ed25519::{Pair, Public, Signature},
Pair as PairT,
Encode, Pair as PairT,
};
use std::collections::HashMap;
use xactor::*;
Expand Down Expand Up @@ -142,10 +142,18 @@ impl Handler<Verify> for VerifierService {
}
}

// todo: generate scale-encoded signed data to be included in signup tx
let phone_number_hash =
sp_core::hashing::blake2_512(user_data.phone_number.clone().as_bytes());
let verification_evidence = sp_rpc::verifier::VerificationEvidence {
verifier_public_key: self.key_pair.unwrap().public(),
account_id: account_id,
username: user_data.user_name,
phone_number_hash: phone_number_hash,
};
let bytes = verification_evidence.encode();

let response = VerifyNumberResponse {
data: vec![],
data: self.key_pair.unwrap().sign(&bytes).0.to_vec(),
result: VerificationResult::Verified as i32,
};

Expand Down

0 comments on commit 879b271

Please sign in to comment.