fix old hash reverse confusion
This commit is contained in:
parent
1fb719dd61
commit
c1d3b5984d
3 changed files with 7 additions and 7 deletions
|
@ -77,7 +77,7 @@ def from_types_v1(claim, payload: bytes):
|
||||||
sig = old.publisherSignature
|
sig = old.publisherSignature
|
||||||
claim.signature = sig.signature
|
claim.signature = sig.signature
|
||||||
claim.signature_type = KeyType.Name(sig.signatureType)
|
claim.signature_type = KeyType.Name(sig.signatureType)
|
||||||
claim.signing_channel_hash = sig.certificateId
|
claim.signing_channel_hash = sig.certificateId[::-1]
|
||||||
old.ClearField("publisherSignature")
|
old.ClearField("publisherSignature")
|
||||||
claim.unsigned_payload = old.SerializeToString()
|
claim.unsigned_payload = old.SerializeToString()
|
||||||
elif old.claimType == 2:
|
elif old.claimType == 2:
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Output(BaseOutput):
|
||||||
pieces = [
|
pieces = [
|
||||||
Base58.decode(self.get_address(ledger)),
|
Base58.decode(self.get_address(ledger)),
|
||||||
self.claim.unsigned_payload,
|
self.claim.unsigned_payload,
|
||||||
self.claim.signing_channel_hash
|
self.claim.signing_channel_hash[::-1]
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
pieces = [
|
pieces = [
|
||||||
|
|
|
@ -591,7 +591,7 @@ class StreamCommands(CommandTestCase):
|
||||||
channel = await self.daemon.jsonrpc_channel_create('@olds', '1.0')
|
channel = await self.daemon.jsonrpc_channel_create('@olds', '1.0')
|
||||||
await self.confirm_tx(channel.id)
|
await self.confirm_tx(channel.id)
|
||||||
address = channel.outputs[0].get_address(self.account.ledger)
|
address = channel.outputs[0].get_address(self.account.ledger)
|
||||||
claim = generate_signed_legacy('example', address, channel.outputs[0])
|
claim = generate_signed_legacy(address, channel.outputs[0])
|
||||||
tx = await Transaction.claim_create('example', claim.SerializeToString(), 1, address, [self.account], self.account)
|
tx = await Transaction.claim_create('example', claim.SerializeToString(), 1, address, [self.account], self.account)
|
||||||
await tx.sign([self.account])
|
await tx.sign([self.account])
|
||||||
await self.broadcast(tx)
|
await self.broadcast(tx)
|
||||||
|
@ -609,12 +609,12 @@ class StreamCommands(CommandTestCase):
|
||||||
await self.confirm_tx(tx.id)
|
await self.confirm_tx(tx.id)
|
||||||
|
|
||||||
response = await self.daemon.jsonrpc_resolve(urls='bad_example')
|
response = await self.daemon.jsonrpc_resolve(urls='bad_example')
|
||||||
self.assertFalse(response['bad_example']['claim']['signature_is_valid'], response)
|
self.assertIs(False, response['bad_example']['claim']['signature_is_valid'], response)
|
||||||
response = await self.daemon.jsonrpc_resolve(urls='@olds/bad_example')
|
response = await self.daemon.jsonrpc_resolve(urls='@olds/bad_example')
|
||||||
self.assertEqual('URI lbry://@olds/bad_example cannot be resolved', response['@olds/bad_example']['error'])
|
self.assertEqual('URI lbry://@olds/bad_example cannot be resolved', response['@olds/bad_example']['error'])
|
||||||
|
|
||||||
|
|
||||||
def generate_signed_legacy(name: str, address: bytes, output: Output):
|
def generate_signed_legacy(address: bytes, output: Output):
|
||||||
decoded_address = Base58.decode(address)
|
decoded_address = Base58.decode(address)
|
||||||
claim = OldClaimMessage()
|
claim = OldClaimMessage()
|
||||||
claim.ParseFromString(unhexlify(
|
claim.ParseFromString(unhexlify(
|
||||||
|
@ -640,14 +640,14 @@ def generate_signed_legacy(name: str, address: bytes, output: Output):
|
||||||
digest = sha256(b''.join([
|
digest = sha256(b''.join([
|
||||||
decoded_address,
|
decoded_address,
|
||||||
claim.SerializeToString(),
|
claim.SerializeToString(),
|
||||||
output.claim_hash
|
output.claim_hash[::-1]
|
||||||
]))
|
]))
|
||||||
private_key = ecdsa.SigningKey.from_pem(output.private_key, hashfunc=hashlib.sha256)
|
private_key = ecdsa.SigningKey.from_pem(output.private_key, hashfunc=hashlib.sha256)
|
||||||
signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256)
|
||||||
claim.publisherSignature.version = 1
|
claim.publisherSignature.version = 1
|
||||||
claim.publisherSignature.signatureType = 1
|
claim.publisherSignature.signatureType = 1
|
||||||
claim.publisherSignature.signature = signature
|
claim.publisherSignature.signature = signature
|
||||||
claim.publisherSignature.certificateId = output.claim_hash
|
claim.publisherSignature.certificateId = output.claim_hash[::-1]
|
||||||
return claim
|
return claim
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue