use-truapi
Accounts

useRingVrfSign

Plain signature under a registered ring-VRF member key, without a membership proof

useRingVrfSign signs bytes directly with a registered ring-VRF key: sign(keyHandle, message) resolves the 64-byte signature. Unlike useCreateAccountProof it proves nothing about ring membership; it is the raw signature under the member key, for protocols that carry their own proof or only need to show continuity of the same key across messages.

The handle comes from useRingVrfKeys. Signing with your own product's key does not prompt on hosts that treat same-product requests as pre-approved; another product's key prompts or is refused. Host-only: standalone sign rejects with HostUnavailableError.

Usage

import { useRingVrfKeys, useRingVrfSign } from "@use-truapi/react";

function SignWithKey() {
  const { data: keys } = useRingVrfKeys();
  const { sign, data, isPending } = useRingVrfSign();
  const key = keys?.[0];

  return (
    <>
      <button
        type="button"
        disabled={!key || isPending}
        onClick={() => key && sign(key.handle, new TextEncoder().encode("hello"))}
      >
        Sign
      </button>
      {data && <code>{data.length} byte signature</code>}
    </>
  );
}
<script setup lang="ts">
import { useRingVrfKeys, useRingVrfSign } from "@use-truapi/vue";

const keys = useRingVrfKeys();
const { sign, data, isPending } = useRingVrfSign();

function onSign() {
  const key = keys.data.value?.[0];
  if (key) void sign(key.handle, new TextEncoder().encode("hello"));
}
</script>

<template>
  <button type="button" :disabled="isPending" @click="onSign">Sign</button>
  <code v-if="data">{{ data.length }} byte signature</code>
</template>

API reference

React

function useRingVrfSign(options?): NamedMutation<Uint8Array<ArrayBufferLike>, RingVrfSignVariables> & object;

Plain signature under a registered ring-VRF member key (no membership proof): sign(handle, message).

Parameters

ParameterType
options?{ mutation?: MutationOptions<Uint8Array<ArrayBufferLike>, RingVrfSignVariables>; }
options.mutation?MutationOptions<Uint8Array<ArrayBufferLike>, RingVrfSignVariables>

Returns

NamedMutation<Uint8Array<ArrayBufferLike>, RingVrfSignVariables> & object

Vue

function useRingVrfSign(options?): NamedMutation<Uint8Array<ArrayBufferLike>, RingVrfSignVariables> & object;

Plain signature under a registered ring-VRF member key (no membership proof): sign(handle, message).

Parameters

ParameterType
options?{ mutation?: MutationOptions<Uint8Array<ArrayBufferLike>, RingVrfSignVariables>; }
options.mutation?MutationOptions<Uint8Array<ArrayBufferLike>, RingVrfSignVariables>

Returns

NamedMutation<Uint8Array<ArrayBufferLike>, RingVrfSignVariables> & object

On this page