예제 #1
0
 def sign(self, signer: SigningKey) -> bytes:
     """
     署名を実施
     :param signer:
     :return:
     """
     new_bytes = self.convert()
     #print(new_bytes)
     signature = signer.sign_deterministic(new_bytes, sigencode=sigencode_der)
     self.data["signature"] = signature
     return signature
예제 #2
0
def make_tx(key: ecdsa.SigningKey, contract, func, arguments={}):
    tx = {
        'sender': key.get_verifying_key().to_string().hex(),
        'signature': None,
        'payload': {
            'contract': contract,
            'function': func,
            'arguments': arguments
        }
    }

    message = encode(tx['payload']).encode()

    signature = key.sign_deterministic(message, hashlib.sha256)[:64]

    tx['signature'] = signature.hex()

    return tx
예제 #3
0
파일: cose.py 프로젝트: IO42630/ace
    def create_signature(cls,
                         context: str,
                         body_protected: bytes,
                         payload: bytes,
                         key: SigningKey,
                         external_aad: bytes,
                         sign_protected: bytes = None) -> bytes:

        sign_structure = Signature1Message.sign_structure(
            context, body_protected, payload, external_aad, sign_protected)

        to_sign = dumps(sign_structure)

        signature = key.sign_deterministic(to_sign,
                                           hashlib.sha256,
                                           sigencode=util.sigencode_string)

        return signature