Commit graph

16 commits

Author SHA1 Message Date
Roman Khimov
df12adaa9e crypto: remove crypto.Verifiable interface
We can now verify any hash.Hashable thing.
2021-03-26 13:45:18 +03:00
Evgenii Stratonikov
d5b4553bb3 keys: allow to create keys on arbitrary curve 2020-12-03 14:06:35 +03:00
Roman Khimov
53c014a0bb crypto/consensus: sign hashes and cache them for consensus payloads
Avoid serializing payload again and again for various purposes. To sign it, we
only need a hash.

Some 2.4% gain in TPS could be achieved with this.
2020-09-09 20:46:31 +03:00
Evgenii Stratonikov
76fdbea331 keys: fix failing Secp256k1 test
Pad R and S when computing signature.
Fix #1223.
2020-07-25 12:01:12 +03:00
Anna Shaleva
8f17c7fb05 crypto: switch to standard ecdsa keys
Now we have not only Random EC curve, but also Koblitz curve, so
it will be useful to have information about the curve for each
particular EC point. ecdsa.PublicKey has this information.
2020-07-14 16:19:07 +03:00
Roman Khimov
e41d434a49 *: move all packages from CityOfZion to nspcc-dev 2020-03-03 17:21:42 +03:00
Roman Khimov
a903147b60 keys: rename Signature to GetScriptHash, make it return Uint160
Signature itself wasn't used at all and its name is very misleading, Uint160
script hash is way more useful.
2020-02-19 12:19:03 +03:00
Roman Khimov
46b82b4fb5 keys: don't return error from PrivateKey.Sign
As it can't ever happen.
2020-01-17 17:00:30 +03:00
Roman Khimov
e2fff3bb1d keys: update to newer rfc6979 package
Fixes #592.
2020-01-16 18:21:10 +03:00
Roman Khimov
6b70c5f2bd keys: rename New*FromRawBytes to New*FromASN1
RawBytes is too confusing and may be read as being compatible with
NEO-serialized format.
2019-10-15 12:56:25 +03:00
Roman Khimov
2c3e92923f keys: simplify error handling for PublicKey() and associated
PublicKey() for PrivateKey now just can't fail and it makes no sense to return
an error from it. There is a lot of associated functionality for which this
also is true, so adjust it accordingly and simplify a lot of code.
2019-09-05 12:34:12 +03:00
Roman Khimov
60bc2e8053 keys: simplify PublicKey() for PrivateKey
Public key is just a point, so use the coordinates obtained previously to
initialize the PublicKey structure without jumping through the hoops of
encoding/decoding.
2019-09-05 12:34:12 +03:00
Roman Khimov
f0fbe9f6c9 crypto: drop home-grown elliptic crypto, use crypto/elliptic
As NEO uses P256 we can use standard crypto/elliptic library for almost
everything, the only exception being decompression of the Y coordinate. For
some reason the standard library only supports uncompressed format in its
Marshal()/Unmarshal() functions. elliptic.P256() is known to have
constant-time implementation, so it fixes #245 (and the decompression using
big.Int operates on public key, so nobody really cares about that part being
constant-time).

New decompress function is inspired by
https://stackoverflow.com/questions/46283760, even though the previous one
really did the same thing just in a little less obvious way.
2019-09-05 12:33:27 +03:00
Roman Khimov
a9b9c9226d *: add/fix godoc comments to satisfy golint
Fixes things like:
 * exported type/method/function X should have comment or be unexported
 * comment on exported type/method/function X should be of the form "X ..."
   (with optional leading article)

Refs. #213.
2019-09-03 17:57:51 +03:00
Roman Khimov
5836ae6873 keys: change Signature() and Address() to not return errors
As they never can return any real one.
2019-08-27 17:46:01 +03:00
Roman Khimov
b77e533d13 crypto/wallet: move public/private key into the new keys package
And drop associated _pkg.dev remnants (refs. #307).

Original `dev` branch had two separate packages for public and private keys,
but those are so intertwined (`TestHelper` subpackage is a proof) that it's
better unite them and all associated code (like WIF and NEP-2) in one
package. This patch also:
 * creates internal `keytestcases` package to share things with wallet (maybe
   it'll be changed in some future)
 * ports some tests from `dev`
 * ports Verify() method for public key from `dev`
 * expands TestPrivateKey() with public key check
2019-08-27 17:45:51 +03:00
Renamed from pkg/wallet/private_key.go (Browse further)