mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Remove .is_some() unwraps for if let Some
This commit is contained in:
@@ -60,6 +60,9 @@ impl Curve for Ed25519 {
|
|||||||
dfg::EdwardsPoint(DPoint::vartime_multiscalar_mul(scalars, points))
|
dfg::EdwardsPoint(DPoint::vartime_multiscalar_mul(scalars, points))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This, as used by CLSAG, will already be a keccak256 hash
|
||||||
|
// The only necessity is for this to be unique, which means skipping a hash here should be fine accordingly
|
||||||
|
// TODO: Decide
|
||||||
fn hash_msg(msg: &[u8]) -> Vec<u8> {
|
fn hash_msg(msg: &[u8]) -> Vec<u8> {
|
||||||
Blake2b512::digest(msg).to_vec()
|
Blake2b512::digest(msg).to_vec()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ pub struct SpendableOutput {
|
|||||||
|
|
||||||
pub fn scan(tx: &Transaction, view: Scalar, spend: EdwardsPoint) -> Vec<SpendableOutput> {
|
pub fn scan(tx: &Transaction, view: Scalar, spend: EdwardsPoint) -> Vec<SpendableOutput> {
|
||||||
let mut pubkeys = vec![];
|
let mut pubkeys = vec![];
|
||||||
if tx.tx_pubkey().is_some() {
|
if let Some(key) = tx.tx_pubkey() {
|
||||||
pubkeys.push(tx.tx_pubkey().unwrap());
|
pubkeys.push(key);
|
||||||
}
|
}
|
||||||
if tx.tx_additional_pubkeys().is_some() {
|
if let Some(keys) = tx.tx_additional_pubkeys() {
|
||||||
pubkeys.extend(&tx.tx_additional_pubkeys().unwrap());
|
pubkeys.extend(&keys);
|
||||||
}
|
}
|
||||||
let pubkeys: Vec<EdwardsPoint> = pubkeys.iter().map(|key| key.point.decompress()).filter_map(|key| key).collect();
|
let pubkeys: Vec<EdwardsPoint> = pubkeys.iter().map(|key| key.point.decompress()).filter_map(|key| key).collect();
|
||||||
|
|
||||||
|
|||||||
@@ -268,12 +268,8 @@ impl<C: Curve> MultisigKeys<C> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let secret_share = self.secret_share * lagrange::<C::F>(self.params.i, &included);
|
let secret_share = self.secret_share * lagrange::<C::F>(self.params.i, &included);
|
||||||
let (offset, offset_share) = if self.offset.is_some() {
|
let offset = self.offset.unwrap_or(C::F::zero());
|
||||||
let offset = self.offset.unwrap();
|
let offset_share = offset * C::F::from(included.len().try_into().unwrap()).invert().unwrap();
|
||||||
(offset, offset * C::F::from(included.len().try_into().unwrap()).invert().unwrap())
|
|
||||||
} else {
|
|
||||||
(C::F::zero(), C::F::zero())
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(MultisigView {
|
Ok(MultisigView {
|
||||||
group_key: self.group_key + (C::generator_table() * offset),
|
group_key: self.group_key + (C::generator_table() * offset),
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ fn sign_with_share<C: Curve, A: Algorithm<C>>(
|
|||||||
{
|
{
|
||||||
let transcript = params.algorithm.transcript();
|
let transcript = params.algorithm.transcript();
|
||||||
transcript.domain_separate(b"FROST");
|
transcript.domain_separate(b"FROST");
|
||||||
if params.keys.offset.is_some() {
|
if let Some(offset) = params.keys.offset {
|
||||||
transcript.append_message(b"offset", &C::F_to_bytes(¶ms.keys.offset.unwrap()));
|
transcript.append_message(b"offset", &C::F_to_bytes(&offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,8 +301,8 @@ fn complete<C: Curve, A: Algorithm<C>>(
|
|||||||
// For the success route, which should be much more frequent, this should be faster
|
// For the success route, which should be much more frequent, this should be faster
|
||||||
// It also acts as an integrity check of this library's signing function
|
// It also acts as an integrity check of this library's signing function
|
||||||
let res = sign_params.algorithm.verify(sign_params.view.group_key, sign.R, sum);
|
let res = sign_params.algorithm.verify(sign_params.view.group_key, sign.R, sum);
|
||||||
if res.is_some() {
|
if let Some(res) = res {
|
||||||
return Ok(res.unwrap());
|
return Ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out who misbehaved
|
// Find out who misbehaved
|
||||||
|
|||||||
Reference in New Issue
Block a user