Commit c75feffb authored by Éloïs's avatar Éloïs
Browse files

[feat] gva:bca: add req ProofServerPubkey

parent 949b2a3f
......@@ -16,6 +16,8 @@
mod members_count;
mod prepare_simple_payment;
use dubp::crypto::keys::KeyPair;
use crate::*;
#[derive(Debug, PartialEq)]
......@@ -40,6 +42,14 @@ pub(super) async fn execute_req_type(
BcaReqTypeV0::PrepareSimplePayment(params) => {
prepare_simple_payment::exec_req_prepare_simple_payment(bca_executor, params).await
}
BcaReqTypeV0::ProofServerPubkey { challenge } => Ok(BcaRespTypeV0::ProofServerPubkey {
challenge,
server_pubkey: bca_executor.self_keypair.public_key(),
sig: bca_executor
.self_keypair
.generate_signator()
.sign(&challenge),
}),
BcaReqTypeV0::Ping => Ok(BcaRespTypeV0::Pong),
}
}
......@@ -32,7 +32,7 @@ use crate::exec_req_type::ExecReqTypeError;
use crate::utils::AsyncReader;
use async_bincode::AsyncBincodeReader;
use bincode::Options as _;
use dubp::crypto::keys::ed25519::Ed25519KeyPair;
use dubp::crypto::keys::{ed25519::Ed25519KeyPair, Signator};
use duniter_bca_types::{BcaReq, BcaReqTypeV0, BcaResp, BcaRespTypeV0, BcaRespV0, ReqExecError};
use duniter_dbs::{FileBackend, SharedDbs};
use futures::{prelude::stream::FuturesUnordered, StreamExt, TryStream, TryStreamExt};
......
......@@ -26,7 +26,7 @@ pub mod prepare_payment;
use crate::prepare_payment::{PrepareSimplePayment, PrepareSimplePaymentResp};
use dubp::crypto::hashs::Hash;
use dubp::crypto::keys::ed25519::PublicKey;
use dubp::crypto::keys::ed25519::{PublicKey, Signature};
use dubp::wallet::prelude::*;
use serde::{Deserialize, Serialize};
//use smallvec::SmallVec;
......@@ -47,6 +47,7 @@ pub struct BcaReqV0 {
pub enum BcaReqTypeV0 {
MembersCount,
PrepareSimplePayment(PrepareSimplePayment),
ProofServerPubkey { challenge: [u8; 16] },
Ping,
}
......@@ -65,6 +66,11 @@ pub struct BcaRespV0 {
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub enum BcaRespTypeV0 {
Error(String),
ProofServerPubkey {
challenge: [u8; 16],
server_pubkey: PublicKey,
sig: Signature,
},
MembersCount(u64),
PrepareSimplePayment(PrepareSimplePaymentResp),
Pong,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment