我们可以为OpenSSL ECC提供多个公共密钥和一个私有密钥吗?

时间:2020-01-08 08:27:29

标签: php openssl cryptography php-openssl

我在我的项目中使用php OpenSSL。如何使用单个私钥创建多个公钥?

在RSA中,我们无法执行此类操作。但是ECC呢?

2 个答案:

答案 0 :(得分:4)

根据定义,对于一般椭圆曲线密码系统中的每个私标量(私钥),由[k]G生成的曲线(公钥)上只有一个点,其中G是曲线生成器点,k是私有标量。

仅供参考,在有点不寻常的双等价曲线怪癖中,您实际上可以将蒙哥马利曲线X25519公钥映射到两个扭曲的爱德华兹曲线Ed25519公钥,因为蒙哥马利曲线点不带有视点坐标,但是,这不会帮助您的用例。

通常,如果我们想从单个种子(源)定义多个密钥对(而不仅仅是公共密钥),则可以使用从主密钥派生的密钥来实现。

但是,那么您必须照顾多个私钥。

您似乎暗示私钥将存在于服务器上,因此我认为您实际上不需要多个公钥。我建议您使用一个密钥对和EdDSA或ECDSA来对多个密钥对进行签名,以在客户端设备上使用。签名可用于将其来源链接到单个身份。

请提供更多背景信息,我会进一步提供帮助。

答案 1 :(得分:1)

在ECC中,有一种方法称为多样化密钥。它存在于CommonECCryptor.h

下面的Apple的CommonCrypto中
@function   CCECCryptorTwinDiversifyKey

@abstract   Diversifies a given EC key by deriving two scalars u,v from the
            given entropy.

@discussion entropyLen must be a multiple of two, greater or equal to two
            times the bitsize of the order of the chosen curve plus eight
            bytes, e.g. 2 * (32 + 8) = 80 bytes for NIST P-256.

            Use CCECCryptorTwinDiversifyEntropySize() to determine the
            minimum entropy length that needs to be generated and passed.

            entropy must be chosen from a uniform distribution, e.g.
            random bytes, the output of a DRBG, or the output of a KDF.

            u,v are computed by splitting the entropy into two parts of
            equal size. For each part t (interpreted as a big-endian number),
            a scalar s on the chosen curve will be computed via
            s = (t mod (q-1)) + 1, where q is the order of curve's
            generator G.

            For a public key, this will compute u.P + v.G,
            with G being the generator of the chosen curve.

            For a private key, this will compute d' = (d * u + v) and
            P = d' * G; G being the generator of the chosen curve.

就像您的情况一样,也可能需要CryptoCurrencies。通过多样化,人们可以实现某种程度的匿名性。如果一个人总是使用相同的公钥,那么它们一直都与此公钥链接。如果一个人可以使用其私钥/公钥来使其公钥多样化,那么他们便可以使用多样化的新身份。身份多样化,无法轻易将其与原始身份联系起来。

在上述方案中,使用uv进行了多样化处理的新公钥将为[u]P + [v]G,并且经过了多样化处理的私钥将为

d' = (d \cdot u + v)

并验证多样化的公钥

P' = [d']G = [d \cdot u + v]G = [d \cdot u]G + [v]G = [u]P + [v]G

简而言之,您拥有一个新的身份,但在幕后,仍然是您。