2 回答

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊
Ed25519鍵可以X25519很容易地轉(zhuǎn)換為鍵,使用的扭曲愛德華茲曲線Ed25519和使用的蒙哥馬利曲線X25519是birationally等效的。
愛德華茲曲線上的點(diǎn)通常稱為 ( x, y),而蒙哥馬利曲線上的點(diǎn)通常稱為 ( u, v)。
您不需要庫(kù)來進(jìn)行轉(zhuǎn)換,它真的很簡(jiǎn)單......
(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)
(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))
這是Google 的 Golang 安全主管 Filippo Valsorda 撰寫的一篇很棒的博客,討論了這個(gè)話題。

TA貢獻(xiàn)1951條經(jīng)驗(yàn) 獲得超3個(gè)贊
這需要一個(gè)公共的curve25519 密鑰并將其轉(zhuǎn)換為一個(gè)ed25519 的公共密鑰。我沒有編寫此代碼,但似乎正在做上面伍德斯托克所說的事情。歡迎提供更多信息:
func Verify(publicKey [32]byte, message []byte, signature *[64]byte) bool {
publicKey[31] &= 0x7F
/* Convert the Curve25519 public key into an Ed25519 public key. In
particular, convert Curve25519's "montgomery" x-coordinate into an
Ed25519 "edwards" y-coordinate:
ed_y = (mont_x - 1) / (mont_x + 1)
NOTE: mont_x=-1 is converted to ed_y=0 since fe_invert is mod-exp
Then move the sign bit into the pubkey from the signature.
*/
var edY, one, montX, montXMinusOne, montXPlusOne FieldElement
FeFromBytes(&montX, &publicKey)
FeOne(&one)
FeSub(&montXMinusOne, &montX, &one)
FeAdd(&montXPlusOne, &montX, &one)
FeInvert(&montXPlusOne, &montXPlusOne)
FeMul(&edY, &montXMinusOne, &montXPlusOne)
var A_ed [32]byte
FeToBytes(&A_ed, &edY)
A_ed[31] |= signature[63] & 0x80
signature[63] &= 0x7F
var sig = make([]byte, 64)
var aed = make([]byte, 32)
copy(sig, signature[:])
copy(aed, A_ed[:])
return ed25519.Verify(aed, message, sig)
這使用“golang.org/x/crypto/ed25519/internal”中的函數(shù)
- 2 回答
- 0 關(guān)注
- 319 瀏覽
添加回答
舉報(bào)