mirror of
https://github.com/danog/toncontest.git
synced 2024-11-29 20:19:11 +01:00
Bugfix
This commit is contained in:
parent
c7a6366724
commit
ba530ff3d2
@ -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.
|
||||
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
|
||||
```
|
@ -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@ <s quit } if
|
||||
{ ."Is code message!" cr }
|
||||
{
|
||||
8 u@+ swap
|
||||
."Mode: " . cr
|
||||
|
||||
8 u@+ swap
|
||||
."Mode: " . cr
|
||||
|
||||
// Now on to the actual message we're agreeing to sign
|
||||
//
|
||||
// int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
// src:MsgAddressInt dest:MsgAddressInt
|
||||
// value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
||||
// import_fee:Grams = CommonMsgInfo;
|
||||
// ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
."=>" cr ref@ <s
|
||||
|
||||
1 u@+ swap
|
||||
{ // External message *$1*
|
||||
."Inside: external message" cr
|
||||
}
|
||||
{ // Internal message int_msg_info$0
|
||||
."Inside: internal message" cr
|
||||
1 u@+ swap
|
||||
."Instant hypercube routing disabled? " . cr
|
||||
// Now on to the actual message we're agreeing to sign
|
||||
//
|
||||
// int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
// src:MsgAddressInt dest:MsgAddressInt
|
||||
// value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
||||
// import_fee:Grams = CommonMsgInfo;
|
||||
// ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
."=>" cr ref@ <s
|
||||
|
||||
1 u@+ swap
|
||||
."Bounce flag set? " . cr
|
||||
{ // External message *$1*
|
||||
."Inside: external message" cr
|
||||
}
|
||||
{ // Internal message int_msg_info$0
|
||||
."Inside: internal message" cr
|
||||
1 u@+ swap
|
||||
."Instant hypercube routing disabled? " . cr
|
||||
|
||||
1 u@+ swap
|
||||
// ."Bounced flag set? " . cr
|
||||
drop
|
||||
1 u@+ swap
|
||||
."Bounce flag set? " . cr
|
||||
|
||||
2 u@+ nip // Drop src address constructor + flags
|
||||
1 u@+ swap
|
||||
// ."Bounced flag set? " . cr
|
||||
drop
|
||||
|
||||
3 u@+ swap // Read dst address constructor + flags
|
||||
// addr_std$10 anycast 0 => 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
|
@ -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
|
||||
|
@ -30,9 +30,9 @@ dup ."signing message: " <s csr. cr
|
||||
dup hash wallet_pk ed25519_sign_uint
|
||||
|
||||
256 B>u@+ swap 256 B>u@ swap
|
||||
<b swap 256 u, swap 256 u, b> <s
|
||||
<b swap B,
|
||||
|
||||
.s rot
|
||||
rot
|
||||
// Now we have (message) value dict
|
||||
|
||||
// udict! => value key dict bits
|
||||
|
@ -1,6 +1,6 @@
|
||||
"TonUtil.fif" include
|
||||
"lib.fif" include
|
||||
|
||||
' constant : const
|
||||
{ file>B B>boc } : load-boc
|
||||
{
|
||||
."usage: " @' $0 type ." <message> <init-message> <func>" cr
|
||||
@ -52,20 +52,7 @@ init-boc <s
|
||||
|
||||
drop
|
||||
|
||||
message-boc <s
|
||||
// External message
|
||||
7 u@+ swap 68 <> { ."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 <b 1234 32 u, b> hash 7 tuple 1 tuple constant ctx
|
||||
|
||||
|
||||
message function code storage ctx runvmctx .s
|
||||
message-contents function code storage ctx runvmctx .s
|
||||
// rot
|
||||
// ."Signature: "
|
||||
// 64 B@ Bx.
|
@ -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)) {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
<b swap 256 u, // Create builder bval
|
||||
swap // Get x (dict ncount curcount bval)
|
||||
|
Loading…
Reference in New Issue
Block a user