看起来流程是对的,但是不知道 json_hash 是不是字节数组。

Reply to this note

Please Login to reply.

Discussion

json_hash 是这样的

# Serialize the event data

serialized_event = json.dumps([

0,

event["pubkey"],

event["created_at"],

event["kind"],

event["tags"],

event["content"]

], separators=(',', ':'), ensure_ascii=False

)

print("json content:", serialized_event)

# hash the json using sha-256

json_hash = hashlib.sha256(serialized_event.encode('utf-8')).digest()

json_hash应该是二进制的哈希值吧?

n文档关于sig就这么一句话而已

sig": <64-bytes lowercase hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field>

}

print(type(json_hash)到结果是class ‘bytes’.

是不是要字符串str才是正确的?

就是 bytes 了

搞不懂了哈哈😂,我觉得是公钥格式的问题。 本地验证是用直接生成的full public key验证的所以结果是valid。传到relay的pubkey是hex格式公钥,好像是full key的32字节x坐标而已。 不知道是不是这么复杂

是的 32位公钥。你取后面32位就可以了