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

Mochimo 3.0 Suggestion - Prevent tag on existing naked WOTS #78

Open
0rtis opened this issue Mar 25, 2021 · 1 comment
Open

Mochimo 3.0 Suggestion - Prevent tag on existing naked WOTS #78

0rtis opened this issue Mar 25, 2021 · 1 comment

Comments

@0rtis
Copy link
Contributor

0rtis commented Mar 25, 2021

Add check while creating tag to insure that the target WOTS doesnt not exist in the ledger.
The fix below was made by @chrisdigity but never made it to pull request I guess:

@@ -113,6 +113,8 @@ int tag_valid(byte *src_addr, byte *chg_addr, byte *dst_addr, int checkq, byte *
 {
    LENTRY le;
    word32 tagval_trigger[2];
+   byte dummy_chg_addr[TXADDRLEN];
+   byte default_tag[12] = {0x42, 0, 0, 0, 0xe, 0, 0, 0, 0x1, 0, 0, 0};
 
    tagval_trigger[0] = tagval_trigger[1] = 0;
    if(checkq == 0 && bnum != NULL) {
@@ -146,6 +148,14 @@ int tag_valid(byte *src_addr, byte *chg_addr, byte *dst_addr, int checkq, byte *
       plog("SRC_TAG != CHG_TAG, and SRC_TAG is Non-Default!"); 
       goto bad;
    }
+   /* If the change address already exists in ledger.dat as a WOTS+
+    * with a default tag, tx is invalid */
+   memcpy(dummy_chg_addr, dst_addr, TXADDRLEN - 12);
+   memcpy(ADDR_TAG_PTR(dummy_chg_addr), default_tag, 12);
+   if(le_find(dummy_chg_addr, &le, NULL, 0) == FALSE) {
+      plog("CHG_ADDR WOTS+ already exists in ledger!");
+      goto bad;
+   }
    /* Otherwise, check all queues and ledger.dat for change tag.
     * First, if change tag is in ledger.dat, tx is invalid.
     */
@chrisdigity
Copy link
Collaborator

Will bring up a discussion during the next meeting to determine if this will cause any issues with the current state of the ledger.

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

No branches or pull requests

2 participants