X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost3410%2Fpublic.go;h=957293e61f7830b266a7f0731729b989dac8d0d0;hb=c19a111af499e05273906e9d5f7c059ab38d6f02;hp=8642a274bbceb0b19046bcdc72c6062339b2ed81;hpb=6bb01904f8685018353233727eafceeb5a05ec64;p=gogost.git diff --git a/gost3410/public.go b/gost3410/public.go index 8642a27..957293e 100644 --- a/gost3410/public.go +++ b/gost3410/public.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2021 Sergey Matveev +// Copyright (C) 2015-2023 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -27,8 +27,8 @@ type PublicKey struct { Y *big.Int } -func NewPublicKey(curve *Curve, raw []byte) (*PublicKey, error) { - pointSize := curve.PointSize() +func NewPublicKey(c *Curve, raw []byte) (*PublicKey, error) { + pointSize := c.PointSize() key := make([]byte, 2*pointSize) if len(raw) != len(key) { return nil, fmt.Errorf("gogost/gost3410: len(key) != %d", len(key)) @@ -37,7 +37,7 @@ func NewPublicKey(curve *Curve, raw []byte) (*PublicKey, error) { key[i] = raw[len(raw)-i-1] } return &PublicKey{ - curve, + c, bytes2big(key[pointSize : 2*pointSize]), bytes2big(key[:pointSize]), }, nil @@ -56,7 +56,7 @@ func (pub *PublicKey) Raw() []byte { func (pub *PublicKey) VerifyDigest(digest, signature []byte) (bool, error) { pointSize := pub.C.PointSize() if len(signature) != 2*pointSize { - return false, fmt.Errorf("gogost/gost3410: len(signature) != %d", 2*pointSize) + return false, fmt.Errorf("gogost/gost3410: len(signature)=%d != %d", len(signature), 2*pointSize) } s := bytes2big(signature[:pointSize]) r := bytes2big(signature[pointSize:]) @@ -114,5 +114,5 @@ func (our *PublicKey) Equal(theirKey crypto.PublicKey) bool { if !ok { return false } - return our.X.Cmp(their.X) == 0 && our.X.Cmp(their.Y) == 0 && our.C.Equal(their.C) + return our.X.Cmp(their.X) == 0 && our.Y.Cmp(their.Y) == 0 && our.C.Equal(their.C) }