Trustless bridge with contract issue

I was working on the recent TON context and encountered a roadblock. I synchronized the key blocks every 4 hours, but to confirm a block, I need to validate its signatures. I compiled the node IDs of the validators using their public keys and a predefined prefix, retrieved their weights, and attempted to validate the signatures to calculate the total weight to compare it with 2/3 total weight of all validators. However, I was surprised to discover that the verify_signature function in FunC only supports 256-bit hashes, whereas the message I need to validate is 544 bits.

4 Likes

The problem is that I am not that quite understand your question tbh, but maybe you can check this: ton/crypto/smartcont/stdlib.fc at 2a68c8610bf28b43b2019a479a70d0606c2a0aa1 · ton-blockchain/ton · GitHub


I tried to decode your idea here with ChatGPT but:

To solve this problem, I need to clarify a few things:

  1. What is the exact structure of the 544-bit message that needs to be validated?

    • Is it a single block of data, or does it contain multiple parts that can be hashed separately?
  2. What is the expected signature verification process in the TON blockchain for such messages?

    • Are there alternative methods in TON that handle signatures for messages longer than 256 bits?
  3. Would hashing the 544-bit message down to 256 bits before verification be acceptable?

    • For example, using SHA-256 or another hashing method to generate a 256-bit digest and then verifying the signature against that.
  4. Are there existing implementations or best practices in the TON ecosystem for verifying messages longer than 256 bits?

    • If so, should I focus on finding an existing approach or designing a new workaround?

Let me know these details, and I can provide a precise solution.