Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of Falcon DSA into VM #1068

Closed
wants to merge 18 commits into from
Closed

Conversation

Al-Kindi-0
Copy link
Collaborator

Describe your changes

Addresses #1048

Checklist before requesting a review

  • Repo forked and branch created from next according to naming convention.
  • Commit messages and codestyle follow conventions.
  • Relevant issues are linked in the PR description.
  • Tests added for new functionality.
  • Documentation/comments updated according to changes.

@bobbinth bobbinth changed the base branch from next to al-falcon September 8, 2023 09:52
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

This looks great! - almost exactly how I was thinking about it as well. Thank you!

This is not a full review - but wanted to leave a few high-level comments about the structure.

processor/src/advice/mod.rs Outdated Show resolved Hide resolved
assembly/src/ast/nodes/advice.rs Outdated Show resolved Hide resolved
assembly/src/ast/parsers/adv_ops.rs Outdated Show resolved Hide resolved
processor/src/advice/providers.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you! I reviewed pretty much everything except for the MASM code. I left some comments inline - most of them are very minor.

processor/src/advice/mod.rs Outdated Show resolved Hide resolved
processor/src/advice/mod.rs Outdated Show resolved Hide resolved
processor/src/advice/providers.rs Show resolved Hide resolved
processor/src/advice/mod.rs Outdated Show resolved Hide resolved
processor/src/advice/mod.rs Outdated Show resolved Hide resolved
@@ -77,6 +79,16 @@ pub fn parse_adv_inject(op: &Token) -> Result<Node, ParsingError> {
}
_ => return Err(ParsingError::extra_param(op)),
},
"push_sign" => match op.num_parts() {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit: could we change "push_sign" to "push_sig"?

Comment on lines 160 to 162
PUSH_SIGN => Ok(AdviceInjectorNode::PushSignature {
kind: SignatureKind::RpoFalcon512,
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be good to write the actual serialization and deserialization code for SignatureKind. The pattern we can use could be something similar to what I used for serializing/deserializing DebugOptions here.

I know we have just a single signature scheme for now, but it would make it more "future-compatible".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Where should this be placed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd put it into assembly/src/ast/nodes/serde/signatures.rs or something like that.

Comment on lines +16 to +24
/// Inputs:
/// Operand stack: [PK, MSG, ...]
/// Advice stack: [...]
/// Advice map: {PK: [pk_raw, sk_raw]}
///
/// Outputs:
/// Operand stack: [PK, MSG, ...]
/// Advice stack: [NONCE1, NONCE0, h, s2, pi]
/// Advice map: {PK: [pk_raw, sk_raw]}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be removed from here, and we may want to update some of the description above to reflect that this just generates a signature (and does not interact with the rest of the VM in any way).

Comment on lines +43 to +45
if pk_sk.len() != (PK_LEN + SK_LEN) {
return Err(ExecutionError::AdviceStackReadFailed(0));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should create a specialized error variant for this. Maybe something like InvalidKeyPair?

/// Where:
/// - PK is the digest of an expanded public.
/// - MSG is the digest of the message to be signed.
/// - DATA is the needed data for signature verification in the VM.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably define DATA in a bit more detail (I believe there are several components to it).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But they are very specific to Falcon signature. For other DSA they could be group elements etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah - makes sense! Let's leave it as is.

@Al-Kindi-0
Copy link
Collaborator Author

I have included all the above remarks. I am just not sure about the serialization of SignatureKind so let me know if it should be modified.

@Al-Kindi-0 Al-Kindi-0 force-pushed the al-falcon branch 2 times, most recently from a465a17 to b54c7a1 Compare October 4, 2023 20:10
Base automatically changed from al-falcon to next October 5, 2023 08:35
@bobbinth
Copy link
Contributor

bobbinth commented Oct 5, 2023

Superseded by #1094.

@bobbinth bobbinth closed this Oct 5, 2023
@bobbinth bobbinth deleted the al-decorator-falcon branch October 11, 2023 22:30
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