Replace CipherMessage with Prd and put data in Pcd
This commit is contained in:
parent
d61b210dda
commit
41743ab3e7
@ -109,18 +109,36 @@ impl NewTxMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Tsify)]
|
#[derive(Debug, Serialize, Deserialize, Clone, Tsify)]
|
||||||
#[tsify(into_wasm_abi, from_wasm_abi)]
|
#[tsify(into_wasm_abi, from_wasm_abi)]
|
||||||
pub struct CipherMessage {
|
pub struct Prd {
|
||||||
pub sender: String,
|
pub sender: String,
|
||||||
|
pub keys: Vec<String>,
|
||||||
|
pub pcd_commitment: String, // hash of the pcd
|
||||||
|
pub error: Option<AnkError>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Prd {
|
||||||
|
pub fn new(sender: String, keys: Vec<String>, pcd_commitment: String) -> Self {
|
||||||
|
Self {
|
||||||
|
sender,
|
||||||
|
keys,
|
||||||
|
pcd_commitment,
|
||||||
|
error: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone, Tsify)]
|
||||||
|
#[tsify(into_wasm_abi, from_wasm_abi)]
|
||||||
|
pub struct Pcd {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub error: Option<AnkError>,
|
pub error: Option<AnkError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CipherMessage {
|
impl Pcd {
|
||||||
pub fn new(sender: String, message: String) -> Self {
|
pub fn new(message: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
sender,
|
|
||||||
message,
|
message,
|
||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
@ -199,6 +217,11 @@ pub struct CachedMessage {
|
|||||||
pub recipient: Option<String>, // Never None when message sent
|
pub recipient: Option<String>, // Never None when message sent
|
||||||
pub shared_secret: Option<String>, // Never None when message sent
|
pub shared_secret: Option<String>, // Never None when message sent
|
||||||
pub key: Option<String>, // Never None when message sent
|
pub key: Option<String>, // Never None when message sent
|
||||||
|
pub prd_cipher: Option<String>, // When we receive message we can't decrypt we only have this and commited_in_tx
|
||||||
|
pub prd: Option<Prd>, // Never None when message sent
|
||||||
|
pub pcd_cipher: Option<String>,
|
||||||
|
pub pcd: Option<Pcd>, // Never None when message sent
|
||||||
|
pub pcd_commitment: Option<String>,
|
||||||
pub confirmed_by: Option<OutPoint>, // If this None, Sender keeps sending
|
pub confirmed_by: Option<OutPoint>, // If this None, Sender keeps sending
|
||||||
pub timestamp: u64,
|
pub timestamp: u64,
|
||||||
pub error: Option<AnkError>,
|
pub error: Option<AnkError>,
|
||||||
@ -237,7 +260,7 @@ impl CachedMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_decrypt_with_shared_secret(&self, shared_secret: [u8; 32]) -> Result<Vec<u8>> {
|
pub fn try_decrypt_with_shared_secret(&self, shared_secret: [u8; 32]) -> Result<Vec<u8>> {
|
||||||
if self.ciphertext.is_none() || self.shared_secret.is_some() {
|
if self.prd_cipher.is_none() || self.shared_secret.is_some() {
|
||||||
return Err(Error::msg(
|
return Err(Error::msg(
|
||||||
"Can't try decrypt this message, ciphertext is none or shared_secret already found",
|
"Can't try decrypt this message, ciphertext is none or shared_secret already found",
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user