这个问题涉及基本椭圆曲线加密在比特币项目中的应用。
我需要生成一个与另一个 ( ) 和一些元数据contract_public_key
直接关联的接收地址 ( ) ,以形成比特币合约。issuer_public_key
M
我会尝试用更笼统的术语...
所以我们有以下内容:
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'
我想要一个函数,GenPub,其中:
GenPub(issuer_public_key, M) = contract_public_key
我想要一个函数,GenPriv,其中:
GenPub(issuer_public_key, issuer_private_key, M) = contract_private_key
这样,
contract_public_key = contract_private_key * G
这是我在伪 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)
非常感谢反馈