Noise stuff
This commit is contained in:
parent
209ae51580
commit
c06a94bcb9
|
@ -0,0 +1,46 @@
|
|||
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import std/options
|
||||
import preserves
|
||||
import ./actors, ./durings, ./protocols/[protocol, sturdy]
|
||||
|
||||
import noiseprotocol
|
||||
const cipher = CIPHER.CHACHAPOLY
|
||||
|
||||
type Value = Preserve[void]
|
||||
|
||||
func protocolName(spec: Value): string =
|
||||
if spec.isDictionary:
|
||||
var o = step(spec, toSymbol"protocol")
|
||||
if o.isNone:
|
||||
result = "Noise_NK_25519_ChaChaPoly_BLAKE2s" # TODO: this is in the schema.
|
||||
else:
|
||||
discard fromPreserve(result, get o)
|
||||
|
||||
proc prologue(spec: Value): seq[byte] =
|
||||
if spec.isDictionary:
|
||||
var o = step(spec, toSymbol"service")
|
||||
if o.isSome: result = encode(get o)
|
||||
|
||||
func preSharedKey(spec: Value): seq[seq[byte]] =
|
||||
if spec.isDictionary:
|
||||
var o = step(spec, toSymbol"preSharedKeys")
|
||||
if o.isSome:
|
||||
discard fromPreserve(result, get o)
|
||||
|
||||
proc noiseStep*(turn: var actors.Turn; ds: Ref) =
|
||||
discard
|
||||
#[
|
||||
let pat = ?Observe(pattern: dropType(ResolvedPathStep)) ?? {1: grabLit()}
|
||||
during(turn, ds, pat) do (noiseDetailLit: Value):
|
||||
stderr.writeLine("should do something with noise detail ", noiseDetailLit)
|
||||
var spec = noiseDetailLit
|
||||
let proto = protocolName(spec)
|
||||
if proto != "":
|
||||
let handshake = newByName(proto, ROLE.INITIATOR)
|
||||
defer: destroy(handshake)
|
||||
var prologue = prologue(spec)
|
||||
if len(prologue) > 0: setPrologue(handshake, prologue)
|
||||
var preSharedKeys = preSharedKeys(spec)
|
||||
]#
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "20230608"
|
||||
version = "20230609"
|
||||
author = "Emery Hemingway"
|
||||
description = "Syndicated actors for conversational concurrency"
|
||||
license = "Unlicense"
|
||||
|
|
Loading…
Reference in New Issue