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:
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:
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: