-1

这个问题涉及基本椭圆曲线加密在比特币项目中的应用。

我需要生成一个与另一个 ( ) 和一些元数据contract_public_key直接关联的接收地址 ( ) ,以形成比特币合约。issuer_public_keyM

我会尝试用更笼统的术语...

所以我们有以下内容:

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)

非常感谢反馈

4

1 回答 1

1

contract_point + issuer_private_key cannot be computed. contract_point is a point on elliptic curve but issuer_private_key is just a scalar.

Suppose you want is:

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

I am not sure the security of this system. It needs some cryptanalysis. Maybe you can ask help from crypto.stackexchange.com.

In my opinion, I will use a key exchange scheme to negotiate a secret key of the contract.

于 2013-12-27T02:56:29.440 回答