Proof keeps the compressed PublicKey, not x only
This commit is contained in:
parent
a84d1d0508
commit
c191d53769
@ -158,7 +158,7 @@ impl Prd {
|
|||||||
// check that the proof is consistent
|
// check that the proof is consistent
|
||||||
if let Some(proof) = prd.proof {
|
if let Some(proof) = prd.proof {
|
||||||
let proof_key = proof.get_key();
|
let proof_key = proof.get_key();
|
||||||
let local_spend_key: XOnlyPublicKey = local_address.get_spend_key().x_only_public_key().0;
|
let local_spend_key = local_address.get_spend_key();
|
||||||
// If it's our own device key we abort
|
// If it's our own device key we abort
|
||||||
if proof_key == local_spend_key {
|
if proof_key == local_spend_key {
|
||||||
return Err(anyhow::Error::msg("Proof signed by ourselves, we are parsing our own message"));
|
return Err(anyhow::Error::msg("Proof signed by ourselves, we are parsing our own message"));
|
||||||
@ -166,13 +166,11 @@ impl Prd {
|
|||||||
// take the spending keys in sender
|
// take the spending keys in sender
|
||||||
let sender: Member = serde_json::from_str(&prd.sender)?;
|
let sender: Member = serde_json::from_str(&prd.sender)?;
|
||||||
let addresses = sender.get_addresses();
|
let addresses = sender.get_addresses();
|
||||||
let mut spend_keys: Vec<XOnlyPublicKey> = vec![];
|
let mut spend_keys: Vec<PublicKey> = vec![];
|
||||||
for address in addresses {
|
for address in addresses {
|
||||||
spend_keys.push(
|
spend_keys.push(
|
||||||
<SilentPaymentAddress>::try_from(address)?
|
<SilentPaymentAddress>::try_from(address)?
|
||||||
.get_spend_key()
|
.get_spend_key()
|
||||||
.x_only_public_key()
|
|
||||||
.0,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// The key in proof must be one of the sender keys
|
// The key in proof must be one of the sender keys
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use sp_client::bitcoin::hashes::{sha256t_hash_newtype, Hash, HashEngine};
|
use sp_client::bitcoin::hashes::{sha256t_hash_newtype, Hash, HashEngine};
|
||||||
use sp_client::bitcoin::key::Secp256k1;
|
use sp_client::bitcoin::key::Secp256k1;
|
||||||
use sp_client::bitcoin::secp256k1::schnorr::Signature;
|
use sp_client::bitcoin::secp256k1::schnorr::Signature;
|
||||||
use sp_client::bitcoin::secp256k1::{Keypair, Message, SecretKey, XOnlyPublicKey};
|
use sp_client::bitcoin::secp256k1::{Keypair, Message, PublicKey, SecretKey};
|
||||||
|
|
||||||
use crate::pcd::AnkPcdHash;
|
use crate::pcd::AnkPcdHash;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ impl AnkHash {
|
|||||||
pub struct Proof {
|
pub struct Proof {
|
||||||
signature: Signature,
|
signature: Signature,
|
||||||
message: AnkHash,
|
message: AnkHash,
|
||||||
key: XOnlyPublicKey,
|
key: PublicKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Proof {
|
impl Proof {
|
||||||
@ -92,11 +92,11 @@ impl Proof {
|
|||||||
Self {
|
Self {
|
||||||
signature: sig,
|
signature: sig,
|
||||||
message: message_hash,
|
message: message_hash,
|
||||||
key: keypair.x_only_public_key().0,
|
key: keypair.public_key(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key(&self) -> XOnlyPublicKey {
|
pub fn get_key(&self) -> PublicKey {
|
||||||
self.key
|
self.key
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ impl Proof {
|
|||||||
secp.verify_schnorr(
|
secp.verify_schnorr(
|
||||||
&self.signature,
|
&self.signature,
|
||||||
&Message::from_digest(self.message.to_byte_array()),
|
&Message::from_digest(self.message.to_byte_array()),
|
||||||
&self.key,
|
&self.key.x_only_public_key().0,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user