You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/v3/guidelines/smart-contracts/security/random-number-generation.md
+18-22Lines changed: 18 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -12,75 +12,73 @@ These algorithms typically require a _seed_ value to produce a sequence of _pseu
12
12
13
13
To predict the result of the `random()` function in a smart contract, one would need to know the current `seed` of the block, which is impossible unless you are a validator.
14
14
15
-
# Approaches and security considerations
16
-
17
-
There are multiple methods for generating random values, each with distinct trade-offs between speed, security, and decentralization guarantees.
15
+
There are multiple approaches to generate random values, each offering different trade-offs between speed, security, and decentralization guarantees.
18
16
19
17
Below we outline three fundamental approaches:
20
18
21
19
---
22
20
23
-
## Approach 1: randomize_lt
21
+
## Approach 1: randomize_lt {#randomize_lt}
24
22
25
-
**Mechanism**: Generates randomness using block logical time (`lt`) and blockchain entropy.
26
-
**Security Model**:
23
+
**Mechanism**: Generates [randomness using block logical time](https://docs.ton.org/v3/guidelines/smart-contracts/security/ton-hack-challenge-1/#4-lottery) (`lt`) and blockchain entropy.
24
+
**Security model**:
27
25
28
26
- ✅ Safe against user manipulation
29
27
- ❌ Vulnerable to colluding validators (could theoretically predict/influence values)
30
28
31
29
**Speed**: Fast (single-block operation)
32
-
**Use Cases**:
30
+
**Use cases**:
33
31
34
32
- Non-critical applications, for example gaming & NFTs
35
33
- Scenarios where validator trust is assumed
36
34
37
35
---
38
36
39
-
## Approach 2: Block skipping
37
+
## Approach 2: Block skipping {#block-skip}
40
38
41
-
**Mechanism**: Uses entropy from skipped blocks in blockchain history.
42
-
**Security Model**:
39
+
**Mechanism**: Uses [entropy from skipped blocks](https://github.com/puppycats/ton-random?tab=readme-ov-file#ton-random) in blockchain history.
40
+
**Security model**:
43
41
44
42
- ✅ Resistant to user manipulation
45
43
- ⚠️ Not fully secure against determined validators (may influence block inclusion timing)
46
44
47
45
**Speed**: Slow (requires multiple blocks to finalize)
48
-
**Use Cases**:
46
+
**Use cases**:
49
47
50
48
- Medium-stakes applications, for example lottery systems
0 commit comments