wickra

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: Apache-2.0, MIT Imports: 4 Imported by: 0

README

Wickra Verify — Go

Recompute a claimed backtest report with the deterministic Wickra engine and confirm or refute it, from Go over the C ABI hub (cgo). A doctored claimed_report cannot pass, because verification recomputes rather than trusting the supplied numbers.

Install

go get github.com/wickra-lib/wickra-verify-go

The binding links the prebuilt C ABI library, staged per platform under lib/<goos>_<goarch>/, with the header vendored under include/. Building from source requires a C toolchain (cgo) and the staged native library.

Usage

Everything goes through a Verifier driven by JSON commands — the same command protocol every Wickra binding shares.

package main

import (
    "encoding/json"
    "fmt"

    wickra "github.com/wickra-lib/wickra-verify-go"
)

func main() {
    v := wickra.New()
    defer v.Close()

    claim := map[string]any{
        "strategy":       strategySpec,                     // a wickra-backtest StrategySpec
        "dataset_ref":    map[string]any{"kind": "inline", "data": data},
        "claimed_report": report,                           // the report being checked (untrusted)
    }
    cmd, _ := json.Marshal(map[string]any{"cmd": "verify", "claim": claim})
    out, err := v.Command(string(cmd))
    if err != nil {
        panic(err)
    }
    fmt.Println(out) // the full Verdict as JSON
}

Commands

cmd Payload Response
verify {claim, data?} the full Verdict
explain {verdict} {ok:true,text:...}
canonicalize {value} {ok:true,canonical:...}
version {version:...,engine_version:...}

For files-kind claims, supply the candle data under a top-level data key; inline claims carry their data already.

Domain errors (a bad claim, an unknown command) come back in-band as {ok:false,error:...}; only null/UTF-8/panic conditions produce a Go error.

License

MIT OR Apache-2.0.

Documentation

Overview

Package wickra provides idiomatic Go bindings for wickra-verify over its C ABI hub: create a Verifier, drive it with command JSON (verify, explain, canonicalize, version) and read back the response JSON — the same protocol as the CLI and every other binding.

The binding links the prebuilt C ABI library, staged per platform under ./lib/<goos>_<goarch>/, with the header vendored under ./include.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the library version.

Types

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier is driven by JSON commands.

func New

func New() *Verifier

New creates a verifier with the default tolerances. Call Close when done (a finalizer also frees it, but explicit Close is preferred).

func (*Verifier) Close

func (v *Verifier) Close()

Close frees the verifier handle. Safe to call more than once.

func (*Verifier) Command

func (v *Verifier) Command(cmdJSON string) (string, error)

Command applies a command JSON and returns the response JSON. It uses the C ABI's length-out protocol: a first call learns the length, then the response is read into a caller-owned buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL