Cette question concerne l'application de la crypto elliptique de base pour les besoins d'un projet Bitcoin.Génère une nouvelle clé publique à partir du hachage d'un message.
J'ai besoin de générer une adresse de réception (contract_public_key
) qui est directement associé à un autre (issuer_public_key
) et certaines métadonnées, M
, pour former un contrat Bitcoin.
Je vais essayer de mettre en termes plus généraux ...
Nous avons donc les suivantes:
G is the elliptic curve base point.
issuer_private_key = <some random 256bit scalar>
issuer_public_key = issuer_private_key * G
M = 'Terms of contract bla bla and also includes issuer_public_key for safety'
Je veux une fonction, GenPub, où:
GenPub(issuer_public_key, M) = contract_public_key
I voulez une fonction, GenPriv, où:
GenPub(issuer_public_key, issuer_private_key, M) = contract_private_key
de telle sorte que,
contract_public_key = contract_private_key * G
Voici ma première tentative de pseudo-python:
def GenPub(issuer_public_key, M):
# generate a hash of the message
e = SHA256(M)
# create an EC point that is known to both parties
contract_point = (e * issuer_public_key)
# generate a public key for this contract
return contract_point + issuer_public_key
def GenPriv(issuer_public_key, issuer_private_key, M):
# generate a hash of the message
e = SHA256(M)
# create an EC point that is known to both parties
contract_point = (e * issuer_public_key)
# generate a private key for this contract
return contract_point + issuer_private_key
# the public key for the contract
contract_private_key = GenPub(issuer_public_key, M)
# the private key for contract
contract_private_key = GenPriv(issuer_public_key, issuer_private_key, M)
Commentaires beaucoup apprécié
Il vaudrait mieux mettre cela en forme mathématique semi-formelle et l'afficher sur crypto.stackexchange.com. –