Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/fift -s
- "TonUtil.fif" include
- "Asm.fif" include
- "multisig.fift" include <s constant contract_code
- "multisig_init_storage.fift" include <s constant contract_storage_initializer // (uniq_token, min_signature_num, public_keys_dict) -> cell
- // PARAMS
- 0 =: wc
- 16 =: keys_num
- // CREATE KEYS
- {
- file>B dup Blen 32 <> abort"Private key must be exactly 32 bytes long"
- dup priv>pub swap
- } : load-keypair'
- // ( fname -- pubkey privkey )
- { dup file-exists?
- { load-keypair' }
- { dup newkeypair swap rot over swap B>file
- rot drop
- } cond
- } : load-generate-keypair'
- { load-generate-keypair' swap 256 B>u@ } : nkp
- "p01.pk" nkp =: pub01 =: priv01
- "p02.pk" nkp =: pub02 =: priv02
- "p03.pk" nkp =: pub03 =: priv03
- "p04.pk" nkp =: pub04 =: priv04
- "p05.pk" nkp =: pub05 =: priv05
- "p06.pk" nkp =: pub06 =: priv06
- "p07.pk" nkp =: pub07 =: priv07
- "p08.pk" nkp =: pub08 =: priv08
- "p09.pk" nkp =: pub09 =: priv09
- "p0a.pk" nkp =: pub0a =: priv0a
- "p0b.pk" nkp =: pub0b =: priv0b
- "p0c.pk" nkp =: pub0c =: priv0c
- "p0d.pk" nkp =: pub0d =: priv0d
- "p0e.pk" nkp =: pub0e =: priv0e
- "p0f.pk" nkp =: pub0f =: priv0f
- "p10.pk" nkp =: pub10 =: priv10
- // CREATE ORDER
- -1 constant bounce
- <b b{01} s, bounce 1 i, b{000100} s, 0 4973788529520401637175306036311921661440676526367978167240186796235618131100 addr, 0 Gram, 0 9 64 32 + + 1+ u,
- 3 10 u,
- b> constant example_message_body
- 3 constant message_mode
- <b message_mode 8 u, example_message_body ref, b> <s constant example_message_root
- // CREATE LIST OF PUBKEYS
- pub01 pub02 pub03 pub04 pub05 pub06 pub07 pub08 pub09 pub0a pub0b pub0c pub0d pub0e pub0f pub10
- dictnew
- {
- <b b> <s
- -rot
- 256
- udict!
- drop
- } 16 times
- =: keys
- 10 constant min_signature_num
- // INITIALIZE PERSISTENT STORAGE
- min_signature_num keys contract_storage_initializer runvmdict
- drop // TODO check execution code
- constant contract_storage
- <b b{00110} s, <b contract_code s, b> ref, contract_storage ref, b>
- dup =: state_init
- dup hashu wc swap 2constant multisig_addr
- multisig_addr
- 256 u>B swap
- 32 u>B
- min_signature_num 8 u>B
- keys_num 8 u>B
- B+ B+ B+ =: contract_description
- contract_description "multisig.ctr" B>file
- multisig_addr swap drop 6277101735386680763835789423207666416102355444464034512896 / =: uniq_token
- <b 0 8 u, b> <s =: init_message
- <b b{1000100} s, multisig_addr addr, b{000010} s, state_init <s s, b{0} s, init_message s, b>
- 2 boc+>B
- "multisig-init.boc" B>file
- 1 constant op_num
- 1 constant seq_no
- 0xFFFFFFFF constant unix_time_bound
- 10 =: min_signatures_num
- example_message_root
- 0 dictnew 7 udict! drop constant order_dict
- <b op_num 8 u, seq_no 32 u, unix_time_bound 32 u, min_signatures_num 8 u, uniq_token 64 u,
- dup constant message_builder
- order_dict dict, b> constant data_for_signing
- pub01 priv01
- pub02 priv02
- pub03 priv03
- pub04 priv04
- pub05 priv05
- pub06 priv06
- pub07 priv07
- pub08 priv08
- pub09 priv09
- pub0a priv0a
- data_for_signing
- dictnew
- // SIGNING
- {
- swap dup hashu 3 roll ed25519_sign_uint // keys pubk dict data_for_signing signature
- <b swap B, b> <s
- // keys pubk dict data_for_signing <signature>
- 3 -roll 3 -roll
- 256 udict! drop // keys data_for_siging dict
- } 9 times
- =: provided_signatures
- hashu swap ed25519_sign_uint =: header_signature
- message_builder swap 256 u, header_signature B, provided_signatures dict, order_dict dict, b> constant store_order_message
- <b b{1000100} s, multisig_addr addr, 0 Gram, b{00} s, store_order_message ref, b>
- 2 boc+>B
- "10signatures.boc" B>file
- ."new multisig wallet address = " multisig_addr .addr cr
- ."Non-bounceable address (for init): " multisig_addr 7 .Addr cr
- ."Bounceable address (for later access): " multisig_addr 6 .Addr cr
- ."(Saved multisig contract creating query to file multisig-init.boc)" cr
- ."(Saved order with 10 signatures to file 10signatures.boc)" cr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement