本文整理汇总了Golang中github.com/yahoo/coname/ed25519/edwards25519.ExtendedGroupElement.FromParityAndY方法的典型用法代码示例。如果您正苦于以下问题:Golang ExtendedGroupElement.FromParityAndY方法的具体用法?Golang ExtendedGroupElement.FromParityAndY怎么用?Golang ExtendedGroupElement.FromParityAndY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/yahoo/coname/ed25519/edwards25519.ExtendedGroupElement
的用法示例。
在下文中一共展示了ExtendedGroupElement.FromParityAndY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: HashToEdwards
// HashToEdwards converts a 256-bit hash output into a point on the Edwards
// curve isomorphic to Curve25519 in a manner that preserves
// collision-resistance. The returned curve points are NOT indistinguishable
// from random even if the hash value is.
// Specifically, first one bit of the hash output is set aside for parity and
// the rest is tuncated and fed into the elligator bijection (which covers half
// of the points on the elliptic curve).
func HashToEdwards(out *edwards25519.ExtendedGroupElement, h *[32]byte) {
hh := *h
bit := hh[31] >> 7
hh[31] &= 127
edwards25519.FeFromBytes(&out.Y, &hh)
representativeToMontgomeryX(&out.X, &out.Y)
montgomeryXToEdwardsY(&out.Y, &out.X)
if ok := out.FromParityAndY(bit, &out.Y); !ok {
panic("HashToEdwards: point not on curve")
}
}