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

Falcon Post Quantum Digital Signature Verification, in Miden Assembly #369

Merged
merged 12 commits into from Oct 12, 2022

Conversation

itzmeanjan
Copy link
Contributor

This PR implements Falcon-512 PQ DSA, in Miden Assembly, with following assumptions

  • Signature decompression is done outside of VM. Degree-512 polynomial obtained after signature decompression, is provided as input to program, using absolute memory addresses ( 128 of them ) on stack. Let's call it f.

Note, f is provided as input such that each coefficient ∈ [0, Q) | Q = 2 ** 64 - 2 ** 32 + 1 ( Miden VM Prime Number )

  • Public key is provided as degree-512 polynomial, calling it g
  • Input message is hashed using SHAKE256 XOF and converted into degree-512 polynomial ( both done outside of VM ), call it h
  • Finally, another degree-512 polynomial k is supplied as input to program, which is actually decompressed signature, just that each coefficient is represented as absolute value ( sign bit is ignored )

If signature verification fails, program execution should stop, due to assertion failure, which checks whether norm of signature is small enough or not.


Note, this PR needs to be reviewed after PR #349 , #368 ( in order appearing ) are reviewed & merged


Cost of signature verification at 7357b77, 335399 cycles

itzmeanjan added 3 commits Aug 16, 2022
…ion of Falcon signature

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
This implementation has some assumptions about input state ( more concretely
how input is provided to verification routine ), which can be understood by go through
comments accompanying the implementation assembly.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
itzmeanjan added 2 commits Aug 30, 2022
…degree 512

This optimization gain is achieved by using `loadw.mem` instead of `pushw.mem` instruction.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
…oopifying repetitive instructions

This increases cost of signature verification by 1762 VM cycles

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@itzmeanjan
Copy link
Contributor Author

Cost of signature verification at 7357b77, 335399 cycles

At commit bbd1268, cost of Falcon signature verification increases to 337,161 cycles.

itzmeanjan added 3 commits Aug 31, 2022
Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
…ory address ) when normalizing a degree-512 polynomial

Some unnecessary stack push operations are skipped.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
…ng to pointer based interface

Pointer based interface denotes traversing memory using pointer arithmetic ( i.e. applying `INCR`
instruction on previous memory address to compute next absolute memory address ).

Cost of signature verification: 347,649 cycles

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@itzmeanjan
Copy link
Contributor Author

At commit 23aad20, cost of Falcon512 signature verification: 347,649 cycles.

@itzmeanjan
Copy link
Contributor Author

At commit 23aad20, cost of Falcon512 signature verification: 347,649 cycles.

This PR has all the latest changes from both #349 & #368.

itzmeanjan added 2 commits Sep 11, 2022
Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
…w API, avoiding some memcpy(s)

Cost of signature verification is 337,402 cycles.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@itzmeanjan
Copy link
Contributor Author

At commit 562425b, cost of signature verification is 337,402 cycles.

…cal memory indexing order

This commit is due to rebasing from `next`.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@itzmeanjan
Copy link
Contributor Author

itzmeanjan commented Oct 12, 2022

Commit 17882bb includes latest from next [ READY FOR REVIEW ]

# Expected stack state :
#
# [f_addr0, f_addr1, ..., f_addr126, f_addr127, g_addr0, g_addr1, ..., g_addr126, g_addr127,
# h_addr0, h_addr1, ..., h_addr126, h_addr127, k_addr0, k_addr1, ..., k_addr126, k_addr127, ...] | 512 absolute memory addresses
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still accurate? I thought we are providing just starting addresses via the stack (e.g., f_start_addr) rather than consecutive addresses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out @bobbinth , I've corrected this in 12cfe44.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
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.

All looks good! Thank you!

@bobbinth bobbinth merged commit ee5d24f into 0xPolygonMiden:next Oct 12, 2022
7 checks passed
@itzmeanjan itzmeanjan deleted the falcon branch Oct 13, 2022
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.

None yet

2 participants