bbsnative

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package bbsnative is a cgo wrapper around zk-cred-bbs's plain C-ABI Go binding (src/go_ffi.rs / include/zk_cred_bbs_go.h in that crate). The static library is staged by the repository Makefile's `bbs-native-lib` target.

Unlike zk-cred-longfellow's verifier binding, this exposes the ISSUER side too: an issuer offering BBS credentials must verify the holder's commitment and blind-sign it, and there is no pure-Go implementation of either.

Memory

The C ABI has no handles — BBS has no proving key to load and no circuit to compile, so every call is bytes in, bytes out. The only owned allocations crossing back are the signature buffer and the error string, each freed here immediately after being copied into Go memory.

Index

Constants

View Source
const StatusOK int32 = C.ZK_CRED_BBS_OK

StatusOK is the ABI's success code.

View Source
const StatusPanic int32 = C.ZK_CRED_BBS_PANIC

StatusPanic is the ABI's "a panic was caught crossing the boundary" code. Exposed so the wrapping package can distinguish it from an ordinary verification failure without duplicating the constant.

Variables

This section is empty.

Functions

func Describe

func Describe(status int32, msg string) string

Describe renders a non-OK status for logs.

Types

type Backend

type Backend struct{}

Backend is the cgo-backed implementation. Stateless; safe to share.

func (Backend) BlindSign

func (Backend) BlindSign(suite uint32, secretKey, publicKey, commitment, header []byte, messages [][]byte) ([]byte, int32, string)

BlindSign implements the issuer half. See bbs.BlindSigner.

func (Backend) Issue

func (Backend) Issue(suite uint32, secretKey, publicKey, commitment []byte,
	vct string, issuerClaimsJSON, holderPointersJSON, extraHeaderJSON []byte,
	keybind uint32) (string, int32, string)

Issue verifies the holder's commitment and returns a finished credential in JWP Compact Serialization.

The claim-to-message mapping happens on the Rust side, not here. It has to be byte-identical in the issuer, the wallet and the verifier, and when it is not every proof fails with nothing pointing at the cause - so there is exactly one implementation of it.

func (Backend) SkToPk

func (Backend) SkToPk(secretKey []byte) ([]byte, int32, string)

SkToPk derives the public key belonging to a secret key.

The one call here that is not about signing or verifying a credential. It exists so an issuer can check, once at startup, that the two halves of a configured key pair belong together - a mismatch otherwise surfaces as credentials that fail at every relying party reporting only "does not verify", with nothing in the failure pointing at the configuration.

func (Backend) VerifyPresentation

func (Backend) VerifyPresentation(suite uint32, presentedJWP string, publicKey []byte) ([]byte, int32, string)

VerifyPresentation checks a presentation and returns the raw JSON describing what it disclosed. Decoding that is the caller's job, so this layer stays free of the package's own types.

func (Backend) VerifyProof

func (Backend) VerifyProof(suite uint32, publicKey, proof, header, presentationHeader []byte,
	issuerKnownMessages int, disclosedMessages [][]byte, disclosures []byte) (int32, string)

VerifyProof implements the verifier half. See bbs.ProofVerifier.

Jump to

Keyboard shortcuts

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