[CERES] cannot verify global AENS delegation signature #479

Closed
opened 2023-08-07 19:21:50 +09:00 by zxq9 · 0 comments
zxq9 commented 2023-08-07 19:21:50 +09:00 (Migrated from gitlab.com)

Created by: marc0olo

I am currently trying to implement a check in Sophia that verifies if the provided AENS delegation signature is valid. after some discussions with @hanssv it turns out that this is currently impossible.

I have following logic implemented right now:

    /// @notice provides delegation signature to let the contract manage all existing and future AENS names on behalf of the owner
    /// @param delegation_sig the global delegation signature (network id + owner address + string "AENS" + Contract.address)
    stateful entrypoint provide_delegation_sig(delegation_sig: signature) : unit =
        let expected : bytes() = Bytes.concat(
            Bytes.concat(String.to_bytes(Chain.network_id), Address.to_bytes(Call.caller)),
            Bytes.concat(String.to_bytes("AENS"), Address.to_bytes(Contract.address)))
        require(Crypto.verify_sig(Crypto.blake2b(expected), Call.caller, delegation_sig), "INVALID_DELEGATION_SIGNATURE")
        put(state{ account_to_signature[Call.caller] @sig = delegation_sig })

with this logic I always run into INVALID_DELEGATION_SIGNATURE, even if providing a correct signature.

I would need to be able to verify the signature for the unhashed bytes as follows:

  • require(Crypto.verify_sig(expected, Call.caller, delegation_sig), "INVALID_DELEGATION_SIGNATURE")

obviously this currently leads to following compiler error:

CompilerError: compile error:
type_error:253:17: Cannot unify `bytes(32)` and `bytes()` (when checking the application of
  `Crypto.verify_sig : (hash, address, signature) => bool`
to arguments
  `expected : bytes()`
  `Call.caller : address`
  `delegation_sig : bytes(64)`)
*Created by: marc0olo* I am currently trying to implement a check in Sophia that verifies if the provided AENS delegation signature is valid. after some discussions with @hanssv it turns out that this is currently impossible. I have following logic implemented right now: ```sophia /// @notice provides delegation signature to let the contract manage all existing and future AENS names on behalf of the owner /// @param delegation_sig the global delegation signature (network id + owner address + string "AENS" + Contract.address) stateful entrypoint provide_delegation_sig(delegation_sig: signature) : unit = let expected : bytes() = Bytes.concat( Bytes.concat(String.to_bytes(Chain.network_id), Address.to_bytes(Call.caller)), Bytes.concat(String.to_bytes("AENS"), Address.to_bytes(Contract.address))) require(Crypto.verify_sig(Crypto.blake2b(expected), Call.caller, delegation_sig), "INVALID_DELEGATION_SIGNATURE") put(state{ account_to_signature[Call.caller] @sig = delegation_sig }) ``` with this logic I always run into `INVALID_DELEGATION_SIGNATURE`, even if providing a correct signature. I would need to be able to verify the signature for the unhashed bytes as follows: - `require(Crypto.verify_sig(expected, Call.caller, delegation_sig), "INVALID_DELEGATION_SIGNATURE")` obviously this currently leads to following compiler error: ```sh CompilerError: compile error: type_error:253:17: Cannot unify `bytes(32)` and `bytes()` (when checking the application of `Crypto.verify_sig : (hash, address, signature) => bool` to arguments `expected : bytes()` `Call.caller : address` `delegation_sig : bytes(64)`) ```
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#479
No description provided.