return &c, nil
}
+// Get the size of the point's coordinate in bytes.
+// 32 for 256-bit curves, 64 for 512-bit ones.
func (c *Curve) PointSize() int {
return pointSize(c.P)
}
Key *big.Int
}
+// Unmarshal little-endian private key. "raw" must be c.PointSize() length.
func NewPrivateKey(c *Curve, raw []byte) (*PrivateKey, error) {
pointSize := c.PointSize()
if len(raw) != pointSize {
return NewPrivateKey(c, raw)
}
-func (prv *PrivateKey) Raw() []byte {
- raw := pad(prv.Key.Bytes(), prv.C.PointSize())
+// Marshal little-endian private key. raw will be prv.C.PointSize() length.
+func (prv *PrivateKey) Raw() (raw []byte) {
+ raw = pad(prv.Key.Bytes(), prv.C.PointSize())
reverse(raw)
return raw
}
), nil
}
+// Sign the digest. opts argument is unused.
func (prv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) {
return prv.SignDigest(digest, rand)
}
Y *big.Int
}
+// Unmarshal LE(X)||LE(Y) public key. "raw" must be 2*c.PointSize() length.
func NewPublicKey(c *Curve, raw []byte) (*PublicKey, error) {
pointSize := c.PointSize()
key := make([]byte, 2*pointSize)
}, nil
}
-func (pub *PublicKey) Raw() []byte {
+// Marshal LE(X)||LE(Y) public key. raw will be 2*pub.C.PointSize() length.
+func (pub *PublicKey) Raw() (raw []byte) {
pointSize := pub.C.PointSize()
- raw := append(
+ raw = append(
pad(pub.Y.Bytes(), pointSize),
pad(pub.X.Bytes(), pointSize)...,
)
"math/big"
)
+// Unmarshal little-endian UKM value.
func NewUKM(raw []byte) *big.Int {
t := make([]byte, len(raw))
for i := 0; i < len(t); i++ {
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// GOST R 34.11-2012 256-bit hash function.
-// RFC 6986.
+// RFC 6986. Big-endian hash output.
package gost34112012256
import (
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// GOST R 34.11-2012 512-bit hash function.
-// RFC 6986.
+// RFC 6986. Big-endian hash output.
package gost34112012512
import (