mirror of
https://github.com/danog/toncontest.git
synced 2024-12-02 09:27:47 +01:00
Bugfix
This commit is contained in:
parent
c7a6366724
commit
ba530ff3d2
@ -4,3 +4,36 @@ Upgradable multisignature wallet.
|
|||||||
Included signature verification scripts to avoid problems with eventual preloaded orders with invalid signatures.
|
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
|
} : load-pubkey
|
||||||
|
|
||||||
' constant : const
|
' constant : const
|
||||||
|
' 2constant : 2const
|
||||||
|
|
||||||
// D n -- uint
|
// D n -- uint
|
||||||
{
|
{
|
||||||
@ -113,7 +114,7 @@ variable-set sig-count sig-count!
|
|||||||
dup 4 dictlen sig-count!
|
dup 4 dictlen sig-count!
|
||||||
|
|
||||||
."Signed by the following keys: "
|
."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
|
."Hash: " dup s>c hashu dup x. cr
|
||||||
message-hash!
|
message-hash!
|
||||||
@ -129,51 +130,52 @@ variable-set sig-count sig-count!
|
|||||||
."Seqno: " . cr
|
."Seqno: " . cr
|
||||||
|
|
||||||
1 u@+ swap
|
1 u@+ swap
|
||||||
{ ."Is code message!" cr ref@ <s quit } if
|
{ ."Is code message!" cr }
|
||||||
|
{
|
||||||
|
8 u@+ swap
|
||||||
|
."Mode: " . cr
|
||||||
|
|
||||||
8 u@+ swap
|
// Now on to the actual message we're agreeing to sign
|
||||||
."Mode: " . cr
|
//
|
||||||
|
// int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||||
// Now on to the actual message we're agreeing to sign
|
// src:MsgAddressInt dest:MsgAddressInt
|
||||||
//
|
// value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
||||||
// int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||||
// src:MsgAddressInt dest:MsgAddressInt
|
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
||||||
// value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
// import_fee:Grams = CommonMsgInfo;
|
||||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
// ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt
|
||||||
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||||
// import_fee:Grams = CommonMsgInfo;
|
."=>" cr ref@ <s
|
||||||
// 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
|
|
||||||
|
|
||||||
1 u@+ swap
|
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
|
1 u@+ swap
|
||||||
// ."Bounced flag set? " . cr
|
."Bounce flag set? " . cr
|
||||||
drop
|
|
||||||
|
|
||||||
2 u@+ nip // Drop src address constructor + flags
|
1 u@+ swap
|
||||||
|
// ."Bounced flag set? " . cr
|
||||||
|
drop
|
||||||
|
|
||||||
3 u@+ swap // Read dst address constructor + flags
|
2 u@+ nip // Drop src address constructor + flags
|
||||||
// addr_std$10 anycast 0 => 100 => 4
|
|
||||||
4 <> abort"Unsupported address!" // Make things simple for now
|
|
||||||
|
|
||||||
8 i@+
|
3 u@+ swap // Read dst address constructor + flags
|
||||||
256 u@+ -rot
|
// addr_std$10 anycast 0 => 100 => 4
|
||||||
."Destination address: " .addr cr
|
4 <> abort"Unsupported address!" // Make things simple for now
|
||||||
|
|
||||||
Gram@+ swap
|
8 i@+
|
||||||
."Grams: " .GR cr
|
256 u@+ -rot
|
||||||
|
."Destination address: " .addr cr
|
||||||
|
|
||||||
|
Gram@+ swap
|
||||||
|
."Grams: " .GR cr
|
||||||
|
} cond
|
||||||
} cond
|
} cond
|
||||||
drop
|
drop
|
||||||
} : inspect
|
} : inspect
|
@ -18,7 +18,7 @@ $# $() +".boc" const output-file
|
|||||||
input-files explode 1- swap
|
input-files explode 1- swap
|
||||||
load-boc inspect cr
|
load-boc inspect cr
|
||||||
message-hash const previous-hash
|
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;
|
// multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X;
|
||||||
message-contents
|
message-contents
|
||||||
|
@ -30,9 +30,9 @@ dup ."signing message: " <s csr. cr
|
|||||||
dup hash wallet_pk ed25519_sign_uint
|
dup hash wallet_pk ed25519_sign_uint
|
||||||
|
|
||||||
256 B>u@+ swap 256 B>u@ swap
|
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
|
// Now we have (message) value dict
|
||||||
|
|
||||||
// udict! => value key dict bits
|
// udict! => value key dict bits
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"TonUtil.fif" include
|
"TonUtil.fif" include
|
||||||
|
"lib.fif" include
|
||||||
|
|
||||||
' constant : const
|
|
||||||
{ file>B B>boc } : load-boc
|
{ file>B B>boc } : load-boc
|
||||||
{
|
{
|
||||||
."usage: " @' $0 type ." <message> <init-message> <func>" cr
|
."usage: " @' $0 type ." <message> <init-message> <func>" cr
|
||||||
@ -52,20 +52,7 @@ init-boc <s
|
|||||||
|
|
||||||
drop
|
drop
|
||||||
|
|
||||||
message-boc <s
|
message-boc inspect
|
||||||
// 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
|
|
||||||
|
|
||||||
// c7
|
// c7
|
||||||
// [ magic:0x076ef1ea actions:Integer msgs_sent:Integer
|
// [ 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
|
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);
|
throw_unless(36, ok);
|
||||||
|
|
||||||
var slice_copy = signature;
|
var slice_copy = signature;
|
||||||
|
|
||||||
throw_unless(37, check_signature(hash, slice_copy, public_key.preload_uint(256)));
|
throw_unless(37, check_signature(hash, slice_copy, public_key.preload_uint(256)));
|
||||||
|
|
||||||
if (~ storedMessageSignatures.udict_has?(4, idx)) {
|
if (~ storedMessageSignatures.udict_has?(4, idx)) {
|
||||||
|
@ -118,9 +118,10 @@ PROGRAM{
|
|||||||
NULLSWAPIFNOT
|
NULLSWAPIFNOT
|
||||||
DUP
|
DUP
|
||||||
36 THROWIFNOT
|
36 THROWIFNOT
|
||||||
s3 s(-1) s0 PUXC2
|
SWAP
|
||||||
256 PLDU
|
256 PLDU
|
||||||
s10 s2 s2 PUXC2
|
s9 s3 s(-2) PU2XC
|
||||||
|
DUMPSTK
|
||||||
CHKSIGNU
|
CHKSIGNU
|
||||||
37 THROWIFNOT
|
37 THROWIFNOT
|
||||||
s1 s9 PUSH2
|
s1 s9 PUSH2
|
||||||
|
@ -42,9 +42,10 @@ cr
|
|||||||
// Extract keys
|
// Extract keys
|
||||||
keys explode
|
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
|
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)
|
3 roll // Get n-th value v (val dict ncount curcount)
|
||||||
<b swap 256 u, // Create builder bval
|
<b swap 256 u, // Create builder bval
|
||||||
swap // Get x (dict ncount curcount bval)
|
swap // Get x (dict ncount curcount bval)
|
||||||
|
Loading…
Reference in New Issue
Block a user