219: Rename variables to add to understanding the code r=da-kami a=da-kami



221: Fix/improve comment explaining TxRefund encsigning r=thomaseizinger a=rishflab



Co-authored-by: Daniel Karzel <daniel@comit.network>
Co-authored-by: rishflab <rishflab@hotmail.com>
pull/226/head
bors[bot] 3 years ago committed by GitHub
commit fb2057453a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,23 +66,23 @@ impl From<serde_json::Error> for Error {
impl RateService {
pub async fn new() -> Result<Self> {
let (tx, rx) = watch::channel(Err(Error::NotYetRetrieved));
let (rate_update, rate_update_receiver) = watch::channel(Err(Error::NotYetRetrieved));
let (ws, _response) =
let (rate_stream, _response) =
tokio_tungstenite::connect_async(Url::parse(KRAKEN_WS_URL).expect("valid url")).await?;
let (mut write, mut read) = ws.split();
let (mut rate_stream_sink, mut rate_stream) = rate_stream.split();
tokio::spawn(async move {
while let Some(msg) = read.next().await {
while let Some(msg) = rate_stream.next().await {
let msg = match msg {
Ok(Message::Text(msg)) => msg,
Ok(_) => {
let _ = tx.send(Err(Error::NonTextMessage));
let _ = rate_update.send(Err(Error::NonTextMessage));
continue;
}
Err(e) => {
let _ = tx.send(Err(e.into()));
let _ = rate_update.send(Err(e.into()));
continue;
}
};
@ -95,7 +95,7 @@ impl RateService {
let ticker = match serde_json::from_str::<TickerUpdate>(&msg) {
Ok(ticker) => ticker,
Err(e) => {
let _ = tx.send(Err(e.into()));
let _ = rate_update.send(Err(e.into()));
continue;
}
};
@ -103,18 +103,22 @@ impl RateService {
let rate = match Rate::try_from(ticker) {
Ok(rate) => rate,
Err(e) => {
let _ = tx.send(Err(e));
let _ = rate_update.send(Err(e));
continue;
}
};
let _ = tx.send(Ok(rate));
let _ = rate_update.send(Ok(rate));
}
});
write.send(SUBSCRIBE_XMR_BTC_TICKER_PAYLOAD.into()).await?;
rate_stream_sink
.send(SUBSCRIBE_XMR_BTC_TICKER_PAYLOAD.into())
.await?;
Ok(Self { receiver: rx })
Ok(Self {
receiver: rate_update_receiver,
})
}
}

@ -89,12 +89,11 @@ impl SecretKey {
// joint output for TxLock_Monero
// tx_refund: multisig(A, B), published by bob
// bob can produce sig on B for tx_refund using b
// alice sends over an encrypted signature on A for tx_refund using a encrypted
// with S_b we want to leak s_b
// produced (by Alice) encsig - published (by Bob) sig = s_b (it's not really
// subtraction, it's recover)
// bob can produce sig on B using b
// alice sends over an encrypted signature on A encrypted with S_b
// s_b is leaked to alice when bob publishes signed tx_refund allowing her to
// recover s_b: recover(encsig, S_b, sig_tx_refund) = s_b
// alice now has s_a and s_b and can refund monero
// self = a, Y = S_b, digest = tx_refund
pub fn encsign(&self, Y: PublicKey, digest: SigHash) -> EncryptedSignature {

Loading…
Cancel
Save