WeBASE icon indicating copy to clipboard operation
WeBASE copied to clipboard

webase对bytes入参的错误调整引起的sm3接口问题

Open ethan75 opened this issue 4 years ago • 2 comments

使用FISCO BCOS2.8.0版本的0x5006国密预编译接口中,使用webase1.5.1 合约IDE测试function sm3(bytes memory data) public view returns(bytes32){},传入"hello world",发交易返回的哈希值不对,传入"hello world"的16进制数据,发交易返回的哈希值正确,webase对入参进行了调整导致错误。

ethan75 avatar Aug 04 '21 01:08 ethan75

openssl命令计算哈希: image

hello world的sm3哈希: 44f0061e69fa6fdfc290c494654a05dc0c053da7e5c52b84ef93a9d67d3fff88 交易1: image image

返回值0xb7d9aad52768f37cc28f23bf2ab0c88961c86d7a4cacf4d23612bfc280a50950和命令生成的不一致。 交易2 16进制 :68656C6C6F20776F726C64 image image

哈希值正确0x44f0061e69fa6fdfc290c494654a05dc0c053da7e5c52b84ef93a9d67d3fff88

ethan75 avatar Aug 04 '21 02:08 ethan75

function sm3hash(bytes data) returns(bytes32 hash){ Crypto crypto = Crypto(0x5011); //return crypto.sm3(data); return crypto.sm3("hello world"); } 这样调用可以

ethan75 avatar Aug 05 '21 00:08 ethan75