PrdConnect takes a secret hash as payload and previous proof

This commit is contained in:
Sosthene 2024-10-29 12:59:53 +01:00
parent c3a7a3570b
commit b858c68ae0

View File

@ -67,17 +67,19 @@ pub struct Prd {
}
impl Prd {
/// We answer with all our addresses to ack we received a transaction and got the shared_secret
/// pairing_commitment can be null but in that case we can't be fully trusted
/// We expect another prd connect in return so that we can trust the shared secret
pub fn new_connect(sender: Member, pairing_commitment: OutPoint) -> Self {
/// We answer to ack we received a transaction and got the shared_secret
/// If validation_tokens is empty we put the proof into it and return it
/// If validation_tokens contains a valid proof signed by ourselves of empty prd,
/// we confirm the secret if necessary and don't return anything
pub fn new_connect(sender: Member, secret_hash: AnkMessageHash, previous_proof: Option<Proof>) -> Self {
let validation_tokens = if let Some(proof) = previous_proof { vec![proof] } else { vec![] };
Self {
prd_type: PrdType::Connect,
root_commitment: String::default(),
sender: serde_json::to_string(&sender).unwrap(),
validation_tokens: vec![],
validation_tokens,
keys: Map::new(),
payload: pairing_commitment.to_string(),
payload: secret_hash.to_string(),
proof: None,
}
}