Skip to content

Commit

Permalink
Fixed RLP serialization for crypto primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
yglukhov committed Mar 1, 2019
1 parent dd272db commit 8058079
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
4 changes: 2 additions & 2 deletions beacon_chain/spec/crypto.nim
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
import
sequtils,
hashes,
blscurve, json_serialization
blscurve, json_serialization, eth/rlp

export
json_serialization
json_serialization, rlp

export blscurve.init, blscurve.getBytes, blscurve.combine, blscurve.`$`, blscurve.`==`

Expand Down
28 changes: 3 additions & 25 deletions beacon_chain/spec/datatypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -494,29 +494,6 @@ type
# TODO: not in spec
CrosslinkCommittee* = tuple[committee: seq[ValidatorIndex], shard: uint64]

when true:
# TODO: Remove these once RLP serialization is no longer used
import nimcrypto, eth/rlp, json_serialization
export append, read, json_serialization

proc append*(rlpWriter: var RlpWriter, value: ValidatorPubKey) =
discard

proc read*(rlp: var Rlp, T: type ValidatorPubKey): T {.inline.} =
discard

proc append*(rlpWriter: var RlpWriter, value: ValidatorIndex) =
discard

proc read*(rlp: var Rlp, T: type ValidatorIndex): T {.inline.} =
discard

proc append*(rlpWriter: var RlpWriter, value: ValidatorSig) =
discard

proc read*(rlp: var Rlp, T: type ValidatorSig): T {.inline.} =
discard

func shortValidatorKey*(state: BeaconState, validatorIdx: int): string =
($state.validator_registry[validatorIdx].pubkey)[0..7]

Expand All @@ -526,6 +503,7 @@ func humaneSlotNum*(s: Slot): Slot =
func humaneEpochNum*(e: Epoch): Epoch =
e - GENESIS_EPOCH

export
writeValue, readValue
import nimcrypto, eth/rlp, json_serialization
export json_serialization, rlp
export writeValue, readValue, append, read

0 comments on commit 8058079

Please sign in to comment.