mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
bugfixed + crypto update
- compiles vs BoringSSL - config proposal/vote fift code - bugfixes in catchain - other small fixes
This commit is contained in:
parent
606e970ed5
commit
a31f8d4424
39 changed files with 722 additions and 132 deletions
51
crypto/smartcont/config-proposal-vote-signed.fif
Normal file
51
crypto/smartcont/config-proposal-vote-signed.fif
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/fift -s
|
||||
"TonUtil.fif" include
|
||||
"GetOpt.fif" include
|
||||
|
||||
"vote-query.boc" =: savefile
|
||||
|
||||
{ ."usage: " @' $0 type ." <config-addr> <expire-at> <validator-idx> <proposal-hash> <validator-pubkey> <validator-signature> [<savefile>]" cr
|
||||
."Creates an external message addressed to the configuration smart contract <config-addr> containing a signed request expiring at unixtime <expire-at> to vote for configuration proposal <proposal-hash> (decimal; prefix with '0x' if needed) on behalf of validator with zero-based index <validator-idx> and (Base64) public key <validator-pubkey> in current validator set (as stored in configuration parameter 34)" cr
|
||||
."<validator-signature> must be the base64 representation of Ed25519 signature of the previously generated unsigned request by means of <validator-pubkey>" cr
|
||||
."The result is saved into <savefile> (" savefile type ." by default), to be sent later by the lite-client" cr 1 halt
|
||||
} : usage
|
||||
|
||||
$# dup 6 < swap 7 > or ' usage if
|
||||
7 :$1..n
|
||||
|
||||
$1 true parse-load-address drop over 1+ abort"configuration smart contract must be in masterchain"
|
||||
2=: config-addr
|
||||
$2 parse-int dup 30 1<< < { now + 1000 + 2000 /c 2000 * } if
|
||||
dup =: expire-at
|
||||
dup now <= abort"expiration time must be in the future"
|
||||
32 ufits not abort"invalid expiration time"
|
||||
$3 parse-int dup =: val-idx
|
||||
16 ufits not abort"validator index out of range"
|
||||
$4 parse-int dup =: prop-hash
|
||||
256 ufits not abort"invalid proposal hash"
|
||||
$5 base64>B dup Blen 36 <> abort"validator Ed25519 public key must be exactly 36 bytes long"
|
||||
32 B>u@+ 0xC6B41348 <> abort"invalid Ed25519 public key: unknown magic number"
|
||||
=: pubkey
|
||||
$6 base64>B dup Blen 64 <> abort"validator Ed25519 signature must be exactly 64 bytes long"
|
||||
=: signature
|
||||
$7 savefile replace-if-null =: savefile
|
||||
0 =: seqno
|
||||
|
||||
."Creating an external message to configuration smart contract "
|
||||
config-addr 2dup 6 .Addr ." = " .addr cr
|
||||
."containing a signed request expiring at " expire-at .
|
||||
."to vote for configuration proposal 0x" prop-hash 64x.
|
||||
."on behalf of validator with index " val-idx . "and public key" pubkey 64x. cr
|
||||
|
||||
B{566f7465} seqno 32 u>B B+ expire-at 32 u>B B+ val-idx 16 u>B B+ prop-hash 256 u>B B+
|
||||
dup =: to_sign
|
||||
."String to sign is " Bx. cr
|
||||
|
||||
to_sign signature pubkey ed25519_chksign not abort"Ed25519 signature is invalid"
|
||||
."Provided a valid Ed25519 signature " signature Bx. ." with validator public key " pubkey Bx. cr
|
||||
|
||||
<b b{1000100} s, config-addr addr, 0 Gram, b{00} s,
|
||||
signature B, to_sign B, b>
|
||||
cr ."External message is " dup <s csr. cr
|
||||
|
||||
2 boc+>B savefile tuck B>file ."Saved to file " type cr
|
Loading…
Add table
Add a link
Reference in a new issue