Skip to content

Nested witness signature path injection#45

Open
topologoanatom wants to merge 1 commit intoBlockstreamResearch:devfrom
topologoanatom:nested-sig-path
Open

Nested witness signature path injection#45
topologoanatom wants to merge 1 commit intoBlockstreamResearch:devfrom
topologoanatom:nested-sig-path

Conversation

@topologoanatom
Copy link
Copy Markdown

Changes

Added functionality to inject signature value from RequiredSignature into nested match blocks.

@topologoanatom topologoanatom marked this pull request as ready for review April 8, 2026 08:29
@topologoanatom topologoanatom requested a review from Arvolear as a code owner April 8, 2026 08:29
}
}

enum EitherDirection {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move all this code to a new "WitnessParser" module.

Ok(res)
}

fn wrap_signature_along_path(ty: &ResolvedType, sig: Value, path: &[EitherDirection]) -> Result<Value, SignerError> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this work with arbitrary values? Let's generalize the naming a bit.

Comment on lines +66 to +68
let witness = NestedSigWitness {
inherit_or_not: simplex::either::Either::Left(DUMMY_SIGNATURE),
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to implement a "Default" trait for these autogenerated objects?

Comment on lines +552 to +558
for dir in path.split_ascii_whitespace() {
match dir {
"Left" | "L" | "0" => res.push(EitherDirection::Left),
"Right" | "R" | "1" => res.push(EitherDirection::Right),
_ => return Err(SignerError::WtnsSigParse),
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't cover the case when the signature is inside a tuple.

inherit_or_not: simplex::either::Either::Right(simplex::either::Either::Right(DUMMY_SIGNATURE)),
};

let spend_tx = spend_nested_sig(&context, witness, Some("Right Right".to_string()))?;
Copy link
Copy Markdown
Collaborator

@Arvolear Arvolear Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the path be more readable if it were an array "[Right, Right]"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants