2018-03-02 11:57:43 +01:00
|
|
|
# Nim Eth-keys
|
2018-02-13 19:20:27 +01:00
|
|
|
# Copyright (c) 2018 Status Research & Development GmbH
|
2018-03-02 11:57:43 +01:00
|
|
|
# Licensed under either of
|
|
|
|
#
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
|
|
#
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
2018-02-13 19:20:27 +01:00
|
|
|
|
2018-03-21 14:11:48 +01:00
|
|
|
import ./private/conversion_bytes
|
2018-02-14 19:50:36 +01:00
|
|
|
|
2018-03-21 16:45:39 +01:00
|
|
|
# Note: Fields F should be private, it is intentionally ugly to directly access them
|
|
|
|
# See private field access issue: https://github.com/nim-lang/Nim/issues/7390
|
2018-02-13 19:20:27 +01:00
|
|
|
type
|
|
|
|
PublicKey* = object
|
2018-03-21 16:45:39 +01:00
|
|
|
Fraw_key*: array[64, byte]
|
2018-02-13 19:20:27 +01:00
|
|
|
|
|
|
|
PrivateKey* = object
|
2018-03-21 16:45:39 +01:00
|
|
|
Fraw_key*: array[32, byte]
|
|
|
|
Fpublic_key*: PublicKey
|
2018-02-13 19:20:27 +01:00
|
|
|
|
2018-03-21 17:59:50 +01:00
|
|
|
|
|
|
|
type
|
|
|
|
Scalar256 = array[32, byte]
|
|
|
|
# Secp256k1 makes the signature an opaque "implementation dependent".
|
|
|
|
#
|
|
|
|
# Scalar256 is opaque/distinct too as in practice, they are uint256
|
|
|
|
# and by default we don't load any.
|
|
|
|
# See implementation details in datatypes.md.
|
|
|
|
|
2018-02-14 19:50:36 +01:00
|
|
|
Signature* {.packed.}= object
|
2018-03-21 17:59:50 +01:00
|
|
|
Fr*: Scalar256
|
|
|
|
Fs*: Scalar256
|
2018-03-21 16:45:39 +01:00
|
|
|
Fv*: range[0.byte .. 1.byte] # This should be 27..28 as per Ethereum but it's 0..1 in eth-keys ...
|
2018-03-21 14:11:48 +01:00
|
|
|
|