mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-23 05:56:02 +01:00
feat: sig all (#862)
* feat: swap sig all * feat: melt sig all * feat: swap and melt sig flag verify for mint * feat: msg to sign tests
This commit is contained in:
5
.goosehints
Normal file
5
.goosehints
Normal file
@@ -0,0 +1,5 @@
|
||||
This is a rust project with crates in crate dir.
|
||||
|
||||
tips:
|
||||
- can look at unstaged changes for what is being worked on if starting
|
||||
- Do not make code comments that explain *what* is happening. Only explain *why* something is being done.
|
||||
@@ -61,6 +61,11 @@ impl SwapRequest {
|
||||
&self.inputs
|
||||
}
|
||||
|
||||
/// Get mutable inputs (proofs)
|
||||
pub fn inputs_mut(&mut self) -> &mut Proofs {
|
||||
&mut self.inputs
|
||||
}
|
||||
|
||||
/// Get outputs (blinded messages)
|
||||
pub fn outputs(&self) -> &Vec<BlindedMessage> {
|
||||
&self.outputs
|
||||
|
||||
@@ -115,6 +115,11 @@ impl<Q> MeltRequest<Q> {
|
||||
&self.inputs
|
||||
}
|
||||
|
||||
/// Get mutable inputs (proofs)
|
||||
pub fn inputs_mut(&mut self) -> &mut Proofs {
|
||||
&mut self.inputs
|
||||
}
|
||||
|
||||
/// Get outputs (blinded messages for change)
|
||||
pub fn outputs(&self) -> &Option<Vec<BlindedMessage>> {
|
||||
&self.outputs
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -498,7 +498,9 @@ impl Mint {
|
||||
|
||||
let EnforceSigFlag { sig_flag, .. } = enforce_sig_flag(melt_request.inputs().clone());
|
||||
|
||||
ensure_cdk!(sig_flag.ne(&SigFlag::SigAll), Error::SigAllUsedInMelt);
|
||||
if sig_flag == SigFlag::SigAll {
|
||||
melt_request.verify_sig_all()?;
|
||||
}
|
||||
|
||||
if let Some(outputs) = &melt_request.outputs() {
|
||||
if !outputs.is_empty() {
|
||||
|
||||
@@ -59,20 +59,10 @@ impl Mint {
|
||||
}
|
||||
|
||||
async fn validate_sig_flag(&self, swap_request: &SwapRequest) -> Result<(), Error> {
|
||||
let EnforceSigFlag {
|
||||
sig_flag,
|
||||
pubkeys,
|
||||
sigs_required,
|
||||
} = enforce_sig_flag(swap_request.inputs().clone());
|
||||
let EnforceSigFlag { sig_flag, .. } = enforce_sig_flag(swap_request.inputs().clone());
|
||||
|
||||
if sig_flag.eq(&SigFlag::SigAll) {
|
||||
let pubkeys = pubkeys.into_iter().collect();
|
||||
for blinded_message in swap_request.outputs() {
|
||||
if let Err(err) = blinded_message.verify_p2pk(&pubkeys, sigs_required) {
|
||||
tracing::info!("Could not verify p2pk in swap request");
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
if sig_flag == SigFlag::SigAll {
|
||||
swap_request.verify_sig_all()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user