Skip to content

Conversation

pyAndr3w
Copy link
Collaborator

Closes #49

@Gusarich
Copy link
Collaborator

/review

Copy link

Thanks for the updates to the signing techniques docs. A couple of high‑severity items need changes to meet the safety and style‑guide requirements.

Findings (2)

High (2)

[HIGH] Unsafe inline mnemonic example and non-compliant placeholder/ellipsis

Location: https://github.com/tact-lang/mintlify-ton-docs/blob/bf402aa4a1f21b6f05e81915fbd24e093ed8761a/techniques/signing.mdx?plain=1#L294-L296

Description:
The example hardcodes a mnemonic-like string and uses a literal ellipsis, which encourages unsafe handling of secrets and creates copy/paste hazards. The style guide forbids including secrets in examples, requires environment-based configuration with compliant placeholders (UPPER_SNAKE), and bans literal ellipses that alter code semantics. See https://github.com/tact-lang/mintlify-ton-docs/blob/main/contribute/style-guide-extended.mdx?plain=1#L488-L489, https://github.com/tact-lang/mintlify-ton-docs/blob/main/contribute/style-guide-extended.mdx?plain=1#L498-L499, and https://github.com/tact-lang/mintlify-ton-docs/blob/main/contribute/style-guide-extended.mdx?plain=1#L645-L649.

Suggestion:

// Read from environment; do not inline secrets
const mnemonic = (process.env.MNEMONIC ?? 'MNEMONIC_WORDS').split(' ');

[HIGH] Safety callout for mnemonics is missing required elements

Location: https://github.com/tact-lang/mintlify-ton-docs/blob/bf402aa4a1f21b6f05e81915fbd24e093ed8761a/techniques/signing.mdx?plain=1#L298-L302

Description:
The Warning callout about mnemonics omits required safety-callout fields: explicit scope (blast radius), an environment label prioritizing testnet-first, and rollback guidance if exposure occurs. Per the style guide, safety callouts must include risk, scope, mitigation/rollback, and an environment label with safer defaults first. See https://github.com/tact-lang/mintlify-ton-docs/blob/main/contribute/style-guide-extended.mdx?plain=1#L516-L527.

Suggestion:

--- a/techniques/signing.mdx
+++ b/techniques/signing.mdx
@@
-<Aside
-  type="danger"
->
-  **Protect your mnemonic:** Anyone with access to your mnemonic can control your wallet and all funds. Store it securely (password manager, hardware wallet, encrypted storage). Never commit it to version control.
-</Aside>
+<Aside type="danger" title="Keys at risk">
+  Risk: Anyone with your mnemonic can control your wallets and funds.
+
+  Scope: Affects every wallet derived from this mnemonic (testnet and mainnet).
+
+  Mitigation/rollback: Store mnemonics in an encrypted manager or hardware wallet; never paste into logs or code. If exposed, generate a new mnemonic and move funds to new addresses.
+
+  Environment (safer first): Use testnet mnemonics for development; avoid mainnet keys in examples and tests.
+</Aside>

@skywardboundd
Copy link
Collaborator

can we add link to it page in wallets: how it works?

@pyAndr3w
Copy link
Collaborator Author

can we add link to it page in wallets: how it works?

of course we can

@skywardboundd skywardboundd self-requested a review October 15, 2025 13:58
Copy link
Collaborator

@skywardboundd skywardboundd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice page, but i found some issues

This guide focuses on Ed25519, the standard for TON.
</Aside>

### What gets signed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename it?
seems like full pipeline, not what gets signed


## Message structure for signing

When designing a signed message, you choose how to organize the signed data — the message fields that will be hashed and verified. The key question: is the signed data a **slice** (part of a cell) or a **cell** (separate cell)? This affects gas consumption during signature verification.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's depends on data size too, may be here add examples?

**Trade-off:**\
This approach adds one extra cell to the message, slightly increasing the forward fee. However, the gas savings (\~500 gas) outweigh the forward fee increase.

### TVM v12 improvement
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need it? I guess before update It's not valid, and after update we can rename it like "possible improve"

npm install @ton/core @ton/crypto
```

### Step 1: Generate or load a mnemonic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create issue for open-source project, including this file? May be helpful

import { beginCell } from '@ton/core';

// Build signed data (example: wallet message)
const seqno = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add description how to get seqno, or just get it in code


1. User signs a message off-chain (includes replay protection data and transfer details)
1. User sends external message to blockchain
1. Wallet contract verifies the signature
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not about check signing, idk do we really need it here


**Gas analysis:**

After loading the signature, the remaining data is a **slice**. To verify the signature, the contract needs to hash this slice. In TVM, the method for hashing a slice is `slice_hash()`, which costs 526 gas.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Patterns > Signing]

3 participants