-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from 0xPolygonMiden/dominik_test_falcon_authe…
…ntication feat: adding Falcon auth
- Loading branch information
Showing
5 changed files
with
298 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,50 @@ | ||
use.miden::sat::account | ||
use.miden::sat::tx | ||
use.std::crypto::dsa::rpo_falcon512 | ||
|
||
#! Authenticate a transaction using Falcon | ||
#! WIP - FALCON VERIFICATION IS MISSING, NOT SURE IF HASHING IN CORRECT ORDER | ||
# CONSTANTS | ||
# ================================================================================================= | ||
|
||
# Slot in account storage at which the public key is stored. | ||
const.PUBLIC_KEY_SLOT=0 | ||
|
||
#! Authenticate a transaction using the Falcon signature scheme | ||
#! Stack: [] | ||
#! Output: [] | ||
#! | ||
#! - ASSET is the non-fungible asset of interest. | ||
#! - tag is the tag to be included in the note. | ||
#! - RECIPIENT is the recipient of the note. | ||
export.auth_tx_rpo_falcon512 | ||
# update the nonce | ||
push.1 | ||
exec.account::incr_nonce | ||
|
||
# get commitments to consumed and created notes, new nonce, and ID | ||
#exec.tx::get_output_notes_hash | ||
#exec.tx::get_input_notes_hash | ||
#exec.account::get_nonce push.0.0.0 | ||
#exec.account::get_id push.0.0.0 | ||
|
||
# compute the message to be signed | ||
# M = h(output_notes_hash, h(input_notes_hash, h(0, 0, 0, id, 0, 0, 0, nonce))) | ||
#hmerge hmerge hmerge | ||
|
||
# get public key from account storage (assuming it is stored at index 0) and verify signature | ||
#push.0 | ||
#exec.account::get_item | ||
# [PUB_KEY, M] | ||
# TODO: sign the message using FALCON | ||
# Get commitments to created notes | ||
exec.tx::get_output_notes_hash | ||
# => [OUTPUT_NOTES_HASH, ...] | ||
|
||
# Get commitments to consumed notes | ||
exec.tx::get_input_notes_hash | ||
# => [INPUT_NOTES_HASH, OUTPUT_NOTES_HASH, ...] | ||
|
||
# Get current nonce of the account and pad | ||
exec.account::get_nonce push.0.0.0 | ||
# => [0, 0, 0, nonce, INPUT_NOTES_HASH, OUTPUT_NOTES_HASH, ...] | ||
|
||
# Get current AccountID and pad | ||
exec.account::get_id push.0.0.0 | ||
# => [0, 0, 0, account_id, 0, 0, 0, nonce, INPUT_NOTES_HASH, OUTPUT_NOTES_HASH, ...] | ||
|
||
# Compute the message to be signed | ||
# M = h(OUTPUT_NOTES_HASH, h(INPUT_NOTES_HASH, h(0, 0, 0, account_id, 0, 0, 0, nonce))) | ||
hmerge hmerge hmerge | ||
|
||
# Get public key from account storage at pos 0 and verify signature | ||
push.PUBLIC_KEY_SLOT exec.account::get_item | ||
# => [PUB_KEY, M] | ||
|
||
# Verify the signature against the public key and the message. The procedure gets as | ||
# inputs the hash of the public key and the hash of the message via the operand | ||
# stack. The signature is provided via the advice stack.The signature is valid if and | ||
# only if the procedure returns. | ||
exec.rpo_falcon512::verify | ||
# => [] | ||
|
||
# Update the nonce | ||
push.1 exec.account::incr_nonce | ||
# => [] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.