View hkdf.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nimcrypto, math, byteutils | |
proc hkdf*(HashType: typedesc, secret, salt, info: openarray[byte], output: var openarray[byte]) = | |
var ctx: HMAC[HashType] | |
ctx.init(salt) | |
ctx.update(secret) | |
let prk = ctx.finish().data | |
const hashLen = HashType.bits div 8 | |
var t: MDigest[HashType.bits] |
View wrc20.wat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(type (;0;) (func (result i32))) | |
(type (;1;) (func (param i32 i32))) | |
(type (;2;) (func (param i32 i32 i32))) | |
(type (;3;) (func (param i32))) | |
(type (;4;) (func)) | |
(import "ethereum" "getCallDataSize" (func (;0;) (type 0))) | |
(import "ethereum" "finish" (func (;1;) (type 1))) | |
(import "ethereum" "revert" (func (;2;) (type 1))) | |
(import "ethereum" "callDataCopy" (func (;3;) (type 2))) |
View NIP_rlpx.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This gist should explain the rlpx.nim improvements | |
# Main points | |
# Rlpx is an entity which is responsible only for rlpx messaging. The rlpx | |
# subsystem doesn't know anything about Ethereum or even Peer. | |
# Subprotocol functions are "namespaced" to corresponding protocol types. | |
# This provides an option to have multiple equally named functions belonging | |
# to different protocols/versions. | |
# A protocol of specific type can be queried from an Rlpx object | |
# The rlpxProtocol macro is used to help generate a new Protocol type. | |
# An object of a protocol type is capable of |
View gist.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# | |
# Nim's Runtime Library | |
# (c) Copyright 2015 Andreas Rumpf | |
# | |
# See the file "copying.txt", included in this | |
# distribution, for details about the copyright. | |
# | |
View new_ranges.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import | |
ranges/ptr_arith | |
const rangesGCHoldEnabled = not defined(rangesDisableGCHold) | |
const unsafeAPIEnabled = defined(rangesEnableUnsafeAPI) | |
type | |
Bytes* = seq[byte] | |
# A view into immutable array |
View test.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eth_keys | |
let privKey = initPrivateKey("a2b50376a79b1a8c8a3296485572bdfbf54708bb46d3c25d73d2723aaaf6a617") | |
echo "priv: ", privKey.raw_key.toHex() | |
echo "pub: ", privKey.public_key.raw_key.toHex() | |
# OUTPUT: | |
# priv: a2b50376a79b1a8c8a3296485572bdfbf54708bb46d3c25d73d2723aaaf6a617 | |
# pub: c58a9e3bcea19d6284a1a5b7da269ef100f8f48fef1e165ab1c625dade34cd717400e3d43682e6061472007fbb303c3896c48926912a6e57d7c024087fd45c40 |
View rest.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# protocol.nim | |
import super_rest_lib | |
type Foo = object | |
a: int | |
restInterface myInterface: | |
proc bar(arg1, arg2: Foo) | |
proc someOtherBar(arg1: string): string | |
proc someOtherBar2(arg1, arg2: string) |
View nimx_layout_tests.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nimx / [ window, button, text_field, layout, split_view, context, scroll_view2 ] | |
type Label = ref object of TextField | |
method init*(v: Label, r: Rect) = | |
procCall v.TextField.init(r) | |
v.editable = false | |
v.selectable = false | |
type TestView = ref object of View |
View nimx_layout_test.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc createLayout4(w: Window) = | |
w.makeLayout: | |
- SplitView sv: | |
vertical: true # Comment this line to make me horizontal | |
backgroundColor: blue | |
top == super | |
bottom == super | |
leading == super | |
trailing == super |
View threadpools.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros, cpuinfo | |
when not compileOption("threads"): | |
{.error: "ThreadPool requires --threads:on compiler option".} | |
type | |
ThreadPool* = ref object | |
chanTo: ChannelTo # Tasks are added to this channel | |
chanFrom: ChannelFrom # Results are read from this channel | |
threads: seq[ThreadType] |
NewerOlder