change default curve to SECP256k1, pass name parameter

This commit is contained in:
Victor Shyba 2018-12-31 01:08:02 -03:00 committed by Lex Berezhny
parent 74cccdbfc7
commit 523c4c86a9
4 changed files with 5 additions and 5 deletions

View file

@ -413,7 +413,7 @@ class LbryWalletManager(BaseWalletManager):
claim_address = await account.receiving.get_or_create_usable_address()
if certificate:
claim = claim.sign(
certificate.private_key, claim_address, certificate.claim_id, curve=SECP256k1
certificate.private_key, claim_address, certificate.claim_id, curve=SECP256k1, name=name
)
existing_claims = await account.get_claims(
claim_name_type__any={'is_claim': 1, 'is_update': 1}, # exclude is_supports

View file

@ -160,11 +160,11 @@ class ClaimDict(OrderedDict):
return cls.load_protobuf(temp_claim, detached_signature=detached_signature)
@classmethod
def generate_certificate(cls, private_key, curve=NIST256p):
def generate_certificate(cls, private_key, curve=SECP256k1):
signer = get_signer(curve).load_pem(private_key)
return cls.load_protobuf(signer.certificate)
def sign(self, private_key, claim_address, cert_claim_id, curve=NIST256p, name=None):
def sign(self, private_key, claim_address, cert_claim_id, curve=SECP256k1, name=None):
signer = get_signer(curve).load_pem(private_key)
signed, signature = signer.sign_stream_claim(self, claim_address, cert_claim_id, name)
return ClaimDict.load_protobuf(signed, signature)

View file

@ -64,7 +64,7 @@ class NIST_ECDSASigner(object):
digest = self.HASHFUNC(to_sign).digest()
if self.DETACHED:
return claim.protobuf_dict, Signature(
return Claim.load(decode_b64_fields(claim.protobuf_dict)), Signature(
self.private_key.sign_digest_deterministic(digest, hashfunc=self.HASHFUNC), raw_cert_id
)

View file

@ -61,7 +61,7 @@ class BasicTransactionTest(IntegrationTestCase):
cert, key = generate_certificate()
cert_tx = await Transaction.claim('@bar', cert, l2d('1.0'), address1, [self.account], self.account)
claim = ClaimDict.load_dict(example_claim_dict)
claim = claim.sign(key, address1, cert_tx.outputs[0].claim_id)
claim = claim.sign(key, address1, cert_tx.outputs[0].claim_id, name='foo')
claim_tx = await Transaction.claim('foo', claim, l2d('1.0'), address1, [self.account], self.account)
await self.broadcast(cert_tx)