这个问题涉及基本椭圆曲线加密技术在比特币项目中的应用。
我需要生成一个与另一个(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
这是我在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)
非常感谢
答案 0 :(得分:1)
contract_point + issuer_private_key
无法计算。 contract_point
是椭圆曲线上的一个点,但issuer_private_key
只是一个标量。
假设你想要的是:
def GenPriv(issuer_public_key, issuer_private_key, M):
# generate a hash of the message
e = SHA256(M)
# generate a private key for this contract
return e + issuer_private_key
我不确定这个系统的安全性。它需要一些密码分析。也许你可以向crypto.stackexchange.com寻求帮助。
在我看来,我将使用key exchange计划来协商合同的密钥。