diff --git a/wallet/README.md b/wallet/README.md index a2ad161..8f26763 100644 --- a/wallet/README.md +++ b/wallet/README.md @@ -3,4 +3,37 @@ Upgradable multisignature wallet. Included signature verification scripts to avoid problems with eventual preloaded orders with invalid signatures. -Code can be upgraded via a special multisignature message. \ No newline at end of file +Code can be upgraded via a special multisignature message. + +``` + 633 fift -s ../wallet-create.fif 0 pony 10 10 {a..k} + 634 chr() { [ "$1" -lt 256 ] || return 1; printf "\\$(printf '%03o' "$1")"; } + 635 ord() { LC_CTYPE=C printf '%d' "'$1"; } + 636 ord a + 637 for f in {0..9}; do fift -s ../gen-pub.fif ;done + 638 for f in {a..k}; do fift -s ../gen-pub.fif ;done + 639 for f in {a..k}; do fift -s ../gen-pub.fif $f;done + 640 fift -s ../wallet-create.fif 0 pony 10 10 {a..k} + 641 ls + 642 fift -s ../create.fif + 643 for f in {0..9}; do fift -s ../create.fif $(chr $((97+f))) $f kQB_1uJkjQ06tWkLoX6WJjqmpgMctmSX8Z7jVbAWhaENe_qJ 10 $(chr $((97+f)));done + 644 for f in {0..9}; do fift -s ../create.fif pony $(chr $((97+f))) $f kQB_1uJkjQ06tWkLoX6WJjqmpgMctmSX8Z7jVbAWhaENe_qJ 10 $(chr $((97+f)));done + 645 for f in {0..9}; do fift -s ../create.fif pony $(chr $((97+f))) $f kQB_1uJkjQ06tWkLoX6WJjqmpgMctmSX8Z7jVbAWhaENe_qJ 0 10 $(chr $((97+f)));done + 646 fift -s ../merge.fif + 647 fift -s ../merge.fif {a..k} merge + 648 fift -s ../merge.fif {a..j} merge + 649 fift -s ../inspect.fif merge + 650 fift -s ../inspect.fif merge + 651 fift -s ../merge.fif {a..j} merge + 652 fift -s ../merge.fif {a..j} merge + 653 fift -s ../merge.fif {a..j} merge + 654 fift -s ../merge.fif {a..j} merge + 655 fift -s ../merge.fif {a..j} merge + 656 fift -s ../merge.fif {a..j} merge + 657 fift -s ../merge.fif {a..j} merge + 658 fift -s ../merge.fif {a..j} merge + 659 for f in {1..9}; do fift -s ../sign.fif a $(chr $((97+f))) $(chr $((97+f))) $f;done + 660 fift -s ../merge.fif {a..j} merge + 661 fift -s ../inspect.fif j + 662 fift -s ../inspect.fif merge +``` \ No newline at end of file diff --git a/wallet/lib.fif b/wallet/lib.fif index 541c0bf..723ccc2 100644 --- a/wallet/lib.fif +++ b/wallet/lib.fif @@ -17,6 +17,7 @@ } : load-pubkey ' constant : const +' 2constant : 2const // D n -- uint { @@ -113,7 +114,7 @@ variable-set sig-count sig-count! dup 4 dictlen sig-count! ."Signed by the following keys: " - 4 { drop . ."- " -1 } dictforeach cr drop + 4 { 64 B@ Bx. . ."- " -1 } dictforeach cr drop ."Hash: " dup s>c hashu dup x. cr message-hash! @@ -129,51 +130,52 @@ variable-set sig-count sig-count! ."Seqno: " . cr 1 u@+ swap - { ."Is code message!" cr ref@ " cr ref@ " cr ref@ 100 => 4 - 4 <> abort"Unsupported address!" // Make things simple for now + 2 u@+ nip // Drop src address constructor + flags - 8 i@+ - 256 u@+ -rot - ."Destination address: " .addr cr + 3 u@+ swap // Read dst address constructor + flags + // addr_std$10 anycast 0 => 100 => 4 + 4 <> abort"Unsupported address!" // Make things simple for now - Gram@+ swap - ."Grams: " .GR cr + 8 i@+ + 256 u@+ -rot + ."Destination address: " .addr cr + + Gram@+ swap + ."Grams: " .GR cr + } cond } cond drop } : inspect \ No newline at end of file diff --git a/wallet/merge.fif b/wallet/merge.fif index 54248c5..c746610 100644 --- a/wallet/merge.fif +++ b/wallet/merge.fif @@ -18,7 +18,7 @@ $# $() +".boc" const output-file input-files explode 1- swap load-boc inspect cr message-hash const previous-hash -wallet-addr const previous-address +wallet-addr 2const previous-address // multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X; message-contents diff --git a/wallet/sign.fif b/wallet/sign.fif index 4d0f1fb..d71a392 100644 --- a/wallet/sign.fif +++ b/wallet/sign.fif @@ -30,9 +30,9 @@ dup ."signing message: " u@+ swap 256 B>u@ swap - value key dict bits diff --git a/wallet/test.fif b/wallet/test.fif index d0a8997..8798a2b 100644 --- a/wallet/test.fif +++ b/wallet/test.fif @@ -1,6 +1,6 @@ "TonUtil.fif" include +"lib.fif" include -' constant : const { file>B B>boc } : load-boc { ."usage: " @' $0 type ." " cr @@ -52,20 +52,7 @@ init-boc { ."There seems to be an invalid header" cr } if // 1000100 => 68 - - 8 i@+ - 256 u@+ -rot - ."Message wallet address: " .addr cr - - Gram@+ nip // Ignore grams - - 1 u@+ swap - abort"This seems to be an init message" - -constant message +message-boc inspect // c7 // [ magic:0x076ef1ea actions:Integer msgs_sent:Integer @@ -76,4 +63,7 @@ constant message 0x076ef1ea 0 0 now 0 0 hash 7 tuple 1 tuple constant ctx -message function code storage ctx runvmctx .s \ No newline at end of file +message-contents function code storage ctx runvmctx .s +// rot +// ."Signature: " +// 64 B@ Bx. \ No newline at end of file diff --git a/wallet/wallet-code.fc b/wallet/wallet-code.fc index 2bb09fd..ed707ef 100644 --- a/wallet/wallet-code.fc +++ b/wallet/wallet-code.fc @@ -100,7 +100,6 @@ int udict_has?(cell dict, int key_len, int index) asm(index dict key_len) "DICTU throw_unless(36, ok); var slice_copy = signature; - throw_unless(37, check_signature(hash, slice_copy, public_key.preload_uint(256))); if (~ storedMessageSignatures.udict_has?(4, idx)) { diff --git a/wallet/wallet-code.fif b/wallet/wallet-code.fif index 116e6e8..0f92f05 100644 --- a/wallet/wallet-code.fif +++ b/wallet/wallet-code.fif @@ -118,9 +118,10 @@ PROGRAM{ NULLSWAPIFNOT DUP 36 THROWIFNOT - s3 s(-1) s0 PUXC2 + SWAP 256 PLDU - s10 s2 s2 PUXC2 + s9 s3 s(-2) PU2XC + DUMPSTK CHKSIGNU 37 THROWIFNOT s1 s9 PUSH2 diff --git a/wallet/wallet-create.fif b/wallet/wallet-create.fif index 836d8b5..57a22bb 100644 --- a/wallet/wallet-create.fif +++ b/wallet/wallet-create.fif @@ -42,9 +42,10 @@ cr // Extract keys keys explode -dictnew 0 // Create counter and dict +dup 1- // Create counter +dictnew swap // ...and dict (swap the two) rot // Put length on top for times -{ dup 1+ swap // Increment counter +{ dup 1- swap // Decrement counter 3 roll // Get n-th value v (val dict ncount curcount)