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
7854dcfd8f
core: replace interop names with named constants
2020-08-14 14:21:54 +03:00
Roman Khimov
5ef08f60ae
remove github.com/pkg/errors from dependencies
...
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +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
a3e306ff78
core: implement Secp256k1 Verify and CheckMultisig interops
...
Closes #918 .
2020-07-14 16:21:34 +03:00
Anna Shaleva
17233e1d8e
core: rename Neo.Crypto.Verify to Neo.Crypto.VerifyWithECDsaSecp256r1
...
Part of #918
2020-07-14 16:19: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
56a8f11ad6
Merge pull request #1115 from nspcc-dev/fix/convert
...
keys: support returning legacy verification script
2020-07-10 19:27:36 +03:00
Roman Khimov
8ad355b444
Merge pull request #1124 from nspcc-dev/forward-port-from-2.x
...
Forward port from 2.x
2020-06-29 11:52:45 +03:00
Evgenii Stratonikov
8c18142e8a
keys: implement PublicKeys.Copy()
...
Implement convenient wrapper over explicit allocation and copying.
2020-06-29 10:44:35 +03:00
Roman Khimov
7e2e5e1879
keys: add support for uncompressed serialization in PublicKey
2020-06-27 12:16:31 +03:00
Evgenii Stratonikov
f5cb035996
keys: support returning legacy verification script
...
When one works with legacy (NEO2) wallets, it is useful to have access
to old verification script formats.
2020-06-26 11:15:03 +03:00
Evgenii Stratonikov
7b4ca57e33
*: change address to the new format
...
NEO3 uses new prefix for address (53 = 0x35), thus string representations as
well as encrypted WIFs should be changed.
2020-06-17 15:58:21 +03:00
Evgenii Stratonikov
f9f3192b48
vm: move RET and SYSCALL opcodes
2020-05-07 13:23:05 +03:00
Roman Khimov
bc4a6a6bab
core/native: move NextValidators storage to NEO contract
2020-04-27 12:30:39 +03:00
Evgenii Stratonikov
008e6eb233
vm: implement new PUSH opcodes
2020-04-23 10:52:28 +03:00
Evgenii Stratonikov
941410a840
core: change verification scripts to new format
...
Verification scripts now invoke Neo.Crypto.* interops instead of
CHECKSIG/VERIFY opcodes.
2020-04-20 11:55:24 +03:00
Evgenii Stratonikov
1611ede58c
crypto/keys: implement NewPublicKeyFromBytes()
...
It is convenient to have a single function instead of
allocating new `PublicKey` and using `DecodeBytes()` on it.
2020-04-13 13:13:15 +03:00
Evgenii Stratonikov
9abda40171
testserdes: implement helpers for encode/decode routines
...
Frequently one needs to check if struct serializes/deserializes
properly. This commit implements helpers for such cases including:
1. JSON
2. io.Serializable interface
2020-03-27 10:27:46 +03:00
Anna Shaleva
8e05bfe99c
rpc/crypto: fix validator field marshalling in getvalidators RPC server
...
Problem: wrong `PublicKey` field json marshalling of result.Validator
Solution: add marshaller to publickey (crypto)
2020-03-24 15:52:51 +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
32a064aa31
keys: add Cmp method to PublicKey
...
It can be used by code that doesn't operate with PublicKeys, but still needs
to be able to compare keys for some purposes.
2020-02-12 21:27:40 +03:00
Roman Khimov
141553da4c
keys: fix PublicKeys decoding
...
It changes the slice, thus it has to work via a pointer.
2020-02-12 21:23:28 +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
951ee383e9
keys: improve NEP2 testing
2020-01-09 18:06:03 +03:00
Roman Khimov
b5b05a969c
keys: make NEP2Decrypt return a PrivateKey rather than WIF
...
There is no point in encoding the output of this function in a WIF format,
most of the users actually want the real key and those who need a WIF can
easily get if from the key (and it's simpler than getting the key from the
WIF).
It also fixes a severe bug in NEP2Decrypt, base58 decoding errors were not
processed correctly.
2020-01-09 18:05:14 +03:00
Roman Khimov
604b2c8240
keys: add a successful test for 04-encoded public key
2019-12-25 18:06:25 +03:00
Roman Khimov
fa0537758f
keys: add a test for X/Y > P decoding case
2019-12-25 18:01:54 +03:00
Roman Khimov
6c471ecd98
keys: move IsOnCurve decoding check, add a test for it
...
This check only makes sense for 04-encoded points, because 02 and 03 derive Y
from X and they're on the curve by definition.
2019-12-25 18:00:25 +03:00
Roman Khimov
5ac8cae221
keys: fix bad compressed public key decoding, add a test
...
The error was not propagated properly here.
2019-12-25 17:44:30 +03:00
Roman Khimov
b246653f62
address: rename functions as per #579 comments
...
Make them more clear to understand.
2019-12-25 17:34:18 +03:00
Roman Khimov
e25133a385
keys: reuse address package for address generation
...
Deduplicates code and makes prefix overridable.
2019-12-25 16:03:39 +03:00
Roman Khimov
369ac01a27
base58: move into its own package
...
It doesn't belong to crypto in any way other than it uses hash function
internally.
2019-12-25 15:05:54 +03:00
Roman Khimov
db5555bb15
crypto: internalize aes functions into the keys package
...
This is the only user of it and no one outside should care about these
details.
2019-12-25 11:25:05 +03:00
Roman Khimov
8b3080b972
io: rename Read/WriteBytes to Read/WriteB
...
go vet is not happy about them:
pkg/io/binaryReader.go:92:21: method ReadByte() byte should have signature ReadByte() (byte, error)
pkg/io/binaryWriter.go:75:21: method WriteByte(u8 byte) should have signature WriteByte(byte) error
2019-12-12 20:19:50 +03:00
Roman Khimov
54d888ba70
io: add type-specific read/write methods
...
This seriously improves the serialization/deserialization performance for
several reasons:
* no time spent in `binary` reflection
* no memory allocations being made on every read/write
* uses fast ReadBytes everywhere it's appropriate
It also makes Fixed8 Serializable just for convenience.
2019-12-12 20:19:50 +03:00
Evgenii Stratonikov
fccb008594
io: implement ReadBytes()
2019-12-09 15:00:15 +03:00
Evgenii Stratonikov
7179e4ba9f
util: add LE suffix to Uint256 methods
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
57efad912c
util: add LE suffix to Uint160 methods
2019-12-06 12:16:55 +03:00
Roman Khimov
138e125646
*: remove duplicate functions producing verification script
...
Drop wif.GetVerificationScript(), drop
smartcontract.CreateSignatureRedeemScript(), add GetVerificationScript()
directly to the PublicKey and use it everywhere.
2019-12-03 18:23:46 +03:00
Roman Khimov
f48228ef7d
Merge pull request #467 from nspcc-dev/errcheck_297
...
This patchset closes #297 and #457 .
2019-12-03 15:06:11 +03:00
Vsevolod Brekelov
03ff2976ed
io: refactoring for using WriteVarBytes instead of WriteLE
...
goal is to be consistent with C# implementation.
For writing []byte WriteBytes used and for byte - WriteVarByte.
2019-12-03 13:49:33 +03:00
Roman Khimov
bc5beb438f
*: gofmt
...
Somehow these crept into the repository.
2019-12-02 10:10:50 +03:00
Evgenii Stratonikov
0a9a742019
crypto: add invalid testcase
2019-11-29 11:03:03 +03:00
Vsevolod Brekelov
38088b648a
crypto: add unit tests for public key
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
d4e8846ed0
!squash core/crypto
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
c80ee952a1
core/crypto: add validators and interop for validators
...
add processing of validators while block persist;
add validator structure with decoding/encoding;
add validator get from store;
add EnrollmentTX and StateTX processing;
add pubkey decode bytes, unique and contains functions;
2019-11-21 15:23:35 +03:00
Vsevolod Brekelov
8ee421db14
fix spelling and godoc comments
2019-10-22 17:56:03 +03:00