饮歌长啸
这需要一个公共的curve25519 密钥并将其转换为一个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. Inparticular, convert Curve25519's "montgomery" x-coordinate into anEd25519 "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-expThen move the sign bit into the pubkey from the signature.*/var edY, one, montX, montXMinusOne, montXPlusOne FieldElementFeFromBytes(&montX, &publicKey)FeOne(&one)FeSub(&montXMinusOne, &montX, &one)FeAdd(&montXPlusOne, &montX, &one)FeInvert(&montXPlusOne, &montXPlusOne)FeMul(&edY, &montXMinusOne, &montXPlusOne)var A_ed [32]byteFeToBytes(&A_ed, &edY)A_ed[31] |= signature[63] & 0x80signature[63] &= 0x7Fvar 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”中的函数