mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated fift/func
This commit is contained in:
parent
b6f6788532
commit
d41ce55305
31 changed files with 717 additions and 66 deletions
9
crypto/func/test/a10.fc
Normal file
9
crypto/func/test/a10.fc
Normal file
|
@ -0,0 +1,9 @@
|
|||
_ f(int a, int x) {
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
while ((y = x * x) > a) {
|
||||
x -= 1;
|
||||
z = 1;
|
||||
}
|
||||
return (y, z);
|
||||
}
|
20
crypto/func/test/a6_4.fc
Normal file
20
crypto/func/test/a6_4.fc
Normal file
|
@ -0,0 +1,20 @@
|
|||
var calc_root(m) {
|
||||
int base = 1;
|
||||
repeat(70) { base *= 10; }
|
||||
var (a, b, c) = (1, 0, - m);
|
||||
var (p1, q1, p2, q2) = (1, 0, 0, 1);
|
||||
do {
|
||||
int k = -1;
|
||||
var (a1, b1, c1) = (0, 0, 0);
|
||||
do {
|
||||
k += 1;
|
||||
(a1, b1, c1) = (a, b, c);
|
||||
c += b;
|
||||
c += b += a;
|
||||
} until (c > 0);
|
||||
(a, b, c) = (- c1, - b1, - a1);
|
||||
(p1, q1) = (k * p1 + q1, p1);
|
||||
(p2, q2) = (k * p2 + q2, p2);
|
||||
} until (p1 > base);
|
||||
return (p1, q1, p2, q2);
|
||||
}
|
22
crypto/func/test/w8.fc
Normal file
22
crypto/func/test/w8.fc
Normal file
|
@ -0,0 +1,22 @@
|
|||
int check_signatures(msg_hash, signatures, signers, bitmask_size) impure {
|
||||
var bitmask = 0;
|
||||
var id = -1;
|
||||
do {
|
||||
(id, var signature, var f) = signatures.udict_get_next?(32, id);
|
||||
if (f){
|
||||
var sig = signature.preload_bits(512);
|
||||
var public_key = -1;
|
||||
do {
|
||||
(public_key, var cs, var _found) = signers.udict_get_next?(256, public_key);
|
||||
if (_found){
|
||||
if (check_signature(msg_hash, sig, public_key)){
|
||||
var signer_index = cs~load_uint(bitmask_size);
|
||||
bitmask = bitmask | (1 << (signer_index - 1));
|
||||
}
|
||||
}
|
||||
} until (~ _found);
|
||||
;; signature~touch();
|
||||
}
|
||||
} until (~ f);
|
||||
return bitmask;
|
||||
}
|
8
crypto/func/test/w9.fc
Normal file
8
crypto/func/test/w9.fc
Normal file
|
@ -0,0 +1,8 @@
|
|||
_ g(s) {
|
||||
var (z, t) = (17, s);
|
||||
while (z > 0) {
|
||||
t = s;
|
||||
z -= 1;
|
||||
}
|
||||
return ~ t;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue