클레이튼 계정으로 데이터 서명 및 검증하는 로직 질문

안녕하세요 개발 도중 질문이 있어서 글을 올립니다.

이더리움에서 제공하는 시그니쳐 검증하는 오픈소스를 가져와서 개발을 하였는데,
클레이튼에서도 적용을 하려니 오류가 나서 질문드립니다.

public function ecRecover($hex, $signed)
{
$rHex = substr($signed, 2, 64);
$sHex = substr($signed, 66, 64);
$vValue = hexdec(substr($signed, 130, 2));
$messageHex = substr($hex, 2);
$messageByteArray = unpack(‘C*’, hex2bin($messageHex));
$messageGmp = gmp_init(“0x” . $messageHex);
$r = $rHex; //hex string without 0x
$s = $sHex; //hex string without 0x
$v = $vValue; //27 or 28

    //with hex2bin it gives the same byte array as the javascript
    $rByteArray = unpack('C*', hex2bin($r));
    $sByteArray = unpack('C*', hex2bin($s));
    $rGmp = gmp_init("0x" . $r);
    $sGmp = gmp_init("0x" . $s);


    if($vValue == 1 || $vValue == 0) {
        $recovery = $v;
    } else {
        $recovery = $v - 27;            
    }

    if ($recovery !== 0 && $recovery !== 1) {            
        throw new Exception('Invalid signature v value');
    }


    $publicKey = Signature::recoverPublicKey($rGmp, $sGmp, $messageGmp, $recovery);
    $publicKeyString = $publicKey["x"] . $publicKey["y"];

    return '0x'. substr($this->keccak256(hex2bin($publicKeyString)), -40);
}

클레이튼에서도 이와 같은 소스를 제공하는 오픈소스가 있을까요! ㅠㅜㅠ

클레이튼의 키 업데이트 기능으로 인해서 생기는 오류로 추측되는데요,

validateSignedMessage 기능을 참조하시면 될 것 같습니다.

혹은 recoverPublicKey, getAccountKey API를 이용하셔도 됩니다.