Update web3_sha3 to use nimcrypto

This commit is contained in:
coffeepots 2018-03-27 15:08:31 +01:00
parent 4d3c721ef4
commit c8fa9eac7e
2 changed files with 20 additions and 9 deletions

View File

@ -0,0 +1,8 @@
import nimcrypto
proc k256*(data: string): string =
# do not convert, assume string is data
var k = sha3_256()
k.init
k.update(cast[ptr uint8](data[0].unsafeaddr), data.len.uint)
result = $finish(k)

View File

@ -1,25 +1,28 @@
import servertypes, json, asyncdispatch, rpcregistration
import keccak_tiny
import cryptoutils
proc web3_clientVersion {.rpc.} =
return %("Nimbus-RPC-Test")
proc web3_sha3 {.rpc.} =
let
data = params.getStr
res = $sha3_256(data)
return %res
var data = params.getStr
let kres = k256(data)
return %kres
proc net_version {.rpc.} =
discard
proc net_peerCount {.rpc.} =
# TODO: Discovery integration
#[ See:
https://github.com/ethereum/interfaces/issues/6
https://github.com/ethereum/EIPs/issues/611
]#
discard
proc net_listening {.rpc.} =
return %"true"
proc net_peerCount {.rpc.} =
# TODO: Discovery integration
discard
proc eth_protocolVersion {.rpc.} =
discard