Skip to main content

VrfProvider

Trait VrfProvider 

Source
pub trait VrfProvider: Send + Sync {
    // Required methods
    fn derive_member_key(&self) -> Result<[u8; 32], VrfError>;
    fn sign(&self, message: &[u8]) -> Result<Vec<u8>, VrfError>;
    fn create_proof(
        &self,
        members: &[[u8; 32]],
        context: &[u8; 32],
        message: &[u8],
    ) -> Result<Vec<u8>, VrfError>;
    fn alias_in_context(&self, context: &[u8; 32]) -> Result<[u8; 32], VrfError>;
}
Expand description

Provider for Bandersnatch ring-VRF operations.

Constructed with entropy baked in — the secret never crosses this interface after construction. Key material stays inside the provider; only public keys and signatures are exposed to callers.

Implementations:

  • host-vrf-native: Rust-native via the verifiable crate (arkworks)
  • Platform bindings: verifiable-swift (iOS), JNI (Android), verifiablejs (web)

Required Methods§

Source

fn derive_member_key(&self) -> Result<[u8; 32], VrfError>

Derive the Bandersnatch public member key. Returns the 32-byte compressed curve point.

Source

fn sign(&self, message: &[u8]) -> Result<Vec<u8>, VrfError>

Sign a message with the Bandersnatch key (proof of ownership). Returns the signature bytes (variable length, implementation-dependent).

Source

fn create_proof( &self, members: &[[u8; 32]], context: &[u8; 32], message: &[u8], ) -> Result<Vec<u8>, VrfError>

Create a ring-VRF proof proving membership in a set without revealing which member you are.

  • members: the ring of public member keys (each 32 bytes)
  • context: 32-byte context identifier (e.g., CONTEXT_IDENTITY)
  • message: the message to prove against

Returns the proof bytes. CPU-intensive — callers should offload to a thread pool (e.g., tokio::task::spawn_blocking) before calling.

Source

fn alias_in_context(&self, context: &[u8; 32]) -> Result<[u8; 32], VrfError>

Derive a context-specific alias (pseudonymous identity). The same key produces different aliases in different contexts, enabling unlinkable per-context identities.

Implementors§