Bumps lightning to 0.0.99 and bitcoin to 0.27

lightning 0.0.99 requires bitcoin 0.27 and includes some fixes regarding message_signing (functions borrow keys instead of taking ownership of them).
This commit is contained in:
Sergi Delgado Segura 2021-08-04 11:55:36 +02:00
parent 5b4a8c1124
commit 19ee4daf5c
No known key found for this signature in database
GPG key ID: 633B3A2298D70DD8
6 changed files with 26 additions and 26 deletions

View file

@ -14,5 +14,5 @@ hex = "0.4.3"
chacha20poly1305 = "0.8.0"
bitcoin = "0.26"
lightning = "0.0.98"
bitcoin = "0.27"
lightning = "0.0.99"

View file

@ -15,14 +15,14 @@ pub enum DecryptingError {
}
/// Shadows message_signing::sign.
pub fn sign(msg: &[u8], sk: SecretKey) -> Result<String, Error> {
pub fn sign(msg: &[u8], sk: &SecretKey) -> Result<String, Error> {
message_signing::sign(msg, sk)
}
/// Shadows message_signing::verify.
pub fn verify(msg: &[u8], sig: &str, pk: PublicKey) -> bool {
pub fn verify(msg: &[u8], sig: &str, pk: &PublicKey) -> bool {
match message_signing::recover_pk(msg, sig) {
Ok(x) => x == pk,
Ok(x) => x == *pk,
Err(_) => false,
}
}

View file

@ -45,7 +45,7 @@ impl RegistrationReceipt {
ser
}
pub fn sign(&mut self, sk: SecretKey) {
pub fn sign(&mut self, sk: &SecretKey) {
// TODO: Check if there's any case where this can actually fail. Don't unwrap if so.
self.signature = Some(cryptography::sign(&self.serialize(), sk).unwrap());
}
@ -86,7 +86,7 @@ impl AppointmentReceipt {
ser
}
pub fn sign(&mut self, sk: SecretKey) {
pub fn sign(&mut self, sk: &SecretKey) {
// TODO: Check if there's any case where this can actually fail. Don't unwrap if so.
self.signature = Some(cryptography::sign(&self.serialize(), sk).unwrap());
}

View file

@ -18,9 +18,9 @@ serde = "1.0.126"
serde_json = "1.0"
tokio = { version = "1.5", features = [ "io-util", "macros", "rt", "rt-multi-thread", "sync", "net", "time" ] }
bitcoin = "0.26"
lightning-block-sync = {version = "0.0.98", git = "https://github.com/rust-bitcoin/rust-lightning", branch = "main", features = [ "rpc-client" ] }
lightning-net-tokio = { version = "0.0.98", git = "https://github.com/rust-bitcoin/rust-lightning", branch = "main" }
lightning = { version = "0.0.98", git = "https://github.com/rust-bitcoin/rust-lightning", branch = "main" }
bitcoin = "0.27"
lightning-block-sync = {version = "0.0.99", git = "https://github.com/rust-bitcoin/rust-lightning", branch = "main", features = [ "rpc-client" ] }
lightning-net-tokio = { version = "0.0.99", git = "https://github.com/rust-bitcoin/rust-lightning", branch = "main" }
lightning = { version = "0.0.99", git = "https://github.com/rust-bitcoin/rust-lightning", branch = "main" }
teos-common = {path = "../teos-common"}

View file

@ -308,7 +308,7 @@ mod tests {
// Let's now provide data generated by an actual user, still the user is unknown
let user_sk = ONE_KEY;
let signature = cryptography::sign(message, user_sk).unwrap();
let signature = cryptography::sign(message, &user_sk).unwrap();
assert_eq!(
gatekeeper.authenticate_user(message, &signature),
Err(AuthenticationFailure("User not found."))

View file

@ -199,7 +199,7 @@ impl<'a> Watcher<'a> {
pub fn register(&mut self, user_id: &UserId) -> Result<RegistrationReceipt, MaxSlotsReached> {
let mut receipt = self.gatekeeper.add_update_user(user_id)?;
receipt.sign(self.signing_key);
receipt.sign(&self.signing_key);
Ok(receipt)
}
@ -285,7 +285,7 @@ impl<'a> Watcher<'a> {
extended_appointment.user_signature.clone(),
extended_appointment.start_block.clone(),
);
receipt.sign(self.signing_key);
receipt.sign(&self.signing_key);
Ok((receipt, available_slots, expiry))
}
@ -576,7 +576,7 @@ mod tests {
assert!(cryptography::verify(
&receipt.serialize(),
&receipt.signature().unwrap(),
user_pk
&user_pk
));
}
@ -608,7 +608,7 @@ mod tests {
// Add the appointment for a new user (twice so we can check that updates work)
for _ in 0..1 {
let user_sig = cryptography::sign(&appointment.serialize(), user_sk).unwrap();
let user_sig = cryptography::sign(&appointment.serialize(), &user_sk).unwrap();
let (receipt, slots, expiry) = watcher
.add_appointment(appointment.clone(), user_sig.clone())
.unwrap();
@ -628,7 +628,7 @@ mod tests {
let user2_id = UserId(PublicKey::from_secret_key(&Secp256k1::new(), &user2_sk));
watcher.register(&user2_id).unwrap();
let user2_sig = cryptography::sign(&appointment.serialize(), user2_sk).unwrap();
let user2_sig = cryptography::sign(&appointment.serialize(), &user2_sk).unwrap();
let (receipt, slots, expiry) = watcher
.add_appointment(appointment.clone(), user2_sig.clone())
.unwrap();
@ -654,7 +654,7 @@ mod tests {
// TODO: Since we have no Responder yet, test that the data is not kept in the Watcher
let dispute_tx = tip_txs.last().unwrap();
let appointment_in_cache = generate_dummy_appointment(Some(&dispute_tx.txid())).inner;
let user_sig = cryptography::sign(&appointment_in_cache.serialize(), user_sk).unwrap();
let user_sig = cryptography::sign(&appointment_in_cache.serialize(), &user_sk).unwrap();
let (receipt, slots, expiry) = watcher
.add_appointment(appointment_in_cache.clone(), user_sig.clone())
.unwrap();
@ -696,7 +696,7 @@ mod tests {
let dispute_txid = Txid::from_slice(&[2; 32]).unwrap();
let new_appointment = generate_dummy_appointment(Some(&dispute_txid)).inner;
let new_app_sig = cryptography::sign(&new_appointment.serialize(), user_sk).unwrap();
let new_app_sig = cryptography::sign(&new_appointment.serialize(), &user_sk).unwrap();
assert!(matches!(
watcher.add_appointment(new_appointment, new_app_sig),
@ -740,12 +740,12 @@ mod tests {
watcher
.add_appointment(
appointment.clone(),
cryptography::sign(&appointment.serialize(), user_sk).unwrap(),
cryptography::sign(&appointment.serialize(), &user_sk).unwrap(),
)
.unwrap();
let message = format!("get appointment {}", appointment.locator.clone());
let signature = cryptography::sign(message.as_bytes(), user_sk).unwrap();
let signature = cryptography::sign(message.as_bytes(), &user_sk).unwrap();
let r_app = watcher
.get_appointment(appointment.locator.clone(), signature.clone())
.unwrap();
@ -757,7 +757,7 @@ mod tests {
let user2_id = UserId(PublicKey::from_secret_key(&Secp256k1::new(), &user2_sk));
watcher.register(&user2_id).unwrap();
let signature2 = cryptography::sign(message.as_bytes(), user2_sk).unwrap();
let signature2 = cryptography::sign(message.as_bytes(), &user2_sk).unwrap();
assert!(matches!(
watcher.get_appointment(appointment.locator.clone(), signature2),
Err(GetAppointmentFailure::NotFound { .. })
@ -914,11 +914,11 @@ mod tests {
let uuid1 = UUID::new(&appointment.inner.locator, &user_id);
let uuid2 = UUID::new(&appointment.inner.locator, &user2_id);
let user_sig = cryptography::sign(&appointment.inner.serialize(), ONE_KEY).unwrap();
let user_sig = cryptography::sign(&appointment.inner.serialize(), &ONE_KEY).unwrap();
watcher
.add_appointment(appointment.inner.clone(), user_sig)
.unwrap();
let user2_sig = cryptography::sign(&appointment.inner.serialize(), all_two_sk).unwrap();
let user2_sig = cryptography::sign(&appointment.inner.serialize(), &all_two_sk).unwrap();
watcher
.add_appointment(appointment.inner.clone(), user2_sig)
.unwrap();
@ -957,7 +957,7 @@ mod tests {
// Check triggers. Add a new appointment and trigger it with valid data.
let dispute_tx = get_random_tx();
let appointment = generate_dummy_appointment(Some(&dispute_tx.txid()));
let sig = cryptography::sign(&appointment.inner.serialize(), all_two_sk).unwrap();
let sig = cryptography::sign(&appointment.inner.serialize(), &all_two_sk).unwrap();
let uuid = UUID::new(&appointment.inner.locator, &user2_id);
watcher
.add_appointment(appointment.inner.clone(), sig)
@ -982,7 +982,7 @@ mod tests {
let mut appointment = generate_dummy_appointment(Some(&dispute_tx.txid()));
// Modify the encrypted blob so the data is invalid both non-decryptable blobs and blobs with invalid transactions will yield an invalid trigger
appointment.inner.encrypted_blob = vec![1; 64];
let sig = cryptography::sign(&appointment.inner.serialize(), all_two_sk).unwrap();
let sig = cryptography::sign(&appointment.inner.serialize(), &all_two_sk).unwrap();
let uuid = UUID::new(&appointment.inner.locator, &user2_id);
watcher
.add_appointment(appointment.inner.clone(), sig)